Migrate to java.time.Duration 74/75374/41
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 22 Aug 2018 10:26:35 +0000 (12:26 +0200)
committerTom Pantelis <tompantelis@gmail.com>
Wed, 5 Dec 2018 15:08:55 +0000 (15:08 +0000)
Akka 2.5.12 deprecated quite a few methods using Scala duration
to use java.time.Duration. Migrate ourselves.

Change-Id: Ieb92c219f529c5d2c606016d3ea717d4531dda1b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
18 files changed:
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupportTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardCommitCoordinationTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListenerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java
opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java
opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java

index 6e4d536..82017fa 100644 (file)
@@ -24,6 +24,7 @@ import com.google.common.base.Stopwatch;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.io.OutputStream;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -279,7 +280,7 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest
         testkit.watch(actor);
 
         actor.tell(PoisonPill.getInstance(), null);
-        testkit.expectMsgClass(testkit.duration("5 seconds"), Terminated.class);
+        testkit.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
 
         testkit.unwatch(actor);
     }
index 97ab20a..8207fd7 100644 (file)
@@ -28,6 +28,7 @@ import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.google.common.io.ByteSource;
 import java.io.OutputStream;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -173,7 +174,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         List<Object> snapshotState = MockRaftActor.fromState(applySnapshot.getSnapshot().getState());
         assertEquals("Snapshot state", snapshotState, leaderRaftActor.getState());
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
         assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get());
 
@@ -253,7 +254,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         List<Object> snapshotState = MockRaftActor.fromState(applySnapshot.getSnapshot().getState());
         assertEquals("Snapshot state", snapshotState, leaderRaftActor.getState());
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
         assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get());
 
@@ -299,7 +300,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), false), testKit.getRef());
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
         assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get());
 
@@ -336,7 +337,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID2, followerActor.path().toString(), false), testKit.getRef());
 
-        addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
         assertEquals("getLeaderHint", java.util.Optional.of(LEADER_ID), addServerReply.getLeaderHint());
 
@@ -389,10 +390,10 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         newFollowerRaftActor.tell(installSnapshot, leaderActor);
 
         // Verify both complete successfully
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
 
-        addServerReply = testKit2.expectMsgClass(testKit2.duration("5 seconds"), AddServerReply.class);
+        addServerReply = testKit2.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
 
         // Verify ServerConfigurationPayload entries in leader's log
@@ -442,7 +443,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         leaderRaftActor.setDropMessageOfType(null);
         leaderActor.tell(commitMsg, leaderActor);
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
         assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get());
 
@@ -484,7 +485,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef());
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.TIMEOUT, addServerReply.getStatus());
 
         assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size());
@@ -532,7 +533,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new RaftActorServerConfigurationSupport.ServerOperationTimeout(NEW_SERVER_ID), leaderActor);
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus());
 
         assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size());
@@ -578,7 +579,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         leaderRaftActor.setDropMessageOfType(null);
         leaderActor.tell(snapshotReply, leaderActor);
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus());
 
         assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size());
@@ -609,7 +610,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new UnInitializedFollowerSnapshotReply("bogus"), leaderActor);
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.TIMEOUT, addServerReply.getStatus());
 
         assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size());
@@ -636,7 +637,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         noLeaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true),
                 testKit.getRef());
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus());
 
         LOG.info("testAddServerWithNoLeader ending");
@@ -683,7 +684,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         leaderActor.tell(new AddServer(NEW_SERVER_ID2, "", false), testKit.getRef());
 
         // The first AddServer should succeed with OK even though consensus wasn't reached
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus());
         assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get());
 
@@ -692,12 +693,12 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 votingServer(NEW_SERVER_ID));
 
         // The second AddServer should fail since consensus wasn't reached for the first
-        addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.PRIOR_REQUEST_CONSENSUS_TIMEOUT, addServerReply.getStatus());
 
         // Re-send the second AddServer - should also fail
         leaderActor.tell(new AddServer(NEW_SERVER_ID2, "", false), testKit.getRef());
-        addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.PRIOR_REQUEST_CONSENSUS_TIMEOUT, addServerReply.getStatus());
 
         LOG.info("testAddServerWithNoConsensusReached ending");
@@ -716,7 +717,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new AddServer(FOLLOWER_ID, followerActor.path().toString(), true), testKit.getRef());
 
-        AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class);
+        AddServerReply addServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), AddServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.ALREADY_EXISTS, addServerReply.getStatus());
 
         LOG.info("testAddServerWithExistingServer ending");
@@ -793,8 +794,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         leaderActor.underlyingActor().waitForInitializeBehaviorComplete();
 
         leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"),
-                RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerWithNoLeader ending");
@@ -812,8 +812,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new RemoveServer(NEW_SERVER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"),
-                RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.DOES_NOT_EXIST, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerNonExistentServer ending");
@@ -886,8 +885,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         follower2Actor.underlyingActor().waitForInitializeBehaviorComplete();
 
         leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"),
-                RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus());
 
         ApplyState applyState = MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class);
@@ -937,8 +935,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 followerActorId);
 
         leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"),
-                RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus());
 
         final ApplyState applyState = MessageCollectorActor.expectFirstMatching(followerCollector, ApplyState.class);
@@ -961,8 +958,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                 actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef());
-        RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"),
-                RemoveServerReply.class);
+        RemoveServerReply removeServerReply = testKit.expectMsgClass(Duration.ofSeconds(5), RemoveServerReply.class);
         assertEquals("getStatus", ServerChangeStatus.NOT_SUPPORTED, removeServerReply.getStatus());
 
         LOG.info("testRemoveServerLeaderWithNoFollowers ending");
@@ -1005,7 +1001,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(FOLLOWER_ID, false, FOLLOWER_ID2, false)),
                 testKit.getRef());
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         final ApplyState applyState = MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class);
@@ -1030,7 +1026,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         // Send second ChangeServersVotingStatus message
 
         leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(FOLLOWER_ID, true)), testKit.getRef());
-        reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class);
@@ -1083,7 +1079,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         // Send ChangeServersVotingStatus message
 
         leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(LEADER_ID, false)), testKit.getRef());
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class);
@@ -1115,7 +1111,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
                         .withDispatcher(Dispatchers.DefaultDispatcherId()), actorFactory.generateActorId(LEADER_ID));
 
         leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(LEADER_ID, false)), testKit.getRef());
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.INVALID_REQUEST, reply.getStatus());
 
         LOG.info("testChangeLeaderToNonVotingInSingleNode ending");
@@ -1188,7 +1184,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         ChangeServersVotingStatus changeServers = new ChangeServersVotingStatus(ImmutableMap.of(node1ID, true,
                 node2ID, true, "downNode1", false, "downNode2", false));
         node1RaftActorRef.tell(changeServers, testKit.getRef());
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus());
         assertEquals("getRaftState", RaftState.Follower, node1RaftActor.getRaftState());
 
@@ -1209,7 +1205,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         node1RaftActor.setPeerAddress(node2ID, node2RaftActorRef.path().toString());
 
         node1RaftActorRef.tell(changeServers, testKit.getRef());
-        reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         ApplyJournalEntries apply = MessageCollectorActor.expectFirstMatching(node1Collector,
@@ -1283,7 +1279,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         ChangeServersVotingStatus changeServers = new ChangeServersVotingStatus(ImmutableMap.of(node1ID, true));
         node1RaftActorRef.tell(changeServers, testKit.getRef());
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus());
 
         assertEquals("Server config", Sets.newHashSet(nonVotingServer(node1ID), votingServer(node2ID)),
@@ -1343,7 +1339,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
         ChangeServersVotingStatus changeServers = new ChangeServersVotingStatus(
                 ImmutableMap.of(node1ID, true, node2ID, true));
         node1RaftActorRef.tell(changeServers, testKit.getRef());
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         MessageCollectorActor.expectFirstMatching(node2Collector, ApplyJournalEntries.class);
@@ -1413,7 +1409,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest {
 
         node2RaftActorRef.tell(TimeoutNow.INSTANCE, ActorRef.noSender());
 
-        ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class);
+        ServerChangeReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ServerChangeReply.class);
         assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus());
 
         MessageCollectorActor.expectFirstMatching(node1Collector, ApplyJournalEntries.class);
index f9c88f7..d0cedce 100644 (file)
@@ -14,10 +14,10 @@ import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyObject;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.same;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.same;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
@@ -43,6 +43,7 @@ import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectOutputStream;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -91,7 +92,6 @@ import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
 import org.opendaylight.yangtools.concepts.Identifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class RaftActorTest extends AbstractActorTest {
@@ -183,7 +183,7 @@ public class RaftActorTest extends AbstractActorTest {
 
         // kill the actor
         followerActor.tell(PoisonPill.getInstance(), null);
-        kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
 
         kit.unwatch(followerActor);
 
@@ -1062,14 +1062,15 @@ public class RaftActorTest extends AbstractActorTest {
         // Test with timeout
 
         mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(
-                Duration.create(200, TimeUnit.MILLISECONDS));
+            FiniteDuration.create(200, TimeUnit.MILLISECONDS));
         reset(mockRaftActor.snapshotCohortDelegate);
 
         raftActorRef.tell(GetSnapshot.INSTANCE, kit.getRef());
         Failure failure = kit.expectMsgClass(akka.actor.Status.Failure.class);
         assertEquals("Failure cause type", TimeoutException.class, failure.cause().getClass());
 
-        mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(Duration.create(30, TimeUnit.SECONDS));
+        mockRaftActor.getSnapshotMessageSupport().setSnapshotReplyActorTimeout(
+            FiniteDuration.create(30, TimeUnit.SECONDS));
 
         // Test with persistence disabled.
 
index 5db2542..8c5cb81 100644 (file)
@@ -20,6 +20,7 @@ import akka.actor.DeadLetter;
 import akka.actor.Props;
 import akka.testkit.javadsl.TestKit;
 import com.google.common.collect.ImmutableList;
+import java.time.Duration;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.messages.DataTreeChanged;
@@ -65,7 +66,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest {
 
         subject.tell(new DataTreeChanged(mockCandidates), testKit.getRef());
 
-        testKit.within(testKit.duration("1 seconds"), () -> {
+        testKit.within(Duration.ofSeconds(1), () -> {
             testKit.expectNoMessage();
             verify(mockListener, never()).onDataTreeChanged(anyCollection());
             return null;
@@ -88,7 +89,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest {
         while (true) {
             DeadLetter deadLetter;
             try {
-                deadLetter = testKit.expectMsgClass(testKit.duration("1 seconds"), DeadLetter.class);
+                deadLetter = testKit.expectMsgClass(Duration.ofSeconds(1), DeadLetter.class);
             } catch (AssertionError e) {
                 // Timed out - got no DeadLetter - this is good
                 break;
index 511c3d2..558171e 100644 (file)
@@ -26,6 +26,7 @@ import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.time.Duration;
 import java.util.concurrent.TimeUnit;
 import org.junit.Test;
 import org.mockito.stubbing.Answer;
@@ -46,7 +47,6 @@ import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import scala.concurrent.ExecutionContextExecutor;
 import scala.concurrent.Future;
-import scala.concurrent.duration.FiniteDuration;
 
 public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
     private final DOMDataTreeChangeListener mockListener = mock(DOMDataTreeChangeListener.class);
@@ -63,7 +63,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
 
         new Thread(() -> proxy.init("shard-1")).start();
 
-        FiniteDuration timeout = kit.duration("5 seconds");
+        Duration timeout = Duration.ofSeconds(5);
         FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
         assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
 
@@ -113,7 +113,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
 
         new Thread(() -> proxy.init("shard-1")).start();
 
-        FiniteDuration timeout = kit.duration("5 seconds");
+        Duration timeout = Duration.ofSeconds(5);
         FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
         assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
 
@@ -139,13 +139,13 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
 
         new Thread(() -> proxy.init("shard-1")).start();
 
-        FiniteDuration timeout = kit.duration("5 seconds");
+        Duration timeout = Duration.ofSeconds(5);
         FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
         assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
 
         kit.reply(new LocalShardNotFound("shard-1"));
 
-        kit.expectNoMessage(kit.duration("1 seconds"));
+        kit.expectNoMessage(Duration.ofSeconds(1));
 
         proxy.close();
     }
@@ -162,13 +162,13 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
 
         new Thread(() -> proxy.init("shard-1")).start();
 
-        FiniteDuration timeout = kit.duration("5 seconds");
+        Duration timeout = Duration.ofSeconds(5);
         FindLocalShard findLocalShard = kit.expectMsgClass(timeout, FindLocalShard.class);
         assertEquals("getShardName", "shard-1", findLocalShard.getShardName());
 
         kit.reply(new NotInitializedException("not initialized"));
 
-        kit.within(kit.duration("1 seconds"), () ->  {
+        kit.within(Duration.ofSeconds(1), () ->  {
             kit.expectNoMessage();
             return null;
         });
@@ -238,7 +238,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest {
 
         proxy.init(shardName);
 
-        kit.expectMsgClass(kit.duration("5 seconds"), CloseDataTreeNotificationListenerRegistration.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistration.class);
 
         assertEquals("getListenerRegistrationActor", null, proxy.getListenerRegistrationActor());
     }
index 0a435fe..aee744e 100644 (file)
@@ -26,6 +26,7 @@ import akka.pattern.Patterns;
 import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
 import akka.util.Timeout;
+import java.time.Duration;
 import java.util.AbstractMap.SimpleEntry;
 import java.util.Map.Entry;
 import java.util.concurrent.TimeUnit;
@@ -42,7 +43,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import scala.concurrent.Await;
-import scala.concurrent.duration.Duration;
+import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Unit tests for DataTreeChangeListenerSupport.
@@ -93,7 +94,7 @@ public class DataTreeChangeListenerSupportTest extends AbstractShardTest {
         listener.reset(1);
         TestKit kit = new TestKit(getSystem());
         entry.getValue().tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), CloseDataTreeNotificationListenerRegistrationReply.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistrationReply.class);
 
         writeToStore(shard.getDataStore(), TEST_PATH, ImmutableNodes.containerNode(TEST_QNAME));
         listener.verifyNoNotifiedData(TEST_PATH);
@@ -164,7 +165,7 @@ public class DataTreeChangeListenerSupportTest extends AbstractShardTest {
         try {
             reply = (RegisterDataTreeNotificationListenerReply)
                     Await.result(Patterns.ask(shardActor, new RegisterDataTreeChangeListener(path, dclActor, false),
-                        new Timeout(5, TimeUnit.SECONDS)), Duration.create(5, TimeUnit.SECONDS));
+                        new Timeout(5, TimeUnit.SECONDS)), FiniteDuration.create(5, TimeUnit.SECONDS));
         } catch (RuntimeException e) {
             throw e;
         } catch (Exception e) {
index a7a265f..bd9c0a4 100644 (file)
@@ -27,8 +27,8 @@ import akka.dispatch.Dispatchers;
 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;
@@ -43,7 +43,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 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.
@@ -116,7 +115,7 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
         // 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.
 
@@ -132,7 +131,7 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
         // 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.
 
@@ -261,18 +260,18 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
         // 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.
 
@@ -412,7 +411,7 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
         // 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.
 
@@ -520,7 +519,7 @@ public class ShardCommitCoordinationTest extends AbstractShardTest {
         // 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.
 
index a2509fa..bdae31c 100644 (file)
@@ -33,6 +33,7 @@ import akka.util.Timeout;
 import com.google.common.base.Stopwatch;
 import com.google.common.base.Throwables;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.time.Duration;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Map;
@@ -139,7 +140,7 @@ public class ShardTest extends AbstractShardTest {
 
         shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor, false), testKit.getRef());
 
-        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(testKit.duration("3 seconds"),
+        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(Duration.ofSeconds(3),
             RegisterDataTreeNotificationListenerReply.class);
         final String replyPath = reply.getListenerRegistrationPath().toString();
         assertTrue("Incorrect reply path: " + replyPath,
@@ -197,13 +198,12 @@ public class ShardTest extends AbstractShardTest {
         assertTrue("Got first ElectionTimeout", onFirstElectionTimeout.await(5, TimeUnit.SECONDS));
 
         shard.tell(new RegisterDataTreeChangeListener(path, dclActor, false), testKit.getRef());
-        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"),
+        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(Duration.ofSeconds(5),
             RegisterDataTreeNotificationListenerReply.class);
         assertNotNull("getListenerRegistratioznPath", reply.getListenerRegistrationPath());
 
         shard.tell(FindLeader.INSTANCE, testKit.getRef());
-        final FindLeaderReply findLeadeReply = testKit.expectMsgClass(testKit.duration("5 seconds"),
-            FindLeaderReply.class);
+        final FindLeaderReply findLeadeReply = testKit.expectMsgClass(Duration.ofSeconds(5), FindLeaderReply.class);
         assertFalse("Expected the shard not to be the leader", findLeadeReply.getLeaderActor().isPresent());
 
         onChangeListenerRegistered.countDown();
@@ -224,7 +224,7 @@ public class ShardTest extends AbstractShardTest {
         shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
             DataStoreVersions.CURRENT_VERSION).toSerializable(), testKit.getRef());
 
-        final CreateTransactionReply reply = testKit.expectMsgClass(testKit.duration("3 seconds"),
+        final CreateTransactionReply reply = testKit.expectMsgClass(Duration.ofSeconds(3),
             CreateTransactionReply.class);
 
         final String path = reply.getTransactionPath().toString();
@@ -243,7 +243,7 @@ public class ShardTest extends AbstractShardTest {
         shard.tell(new CreateTransaction(nextTransactionId(), TransactionType.READ_ONLY.ordinal(),
             DataStoreVersions.CURRENT_VERSION).toSerializable(), testKit.getRef());
 
-        final CreateTransactionReply reply = testKit.expectMsgClass(testKit.duration("3 seconds"),
+        final CreateTransactionReply reply = testKit.expectMsgClass(Duration.ofSeconds(3),
             CreateTransactionReply.class);
 
         final String path = reply.getTransactionPath().toString();
@@ -387,8 +387,8 @@ public class ShardTest extends AbstractShardTest {
         final CountDownLatch commitLatch = new CountDownLatch(2);
 
         final long timeoutSec = 5;
-        final FiniteDuration duration = FiniteDuration.create(timeoutSec, TimeUnit.SECONDS);
-        final Timeout timeout = new Timeout(duration);
+        final Duration duration = Duration.ofSeconds(timeoutSec);
+        final Timeout timeout = Timeout.create(duration);
 
         final TestActorRef<Shard> shard = actorFactory.createTestActor(
                 newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()),
@@ -552,7 +552,7 @@ public class ShardTest extends AbstractShardTest {
         ShardTestKit.waitUntilLeader(shard);
 
         final TransactionIdentifier transactionID = nextTransactionId();
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         // Send a BatchedModifications to start a transaction.
 
@@ -601,7 +601,7 @@ public class ShardTest extends AbstractShardTest {
         ShardTestKit.waitUntilLeader(shard);
 
         final TransactionIdentifier transactionID = nextTransactionId();
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         // Send a BatchedModifications to start a transaction.
 
@@ -645,7 +645,7 @@ public class ShardTest extends AbstractShardTest {
 
         shard.tell(batched, testKit.getRef());
 
-        final Failure failure = testKit.expectMsgClass(testKit.duration("5 seconds"), Failure.class);
+        final Failure failure = testKit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
 
         if (failure != null) {
             Throwables.propagateIfPossible(failure.cause(), Exception.class);
@@ -675,7 +675,7 @@ public class ShardTest extends AbstractShardTest {
         BatchedModifications batched = new BatchedModifications(transactionID, CURRENT_VERSION);
         batched.addModification(new MergeModification(TestModel.TEST_PATH, invalidData));
         shard.tell(batched, testKit.getRef());
-        Failure failure = testKit.expectMsgClass(testKit.duration("5 seconds"), akka.actor.Status.Failure.class);
+        Failure failure = testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
 
         final Throwable cause = failure.cause();
 
@@ -685,7 +685,7 @@ public class ShardTest extends AbstractShardTest {
 
         shard.tell(batched, testKit.getRef());
 
-        failure = testKit.expectMsgClass(testKit.duration("5 seconds"), akka.actor.Status.Failure.class);
+        failure = testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
         assertEquals("Failure cause", cause, failure.cause());
     }
 
@@ -702,7 +702,7 @@ public class ShardTest extends AbstractShardTest {
         final TransactionIdentifier transactionID1 = new TransactionIdentifier(historyId, 0);
         final TransactionIdentifier transactionID2 = new TransactionIdentifier(historyId, 1);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         // Send a BatchedModifications to start a chained write
         // transaction and ready it.
@@ -717,12 +717,12 @@ public class ShardTest extends AbstractShardTest {
         shard.tell(new CreateTransaction(transactionID2, TransactionType.READ_ONLY.ordinal(),
             DataStoreVersions.CURRENT_VERSION).toSerializable(), testKit.getRef());
 
-        final CreateTransactionReply createReply = testKit.expectMsgClass(testKit.duration("3 seconds"),
+        final CreateTransactionReply createReply = testKit.expectMsgClass(Duration.ofSeconds(3),
             CreateTransactionReply.class);
 
         getSystem().actorSelection(createReply.getTransactionPath())
         .tell(new ReadData(path, DataStoreVersions.CURRENT_VERSION), testKit.getRef());
-        final ReadDataReply readReply = testKit.expectMsgClass(testKit.duration("3 seconds"), ReadDataReply.class);
+        final ReadDataReply readReply = testKit.expectMsgClass(Duration.ofSeconds(3), ReadDataReply.class);
         assertEquals("Read node", containerNode, readReply.getNormalizedNode());
 
         // Commit the write transaction.
@@ -836,7 +836,7 @@ public class ShardTest extends AbstractShardTest {
                 testKit.getRef());
         }
 
-        testKit.expectMsgClass(testKit.duration("5 seconds"), CommitTransactionReply.class);
+        testKit.expectMsgClass(Duration.ofSeconds(5), CommitTransactionReply.class);
 
         final NormalizedNode<?, ?> actualNode = readStore(shard, TestModel.TEST_PATH);
         assertEquals(TestModel.TEST_QNAME.getLocalName(), containerNode, actualNode);
@@ -932,7 +932,7 @@ public class ShardTest extends AbstractShardTest {
 
         // Setup a simulated transactions with a mock cohort.
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         final TransactionIdentifier transactionID = nextTransactionId();
         final NormalizedNode<?, ?> containerNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
@@ -975,7 +975,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
         final TransactionIdentifier transactionID = nextTransactionId();
 
         if (readWrite) {
@@ -1029,8 +1029,8 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
-        final Timeout timeout = new Timeout(duration);
+        final Duration duration = Duration.ofSeconds(5);
+        final Timeout timeout = Timeout.create(duration);
 
         // Setup 2 simulated transactions with mock cohorts. The first
         // one fails in the
@@ -1103,8 +1103,8 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
-        final Timeout timeout = new Timeout(duration);
+        final Duration duration = Duration.ofSeconds(5);
+        final Timeout timeout = Timeout.create(duration);
 
         doThrow(new RuntimeException("mock preCommit failure")).when(dataTree)
         .prepare(any(DataTreeModification.class));
@@ -1168,7 +1168,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
         final TransactionIdentifier transactionID1 = nextTransactionId();
 
         doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "mock canCommit failure"))
@@ -1215,7 +1215,7 @@ public class ShardTest extends AbstractShardTest {
         doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "mock canCommit failure"))
         .doNothing().when(dataTree).validate(any(DataTreeModification.class));
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
 
@@ -1267,7 +1267,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         final TransactionIdentifier transactionID = nextTransactionId();
 
@@ -1301,7 +1301,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         writeToStore(shard, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         writeToStore(shard, TestModel.OUTER_LIST_PATH,
@@ -1430,7 +1430,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         final TransactionIdentifier transactionID1 = nextTransactionId();
         shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
@@ -1466,7 +1466,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         final ShardDataTree dataStore = shard.underlyingActor().getDataStore();
 
@@ -1521,7 +1521,7 @@ public class ShardTest extends AbstractShardTest {
             "testCanCommitBeforeReadyFailure");
 
         shard.tell(new CanCommitTransaction(nextTransactionId(), CURRENT_VERSION).toSerializable(), testKit.getRef());
-        testKit.expectMsgClass(testKit.duration("5 seconds"), akka.actor.Status.Failure.class);
+        testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
     }
 
     @Test
@@ -1532,8 +1532,8 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
-        final Timeout timeout = new Timeout(duration);
+        final Duration duration = Duration.ofSeconds(5);
+        final Timeout timeout = Timeout.create(duration);
 
         // Ready 2 transactions - the first one will be aborted.
 
@@ -1570,7 +1570,8 @@ public class ShardTest extends AbstractShardTest {
 
         // Wait for the 2nd Tx to complete the canCommit phase.
 
-        canCommitReply = (CanCommitTransactionReply) Await.result(canCommitFuture, duration);
+        canCommitReply = (CanCommitTransactionReply) Await.result(canCommitFuture,
+            FiniteDuration.create(5, TimeUnit.SECONDS));
         assertTrue("Can commit", canCommitReply.getCanCommit());
     }
 
@@ -1583,7 +1584,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         // Ready a tx.
 
@@ -1624,7 +1625,7 @@ public class ShardTest extends AbstractShardTest {
 
         ShardTestKit.waitUntilLeader(shard);
 
-        final FiniteDuration duration = testKit.duration("5 seconds");
+        final Duration duration = Duration.ofSeconds(5);
 
         // Ready 3 tx's.
 
@@ -1716,8 +1717,6 @@ public class ShardTest extends AbstractShardTest {
             }
         }
 
-        final ShardTestKit testKit = new ShardTestKit(getSystem());
-
         final Creator<Shard> creator = () -> new TestShard(newShardBuilder());
 
         final TestActorRef<Shard> shard = actorFactory.createTestActor(Props
@@ -1895,7 +1894,7 @@ public class ShardTest extends AbstractShardTest {
         testKit.waitUntilNoLeader(shard);
 
         shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor, true), testKit.getRef());
-        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"),
+        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(Duration.ofSeconds(5),
             RegisterDataTreeNotificationListenerReply.class);
         assertNotNull("getListenerRegistrationPath", reply.getListenerRegistrationPath());
 
@@ -1925,7 +1924,7 @@ public class ShardTest extends AbstractShardTest {
         testKit.waitUntilNoLeader(shard);
 
         shard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor, true), testKit.getRef());
-        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"),
+        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(Duration.ofSeconds(5),
             RegisterDataTreeNotificationListenerReply.class);
         assertNotNull("getListenerRegistrationPath", reply.getListenerRegistrationPath());
 
@@ -1974,7 +1973,7 @@ public class ShardTest extends AbstractShardTest {
             actorFactory.generateActorId(testName + "-DataTreeChangeListener"));
 
         followerShard.tell(new RegisterDataTreeChangeListener(TestModel.TEST_PATH, dclActor, true), testKit.getRef());
-        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"),
+        final RegisterDataTreeNotificationListenerReply reply = testKit.expectMsgClass(Duration.ofSeconds(5),
             RegisterDataTreeNotificationListenerReply.class);
         assertNotNull("getListenerRegistrationPath", reply.getListenerRegistrationPath());
 
index 8f952ac..d67d5b4 100644 (file)
@@ -24,6 +24,7 @@ import akka.dispatch.Dispatchers;
 import akka.testkit.TestActorRef;
 import akka.testkit.javadsl.TestKit;
 import com.google.common.base.Throwables;
+import java.time.Duration;
 import java.util.concurrent.TimeUnit;
 import org.junit.Before;
 import org.junit.Test;
@@ -106,7 +107,7 @@ public class ShardTransactionTest extends AbstractActorTest {
         transaction.tell(new ReadData(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION),
             testKit.getRef());
 
-        ReadDataReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ReadDataReply.class);
+        ReadDataReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ReadDataReply.class);
 
         assertNotNull(reply.getNormalizedNode());
     }
@@ -122,7 +123,7 @@ public class ShardTransactionTest extends AbstractActorTest {
     private void testOnReceiveReadDataWhenDataNotFound(final ActorRef transaction) {
         transaction.tell(new ReadData(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION), testKit.getRef());
 
-        ReadDataReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ReadDataReply.class);
+        ReadDataReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), ReadDataReply.class);
 
         assertNull(reply.getNormalizedNode());
     }
@@ -137,7 +138,7 @@ public class ShardTransactionTest extends AbstractActorTest {
         transaction.tell(new DataExists(YangInstanceIdentifier.EMPTY, DataStoreVersions.CURRENT_VERSION),
             testKit.getRef());
 
-        DataExistsReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), DataExistsReply.class);
+        DataExistsReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), DataExistsReply.class);
 
         assertTrue(reply.exists());
     }
@@ -151,7 +152,7 @@ public class ShardTransactionTest extends AbstractActorTest {
     private void testOnReceiveDataExistsNegative(final ActorRef transaction) {
         transaction.tell(new DataExists(TestModel.TEST_PATH, DataStoreVersions.CURRENT_VERSION), testKit.getRef());
 
-        DataExistsReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), DataExistsReply.class);
+        DataExistsReply reply = testKit.expectMsgClass(Duration.ofSeconds(5), DataExistsReply.class);
 
         assertFalse(reply.exists());
     }
@@ -184,7 +185,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         transaction.tell(batched, testKit.getRef());
 
-        BatchedModificationsReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"),
+        BatchedModificationsReply reply = testKit.expectMsgClass(Duration.ofSeconds(5),
             BatchedModificationsReply.class);
         assertEquals("getNumBatched", 3, reply.getNumBatched());
 
@@ -212,7 +213,7 @@ public class ShardTransactionTest extends AbstractActorTest {
         batched.addModification(new WriteModification(writePath, writeData));
 
         transaction.tell(batched, testKit.getRef());
-        BatchedModificationsReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"),
+        BatchedModificationsReply reply = testKit.expectMsgClass(Duration.ofSeconds(5),
             BatchedModificationsReply.class);
         assertEquals("getNumBatched", 1, reply.getNumBatched());
 
@@ -221,8 +222,8 @@ public class ShardTransactionTest extends AbstractActorTest {
         batched.setTotalMessagesSent(2);
 
         transaction.tell(batched, testKit.getRef());
-        testKit.expectMsgClass(testKit.duration("5 seconds"), ReadyTransactionReply.class);
-        watcher.expectMsgClass(watcher.duration("5 seconds"), Terminated.class);
+        testKit.expectMsgClass(Duration.ofSeconds(5), ReadyTransactionReply.class);
+        watcher.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
     }
 
     @Test
@@ -246,8 +247,8 @@ public class ShardTransactionTest extends AbstractActorTest {
         batched.setTotalMessagesSent(1);
 
         transaction.tell(batched, testKit.getRef());
-        testKit.expectMsgClass(testKit.duration("5 seconds"), CommitTransactionReply.class);
-        watcher.expectMsgClass(testKit.duration("5 seconds"), Terminated.class);
+        testKit.expectMsgClass(Duration.ofSeconds(5), CommitTransactionReply.class);
+        watcher.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
     }
 
     @Test(expected = TestException.class)
@@ -272,15 +273,15 @@ public class ShardTransactionTest extends AbstractActorTest {
         batched.addModification(new WriteModification(path, node));
 
         transaction.tell(batched, testKit.getRef());
-        testKit.expectMsgClass(testKit.duration("5 seconds"), akka.actor.Status.Failure.class);
+        testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
 
         batched = new BatchedModifications(tx1, DataStoreVersions.CURRENT_VERSION);
         batched.setReady();
         batched.setTotalMessagesSent(2);
 
         transaction.tell(batched, testKit.getRef());
-        Failure failure = testKit.expectMsgClass(testKit.duration("5 seconds"), akka.actor.Status.Failure.class);
-        watcher.expectMsgClass(testKit.duration("5 seconds"), Terminated.class);
+        Failure failure = testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
+        watcher.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
 
         if (failure != null) {
             Throwables.propagateIfPossible(failure.cause(), Exception.class);
@@ -303,8 +304,8 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         transaction.tell(batched, testKit.getRef());
 
-        Failure failure = testKit.expectMsgClass(testKit.duration("5 seconds"), akka.actor.Status.Failure.class);
-        watcher.expectMsgClass(watcher.duration("5 seconds"), Terminated.class);
+        Failure failure = testKit.expectMsgClass(Duration.ofSeconds(5), akka.actor.Status.Failure.class);
+        watcher.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
 
         if (failure != null) {
             Throwables.throwIfInstanceOf(failure.cause(), Exception.class);
@@ -322,8 +323,8 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         transaction.tell(new CloseTransaction().toSerializable(), testKit.getRef());
 
-        testKit.expectMsgClass(testKit.duration("3 seconds"), CloseTransactionReply.class);
-        testKit.expectTerminated(testKit.duration("3 seconds"), transaction);
+        testKit.expectMsgClass(Duration.ofSeconds(3), CloseTransactionReply.class);
+        testKit.expectTerminated(Duration.ofSeconds(3), transaction);
     }
 
     @Test
@@ -335,8 +336,8 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         transaction.tell(new CloseTransaction().toSerializable(), testKit.getRef());
 
-        testKit.expectMsgClass(testKit.duration("3 seconds"), CloseTransactionReply.class);
-        testKit.expectTerminated(testKit.duration("3 seconds"), transaction);
+        testKit.expectMsgClass(Duration.ofSeconds(3), CloseTransactionReply.class);
+        testKit.expectTerminated(Duration.ofSeconds(3), transaction);
     }
 
     @Test
@@ -348,7 +349,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         transaction.tell(new CloseTransaction().toSerializable(), testKit.getRef());
 
-        testKit.expectMsgClass(testKit.duration("3 seconds"), Terminated.class);
+        testKit.expectMsgClass(Duration.ofSeconds(3), Terminated.class);
     }
 
     @Test
@@ -361,7 +362,7 @@ public class ShardTransactionTest extends AbstractActorTest {
 
         testKit.watch(transaction);
 
-        testKit.expectMsgClass(testKit.duration("3 seconds"), Terminated.class);
+        testKit.expectMsgClass(Duration.ofSeconds(3), Terminated.class);
     }
 
     public static class TestException extends RuntimeException {
index 397724b..00ad155 100644 (file)
@@ -13,6 +13,7 @@ import static org.mockito.Mockito.verify;
 
 import akka.actor.ActorRef;
 import akka.testkit.javadsl.TestKit;
+import java.time.Duration;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -48,12 +49,12 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA
             mockOnClose), ActorRef.noSender());
         subject.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 second"), CloseDataTreeNotificationListenerRegistrationReply.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistrationReply.class);
 
         verify(mockListenerReg, timeout(5000)).close();
         verify(mockOnClose, timeout(5000)).run();
 
-        kit.expectTerminated(kit.duration("5 second"), subject);
+        kit.expectTerminated(Duration.ofSeconds(5), subject);
     }
 
     @Test
@@ -63,7 +64,7 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA
         kit.watch(subject);
 
         subject.tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 second"), CloseDataTreeNotificationListenerRegistrationReply.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), CloseDataTreeNotificationListenerRegistrationReply.class);
 
         subject.tell(new DataTreeNotificationListenerRegistrationActor.SetRegistration(mockListenerReg,
             mockOnClose), ActorRef.noSender());
@@ -71,7 +72,7 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA
         verify(mockListenerReg, timeout(5000)).close();
         verify(mockOnClose, timeout(5000)).run();
 
-        kit.expectTerminated(kit.duration("5 second"), subject);
+        kit.expectTerminated(Duration.ofSeconds(5), subject);
     }
 
     @Test
@@ -95,6 +96,6 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA
         verify(mockListenerReg2, timeout(5000)).close();
         verify(mockOnClose2, timeout(5000)).run();
 
-        kit.expectTerminated(kit.duration("5 second"), subject);
+        kit.expectTerminated(Duration.ofSeconds(5), subject);
     }
 }
index 4ba5e02..5878675 100644 (file)
@@ -16,6 +16,7 @@ import akka.testkit.javadsl.TestKit;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ObjectInputStream;
+import java.time.Duration;
 import java.util.Optional;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
@@ -42,7 +43,7 @@ public class ShardSnapshotActorTest extends AbstractActorTest {
         ShardSnapshotActor.requestSnapshot(snapshotActor, snapshot,
             Optional.ofNullable(installSnapshotStream), kit.getRef());
 
-        final CaptureSnapshotReply reply = kit.expectMsgClass(kit.duration("3 seconds"), CaptureSnapshotReply.class);
+        final CaptureSnapshotReply reply = kit.expectMsgClass(Duration.ofSeconds(3), CaptureSnapshotReply.class);
         assertNotNull("getSnapshotState is null", reply.getSnapshotState());
         assertEquals("SnapshotState type", ShardSnapshotState.class, reply.getSnapshotState().getClass());
         assertEquals("Snapshot", snapshot, ((ShardSnapshotState)reply.getSnapshotState()).getSnapshot());
index e3ae265..d79de61 100644 (file)
@@ -15,7 +15,7 @@ import static org.opendaylight.controller.cluster.datastore.entityownership.Enti
 
 import akka.testkit.javadsl.TestKit;
 import com.google.common.collect.ImmutableSet;
-import java.util.concurrent.TimeUnit;
+import java.time.Duration;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -31,7 +31,6 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
-import scala.concurrent.duration.FiniteDuration;
 
 /**
  * Unit tests for CandidateListChangeListener.
@@ -72,7 +71,7 @@ public class CandidateListChangeListenerTest extends AbstractActorTest {
                 ImmutableSet.copyOf(candidateAdded.getAllCandidates()));
 
         writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, memberName1));
-        kit.expectNoMessage(FiniteDuration.create(500, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(500));
 
         String memberName2 = "member-2";
         writeNode(ENTITY_OWNERS_PATH, entityOwnersWithCandidate(ENTITY_TYPE, ENTITY_ID1, memberName2));
index a91ca9c..887336d 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.datastore.entityownership;
 
 import static org.junit.Assert.assertEquals;
 import static org.mockito.AdditionalMatchers.or;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.reset;
@@ -29,6 +29,7 @@ import akka.dispatch.Dispatchers;
 import akka.testkit.TestActorRef;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.util.concurrent.Uninterruptibles;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -523,7 +524,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         kit.watch(peer2);
         peer2.tell(PoisonPill.getInstance(), ActorRef.noSender());
-        kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
         kit.unwatch(peer2);
 
         leader.tell(new PeerDown(peerId2.getMemberName(), peerId2.toString()), ActorRef.noSender());
@@ -590,7 +591,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         kit.watch(peer1);
         peer1.tell(PoisonPill.getInstance(), ActorRef.noSender());
-        kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
         kit.unwatch(peer1);
         leader.tell(new PeerDown(peerId1.getMemberName(), peerId1.toString()), ActorRef.noSender());
 
@@ -647,7 +648,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest {
 
         kit.watch(leader);
         leader.tell(PoisonPill.getInstance(), ActorRef.noSender());
-        kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Terminated.class);
         kit.unwatch(leader);
         peer2.tell(new PeerDown(leaderId.getMemberName(), leaderId.toString()), ActorRef.noSender());
         peer2.tell(TimeoutNow.INSTANCE, peer2);
index 752c8e1..d289e02 100644 (file)
@@ -13,6 +13,7 @@ import akka.actor.ActorRef;
 import akka.actor.Status.Failure;
 import akka.actor.Terminated;
 import akka.testkit.javadsl.TestKit;
+import java.time.Duration;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
@@ -29,7 +30,6 @@ import org.opendaylight.controller.cluster.raft.ReplicatedLogEntry;
 import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
 import org.opendaylight.controller.cluster.raft.persisted.ByteState;
 import org.opendaylight.controller.cluster.raft.persisted.Snapshot;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 /**
@@ -48,7 +48,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
         ShardManagerSnapshot shardManagerSnapshot = new ShardManagerSnapshot(shardList, Collections.emptyMap());
         ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
                 shardList, "config", shardManagerSnapshot, kit.getRef(),
-                "shard-manager", Duration.create(100, TimeUnit.SECONDS)), "testSuccess");
+                "shard-manager", FiniteDuration.create(100, TimeUnit.SECONDS)), "testSuccess");
 
         kit.watch(replyActor);
 
@@ -62,7 +62,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
                 Snapshot.create(shard2SnapshotState, Collections.<ReplicatedLogEntry>emptyList(),
                         2, 1, 2, 1, 1, "member-1", null)), ActorRef.noSender());
 
-        kit.expectNoMessage(FiniteDuration.create(500, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(500));
 
         ByteState shard3SnapshotState = ByteState.of(new byte[]{7,8,9});
         replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard3", MEMBER_1, "config").toString(),
@@ -95,7 +95,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
 
         ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
                 Arrays.asList("shard1", "shard2"), "config", null, kit.getRef(), "shard-manager",
-                Duration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
+                FiniteDuration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
 
         kit.watch(replyActor);
 
@@ -115,7 +115,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
 
         ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
                 Arrays.asList("shard1"), "config", null, kit.getRef(), "shard-manager",
-                Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
+                FiniteDuration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
 
         kit.watch(replyActor);
 
index 4eea96d..63af6be 100644 (file)
@@ -50,6 +50,7 @@ import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.net.URI;
+import java.time.Duration;
 import java.util.AbstractMap;
 import java.util.Arrays;
 import java.util.Collection;
@@ -134,7 +135,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class ShardManagerTest extends AbstractShardManagerTest {
@@ -352,7 +352,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary("non-existent", false), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), PrimaryNotFoundException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), PrimaryNotFoundException.class);
     }
 
     @Test
@@ -377,7 +377,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        LocalPrimaryShardFound primaryFound = kit.expectMsgClass(kit.duration("5 seconds"),
+        LocalPrimaryShardFound primaryFound = kit.expectMsgClass(Duration.ofSeconds(5),
             LocalPrimaryShardFound.class);
         assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(),
             primaryFound.getPrimaryPath().contains("member-1-shard-default"));
@@ -405,7 +405,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NoShardLeaderException.class);
 
         LOG.info("testOnReceiveFindPrimaryForNonLocalLeaderShardBeforeMemberUp ending");
     }
@@ -431,8 +431,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        RemotePrimaryShardFound primaryFound = kit.expectMsgClass(kit.duration("5 seconds"),
-            RemotePrimaryShardFound.class);
+        RemotePrimaryShardFound primaryFound = kit.expectMsgClass(Duration.ofSeconds(5), RemotePrimaryShardFound.class);
         assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(),
             primaryFound.getPrimaryPath().contains("member-2-shard-default"));
         assertEquals("getPrimaryVersion", leaderVersion, primaryFound.getPrimaryVersion());
@@ -447,7 +446,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NotInitializedException.class);
     }
 
     @Test
@@ -460,7 +459,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NoShardLeaderException.class);
     }
 
     @Test
@@ -479,7 +478,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NoShardLeaderException.class);
 
         DataTree mockDataTree = mock(DataTree.class);
         shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mockDataTree,
@@ -487,7 +486,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        LocalPrimaryShardFound primaryFound = kit.expectMsgClass(kit.duration("5 seconds"),
+        LocalPrimaryShardFound primaryFound = kit.expectMsgClass(Duration.ofSeconds(5),
             LocalPrimaryShardFound.class);
         assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(),
             primaryFound.getPrimaryPath().contains("member-1-shard-default"));
@@ -511,30 +510,29 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         // RoleChangeNotification.
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true), kit.getRef());
 
-        kit.expectNoMessage(FiniteDuration.create(150, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(150));
 
         shardManager.tell(new ActorInitialized(), mockShardActor);
 
-        kit.expectNoMessage(FiniteDuration.create(150, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(150));
 
         String memberId = "member-1-shard-default-" + shardMrgIDSuffix;
         shardManager.tell(
             new RoleChangeNotification(memberId, RaftState.Candidate.name(), RaftState.Leader.name()),
             mockShardActor);
 
-        kit.expectNoMessage(FiniteDuration.create(150, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(150));
 
         DataTree mockDataTree = mock(DataTree.class);
         shardManager.tell(new ShardLeaderStateChanged(memberId, memberId, mockDataTree,
             DataStoreVersions.CURRENT_VERSION), mockShardActor);
 
-        LocalPrimaryShardFound primaryFound = kit.expectMsgClass(kit.duration("5 seconds"),
-            LocalPrimaryShardFound.class);
+        LocalPrimaryShardFound primaryFound = kit.expectMsgClass(Duration.ofSeconds(5), LocalPrimaryShardFound.class);
         assertTrue("Unexpected primary path " + primaryFound.getPrimaryPath(),
             primaryFound.getPrimaryPath().contains("member-1-shard-default"));
         assertSame("getLocalShardDataTree", mockDataTree, primaryFound.getLocalShardDataTree());
 
-        kit.expectNoMessage(FiniteDuration.create(200, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(200));
 
         LOG.info("testOnReceiveFindPrimaryWaitForShardLeader ending");
     }
@@ -549,11 +547,11 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("2 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(2), NotInitializedException.class);
 
         shardManager.tell(new ActorInitialized(), mockShardActor);
 
-        kit.expectNoMessage(FiniteDuration.create(200, TimeUnit.MILLISECONDS));
+        kit.expectNoMessage(Duration.ofMillis(200));
 
         LOG.info("testOnReceiveFindPrimaryWaitForReadyWithUninitializedShard ending");
     }
@@ -571,7 +569,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("2 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(2), NoShardLeaderException.class);
 
         LOG.info("testOnReceiveFindPrimaryWaitForReadyWithCandidateShard ending");
     }
@@ -589,7 +587,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true),kit. getRef());
 
-        kit.expectMsgClass(kit.duration("2 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(2), NoShardLeaderException.class);
 
         LOG.info("testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard ending");
     }
@@ -605,7 +603,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindPrimary(Shard.DEFAULT_NAME, true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("2 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(2), NoShardLeaderException.class);
 
         LOG.info("testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard ending");
     }
@@ -658,7 +656,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         shardManager1.underlyingActor().waitForMemberUp();
         shardManager1.tell(new FindPrimary("astronauts", false), kit.getRef());
 
-        RemotePrimaryShardFound found = kit.expectMsgClass(kit.duration("5 seconds"), RemotePrimaryShardFound.class);
+        RemotePrimaryShardFound found = kit.expectMsgClass(Duration.ofSeconds(5), RemotePrimaryShardFound.class);
         String path = found.getPrimaryPath();
         assertTrue("Unexpected primary path " + path, path.contains("member-2-shard-astronauts-config"));
         assertEquals("getPrimaryVersion", leaderVersion, found.getPrimaryVersion());
@@ -673,7 +671,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 //
 //                shardManager1.tell(new FindPrimary("astronauts", false), getRef());
 //
-//                expectMsgClass(duration("5 seconds"), PrimaryNotFoundException.class);
+//                expectMsgClass(Duration.ofSeconds(5), PrimaryNotFoundException.class);
 
         LOG.info("testOnReceiveFindPrimaryForRemoteShard ending");
     }
@@ -733,7 +731,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager1.tell(new FindPrimary("default", true), kit.getRef());
 
-        RemotePrimaryShardFound found = kit.expectMsgClass(kit.duration("5 seconds"), RemotePrimaryShardFound.class);
+        RemotePrimaryShardFound found = kit.expectMsgClass(Duration.ofSeconds(5), RemotePrimaryShardFound.class);
         String path = found.getPrimaryPath();
         assertTrue("Unexpected primary path " + path, path.contains("member-2-shard-default-config"));
 
@@ -753,7 +751,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager1.tell(new FindPrimary("default", true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NoShardLeaderException.class);
 
         shardManager1.tell(MockClusterWrapper.createReachableMember("member-2", "akka://cluster-test@127.0.0.1:2558"),
             kit.getRef());
@@ -766,7 +764,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager1.tell(new FindPrimary("default", true), kit.getRef());
 
-        RemotePrimaryShardFound found1 = kit.expectMsgClass(kit.duration("5 seconds"), RemotePrimaryShardFound.class);
+        RemotePrimaryShardFound found1 = kit.expectMsgClass(Duration.ofSeconds(5), RemotePrimaryShardFound.class);
         String path1 = found1.getPrimaryPath();
         assertTrue("Unexpected primary path " + path1, path1.contains("member-2-shard-default-config"));
 
@@ -786,7 +784,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         shardManager1.tell(
             MockClusterWrapper.createReachableMember("member-2", "akka://cluster-test@127.0.0.1:2558"), kit.getRef());
 
-        RemotePrimaryShardFound found2 = kit.expectMsgClass(kit.duration("5 seconds"), RemotePrimaryShardFound.class);
+        RemotePrimaryShardFound found2 = kit.expectMsgClass(Duration.ofSeconds(5), RemotePrimaryShardFound.class);
         String path2 = found2.getPrimaryPath();
         assertTrue("Unexpected primary path " + path2, path2.contains("member-2-shard-default-config"));
 
@@ -850,7 +848,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager1.tell(new FindPrimary("default", true), kit.getRef());
 
-        RemotePrimaryShardFound found = kit.expectMsgClass(kit.duration("5 seconds"), RemotePrimaryShardFound.class);
+        RemotePrimaryShardFound found = kit.expectMsgClass(Duration.ofSeconds(5), RemotePrimaryShardFound.class);
         String path = found.getPrimaryPath();
         assertTrue("Unexpected primary path " + path, path.contains("member-2-shard-default-config"));
 
@@ -864,7 +862,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager1.tell(new FindPrimary("default", true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NoShardLeaderException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NoShardLeaderException.class);
 
         assertNull("Expected primaryShardInfoCache entry removed",
             primaryShardInfoCache.getIfPresent("default"));
@@ -877,7 +875,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager1.tell(new FindPrimary("default", true), kit.getRef());
 
-        LocalPrimaryShardFound found1 = kit.expectMsgClass(kit.duration("5 seconds"), LocalPrimaryShardFound.class);
+        LocalPrimaryShardFound found1 = kit.expectMsgClass(Duration.ofSeconds(5), LocalPrimaryShardFound.class);
         String path1 = found1.getPrimaryPath();
         assertTrue("Unexpected primary path " + path1, path1.contains("member-1-shard-default-config"));
 
@@ -946,8 +944,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager256.tell(new FindPrimary("default", true), kit256.getRef());
 
-        LocalPrimaryShardFound found = kit256.expectMsgClass(kit256.duration("5 seconds"),
-            LocalPrimaryShardFound.class);
+        LocalPrimaryShardFound found = kit256.expectMsgClass(Duration.ofSeconds(5), LocalPrimaryShardFound.class);
         String path = found.getPrimaryPath();
         assertTrue("Unexpected primary path " + path + " which must on member-256",
             path.contains("member-256-shard-default-config"));
@@ -963,7 +960,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         // Make sure leader shard on member-256 is still leader and still in the cache.
         shardManager256.tell(new FindPrimary("default", true), kit256.getRef());
-        found = kit256.expectMsgClass(kit256.duration("5 seconds"), LocalPrimaryShardFound.class);
+        found = kit256.expectMsgClass(Duration.ofSeconds(5), LocalPrimaryShardFound.class);
         path = found.getPrimaryPath();
         assertTrue("Unexpected primary path " + path + " which must still not on member-256",
             path.contains("member-256-shard-default-config"));
@@ -992,7 +989,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindLocalShard("non-existent", false), kit.getRef());
 
-        LocalShardNotFound notFound = kit.expectMsgClass(kit.duration("5 seconds"), LocalShardNotFound.class);
+        LocalShardNotFound notFound = kit.expectMsgClass(Duration.ofSeconds(5), LocalShardNotFound.class);
 
         assertEquals("getShardName", "non-existent", notFound.getShardName());
     }
@@ -1007,7 +1004,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        LocalShardFound found = kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        LocalShardFound found = kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         assertTrue("Found path contains " + found.getPath().path().toString(),
             found.getPath().path().toString().contains("member-1-shard-default-config"));
@@ -1020,7 +1017,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NotInitializedException.class);
     }
 
     @Test
@@ -1252,11 +1249,11 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             "foo", null, members("member-1", "member-5", "member-6"));
         shardManager.tell(new CreateShard(config, shardBuilder, datastoreContext), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
 
         shardManager.tell(new FindLocalShard("foo", true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         assertFalse("isRecoveryApplicable", shardBuilder.getDatastoreContext().isPersistent());
         assertTrue("Epxected ShardPeerAddressResolver", shardBuilder.getDatastoreContext().getShardRaftConfig()
@@ -1274,7 +1271,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(new CreateShard(config, shardBuilder, null), kit.getRef());
 
-        Success success = kit.expectMsgClass(kit.duration("5 seconds"), Success.class);
+        Success success = kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
         assertNotNull("Success status is null", success.status());
 
         LOG.info("testOnCreateShard ending");
@@ -1297,10 +1294,10 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             "foo", null, members("member-5", "member-6"));
 
         shardManager.tell(new CreateShard(config, shardBuilder, null), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
 
         shardManager.tell(new FindLocalShard("foo", true), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         assertEquals("peerMembers size", 0, shardBuilder.getPeerAddresses().size());
         assertEquals("schemaContext", DisableElectionsRaftPolicy.class.getName(), shardBuilder
@@ -1323,14 +1320,14 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             "foo", null, members("member-1"));
         shardManager.tell(new CreateShard(config, shardBuilder, null), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
 
         SchemaContext schemaContext = TEST_SCHEMA_CONTEXT;
         shardManager.tell(new UpdateSchemaContext(schemaContext), ActorRef.noSender());
 
         shardManager.tell(new FindLocalShard("foo", true), kit.getRef());
 
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         assertSame("schemaContext", schemaContext, shardBuilder.getSchemaContext());
         assertNotNull("schemaContext is null", shardBuilder.getDatastoreContext());
@@ -1448,7 +1445,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
                     .withDispatcher(Dispatchers.DefaultDispatcherId()));
 
         shardManager.tell(new AddShardReplica("model-inventory"), kit.getRef());
-        Status.Failure resp = kit.expectMsgClass(kit.duration("2 seconds"), Status.Failure.class);
+        Status.Failure resp = kit.expectMsgClass(Duration.ofSeconds(2), Status.Failure.class);
 
         assertTrue("Failure obtained", resp.cause() instanceof IllegalArgumentException);
     }
@@ -1524,7 +1521,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             AddServer.class);
         String addServerId = "member-1-shard-astronauts-" + shardMrgIDSuffix;
         assertEquals("AddServer serverId", addServerId, addServerMsg.getNewServerId());
-        kit.expectMsgClass(kit.duration("5 seconds"), Status.Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Status.Success.class);
 
         InMemorySnapshotStore.waitForSavedSnapshot(shardManagerID, ShardManagerSnapshot.class);
         InMemorySnapshotStore.waitForDeletedSnapshot(shardManagerID);
@@ -1566,17 +1563,17 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         MessageCollectorActor.expectFirstMatching(leaderShardActor, AddServer.class);
 
-        Failure resp = kit.expectMsgClass(kit.duration("5 seconds"), Failure.class);
+        Failure resp = kit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
         assertEquals("Failure cause", AlreadyExistsException.class, resp.cause().getClass());
 
         shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         // Send message again to verify previous in progress state is
         // cleared
 
         shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), kit.getRef());
-        resp = kit.expectMsgClass(kit.duration("5 seconds"), Failure.class);
+        resp = kit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
         assertEquals("Failure cause", AlreadyExistsException.class, resp.cause().getClass());
 
         // Send message again with an AddServer timeout to verify the
@@ -1587,10 +1584,10 @@ public class ShardManagerTest extends AbstractShardManagerTest {
                 datastoreContextBuilder.shardLeaderElectionTimeout(100, TimeUnit.MILLISECONDS).build()), kit.getRef());
         leaderShardActor.tell(MockRespondActor.CLEAR_RESPONSE, ActorRef.noSender());
         shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), Failure.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
 
         shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         LOG.info("testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader ending");
     }
@@ -1611,11 +1608,11 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             mockShardActor);
 
         shardManager.tell(new AddShardReplica(Shard.DEFAULT_NAME), kit.getRef());
-        Failure resp = kit.expectMsgClass(kit.duration("5 seconds"), Failure.class);
+        Failure resp = kit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
         assertEquals("Failure cause", AlreadyExistsException.class, resp.cause().getClass());
 
         shardManager.tell(new FindLocalShard(Shard.DEFAULT_NAME, false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardFound.class);
 
         LOG.info("testAddShardReplicaWithPreExistingLocalReplicaLeader ending");
     }
@@ -1647,18 +1644,18 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             addServerMsg.getNewServerId());
         mockShardLeaderKit.reply(new AddServerReply(ServerChangeStatus.TIMEOUT, null));
 
-        Failure failure = kit.expectMsgClass(kit.duration("5 seconds"), Failure.class);
+        Failure failure = kit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
         assertEquals("Failure cause", TimeoutException.class, failure.cause().getClass());
 
         shardManager.tell(new FindLocalShard("astronauts", false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), LocalShardNotFound.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), LocalShardNotFound.class);
 
         terminateWatcher.expectTerminated(mockNewReplicaShardActor);
 
         shardManager.tell(new AddShardReplica("astronauts"), kit.getRef());
         mockShardLeaderKit.expectMsgClass(AddServer.class);
         mockShardLeaderKit.reply(new AddServerReply(ServerChangeStatus.NO_LEADER, null));
-        failure = kit.expectMsgClass(kit.duration("5 seconds"), Failure.class);
+        failure = kit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
         assertEquals("Failure cause", NoShardLeaderException.class, failure.cause().getClass());
 
         LOG.info("testAddShardReplicaWithAddServerReplyFailure ending");
@@ -1686,7 +1683,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             AddressFromURIString.parse("akka://non-existent@127.0.0.1:5").toString());
 
         newReplicaShardManager.tell(new AddShardReplica("astronauts"), kit.getRef());
-        Status.Failure resp = kit.expectMsgClass(kit.duration("5 seconds"), Status.Failure.class);
+        Status.Failure resp = kit.expectMsgClass(Duration.ofSeconds(5), Status.Failure.class);
         assertTrue("Failure obtained", resp.cause() instanceof RuntimeException);
 
         LOG.info("testAddShardReplicaWithFindPrimaryTimeout ending");
@@ -1700,7 +1697,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
                     .withDispatcher(Dispatchers.DefaultDispatcherId()));
 
         shardManager.tell(new RemoveShardReplica("model-inventory", MEMBER_1), kit.getRef());
-        Status.Failure resp = kit.expectMsgClass(kit.duration("10 seconds"), Status.Failure.class);
+        Status.Failure resp = kit.expectMsgClass(Duration.ofSeconds(10), Status.Failure.class);
         assertTrue("Failure obtained", resp.cause() instanceof PrimaryNotFoundException);
     }
 
@@ -1730,7 +1727,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             RemoveServer.class);
         assertEquals(ShardIdentifier.create("default", MEMBER_1, shardMrgIDSuffix).toString(),
             removeServer.getServerId());
-        kit.expectMsgClass(kit.duration("5 seconds"), Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
     }
 
     @Test
@@ -1818,7 +1815,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
             RemoveServer.class);
         String removeServerId = ShardIdentifier.create("default", MEMBER_1, shardMrgIDSuffix).toString();
         assertEquals("RemoveServer serverId", removeServerId, removeServer.getServerId());
-        kit.expectMsgClass(kit.duration("5 seconds"), Status.Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Status.Success.class);
     }
 
     @Test
@@ -1860,7 +1857,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.tell(secondServerChange, secondRequestKit.getRef());
 
-        secondRequestKit.expectMsgClass(secondRequestKit.duration("5 seconds"), Failure.class);
+        secondRequestKit.expectMsgClass(Duration.ofSeconds(5), Failure.class);
     }
 
     @Test
@@ -1877,10 +1874,10 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         shardManager.underlyingActor().waitForRecoveryComplete();
         shardManager.tell(new FindLocalShard("people", false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NotInitializedException.class);
 
         shardManager.tell(new FindLocalShard("default", false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NotInitializedException.class);
 
         // Removed the default shard replica from member-1
         ShardIdentifier.Builder builder = new ShardIdentifier.Builder();
@@ -1948,7 +1945,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         newRestoredShardManager.underlyingActor().waitForRecoveryComplete();
 
         newRestoredShardManager.tell(new FindLocalShard("people", false), kit.getRef());
-        LocalShardNotFound notFound = kit.expectMsgClass(kit.duration("5 seconds"), LocalShardNotFound.class);
+        LocalShardNotFound notFound = kit.expectMsgClass(Duration.ofSeconds(5), LocalShardNotFound.class);
         assertEquals("for uninitialized shard", "people", notFound.getShardName());
 
         // Verify a local shard is created for the restored shards,
@@ -1956,10 +1953,10 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         // as the actor initialization
         // message is not sent for them
         newRestoredShardManager.tell(new FindLocalShard("default", false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NotInitializedException.class);
 
         newRestoredShardManager.tell(new FindLocalShard("astronauts", false), kit.getRef());
-        kit.expectMsgClass(kit.duration("5 seconds"), NotInitializedException.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), NotInitializedException.class);
 
         LOG.info("testShardPersistenceWithRestoredData ending");
     }
@@ -2035,7 +2032,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
                 .create("default", MemberName.forName("member-2"), shardMrgIDSuffix).toString(),
                 Boolean.TRUE));
 
-        kit.expectMsgClass(kit.duration("5 seconds"), Success.class);
+        kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
     }
 
     @Test
@@ -2058,7 +2055,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
 
         MessageCollectorActor.expectFirstMatching(respondActor, ChangeServersVotingStatus.class);
 
-        Status.Failure resp = kit.expectMsgClass(kit.duration("5 seconds"), Status.Failure.class);
+        Status.Failure resp = kit.expectMsgClass(Duration.ofSeconds(5), Status.Failure.class);
         assertTrue("Failure resposnse", resp.cause() instanceof NoShardLeaderException);
     }
 
@@ -2078,7 +2075,7 @@ public class ShardManagerTest extends AbstractShardManagerTest {
         final Consumer<String> mockCallback = mock(Consumer.class);
         shardManager.tell(new RegisterForShardAvailabilityChanges(mockCallback), kit.getRef());
 
-        final Success reply = kit.expectMsgClass(Duration.apply(5, TimeUnit.SECONDS), Success.class);
+        final Success reply = kit.expectMsgClass(Duration.ofSeconds(5), Success.class);
         final Registration reg = (Registration) reply.status();
 
         final DataTree mockDataTree = mock(DataTree.class);
index 0fa47d7..2ca2192 100644 (file)
@@ -34,6 +34,7 @@ import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
 import com.typesafe.config.ConfigFactory;
+import java.time.Duration;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
@@ -64,7 +65,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import scala.concurrent.Await;
 import scala.concurrent.Future;
-import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
 
 public class ActorContextTest extends AbstractActorTest {
@@ -143,7 +143,7 @@ public class ActorContextTest extends AbstractActorTest {
     @Test
     public void testFindLocalShardWithShardFound() {
         final TestKit testKit = new TestKit(getSystem());
-        testKit.within(testKit.duration("1 seconds"), () -> {
+        testKit.within(Duration.ofSeconds(1), () -> {
             ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
 
             ActorRef shardManagerActorRef = getSystem().actorOf(MockShardManager.props(true, shardActorRef));
@@ -200,7 +200,7 @@ public class ActorContextTest extends AbstractActorTest {
 
         Future<Object> future = actorContext.executeOperationAsync(actor, "hello");
 
-        Object result = Await.result(future, Duration.create(3, TimeUnit.SECONDS));
+        Object result = Await.result(future, FiniteDuration.create(3, TimeUnit.SECONDS));
         assertEquals("Result", "hello", result);
     }
 
@@ -307,7 +307,7 @@ public class ActorContextTest extends AbstractActorTest {
 
         actorContext.setDatastoreContext(mockContextFactory);
 
-        testKit.expectMsgClass(testKit.duration("5 seconds"), DatastoreContextFactory.class);
+        testKit.expectMsgClass(Duration.ofSeconds(5), DatastoreContextFactory.class);
 
         Assert.assertSame("getDatastoreContext", newContext, actorContext.getDatastoreContext());
 
@@ -336,7 +336,7 @@ public class ActorContextTest extends AbstractActorTest {
         };
 
         Future<PrimaryShardInfo> foobar = actorContext.findPrimaryShardAsync("foobar");
-        PrimaryShardInfo actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS));
+        PrimaryShardInfo actual = Await.result(foobar, FiniteDuration.apply(5000, TimeUnit.MILLISECONDS));
 
         assertNotNull(actual);
         assertFalse("LocalShardDataTree present", actual.getLocalShardDataTree().isPresent());
@@ -377,7 +377,7 @@ public class ActorContextTest extends AbstractActorTest {
         };
 
         Future<PrimaryShardInfo> foobar = actorContext.findPrimaryShardAsync("foobar");
-        PrimaryShardInfo actual = Await.result(foobar, Duration.apply(5000, TimeUnit.MILLISECONDS));
+        PrimaryShardInfo actual = Await.result(foobar, FiniteDuration.apply(5000, TimeUnit.MILLISECONDS));
 
         assertNotNull(actual);
         assertTrue("LocalShardDataTree present", actual.getLocalShardDataTree().isPresent());
@@ -429,7 +429,7 @@ public class ActorContextTest extends AbstractActorTest {
         Future<PrimaryShardInfo> foobar = actorContext.findPrimaryShardAsync("foobar");
 
         try {
-            Await.result(foobar, Duration.apply(100, TimeUnit.MILLISECONDS));
+            Await.result(foobar, FiniteDuration.apply(100, TimeUnit.MILLISECONDS));
             fail("Expected" + expectedException.getClass().toString());
         } catch (Exception e) {
             if (!expectedException.getClass().isInstance(e)) {
index ddf0ba3..7ea9191 100644 (file)
@@ -9,11 +9,12 @@ package org.opendaylight.controller.remote.rpc;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.any;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.when;
 
 import akka.actor.Status.Failure;
+import java.time.Duration;
 import org.junit.Test;
 import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
 import org.opendaylight.controller.remote.rpc.messages.RpcResponse;
@@ -37,8 +38,7 @@ public class RpcBrokerTest extends AbstractRpcTest {
 
         rpcInvoker1.tell(executeMsg, rpcRegistry1Probe.getRef());
 
-        final RpcResponse rpcResponse = rpcRegistry1Probe.expectMsgClass(rpcRegistry1Probe.duration("5 seconds"),
-            RpcResponse.class);
+        final RpcResponse rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), RpcResponse.class);
 
         assertEquals(rpcResult.getResult(), rpcResponse.getResultNormalizedNode());
     }
@@ -52,8 +52,7 @@ public class RpcBrokerTest extends AbstractRpcTest {
 
         rpcInvoker1.tell(executeMsg, rpcRegistry1Probe.getRef());
 
-        final Failure rpcResponse = rpcRegistry1Probe.expectMsgClass(rpcRegistry1Probe.duration("5 seconds"),
-            Failure.class);
+        final Failure rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), Failure.class);
 
         assertTrue(rpcResponse.cause() instanceof DOMRpcException);
     }
index 0d3b368..d32e8d8 100644 (file)
@@ -5,9 +5,11 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.remote.rpc.registry;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_ALL_BUCKETS;
 import static org.opendaylight.controller.remote.rpc.registry.gossip.BucketStoreAccess.Singletons.GET_BUCKET_VERSIONS;
@@ -26,6 +28,7 @@ import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Uninterruptibles;
 import com.typesafe.config.ConfigFactory;
 import java.net.URI;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -37,7 +40,6 @@ import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -53,8 +55,6 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import scala.concurrent.duration.Duration;
-import scala.concurrent.duration.FiniteDuration;
 
 public class RpcRegistryTest {
     private static final Logger LOG = LoggerFactory.getLogger(RpcRegistryTest.class);
@@ -191,7 +191,7 @@ public class RpcRegistryTest {
         verifyBucket(buckets.get(nodeAddress), addedRouteIds);
 
         Map<Address, Long> versions = retrieveVersions(registry1, testKit);
-        Assert.assertEquals("Version for bucket " + nodeAddress, (Long) buckets.get(nodeAddress).getVersion(),
+        assertEquals("Version for bucket " + nodeAddress, (Long) buckets.get(nodeAddress).getVersion(),
                 versions.get(nodeAddress));
 
         // Now remove rpc
@@ -269,14 +269,14 @@ public class RpcRegistryTest {
         List<DOMRpcIdentifier> addedRouteIds1 = createRouteIds();
         registry1.tell(new AddOrUpdateRoutes(addedRouteIds1), ActorRef.noSender());
 
-        final UpdateRemoteEndpoints req1 = registrar3.expectMsgClass(Duration.create(3, TimeUnit.SECONDS),
+        final UpdateRemoteEndpoints req1 = registrar3.expectMsgClass(Duration.ofSeconds(3),
             UpdateRemoteEndpoints.class);
 
         // Add rpc on node 2
         List<DOMRpcIdentifier> addedRouteIds2 = createRouteIds();
         registry2.tell(new AddOrUpdateRoutes(addedRouteIds2), ActorRef.noSender());
 
-        final UpdateRemoteEndpoints req2 = registrar3.expectMsgClass(Duration.create(3, TimeUnit.SECONDS),
+        final UpdateRemoteEndpoints req2 = registrar3.expectMsgClass(Duration.ofSeconds(3),
             UpdateRemoteEndpoints.class);
         Address node2Address = node2.provider().getDefaultAddress();
         Address node1Address = node1.provider().getDefaultAddress();
@@ -288,9 +288,9 @@ public class RpcRegistryTest {
         verifyBucket(buckets.get(node2Address), addedRouteIds2);
 
         Map<Address, Long> versions = retrieveVersions(registry3, testKit);
-        Assert.assertEquals("Version for bucket " + node1Address, (Long) buckets.get(node1Address).getVersion(),
+        assertEquals("Version for bucket " + node1Address, (Long) buckets.get(node1Address).getVersion(),
                 versions.get(node1Address));
-        Assert.assertEquals("Version for bucket " + node2Address, (Long) buckets.get(node2Address).getVersion(),
+        assertEquals("Version for bucket " + node2Address, (Long) buckets.get(node2Address).getVersion(),
                 versions.get(node2Address));
 
         assertEndpoints(req1, node1Address, invoker1);
@@ -300,38 +300,38 @@ public class RpcRegistryTest {
 
     private static void assertEndpoints(final UpdateRemoteEndpoints msg, final Address address, final TestKit invoker) {
         final Map<Address, Optional<RemoteRpcEndpoint>> endpoints = msg.getEndpoints();
-        Assert.assertEquals(1, endpoints.size());
+        assertEquals(1, endpoints.size());
 
         final Optional<RemoteRpcEndpoint> maybeEndpoint = endpoints.get(address);
-        Assert.assertNotNull(maybeEndpoint);
-        Assert.assertTrue(maybeEndpoint.isPresent());
+        assertNotNull(maybeEndpoint);
+        assertTrue(maybeEndpoint.isPresent());
 
         final RemoteRpcEndpoint endpoint = maybeEndpoint.get();
         final ActorRef router = endpoint.getRouter();
-        Assert.assertNotNull(router);
+        assertNotNull(router);
 
         router.tell("hello", ActorRef.noSender());
-        final String s = invoker.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), String.class);
-        Assert.assertEquals("hello", s);
+        final String s = invoker.expectMsgClass(Duration.ofSeconds(3), String.class);
+        assertEquals("hello", s);
     }
 
     private static Map<Address, Long> retrieveVersions(final ActorRef bucketStore, final TestKit testKit) {
         bucketStore.tell(GET_BUCKET_VERSIONS, testKit.getRef());
         @SuppressWarnings("unchecked")
-        final Map<Address, Long> reply = testKit.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), Map.class);
+        final Map<Address, Long> reply = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
         return reply;
     }
 
     private static void verifyBucket(final Bucket<RoutingTable> bucket, final List<DOMRpcIdentifier> expRouteIds) {
         RoutingTable table = bucket.getData();
-        Assert.assertNotNull("Bucket RoutingTable is null", table);
+        assertNotNull("Bucket RoutingTable is null", table);
         for (DOMRpcIdentifier r : expRouteIds) {
             if (!table.contains(r)) {
-                Assert.fail("RoutingTable does not contain " + r + ". Actual: " + table);
+                fail("RoutingTable does not contain " + r + ". Actual: " + table);
             }
         }
 
-        Assert.assertEquals("RoutingTable size", expRouteIds.size(), table.size());
+        assertEquals("RoutingTable size", expRouteIds.size(), table.size());
     }
 
     private static Map<Address, Bucket<RoutingTable>> retrieveBuckets(final ActorRef bucketStore,
@@ -340,8 +340,7 @@ public class RpcRegistryTest {
         while (true) {
             bucketStore.tell(GET_ALL_BUCKETS, testKit.getRef());
             @SuppressWarnings("unchecked")
-            Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(Duration.create(3, TimeUnit.SECONDS),
-                    Map.class);
+            Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
 
             boolean foundAll = true;
             for (Address addr : addresses) {
@@ -357,8 +356,7 @@ public class RpcRegistryTest {
             }
 
             if (++numTries >= 50) {
-                Assert.fail("Missing expected buckets for addresses: " + Arrays.toString(addresses)
-                        + ", Actual: " + buckets);
+                fail("Missing expected buckets for addresses: " + Arrays.toString(addresses) + ", Actual: " + buckets);
             }
 
             Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
@@ -381,25 +379,24 @@ public class RpcRegistryTest {
                     ActorRef.noSender());
         }
 
-        FiniteDuration duration = Duration.create(3, TimeUnit.SECONDS);
         int numTries = 0;
         while (true) {
             registry1.tell(GET_ALL_BUCKETS, testKit.getRef());
             @SuppressWarnings("unchecked")
-            Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(duration, Map.class);
+            Map<Address, Bucket<RoutingTable>> buckets = testKit.expectMsgClass(Duration.ofSeconds(3), Map.class);
 
             Bucket<RoutingTable> localBucket = buckets.values().iterator().next();
             RoutingTable table = localBucket.getData();
             if (table != null && table.size() == nRoutes) {
                 for (DOMRpcIdentifier r : added) {
-                    Assert.assertTrue("RoutingTable contains " + r, table.contains(r));
+                    assertTrue("RoutingTable contains " + r, table.contains(r));
                 }
 
                 break;
             }
 
             if (++numTries >= 50) {
-                Assert.fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
+                fail("Expected # routes: " + nRoutes + ", Actual: " + table.size());
             }
 
             Uninterruptibles.sleepUninterruptibly(200, TimeUnit.MILLISECONDS);

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.