import akka.testkit.TestActorRef;
import akka.testkit.javadsl.TestKit;
import com.google.common.collect.ImmutableSortedSet;
+import java.time.Duration;
import java.util.SortedSet;
-import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.opendaylight.controller.cluster.access.concepts.MemberName;
import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.FiniteDuration;
/**
* Unit tests for various 3PC coordination scenarios.
* even though it isn't at the head of the queues.
*/
@Test
- public void testTwoTransactionsWithSameTwoParticipatingShards() throws Exception {
+ public void testTwoTransactionsWithSameTwoParticipatingShards() {
final String testName = "testTwoTransactionsWithSameTwoParticipatingShards";
LOG.info("{} starting", testName);
// in the participating shard list.
shardA.tell(new CanCommitTransaction(txId2, CURRENT_VERSION).toSerializable(), kit2.getRef());
- kit2.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit2.expectNoMessage(Duration.ofMillis(100));
// Send tx1 CanCommit to A - it's at the head of the queue so should proceed.
// Send tx2 CanCommit to B - tx1 should now be at the head of he queue.
shardB.tell(new CanCommitTransaction(txId2, CURRENT_VERSION).toSerializable(), kit2.getRef());
- kit2.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit2.expectNoMessage(Duration.ofMillis(100));
// Finish commit of tx1.
* CanCommit is requested.
*/
@Test
- public void testMultipleTransactionsWithMixedParticipatingShards() throws Exception {
+ public void testMultipleTransactionsWithMixedParticipatingShards() {
final String testName = "testMultipleTransactionsWithMixedParticipatingShards";
LOG.info("{} starting", testName);
// shard list [A] matches that of tx5 so tx3 should be moved ahead of tx5 in the queue.
shardB.tell(new CanCommitTransaction(txId3, CURRENT_VERSION).toSerializable(), kit3.getRef());
- kit3.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit3.expectNoMessage(Duration.ofMillis(100));
// Send tx4 CanCommit to B - tx4's participating shard list [A] matches that of tx3 and tx5 - so tx4 should
// be moved ahead of tx5 in the queue but not tx3 since should be in the CAN_COMMIT_PENDING state.
shardB.tell(new CanCommitTransaction(txId4, CURRENT_VERSION).toSerializable(), kit4.getRef());
- kit4.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit4.expectNoMessage(Duration.ofMillis(100));
// Send tx5 CanCommit to B - it's position in the queue should remain the same.
shardB.tell(new CanCommitTransaction(txId5, CURRENT_VERSION).toSerializable(), kit5.getRef());
- kit5.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit5.expectNoMessage(Duration.ofMillis(100));
// Finish commit of tx1.
* When the tx's re committed verify the ready order is preserved.
*/
@Test
- public void testTwoTransactionsWithOneCommonParticipatingShard1() throws Exception {
+ public void testTwoTransactionsWithOneCommonParticipatingShard1() {
final String testName = "testTwoTransactionsWithOneCommonParticipatingShard1";
LOG.info("{} starting", testName);
// shard list [A] do not match that of tx2 [B] so tx1 should not be allowed to proceed.
shardC.tell(new CanCommitTransaction(txId1, CURRENT_VERSION).toSerializable(), kit1.getRef());
- kit1.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit1.expectNoMessage(Duration.ofMillis(100));
// Send tx2 CanCommit to C - it's at the head of the queue so should proceed.
* When the tx's re committed verify the ready order is preserved.
*/
@Test
- public void testTwoTransactionsWithOneCommonParticipatingShard2() throws Exception {
+ public void testTwoTransactionsWithOneCommonParticipatingShard2() {
final String testName = "testTwoTransactionsWithOneCommonParticipatingShard2";
LOG.info("{} starting", testName);
// shard list [A] do not match that of tx2 [] so tx1 should not be allowed to proceed.
shardB.tell(new CanCommitTransaction(txId1, CURRENT_VERSION).toSerializable(), kit1.getRef());
- kit1.expectNoMessage(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
+ kit1.expectNoMessage(Duration.ofMillis(100));
// Send tx2 CanCommit to B - it's at the head of the queue so should proceed.
LOG.info("{} ending", testName);
}
- static void verifyInnerListEntry(TestActorRef<Shard> shard, int outerID, String innerID)
- throws Exception {
+ static void verifyInnerListEntry(TestActorRef<Shard> shard, int outerID, String innerID) {
final YangInstanceIdentifier path = innerEntryPath(outerID, innerID);
- final NormalizedNode<?, ?> innerListEntry = readStore(shard, path);
+ final NormalizedNode innerListEntry = readStore(shard, path);
assertNotNull(path + " not found", innerListEntry);
}
}