From: Robert Varga Date: Thu, 16 Nov 2017 13:59:36 +0000 (+0100) Subject: Migrate from JavaTestKit to javadsl.TestKit X-Git-Tag: release/oxygen~23 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=e9fc7e7ed2b13d274518d6a872ab67749ef4507a Migrate from JavaTestKit to javadsl.TestKit Remove use of deprecated class and use its 2.5.0 replacement. This leaves a single instance of this class are RaftActorTestKit and ShartTestKit which will need to be migrated in a follow-up patch. Change-Id: I5c112f9984bec3ecf2da530f3505aceb83fa1e05 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java index 9cd2d1cb5e..7784a218f1 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractClientConnectionTest.java @@ -16,8 +16,8 @@ import static org.opendaylight.controller.cluster.access.client.ConnectionEntryM import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.Iterables; import java.util.Optional; import java.util.function.Consumer; @@ -143,7 +143,7 @@ public abstract class AbstractClientConnectionTest createRequest(final ActorRef replyTo) { diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java index 3800da865a..464acdcea8 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/AbstractTransmitQueueTest.java @@ -14,8 +14,8 @@ import static org.mockito.Mockito.verify; import static org.opendaylight.controller.cluster.access.client.ConnectionEntryMatcher.entryWithRequest; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Ticker; import java.util.Collection; import java.util.Optional; @@ -63,7 +63,7 @@ public abstract class AbstractTransmitQueueTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } @Test diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java index 598b598db8..82544657fd 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ActorBehaviorTest.java @@ -19,8 +19,8 @@ import akka.actor.Props; import akka.persistence.Persistence; import akka.persistence.SelectedSnapshot; import akka.persistence.SnapshotMetadata; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import java.lang.reflect.Field; import java.util.Optional; import java.util.concurrent.TimeUnit; @@ -63,7 +63,7 @@ public class ActorBehaviorTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } @Test diff --git a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ClientActorContextTest.java b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ClientActorContextTest.java index 564a2ed340..4dcbccbfb8 100644 --- a/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ClientActorContextTest.java +++ b/opendaylight/md-sal/cds-access-client/src/test/java/org/opendaylight/controller/cluster/access/client/ClientActorContextTest.java @@ -10,8 +10,8 @@ package org.opendaylight.controller.cluster.access.client; import static org.junit.Assert.assertSame; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Ticker; import java.util.concurrent.TimeUnit; import org.junit.After; @@ -76,6 +76,6 @@ public class ClientActorContextTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java index d16e5efaa0..7c1e7784f7 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractActorTest.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.raft; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; @@ -38,7 +38,7 @@ public abstract class AbstractActorTest { @AfterClass public static void tearDownClass() throws Exception { deleteJournal(); - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); system = null; } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java index ef4151d03e..ac970c64e4 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/AbstractRaftActorIntegrationTest.java @@ -17,8 +17,8 @@ import akka.actor.PoisonPill; import akka.actor.Terminated; import akka.dispatch.Dispatchers; import akka.dispatch.Mailboxes; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableMap; @@ -275,11 +275,11 @@ public abstract class AbstractRaftActorIntegrationTest extends AbstractActorTest } protected void killActor(final TestActorRef actor) { - JavaTestKit testkit = new JavaTestKit(getSystem()); + TestKit testkit = new TestKit(getSystem()); testkit.watch(actor); actor.tell(PoisonPill.getInstance(), null); - testkit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class); + testkit.expectMsgClass(testkit.duration("5 seconds"), Terminated.class); testkit.unwatch(actor); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/LeadershipTransferIntegrationTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/LeadershipTransferIntegrationTest.java index 48c9fee8a9..2ed690748e 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/LeadershipTransferIntegrationTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/LeadershipTransferIntegrationTest.java @@ -16,8 +16,8 @@ import static org.opendaylight.controller.cluster.raft.utils.MessageCollectorAct import akka.actor.ActorRef; import akka.actor.Status; import akka.pattern.Patterns; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.ImmutableMap; import java.util.Arrays; import java.util.Collections; @@ -325,8 +325,8 @@ public class LeadershipTransferIntegrationTest extends AbstractRaftActorIntegrat createRaftActors(); createRequestLeadershipResultCollectorActor(); - factory.killActor(follower1Actor, new JavaTestKit(getSystem())); - factory.killActor(follower3Actor, new JavaTestKit(getSystem())); + factory.killActor(follower1Actor, new TestKit(getSystem())); + factory.killActor(follower3Actor, new TestKit(getSystem())); sendFollower2RequestLeadershipTransferToLeader(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java index e844ddf790..29aadbb95c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorServerConfigurationSupportTest.java @@ -19,8 +19,8 @@ import akka.actor.ActorRef; import akka.actor.Props; import akka.actor.UntypedActor; import akka.dispatch.Dispatchers; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableMap; @@ -101,7 +101,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { private ActorRef newFollowerCollectorActor; private RaftActorContext newFollowerActorContext; - private final JavaTestKit testKit = new JavaTestKit(getSystem()); + private final TestKit testKit = new TestKit(getSystem()); @Before public void setup() { @@ -173,7 +173,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { List snapshotState = MockRaftActor.fromState(applySnapshot.getSnapshot().getState()); assertEquals("Snapshot state", snapshotState, leaderRaftActor.getState()); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get()); @@ -253,7 +253,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { List snapshotState = MockRaftActor.fromState(applySnapshot.getSnapshot().getState()); assertEquals("Snapshot state", snapshotState, leaderRaftActor.getState()); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get()); @@ -299,7 +299,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), false), testKit.getRef()); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get()); @@ -336,7 +336,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new AddServer(NEW_SERVER_ID2, followerActor.path().toString(), false), testKit.getRef()); - addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); assertEquals("getLeaderHint", java.util.Optional.of(LEADER_ID), addServerReply.getLeaderHint()); @@ -381,7 +381,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { InstallSnapshot installSnapshot = expectFirstMatching(newFollowerCollectorActor, InstallSnapshot.class); // Send a second AddServer - should get queued - JavaTestKit testKit2 = new JavaTestKit(getSystem()); + TestKit testKit2 = new TestKit(getSystem()); leaderActor.tell(new AddServer(NEW_SERVER_ID2, followerActor.path().toString(), false), testKit2.getRef()); // Continue the first AddServer @@ -389,10 +389,10 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { newFollowerRaftActor.tell(installSnapshot, leaderActor); // Verify both complete successfully - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); - addServerReply = testKit2.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + addServerReply = testKit2.expectMsgClass(testKit2.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); // Verify ServerConfigurationPayload entries in leader's log @@ -442,7 +442,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderRaftActor.setDropMessageOfType(null); leaderActor.tell(commitMsg, leaderActor); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get()); @@ -484,7 +484,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef()); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.TIMEOUT, addServerReply.getStatus()); assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size()); @@ -532,7 +532,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new RaftActorServerConfigurationSupport.ServerOperationTimeout(NEW_SERVER_ID), leaderActor); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus()); assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size()); @@ -578,7 +578,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderRaftActor.setDropMessageOfType(null); leaderActor.tell(snapshotReply, leaderActor); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus()); assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size()); @@ -609,7 +609,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new UnInitializedFollowerSnapshotReply("bogus"), leaderActor); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.TIMEOUT, addServerReply.getStatus()); assertEquals("Leader peers size", 0, leaderActorContext.getPeerIds().size()); @@ -636,7 +636,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { noLeaderActor.tell(new AddServer(NEW_SERVER_ID, newFollowerRaftActor.path().toString(), true), testKit.getRef()); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.NO_LEADER, addServerReply.getStatus()); LOG.info("testAddServerWithNoLeader ending"); @@ -683,7 +683,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(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, addServerReply.getStatus()); assertEquals("getLeaderHint", LEADER_ID, addServerReply.getLeaderHint().get()); @@ -692,12 +692,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(JavaTestKit.duration("5 seconds"), AddServerReply.class); + addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), 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(JavaTestKit.duration("5 seconds"), AddServerReply.class); + addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.PRIOR_REQUEST_CONSENSUS_TIMEOUT, addServerReply.getStatus()); LOG.info("testAddServerWithNoConsensusReached ending"); @@ -716,7 +716,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new AddServer(FOLLOWER_ID, followerActor.path().toString(), true), testKit.getRef()); - AddServerReply addServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), AddServerReply.class); + AddServerReply addServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), AddServerReply.class); assertEquals("getStatus", ServerChangeStatus.ALREADY_EXISTS, addServerReply.getStatus()); LOG.info("testAddServerWithExistingServer ending"); @@ -793,7 +793,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.underlyingActor().waitForInitializeBehaviorComplete(); leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef()); - RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), + RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), RemoveServerReply.class); assertEquals("getStatus", ServerChangeStatus.NO_LEADER, removeServerReply.getStatus()); @@ -812,7 +812,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { actorFactory.generateActorId(LEADER_ID)); leaderActor.tell(new RemoveServer(NEW_SERVER_ID), testKit.getRef()); - RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), + RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), RemoveServerReply.class); assertEquals("getStatus", ServerChangeStatus.DOES_NOT_EXIST, removeServerReply.getStatus()); @@ -886,7 +886,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { follower2Actor.underlyingActor().waitForInitializeBehaviorComplete(); leaderActor.tell(new RemoveServer(FOLLOWER_ID), testKit.getRef()); - RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), + RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), RemoveServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus()); @@ -937,7 +937,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { followerActorId); leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef()); - RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), + RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), RemoveServerReply.class); assertEquals("getStatus", ServerChangeStatus.OK, removeServerReply.getStatus()); @@ -961,7 +961,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { actorFactory.generateActorId(LEADER_ID)); leaderActor.tell(new RemoveServer(LEADER_ID), testKit.getRef()); - RemoveServerReply removeServerReply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), + RemoveServerReply removeServerReply = testKit.expectMsgClass(testKit.duration("5 seconds"), RemoveServerReply.class); assertEquals("getStatus", ServerChangeStatus.NOT_SUPPORTED, removeServerReply.getStatus()); @@ -1005,7 +1005,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(FOLLOWER_ID, false, FOLLOWER_ID2, false)), testKit.getRef()); - ServerChangeReply reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus()); final ApplyState applyState = MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class); @@ -1030,7 +1030,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { // Send second ChangeServersVotingStatus message leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(FOLLOWER_ID, true)), testKit.getRef()); - reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus()); MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class); @@ -1083,7 +1083,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { // Send ChangeServersVotingStatus message leaderActor.tell(new ChangeServersVotingStatus(ImmutableMap.of(LEADER_ID, false)), testKit.getRef()); - ServerChangeReply reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus()); MessageCollectorActor.expectFirstMatching(leaderCollector, ApplyState.class); @@ -1115,7 +1115,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(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.INVALID_REQUEST, reply.getStatus()); LOG.info("testChangeLeaderToNonVotingInSingleNode ending"); @@ -1188,7 +1188,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(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus()); assertEquals("getRaftState", RaftState.Follower, node1RaftActor.getRaftState()); @@ -1209,7 +1209,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { node1RaftActor.setPeerAddress(node2ID, node2RaftActorRef.path().toString()); node1RaftActorRef.tell(changeServers, testKit.getRef()); - reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus()); ApplyJournalEntries apply = MessageCollectorActor.expectFirstMatching(node1Collector, @@ -1283,7 +1283,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { ChangeServersVotingStatus changeServers = new ChangeServersVotingStatus(ImmutableMap.of(node1ID, true)); node1RaftActorRef.tell(changeServers, testKit.getRef()); - ServerChangeReply reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.NO_LEADER, reply.getStatus()); assertEquals("Server config", Sets.newHashSet(nonVotingServer(node1ID), votingServer(node2ID)), @@ -1343,7 +1343,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(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus()); MessageCollectorActor.expectFirstMatching(node2Collector, ApplyJournalEntries.class); @@ -1413,7 +1413,7 @@ public class RaftActorServerConfigurationSupportTest extends AbstractActorTest { node2RaftActorRef.tell(TimeoutNow.INSTANCE, ActorRef.noSender()); - ServerChangeReply reply = testKit.expectMsgClass(JavaTestKit.duration("5 seconds"), ServerChangeReply.class); + ServerChangeReply reply = testKit.expectMsgClass(testKit.duration("5 seconds"), ServerChangeReply.class); assertEquals("getStatus", ServerChangeStatus.OK, reply.getStatus()); MessageCollectorActor.expectFirstMatching(node1Collector, ApplyJournalEntries.class); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java index b8be07a7b6..56089eca4d 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/RaftActorTest.java @@ -35,8 +35,8 @@ import akka.persistence.SaveSnapshotFailure; import akka.persistence.SaveSnapshotSuccess; import akka.persistence.SnapshotMetadata; import akka.persistence.SnapshotOffer; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Uninterruptibles; @@ -128,7 +128,7 @@ public class RaftActorTest extends AbstractActorTest { public void testRaftActorRecoveryWithPersistenceEnabled() throws Exception { TEST_LOG.info("testRaftActorRecoveryWithPersistenceEnabled starting"); - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); String persistenceId = factory.generateActorId("follower-"); DefaultConfigParamsImpl config = new DefaultConfigParamsImpl(); @@ -183,7 +183,7 @@ public class RaftActorTest extends AbstractActorTest { // kill the actor followerActor.tell(PoisonPill.getInstance(), null); - kit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class); + kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class); kit.unwatch(followerActor); @@ -234,7 +234,7 @@ public class RaftActorTest extends AbstractActorTest { @Test public void testUpdateElectionTermPersistedWithPersistenceDisabled() throws Exception { - final JavaTestKit kit = new JavaTestKit(getSystem()); + final TestKit kit = new TestKit(getSystem()); String persistenceId = factory.generateActorId("follower-"); DefaultConfigParamsImpl config = new DefaultConfigParamsImpl(); config.setHeartBeatInterval(new FiniteDuration(100, TimeUnit.MILLISECONDS)); @@ -1009,7 +1009,7 @@ public class RaftActorTest extends AbstractActorTest { public void testGetSnapshot() throws Exception { TEST_LOG.info("testGetSnapshot starting"); - final JavaTestKit kit = new JavaTestKit(getSystem()); + final TestKit kit = new TestKit(getSystem()); String persistenceId = factory.generateActorId("test-actor-"); DefaultConfigParamsImpl config = new DefaultConfigParamsImpl(); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java index 639436d026..ea38c16acc 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/TestActorFactory.java @@ -8,14 +8,6 @@ package org.opendaylight.controller.cluster.raft; -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - import akka.actor.Actor; import akka.actor.ActorIdentity; import akka.actor.ActorRef; @@ -26,8 +18,8 @@ import akka.actor.InvalidActorNameException; import akka.actor.PoisonPill; import akka.actor.Props; import akka.pattern.Patterns; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.base.Stopwatch; import com.google.common.util.concurrent.Uninterruptibles; @@ -181,15 +173,15 @@ public class TestActorFactory implements AutoCloseable { return prefix + actorCount++; } - public void killActor(ActorRef actor, JavaTestKit kit) { + public void killActor(ActorRef actor, TestKit kit) { killActor(actor, kit, true); } - private void killActor(ActorRef actor, JavaTestKit kit, boolean remove) { + private void killActor(ActorRef actor, TestKit kit, boolean remove) { LOG.info("Killing actor {}", actor); kit.watch(actor); actor.tell(PoisonPill.getInstance(), ActorRef.noSender()); - kit.expectTerminated(JavaTestKit.duration("5 seconds"), actor); + kit.expectTerminated(kit.duration("5 seconds"), actor); if (remove) { createdActors.remove(actor); @@ -202,7 +194,7 @@ public class TestActorFactory implements AutoCloseable { @Override public void close() { - JavaTestKit kit = new JavaTestKit(system); + TestKit kit = new TestKit(system); for (ActorRef actor : createdActors) { killActor(actor, kit, false); } diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java index 1212274ddc..f3d1aac030 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeaderElectionScenarioTest.java @@ -19,8 +19,8 @@ import akka.dispatch.ControlMessage; import akka.dispatch.Dispatchers; import akka.dispatch.Mailboxes; import akka.pattern.Patterns; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.util.concurrent.Uninterruptibles; import java.util.Map; @@ -227,7 +227,7 @@ public class AbstractLeaderElectionScenarioTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } DefaultConfigParamsImpl newConfigParams() { diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java index ab8218808f..c4d97ea0e5 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/FollowerTest.java @@ -21,8 +21,8 @@ import static org.mockito.Mockito.verify; import akka.actor.ActorRef; import akka.dispatch.Dispatchers; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.base.Stopwatch; import com.google.common.collect.ImmutableList; @@ -1212,7 +1212,7 @@ public class FollowerTest extends AbstractRaftActorBehaviorTest { // Reinstate the actor from persistence - actorFactory.killActor(followerActorRef, new JavaTestKit(getSystem())); + actorFactory.killActor(followerActorRef, new TestKit(getSystem())); followerActorRef = actorFactory.createTestActor(builder.props() .withDispatcher(Dispatchers.DefaultDispatcherId()), id); diff --git a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java index 5317ec4d34..04ae7ffe8c 100644 --- a/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java +++ b/opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java @@ -23,8 +23,8 @@ import akka.actor.ActorRef; import akka.actor.PoisonPill; import akka.actor.Props; import akka.actor.Terminated; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.collect.ImmutableMap; import com.google.common.io.ByteSource; @@ -1916,7 +1916,7 @@ public class LeaderTest extends AbstractLeaderTest { assertTrue("Behavior not instance of Leader when all followers are active", newBehavior instanceof Leader); // kill 1 follower and verify if that got killed - final JavaTestKit probe = new JavaTestKit(getSystem()); + final TestKit probe = new TestKit(getSystem()); probe.watch(followerActor1); followerActor1.tell(PoisonPill.getInstance(), ActorRef.noSender()); final Terminated termMsg1 = probe.expectMsgClass(Terminated.class); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java index 7f91c1bc85..a40297438d 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/MeteredBoundedMailboxTest.java @@ -12,7 +12,7 @@ import akka.actor.ActorSystem; import akka.actor.DeadLetter; import akka.actor.Props; import akka.actor.UntypedActor; -import akka.testkit.JavaTestKit; +import akka.testkit.TestKit; import com.typesafe.config.ConfigFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.ReentrantLock; @@ -43,8 +43,8 @@ public class MeteredBoundedMailboxTest { @Test public void shouldSendMsgToDeadLetterWhenQueueIsFull() throws InterruptedException { - final JavaTestKit mockReceiver = new JavaTestKit(actorSystem); - actorSystem.eventStream().subscribe(mockReceiver.getRef(), DeadLetter.class); + final TestKit mockReceiver = new TestKit(actorSystem); + actorSystem.eventStream().subscribe(mockReceiver.testActor(), DeadLetter.class); final FiniteDuration twentySeconds = new FiniteDuration(20, TimeUnit.SECONDS); @@ -59,7 +59,7 @@ public class MeteredBoundedMailboxTest { //2nd to 11th messages are put on the queue //12th message is sent to dead letter. for (int i = 0; i < 12; i++) { - pingPongActor.tell("ping", mockReceiver.getRef()); + pingPongActor.tell("ping", mockReceiver.testActor()); } mockReceiver.expectMsgClass(twentySeconds, DeadLetter.class); diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActorTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActorTest.java index f3a453bf4f..1a72f20d36 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActorTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/common/actor/QuarantinedMonitorActorTest.java @@ -19,7 +19,7 @@ import akka.japi.Effect; import akka.remote.AssociationErrorEvent; import akka.remote.InvalidAssociation; import akka.remote.ThisActorSystemQuarantinedEvent; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,7 +46,7 @@ public class QuarantinedMonitorActorTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } @Test diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java index c4738998f3..7e53922632 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/AbstractMessagingTest.java @@ -13,8 +13,8 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import com.google.common.io.ByteSource; import java.io.IOException; import java.io.InputStream; @@ -71,7 +71,7 @@ public class AbstractMessagingTest { @AfterClass public static void tearDownClass() { - JavaTestKit.shutdownActorSystem(ACTOR_SYSTEM, Boolean.TRUE); + TestKit.shutdownActorSystem(ACTOR_SYSTEM, true); } void setupMockFiledBackedStream(final FileBackedOutputStream mockOutputStream) throws IOException { diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceReplyTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceReplyTest.java index fa31fbfeef..51c4479119 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceReplyTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceReplyTest.java @@ -8,12 +8,14 @@ package org.opendaylight.controller.cluster.messaging; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import akka.actor.ActorSystem; import akka.actor.ExtendedActorSystem; import akka.serialization.JavaSerializer; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import org.apache.commons.lang.SerializationUtils; import org.junit.After; import org.junit.Before; @@ -34,7 +36,7 @@ public class MessageSliceReplyTest { @After public void tearDown() { - JavaTestKit.shutdownActorSystem(actorSystem, Boolean.TRUE); + TestKit.shutdownActorSystem(actorSystem, true); } @Test @@ -51,7 +53,7 @@ public class MessageSliceReplyTest { assertEquals("getIdentifier", expected.getIdentifier(), cloned.getIdentifier()); assertEquals("getSliceIndex", expected.getSliceIndex(), cloned.getSliceIndex()); assertEquals("getSendTo", expected.getSendTo(), cloned.getSendTo()); - assertEquals("getFailure present", Boolean.FALSE, cloned.getFailure().isPresent()); + assertFalse("getFailure present", cloned.getFailure().isPresent()); } private void testFailure() { @@ -62,7 +64,7 @@ public class MessageSliceReplyTest { assertEquals("getIdentifier", expected.getIdentifier(), cloned.getIdentifier()); assertEquals("getSliceIndex", expected.getSliceIndex(), cloned.getSliceIndex()); assertEquals("getSendTo", expected.getSendTo(), cloned.getSendTo()); - assertEquals("getFailure present", Boolean.TRUE, cloned.getFailure().isPresent()); + assertTrue("getFailure present", cloned.getFailure().isPresent()); assertEquals("getFailure message", expected.getFailure().get().getMessage(), cloned.getFailure().get().getMessage()); assertEquals("getFailure isRetriable", expected.getFailure().get().isRetriable(), diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceTest.java index 6331e0b7b2..dc2e6de9d7 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSliceTest.java @@ -13,8 +13,8 @@ import static org.junit.Assert.assertEquals; import akka.actor.ActorSystem; import akka.actor.ExtendedActorSystem; import akka.serialization.JavaSerializer; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import org.apache.commons.lang.SerializationUtils; import org.junit.After; import org.junit.Before; @@ -35,7 +35,7 @@ public class MessageSliceTest { @After public void tearDown() { - JavaTestKit.shutdownActorSystem(actorSystem, Boolean.TRUE); + TestKit.shutdownActorSystem(actorSystem, Boolean.TRUE); } @Test diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSlicingIntegrationTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSlicingIntegrationTest.java index 7318960de6..d78e63985b 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSlicingIntegrationTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/messaging/MessageSlicingIntegrationTest.java @@ -19,8 +19,8 @@ import static org.opendaylight.controller.cluster.messaging.MessageSlicerTest.sl import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; @@ -79,7 +79,7 @@ public class MessageSlicingIntegrationTest { @AfterClass public static void staticTearDown() { - JavaTestKit.shutdownActorSystem(ACTOR_SYSTEM, Boolean.TRUE); + TestKit.shutdownActorSystem(ACTOR_SYSTEM, true); } @Test diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifierTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifierTest.java index ab65929fe7..c361963aca 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifierTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/notifications/RoleChangeNotifierTest.java @@ -9,8 +9,8 @@ package org.opendaylight.controller.cluster.notifications; import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import java.util.ArrayList; import java.util.List; import org.junit.After; @@ -38,7 +38,7 @@ public class RoleChangeNotifierTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } @Test diff --git a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStoreTest.java b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStoreTest.java index 417a9db7ea..e23a37a8ae 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStoreTest.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/persistence/LocalSnapshotStoreTest.java @@ -27,7 +27,7 @@ import akka.persistence.SnapshotProtocol.LoadSnapshotResult; import akka.persistence.SnapshotSelectionCriteria; import akka.persistence.serialization.Snapshot; import akka.persistence.serialization.SnapshotSerializer; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.ConfigFactory; import java.io.File; import java.io.FileOutputStream; @@ -69,7 +69,7 @@ public class LocalSnapshotStoreTest { @AfterClass public static void staticCleanup() { FileUtils.deleteQuietly(SNAPSHOT_DIR); - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } @Before @@ -100,7 +100,7 @@ public class LocalSnapshotStoreTest { SnapshotMetadata metadata3 = new SnapshotMetadata(PERSISTENCE_ID, 1, 3000); - JavaTestKit probe = new JavaTestKit(system); + TestKit probe = new TestKit(system); snapshotStore.tell(new LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef()); LoadSnapshotResult result = probe.expectMsgClass(LoadSnapshotResult.class); @@ -124,7 +124,7 @@ public class LocalSnapshotStoreTest { @Test public void testDoLoadAsyncWithNoSnapshots() throws IOException { - JavaTestKit probe = new JavaTestKit(system); + TestKit probe = new TestKit(system); snapshotStore.tell(new LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef()); LoadSnapshotResult result = probe.expectMsgClass(LoadSnapshotResult.class); @@ -140,7 +140,7 @@ public class LocalSnapshotStoreTest { SnapshotMetadata metadata = new SnapshotMetadata(PERSISTENCE_ID, 0, 1000); - JavaTestKit probe = new JavaTestKit(system); + TestKit probe = new TestKit(system); snapshotStore.tell(new LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef()); LoadSnapshotResult result = probe.expectMsgClass(LoadSnapshotResult.class); @@ -156,7 +156,7 @@ public class LocalSnapshotStoreTest { public void testDoLoadAsyncWithFailure() throws Throwable { createSnapshotFile(PERSISTENCE_ID, null, 1, 2000); - JavaTestKit probe = new JavaTestKit(system); + TestKit probe = new TestKit(system); snapshotStore.tell(new SnapshotProtocol.LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef()); LoadSnapshotFailed failed = probe.expectMsgClass(LoadSnapshotFailed.class); @@ -174,7 +174,7 @@ public class LocalSnapshotStoreTest { SnapshotMetadata metadata = new SnapshotMetadata(PERSISTENCE_ID, 1, 1000); - JavaTestKit probe = new JavaTestKit(system); + TestKit probe = new TestKit(system); snapshotStore.tell(new LoadSnapshot(PERSISTENCE_ID, SnapshotSelectionCriteria.latest(), Long.MAX_VALUE), probe.getRef()); LoadSnapshotResult result = probe.expectMsgClass(LoadSnapshotResult.class); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java index 5e30b0464b..254b4fc53f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/AbstractClientHandleTest.java @@ -18,8 +18,8 @@ import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtil import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import java.util.Collection; import java.util.Collections; import java.util.function.Function; @@ -108,7 +108,7 @@ public abstract class AbstractClientHandleTest { + expectNoMsg(); + Mockito.verify(mockListener, Mockito.never()) + .onDataChanged(Mockito.any(AsyncDataChangeEvent.class)); + return null; + }); } }; } @@ -76,7 +73,7 @@ public class DataChangeListenerTest extends AbstractActorTest { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testDataChangedWithNoSender() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final AsyncDataChangeEvent mockChangeEvent = Mockito.mock(AsyncDataChangeEvent.class); final AsyncDataChangeListener mockListener = Mockito.mock(AsyncDataChangeListener.class); @@ -108,7 +105,7 @@ public class DataChangeListenerTest extends AbstractActorTest { @SuppressWarnings({ "rawtypes", "unchecked" }) @Test public void testDataChangedWithListenerRuntimeEx() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final AsyncDataChangeEvent mockChangeEvent1 = Mockito.mock(AsyncDataChangeEvent.class); final AsyncDataChangeEvent mockChangeEvent2 = Mockito.mock(AsyncDataChangeEvent.class); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java index a98d55a99f..7316eef30c 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerActorTest.java @@ -12,7 +12,7 @@ import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.T import akka.actor.ActorRef; import akka.actor.DeadLetter; import akka.actor.Props; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.ImmutableList; import org.junit.Assert; import org.junit.Test; @@ -28,7 +28,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest { @Test public void testDataChangedWhenNotificationsAreEnabled() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class); final ImmutableList mockCandidates = ImmutableList.of(mockTreeCandidate); @@ -51,7 +51,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest { @Test public void testDataChangedWhenNotificationsAreDisabled() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class); final ImmutableList mockCandidates = ImmutableList.of(mockTreeCandidate); @@ -61,22 +61,19 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest { subject.tell(new DataTreeChanged(mockCandidates), getRef()); - new Within(duration("1 seconds")) { - @Override - protected void run() { - expectNoMsg(); - - Mockito.verify(mockListener, Mockito.never()) - .onDataTreeChanged(Matchers.anyCollectionOf(DataTreeCandidate.class)); - } - }; + within(duration("1 seconds"), () -> { + expectNoMsg(); + Mockito.verify(mockListener, Mockito.never()) + .onDataTreeChanged(Matchers.anyCollectionOf(DataTreeCandidate.class)); + return null; + }); } }; } @Test public void testDataChangedWithNoSender() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final DataTreeCandidate mockTreeCandidate = Mockito.mock(DataTreeCandidate.class); final ImmutableList mockCandidates = ImmutableList.of(mockTreeCandidate); @@ -109,7 +106,7 @@ public class DataTreeChangeListenerActorTest extends AbstractActorTest { @Test public void testDataChangedWithListenerRuntimeEx() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final DataTreeCandidate mockTreeCandidate1 = Mockito.mock(DataTreeCandidate.class); final ImmutableList mockCandidates1 = ImmutableList.of(mockTreeCandidate1); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java index 2b99bfa582..7b23260e91 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerProxyTest.java @@ -19,7 +19,7 @@ import akka.actor.Props; import akka.actor.Terminated; import akka.dispatch.ExecutionContexts; import akka.dispatch.Futures; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.util.concurrent.MoreExecutors; import com.google.common.util.concurrent.Uninterruptibles; @@ -51,7 +51,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { @Test(timeout = 10000) public void testSuccessfulRegistration() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class), mock(Configuration.class)); @@ -101,7 +101,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { @Test(timeout = 10000) public void testSuccessfulRegistrationForClusteredListener() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class), mock(Configuration.class)); @@ -133,7 +133,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { @Test(timeout = 10000) public void testLocalShardNotFound() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class), mock(Configuration.class)); @@ -159,7 +159,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { @Test(timeout = 10000) public void testLocalShardNotInitialized() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class), mock(Configuration.class)); @@ -176,12 +176,10 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { reply(new NotInitializedException("not initialized")); - new Within(duration("1 seconds")) { - @Override - protected void run() { - expectNoMsg(); - } - }; + within(duration("1 seconds"), () -> { + expectNoMsg(); + return null; + }); proxy.close(); } @@ -190,7 +188,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { @Test public void testFailedRegistration() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorSystem mockActorSystem = mock(ActorSystem.class); @@ -226,7 +224,7 @@ public class DataTreeChangeListenerProxyTest extends AbstractActorTest { @Test public void testCloseBeforeRegistration() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorContext actorContext = mock(ActorContext.class); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupportTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupportTest.java index 3278ff625f..0a435fe010 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupportTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeChangeListenerSupportTest.java @@ -23,8 +23,8 @@ import static org.opendaylight.controller.md.cluster.datastore.model.TestModel.t import akka.actor.ActorRef; import akka.actor.ActorSelection; import akka.pattern.Patterns; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import java.util.AbstractMap.SimpleEntry; import java.util.Map.Entry; @@ -91,9 +91,9 @@ public class DataTreeChangeListenerSupportTest extends AbstractShardTest { listener.verifyNotifiedData(TEST_PATH); listener.reset(1); - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); entry.getValue().tell(CloseDataTreeNotificationListenerRegistration.getInstance(), kit.getRef()); - kit.expectMsgClass(JavaTestKit.duration("5 seconds"), CloseDataTreeNotificationListenerRegistrationReply.class); + kit.expectMsgClass(kit.duration("5 seconds"), CloseDataTreeNotificationListenerRegistrationReply.class); writeToStore(shard.getDataStore(), TEST_PATH, ImmutableNodes.containerNode(TEST_QNAME)); listener.verifyNoNotifiedData(TEST_PATH); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java index 73a6c74f83..5a131cd8ad 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java @@ -23,7 +23,7 @@ import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.AddressFromURIString; import akka.cluster.Cluster; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.base.Throwables; import com.google.common.util.concurrent.CheckedFuture; @@ -84,7 +84,7 @@ public class DataTreeCohortIntegrationTest { @AfterClass public static void tearDownClass() throws IOException { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); system = null; } @@ -259,8 +259,8 @@ public class DataTreeCohortIntegrationTest { } @SuppressWarnings("rawtypes") - private static DOMDataTreeCandidate findCandidate(ArgumentCaptor candidateCapture, - YangInstanceIdentifier rootPath) { + private static DOMDataTreeCandidate findCandidate(final ArgumentCaptor candidateCapture, + final YangInstanceIdentifier rootPath) { for (Object obj: candidateCapture.getValue()) { DOMDataTreeCandidate candidate = (DOMDataTreeCandidate)obj; if (rootPath.equals(candidate.getRootPath().getRootIdentifier())) { @@ -307,9 +307,9 @@ public class DataTreeCohortIntegrationTest { } } - private static void assertDataTreeCandidate(DOMDataTreeCandidate candidate, DOMDataTreeIdentifier expTreeId, - ModificationType expType, Optional> expDataAfter, - Optional> expDataBefore) { + private static void assertDataTreeCandidate(final DOMDataTreeCandidate candidate, + final DOMDataTreeIdentifier expTreeId, final ModificationType expType, + final Optional> expDataAfter, final Optional> expDataBefore) { assertNotNull("Expected candidate for path " + expTreeId.getRootIdentifier(), candidate); assertEquals("rootPath", expTreeId, candidate.getRootPath()); assertEquals("modificationType", expType, candidate.getRootNode().getModificationType()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java index 0b97772e94..d0798688c8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreIntegrationTest.java @@ -21,7 +21,7 @@ import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.AddressFromURIString; import akka.cluster.Cluster; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.base.Throwables; import com.google.common.collect.ImmutableMap; @@ -124,7 +124,7 @@ public class DistributedDataStoreIntegrationTest { @After public void tearDown() throws IOException { - JavaTestKit.shutdownActorSystem(system, null, Boolean.TRUE); + TestKit.shutdownActorSystem(system, Boolean.TRUE); system = null; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java index b78d017341..c09111e95e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreRemotingIntegrationTest.java @@ -24,7 +24,7 @@ import akka.actor.AddressFromURIString; import akka.cluster.Cluster; import akka.dispatch.Futures; import akka.pattern.Patterns; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.base.Stopwatch; import com.google.common.base.Supplier; @@ -182,9 +182,9 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { leaderDistributedDataStore.close(); } - JavaTestKit.shutdownActorSystem(leaderSystem); - JavaTestKit.shutdownActorSystem(followerSystem); - JavaTestKit.shutdownActorSystem(follower2System); + TestKit.shutdownActorSystem(leaderSystem); + TestKit.shutdownActorSystem(followerSystem); + TestKit.shutdownActorSystem(follower2System); InMemoryJournal.clear(); InMemorySnapshotStore.clear(); @@ -316,8 +316,8 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS); } - JavaTestKit.shutdownActorSystem(leaderSystem, null, Boolean.TRUE); - JavaTestKit.shutdownActorSystem(followerSystem, null, Boolean.TRUE); + TestKit.shutdownActorSystem(leaderSystem, Boolean.TRUE); + TestKit.shutdownActorSystem(followerSystem, Boolean.TRUE); final ActorSystem newSystem = newActorSystem("reinstated-member2", "Member2"); @@ -599,7 +599,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { sendDatastoreContextUpdate(followerDistributedDataStore, followerDatastoreContextBuilder .shardElectionTimeoutFactor(1).customRaftPolicyImplementation(null)); - JavaTestKit.shutdownActorSystem(leaderSystem, null, true); + TestKit.shutdownActorSystem(leaderSystem, true); Cluster.get(followerSystem).leave(MEMBER_1_ADDRESS); followerTestKit.waitUntilNoLeader(followerDistributedDataStore.getActorContext(), CARS); @@ -1011,7 +1011,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { // Shutdown the leader and try to create a new tx. - JavaTestKit.shutdownActorSystem(leaderSystem, null, true); + TestKit.shutdownActorSystem(leaderSystem, true); followerDatastoreContextBuilder.operationTimeoutInMillis(50).shardElectionTimeoutFactor(1); sendDatastoreContextUpdate(followerDistributedDataStore, followerDatastoreContextBuilder); @@ -1046,7 +1046,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { // Shutdown the leader and try to create a new tx. - JavaTestKit.shutdownActorSystem(leaderSystem, null, true); + TestKit.shutdownActorSystem(leaderSystem, true); Cluster.get(followerSystem).leave(MEMBER_1_ADDRESS); @@ -1097,7 +1097,7 @@ public class DistributedDataStoreRemotingIntegrationTest extends AbstractTest { // Shutdown the leader and try to create a new tx. - JavaTestKit.shutdownActorSystem(leaderSystem, null, true); + TestKit.shutdownActorSystem(leaderSystem, true); Cluster.get(followerSystem).leave(MEMBER_1_ADDRESS); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/RoleChangeNotifierTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/RoleChangeNotifierTest.java index 8e391cbf72..344ec10a80 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/RoleChangeNotifierTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/RoleChangeNotifierTest.java @@ -13,8 +13,8 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import akka.actor.ActorRef; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import org.junit.Test; import org.opendaylight.controller.cluster.notifications.LeaderStateChanged; import org.opendaylight.controller.cluster.notifications.RegisterRoleChangeListener; @@ -29,7 +29,7 @@ public class RoleChangeNotifierTest extends AbstractActorTest { @Test public void testHandleRegisterRoleChangeListener() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "testHandleRegisterRoleChangeListener"; ActorRef listenerActor = getSystem().actorOf(MessageCollectorActor.props()); @@ -52,7 +52,7 @@ public class RoleChangeNotifierTest extends AbstractActorTest { @Test public void testHandleRaftRoleChanged() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "testHandleRegisterRoleChangeListenerWithNotificationSet"; ActorRef listenerActor = getSystem().actorOf(MessageCollectorActor.props()); @@ -89,7 +89,7 @@ public class RoleChangeNotifierTest extends AbstractActorTest { @Test public void testHandleLeaderStateChanged() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String actorId = "testHandleLeaderStateChanged"; TestActorRef notifierTestActorRef = TestActorRef.create(getSystem(), diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTestKit.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTestKit.java index 4e08f4a7f1..df1359fc47 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTestKit.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTestKit.java @@ -29,11 +29,11 @@ import scala.concurrent.duration.FiniteDuration; public class ShardTestKit extends JavaTestKit { private static final Logger LOG = LoggerFactory.getLogger(ShardTestKit.class); - public ShardTestKit(ActorSystem actorSystem) { + public ShardTestKit(final ActorSystem actorSystem) { super(actorSystem); } - public void waitForLogMessage(final Class logLevel, ActorRef subject, String logMessage) { + public void waitForLogMessage(final Class logLevel, final ActorRef subject, final String logMessage) { // Wait for a specific log message to show up final boolean result = new JavaTestKit.EventFilter(logLevel @@ -51,7 +51,7 @@ public class ShardTestKit extends JavaTestKit { } @SuppressWarnings("checkstyle:IllegalCatch") - public static String waitUntilLeader(ActorRef shard) { + public static String waitUntilLeader(final ActorRef shard) { FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS); for (int i = 0; i < 20 * 5; i++) { Future future = Patterns.ask(shard, FindLeader.INSTANCE, new Timeout(duration)); @@ -75,7 +75,7 @@ public class ShardTestKit extends JavaTestKit { } @SuppressWarnings("checkstyle:IllegalCatch") - public void waitUntilNoLeader(ActorRef shard) { + public void waitUntilNoLeader(final ActorRef shard) { FiniteDuration duration = Duration.create(100, TimeUnit.MILLISECONDS); Object lastResponse = null; for (int i = 0; i < 20 * 5; i++) { diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java index 0d65faa060..f3acf29e7a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionTest.java @@ -19,8 +19,8 @@ import akka.actor.Props; import akka.actor.Status.Failure; import akka.actor.Terminated; import akka.dispatch.Dispatchers; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Throwables; import java.util.concurrent.TimeUnit; import org.junit.Before; @@ -95,7 +95,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadData() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { testOnReceiveReadData(newTransactionActor(RO, readOnlyTransaction(), "testReadDataRO")); @@ -115,7 +115,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveReadDataWhenDataNotFound() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { testOnReceiveReadDataWhenDataNotFound( newTransactionActor(RO, readOnlyTransaction(), "testReadDataWhenDataNotFoundRO")); @@ -136,7 +136,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveDataExistsPositive() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { testOnReceiveDataExistsPositive( newTransactionActor(RO, readOnlyTransaction(), "testDataExistsPositiveRO")); @@ -158,7 +158,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveDataExistsNegative() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { testOnReceiveDataExistsNegative( newTransactionActor(RO, readOnlyTransaction(), "testDataExistsNegativeRO")); @@ -179,7 +179,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveBatchedModifications() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ShardDataTreeTransactionParent parent = Mockito.mock(ShardDataTreeTransactionParent.class); DataTreeModification mockModification = Mockito.mock(DataTreeModification.class); @@ -221,12 +221,12 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveBatchedModificationsReadyWithoutImmediateCommit() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(), "testOnReceiveBatchedModificationsReadyWithoutImmediateCommit"); - JavaTestKit watcher = new JavaTestKit(getSystem()); + TestKit watcher = new TestKit(getSystem()); watcher.watch(transaction); YangInstanceIdentifier writePath = TestModel.TEST_PATH; @@ -256,12 +256,12 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testOnReceiveBatchedModificationsReadyWithImmediateCommit() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(), "testOnReceiveBatchedModificationsReadyWithImmediateCommit"); - JavaTestKit watcher = new JavaTestKit(getSystem()); + TestKit watcher = new TestKit(getSystem()); watcher.watch(transaction); YangInstanceIdentifier writePath = TestModel.TEST_PATH; @@ -285,7 +285,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test(expected = TestException.class) public void testOnReceiveBatchedModificationsFailure() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ShardDataTreeTransactionParent parent = Mockito.mock(ShardDataTreeTransactionParent.class); @@ -295,7 +295,7 @@ public class ShardTransactionTest extends AbstractActorTest { final ActorRef transaction = newTransactionActor(RW, mockWriteTx, "testOnReceiveBatchedModificationsFailure"); - JavaTestKit watcher = new JavaTestKit(getSystem()); + TestKit watcher = new TestKit(getSystem()); watcher.watch(transaction); YangInstanceIdentifier path = TestModel.TEST_PATH; @@ -328,13 +328,13 @@ public class ShardTransactionTest extends AbstractActorTest { @Test(expected = IllegalStateException.class) public void testOnReceiveBatchedModificationsReadyWithIncorrectTotalMessageCount() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(), "testOnReceiveBatchedModificationsReadyWithIncorrectTotalMessageCount"); - JavaTestKit watcher = new JavaTestKit(getSystem()); + TestKit watcher = new TestKit(getSystem()); watcher.watch(transaction); BatchedModifications batched = new BatchedModifications(nextTransactionId(), @@ -358,7 +358,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testReadWriteTxOnReceiveCloseTransaction() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(RW, readWriteTransaction(), "testReadWriteTxOnReceiveCloseTransaction"); @@ -375,7 +375,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testWriteOnlyTxOnReceiveCloseTransaction() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(WO, readWriteTransaction(), "testWriteTxOnReceiveCloseTransaction"); @@ -392,7 +392,7 @@ public class ShardTransactionTest extends AbstractActorTest { @Test public void testReadOnlyTxOnReceiveCloseTransaction() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(TransactionType.READ_ONLY, readOnlyTransaction(), "testReadOnlyTxOnReceiveCloseTransaction"); @@ -411,7 +411,7 @@ public class ShardTransactionTest extends AbstractActorTest { datastoreContext = DatastoreContext.newBuilder().shardTransactionIdleTimeout( 500, TimeUnit.MILLISECONDS).build(); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef transaction = newTransactionActor(RW, readWriteTransaction(), "testShardTransactionInactivity"); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActorTest.java index 12428e9256..0ae15d6c08 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/DataTreeNotificationListenerRegistrationActorTest.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.datastore.actors; import static org.mockito.Mockito.timeout; import akka.actor.ActorRef; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; @@ -36,7 +36,7 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA @Test public void testOnReceiveCloseListenerRegistrationAfterSetRegistration() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef subject = getSystem().actorOf(DataTreeNotificationListenerRegistrationActor.props(), "testOnReceiveCloseListenerRegistrationAfterSetRegistration"); @@ -58,7 +58,7 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA @Test public void testOnReceiveCloseListenerRegistrationBeforeSetRegistration() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef subject = getSystem().actorOf(DataTreeNotificationListenerRegistrationActor.props(), "testOnReceiveSetRegistrationAfterPriorClose"); @@ -80,7 +80,7 @@ public class DataTreeNotificationListenerRegistrationActorTest extends AbstractA @Test public void testOnReceiveSetRegistrationAfterPriorClose() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { DataTreeNotificationListenerRegistrationActor.killDelay = 1000; final ListenerRegistration mockListenerReg2 = Mockito.mock(ListenerRegistration.class); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActorTest.java index f3660da646..e77ab0357b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/actors/ShardSnapshotActorTest.java @@ -11,7 +11,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import akka.actor.ActorRef; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.ObjectInputStream; @@ -31,7 +31,7 @@ public class ShardSnapshotActorTest extends AbstractActorTest { private static void testSerializeSnapshot(final String testName, final ShardDataTreeSnapshot snapshot, final boolean withInstallSnapshot) throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef snapshotActor = getSystem().actorOf(ShardSnapshotActor.props(), testName); watch(snapshotActor); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractClusterRefEntityOwnershipTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractClusterRefEntityOwnershipTest.java index ae4740dd95..c7013e8181 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractClusterRefEntityOwnershipTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/AbstractClusterRefEntityOwnershipTest.java @@ -9,7 +9,7 @@ package org.opendaylight.controller.cluster.datastore.entityownership; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.ConfigFactory; import java.io.IOException; import org.junit.AfterClass; @@ -26,7 +26,7 @@ public class AbstractClusterRefEntityOwnershipTest extends AbstractEntityOwnersh @AfterClass public static void tearDownClass() throws IOException { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); system = null; } diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListenerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListenerTest.java index b22ed37dc2..bc2f6110d8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListenerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/CandidateListChangeListenerTest.java @@ -13,7 +13,7 @@ import static org.opendaylight.controller.cluster.datastore.entityownership.Enti import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityOwnersWithCandidate; import static org.opendaylight.controller.cluster.datastore.entityownership.EntityOwnersModel.entityPath; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.ImmutableSet; import java.util.concurrent.TimeUnit; import org.junit.Before; @@ -58,7 +58,7 @@ public class CandidateListChangeListenerTest extends AbstractActorTest { @Test public void testOnDataTreeChanged() throws Exception { - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); new CandidateListChangeListener(kit.getRef(), "test").init(shardDataTree); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java index d040eb6cde..9bdacd73f5 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipIntegrationTest.java @@ -28,7 +28,6 @@ import akka.actor.Status.Failure; import akka.actor.Status.Success; import akka.cluster.Cluster; import akka.pattern.Patterns; -import akka.testkit.JavaTestKit; import akka.util.Timeout; import com.google.common.base.Optional; import com.google.common.base.Stopwatch; @@ -614,7 +613,7 @@ public class DistributedEntityOwnershipIntegrationTest { AddShardReplica addReplica = new AddShardReplica(ENTITY_OWNERSHIP_SHARD_NAME); follower1DistributedDataStore.getActorContext().getShardManager().tell(addReplica, follower1Node.kit().getRef()); - Object reply = follower1Node.kit().expectMsgAnyClassOf(JavaTestKit.duration("5 sec"), + Object reply = follower1Node.kit().expectMsgAnyClassOf(follower1Node.kit().duration("5 sec"), Success.class, Failure.class); if (reply instanceof Failure) { throw new AssertionError("AddShardReplica failed", ((Failure)reply).cause()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupportTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupportTest.java index dc40f0fa93..c806d1de10 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupportTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipListenerSupportTest.java @@ -18,8 +18,8 @@ import static org.mockito.Mockito.verify; import akka.actor.ActorContext; import akka.actor.ActorRef; import akka.actor.Props; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.util.concurrent.Uninterruptibles; import java.util.ArrayList; import java.util.List; @@ -127,9 +127,9 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT // Unregister all listeners and verify their listener actors are destroyed. - List watchers = new ArrayList<>(); + List watchers = new ArrayList<>(); for (Iterator iter = listenerActors.iterator(); iter.hasNext();) { - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); kit.watch(iter.next()); watchers.add(kit); } @@ -139,8 +139,8 @@ public class EntityOwnershipListenerSupportTest extends AbstractEntityOwnershipT support.removeEntityOwnershipListener(entityType2, mockListener2); Iterator iter = listenerActors.iterator(); - for (JavaTestKit kit: watchers) { - kit.expectTerminated(JavaTestKit.duration("3 seconds"), iter.next()); + for (TestKit kit: watchers) { + kit.expectTerminated(kit.duration("3 seconds"), iter.next()); } assertEquals("# of listener actors", 0, actorContext.children().size()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java index ca104f1ecf..9eb974170b 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/entityownership/EntityOwnershipShardTest.java @@ -26,7 +26,6 @@ import akka.actor.PoisonPill; import akka.actor.Props; import akka.actor.Terminated; import akka.dispatch.Dispatchers; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; import com.google.common.collect.ImmutableMap; import com.google.common.util.concurrent.Uninterruptibles; @@ -524,7 +523,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { kit.watch(peer2); peer2.tell(PoisonPill.getInstance(), ActorRef.noSender()); - kit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class); + kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class); kit.unwatch(peer2); leader.tell(new PeerDown(peerId2.getMemberName(), peerId2.toString()), ActorRef.noSender()); @@ -591,7 +590,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { kit.watch(peer1); peer1.tell(PoisonPill.getInstance(), ActorRef.noSender()); - kit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class); + kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class); kit.unwatch(peer1); leader.tell(new PeerDown(peerId1.getMemberName(), peerId1.toString()), ActorRef.noSender()); @@ -650,7 +649,7 @@ public class EntityOwnershipShardTest extends AbstractEntityOwnershipTest { kit.watch(leader); leader.tell(PoisonPill.getInstance(), ActorRef.noSender()); - kit.expectMsgClass(JavaTestKit.duration("5 seconds"), Terminated.class); + kit.expectMsgClass(kit.duration("5 seconds"), Terminated.class); kit.unwatch(leader); peer2.tell(new PeerDown(leaderId.getMemberName(), leaderId.toString()), ActorRef.noSender()); peer2.tell(TimeoutNow.INSTANCE, peer2); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java index c50318418e..0f70170df2 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerGetSnapshotReplyActorTest.java @@ -12,7 +12,7 @@ import static org.junit.Assert.assertEquals; import akka.actor.ActorRef; import akka.actor.Status.Failure; import akka.actor.Terminated; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -42,7 +42,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest { @Test public void testSuccess() { - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); List shardList = Arrays.asList("shard1", "shard2", "shard3"); ShardManagerSnapshot shardManagerSnapshot = new ShardManagerSnapshot(shardList, Collections.emptyMap()); @@ -91,7 +91,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest { @Test public void testGetSnapshotFailureReply() { - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props( Arrays.asList("shard1", "shard2"), "config", null, kit.getRef(), "shard-manager", @@ -111,7 +111,7 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest { @Test public void testGetSnapshotTimeout() { - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props( Arrays.asList("shard1"), "config", null, kit.getRef(), "shard-manager", diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java index a23f0077c8..bd387cd740 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardmanager/ShardManagerTest.java @@ -35,8 +35,8 @@ import akka.japi.Creator; import akka.pattern.Patterns; import akka.persistence.RecoveryCompleted; import akka.serialization.Serialization; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.base.Function; import com.google.common.base.Stopwatch; @@ -192,7 +192,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { } private static void waitForShardInitialized(final ActorRef shardManager, final String shardName, - final JavaTestKit kit) { + final TestKit kit) { AssertionError last = null; Stopwatch sw = Stopwatch.createStarted(); while (sw.elapsed(TimeUnit.SECONDS) <= 5) { @@ -211,8 +211,8 @@ public class ShardManagerTest extends AbstractShardManagerTest { } @SuppressWarnings("unchecked") - private static T expectMsgClassOrFailure(final Class msgClass, final JavaTestKit kit, final String msg) { - Object reply = kit.expectMsgAnyClassOf(JavaTestKit.duration("5 sec"), msgClass, Failure.class); + private static T expectMsgClassOrFailure(final Class msgClass, final TestKit kit, final String msg) { + Object reply = kit.expectMsgAnyClassOf(kit.duration("5 sec"), msgClass, Failure.class); if (reply instanceof Failure) { throw new AssertionError(msg + " failed", ((Failure)reply).cause()); } @@ -287,7 +287,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { } }; - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); final ActorRef shardManager = actorFactory.createActor(Props.create( new DelegatingShardManagerCreator(creator)).withDispatcher(Dispatchers.DefaultDispatcherId())); @@ -324,7 +324,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForNonExistentShard() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -340,7 +340,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForLocalLeaderShard() throws Exception { LOG.info("testOnReceiveFindPrimaryForLocalLeaderShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "member-1-shard-default-" + shardMrgIDSuffix; @@ -374,7 +374,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForNonLocalLeaderShardBeforeMemberUp() throws Exception { LOG.info("testOnReceiveFindPrimaryForNonLocalLeaderShardBeforeMemberUp starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -401,7 +401,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForNonLocalLeaderShard() throws Exception { LOG.info("testOnReceiveFindPrimaryForNonLocalLeaderShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -433,7 +433,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForUninitializedShard() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -446,7 +446,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForInitializedShardWithNoRole() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -463,7 +463,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryForFollowerShardWithNoInitialLeaderId() throws Exception { LOG.info("testOnReceiveFindPrimaryForFollowerShardWithNoInitialLeaderId starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -500,7 +500,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { public void testOnReceiveFindPrimaryWaitForShardLeader() throws Exception { LOG.info("testOnReceiveFindPrimaryWaitForShardLeader starting"); datastoreContextBuilder.shardInitializationTimeout(10, TimeUnit.SECONDS); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -545,7 +545,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryWaitForReadyWithUninitializedShard() throws Exception { LOG.info("testOnReceiveFindPrimaryWaitForReadyWithUninitializedShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -567,7 +567,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryWaitForReadyWithCandidateShard() throws Exception { LOG.info("testOnReceiveFindPrimaryWaitForReadyWithCandidateShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -588,7 +588,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard() throws Exception { LOG.info("testOnReceiveFindPrimaryWaitForReadyWithIsolatedLeaderShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -609,7 +609,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard() throws Exception { LOG.info("testOnReceiveFindPrimaryWaitForReadyWithNoRoleShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -657,7 +657,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { new ClusterWrapperImpl(system2)).props().withDispatcher( Dispatchers.DefaultDispatcherId()), shardManagerID); - new JavaTestKit(system1) { + new TestKit(system1) { { shardManager1.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); shardManager2.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); @@ -731,7 +731,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { new ClusterWrapperImpl(system2)).props().withDispatcher( Dispatchers.DefaultDispatcherId()), shardManagerID); - new JavaTestKit(system1) { + new TestKit(system1) { { shardManager1.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); shardManager2.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); @@ -855,7 +855,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { new ClusterWrapperImpl(system2)).props().withDispatcher( Dispatchers.DefaultDispatcherId()), shardManagerID); - new JavaTestKit(system1) { + new TestKit(system1) { { shardManager1.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); shardManager2.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); @@ -955,7 +955,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { new ClusterWrapperImpl(system2)).props().withDispatcher( Dispatchers.DefaultDispatcherId()), shardManagerID); - new JavaTestKit(system256) { + new TestKit(system256) { { shardManager256.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); shardManager2.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); @@ -1018,7 +1018,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindLocalShardForNonExistentShard() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -1035,7 +1035,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindLocalShardForExistentShard() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -1054,7 +1054,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindLocalShardForNotInitializedShard() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -1068,7 +1068,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveFindLocalShardWaitForShardInitialized() throws Exception { LOG.info("testOnReceiveFindLocalShardWaitForShardInitialized starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -1108,7 +1108,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testRoleChangeNotificationToFollowerWithShardLeaderStateChangedReleaseReady() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { TestShardManager shardManager = newTestShardManager(); @@ -1131,7 +1131,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testReadyCountDownForMemberUpAfterLeaderStateChanged() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { TestShardManager shardManager = newTestShardManager(); @@ -1266,7 +1266,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnReceiveSwitchShardBehavior() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -1291,7 +1291,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnCreateShard() { LOG.info("testOnCreateShard starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { datastoreContextBuilder.shardInitializationTimeout(1, TimeUnit.MINUTES).persistent(true); @@ -1343,7 +1343,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnCreateShardWithLocalMemberNotInShardConfig() { LOG.info("testOnCreateShardWithLocalMemberNotInShardConfig starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { datastoreContextBuilder.shardInitializationTimeout(1, TimeUnit.MINUTES).persistent(true); @@ -1375,7 +1375,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testOnCreateShardWithNoInitialSchemaContext() { LOG.info("testOnCreateShardWithNoInitialSchemaContext starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardManager = actorFactory .createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())) @@ -1407,7 +1407,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testGetSnapshot() throws Exception { LOG.info("testGetSnapshot starting"); - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("shard1", Arrays.asList("member-1")).put("shard2", Arrays.asList("member-1")) @@ -1439,7 +1439,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { // Add a new replica - JavaTestKit mockShardLeaderKit = new JavaTestKit(getSystem()); + TestKit mockShardLeaderKit = new TestKit(getSystem()); TestShardManager shardManagerInstance = shardManager.underlyingActor(); shardManagerInstance.setMessageInterceptor(newFindPrimaryInterceptor(mockShardLeaderKit.getRef())); @@ -1472,7 +1472,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { datastoreContextBuilder.shardInitializationTimeout(3, TimeUnit.SECONDS); - JavaTestKit kit = new JavaTestKit(getSystem()); + TestKit kit = new TestKit(getSystem()); MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("shard1", Collections.emptyList()).put("shard2", Collections.emptyList()) @@ -1508,7 +1508,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testAddShardReplicaForNonExistentShardConfig() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardManager = actorFactory .createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())) @@ -1559,7 +1559,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { .withDispatcher(Dispatchers.DefaultDispatcherId()), shardManagerID); - new JavaTestKit(system1) { + new TestKit(system1) { { newReplicaShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); leaderShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); @@ -1612,7 +1612,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader() throws Exception { LOG.info("testAddShardReplicaWithPreExistingReplicaInRemoteShardLeader starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { TestActorRef shardManager = actorFactory .createTestActor(newPropsShardMgrWithMockShardActor(), shardMgrID); @@ -1674,7 +1674,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testAddShardReplicaWithPreExistingLocalReplicaLeader() throws Exception { LOG.info("testAddShardReplicaWithPreExistingLocalReplicaLeader starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "member-1-shard-default-" + shardMrgIDSuffix; ActorRef shardManager = actorFactory.createActor(newPropsShardMgrWithMockShardActor()); @@ -1702,9 +1702,9 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testAddShardReplicaWithAddServerReplyFailure() throws Exception { LOG.info("testAddShardReplicaWithAddServerReplyFailure starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { - JavaTestKit mockShardLeaderKit = new JavaTestKit(getSystem()); + TestKit mockShardLeaderKit = new TestKit(getSystem()); MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("astronauts", Arrays.asList("member-2")).build()); @@ -1718,7 +1718,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { shardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); - JavaTestKit terminateWatcher = new JavaTestKit(getSystem()); + TestKit terminateWatcher = new TestKit(getSystem()); terminateWatcher.watch(mockNewReplicaShardActor); shardManager.tell(new AddShardReplica("astronauts"), getRef()); @@ -1757,7 +1757,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { public void testAddShardReplicaWithFindPrimaryTimeout() throws Exception { LOG.info("testAddShardReplicaWithFindPrimaryTimeout starting"); datastoreContextBuilder.shardInitializationTimeout(100, TimeUnit.MILLISECONDS); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("astronauts", Arrays.asList("member-2")).build()); @@ -1781,7 +1781,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testRemoveShardReplicaForNonExistentShard() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardManager = actorFactory .createActor(newShardMgrProps(new ConfigurationImpl(new EmptyModuleShardConfigProvider())) @@ -1799,7 +1799,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { * Primary is Local. */ public void testRemoveShardReplicaLocal() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "member-1-shard-default-" + shardMrgIDSuffix; @@ -1879,7 +1879,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { LOG.error("Forwarding actor : {}", actorRef); - new JavaTestKit(system1) { + new TestKit(system1) { { newReplicaShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); leaderShardManager.tell(new UpdateSchemaContext(TestModel.createTestContext()), getRef()); @@ -1933,10 +1933,10 @@ public class ShardManagerTest extends AbstractShardManagerTest { public void testServerChangeWhenAlreadyInProgress(final String shardName, final Object firstServerChange, final Class firstForwardedServerChangeClass, final Object secondServerChange) throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { - JavaTestKit mockShardLeaderKit = new JavaTestKit(getSystem()); - final JavaTestKit secondRequestKit = new JavaTestKit(getSystem()); + TestKit mockShardLeaderKit = new TestKit(getSystem()); + final TestKit secondRequestKit = new TestKit(getSystem()); MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put(shardName, Arrays.asList("member-2")).build()); @@ -1966,7 +1966,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testServerRemovedShardActorNotRunning() throws Exception { LOG.info("testServerRemovedShardActorNotRunning starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("default", Arrays.asList("member-1", "member-2")) @@ -1999,7 +1999,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testServerRemovedShardActorRunning() throws Exception { LOG.info("testServerRemovedShardActorRunning starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("default", Arrays.asList("member-1", "member-2")) @@ -2036,7 +2036,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testShardPersistenceWithRestoredData() throws Exception { LOG.info("testShardPersistenceWithRestoredData starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() @@ -2076,7 +2076,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testShutDown() throws Exception { LOG.info("testShutDown starting"); - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { MockConfiguration mockConfig = new MockConfiguration(ImmutableMap.>builder() .put("shard1", Arrays.asList("member-1")).put("shard2", Arrays.asList("member-1")).build()); @@ -2120,7 +2120,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testChangeServersVotingStatus() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "member-1-shard-default-" + shardMrgIDSuffix; @@ -2156,7 +2156,7 @@ public class ShardManagerTest extends AbstractShardManagerTest { @Test public void testChangeServersVotingStatusWithNoLeader() throws Exception { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { String memberId = "member-1-shard-default-" + shardMrgIDSuffix; diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java index 0dc8192690..c8ef12714f 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/utils/ActorContextTest.java @@ -26,8 +26,8 @@ import akka.actor.Props; import akka.actor.UntypedActor; import akka.dispatch.Futures; import akka.japi.Creator; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import akka.util.Timeout; import com.google.common.base.Optional; import com.google.common.collect.Maps; @@ -141,27 +141,24 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testFindLocalShardWithShardFound() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { - new Within(duration("1 seconds")) { - @Override - protected void run() { + within(duration("1 seconds"), () -> { + ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class)); - ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class)); + ActorRef shardManagerActorRef = getSystem() + .actorOf(MockShardManager.props(true, shardActorRef)); - ActorRef shardManagerActorRef = getSystem() - .actorOf(MockShardManager.props(true, shardActorRef)); - - ActorContext actorContext = new ActorContext(getSystem(), shardManagerActorRef, - mock(ClusterWrapper.class), mock(Configuration.class)); + ActorContext actorContext = new ActorContext(getSystem(), shardManagerActorRef, + mock(ClusterWrapper.class), mock(Configuration.class)); - Optional out = actorContext.findLocalShard("default"); + Optional out = actorContext.findLocalShard("default"); - assertEquals(shardActorRef, out.get()); + assertEquals(shardActorRef, out.get()); - expectNoMsg(); - } - }; + expectNoMsg(); + return null; + }); } }; @@ -169,7 +166,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testFindLocalShardWithShardNotFound() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardManagerActorRef = getSystem().actorOf(MockShardManager.props(false, null)); @@ -185,7 +182,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testExecuteRemoteOperation() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class)); @@ -206,7 +203,7 @@ public class ActorContextTest extends AbstractActorTest { @Test @SuppressWarnings("checkstyle:IllegalCatch") public void testExecuteRemoteOperationAsync() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class)); @@ -316,7 +313,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testSetDatastoreContext() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorContext actorContext = new ActorContext(getSystem(), getRef(), mock(ClusterWrapper.class), mock(Configuration.class), DatastoreContext.newBuilder() @@ -474,7 +471,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testBroadcast() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { ActorRef shardActorRef1 = getSystem().actorOf(MessageCollectorActor.props()); ActorRef shardActorRef2 = getSystem().actorOf(MessageCollectorActor.props()); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java index b0d01d514b..d977f93462 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeRemotingTest.java @@ -21,7 +21,7 @@ import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.AddressFromURIString; import akka.cluster.Cluster; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.Lists; import com.typesafe.config.ConfigFactory; import java.util.Collections; @@ -128,8 +128,8 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { followerOperDatastore.close(); } - JavaTestKit.shutdownActorSystem(leaderSystem, null, Boolean.TRUE); - JavaTestKit.shutdownActorSystem(followerSystem, null, Boolean.TRUE); + TestKit.shutdownActorSystem(leaderSystem, Boolean.TRUE); + TestKit.shutdownActorSystem(followerSystem, Boolean.TRUE); InMemoryJournal.clear(); InMemorySnapshotStore.clear(); @@ -139,7 +139,7 @@ public class DistributedShardedDOMDataTreeRemotingTest extends AbstractTest { initEmptyDatastores(MODULE_SHARDS_CONFIG); } - private void initEmptyDatastores(String moduleShardsConfig) throws Exception { + private void initEmptyDatastores(final String moduleShardsConfig) throws Exception { leaderTestKit = new IntegrationTestKit(leaderSystem, leaderDatastoreContextBuilder); leaderConfigDatastore = leaderTestKit.setupDistributedDataStore( diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java index 3e224a9715..6546538bcd 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardedDOMDataTreeTest.java @@ -28,7 +28,7 @@ import akka.actor.Address; import akka.actor.AddressFromURIString; import akka.actor.Props; import akka.cluster.Cluster; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Optional; import com.google.common.collect.Lists; import com.google.common.util.concurrent.CheckedFuture; @@ -158,7 +158,7 @@ public class DistributedShardedDOMDataTreeTest extends AbstractTest { operDistributedDatastore.close(); } - JavaTestKit.shutdownActorSystem(leaderSystem); + TestKit.shutdownActorSystem(leaderSystem); InMemoryJournal.clear(); InMemorySnapshotStore.clear(); diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActorTest.java index 978cc27c9a..ad8a69f79e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/RoleChangeListenerActorTest.java @@ -18,7 +18,7 @@ import static org.mockito.Mockito.verify; import akka.actor.ActorRef; import akka.actor.Props; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.AbstractActorTest; import org.opendaylight.controller.cluster.dom.api.LeaderLocation; @@ -30,7 +30,7 @@ public class RoleChangeListenerActorTest extends AbstractActorTest { @Test public void testRegisterRoleChangeListenerOnStart() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { final LeaderLocationListener listener = mock(LeaderLocationListener.class); final Props props = RoleChangeListenerActor.props(getRef(), listener); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java index 6557934475..8b3b93571d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/AbstractRpcTest.java @@ -15,7 +15,7 @@ import static org.junit.Assert.assertTrue; import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import java.net.URI; import java.util.Collection; import org.junit.AfterClass; @@ -68,9 +68,9 @@ public class AbstractRpcTest { static RemoteRpcProviderConfig config2; protected ActorRef rpcInvoker1; - protected JavaTestKit rpcRegistry1Probe; + protected TestKit rpcRegistry1Probe; protected ActorRef rpcInvoker2; - protected JavaTestKit rpcRegistry2Probe; + protected TestKit rpcRegistry2Probe; protected SchemaContext schemaContext; protected RemoteRpcImplementation remoteRpcImpl1; protected RemoteRpcImplementation remoteRpcImpl2; @@ -90,8 +90,8 @@ public class AbstractRpcTest { @AfterClass public static void teardown() { - JavaTestKit.shutdownActorSystem(node1); - JavaTestKit.shutdownActorSystem(node2); + TestKit.shutdownActorSystem(node1); + TestKit.shutdownActorSystem(node2); node1 = null; node2 = null; } @@ -102,9 +102,9 @@ public class AbstractRpcTest { MockitoAnnotations.initMocks(this); - rpcRegistry1Probe = new JavaTestKit(node1); + rpcRegistry1Probe = new TestKit(node1); rpcInvoker1 = node1.actorOf(RpcInvoker.props(domRpcService1)); - rpcRegistry2Probe = new JavaTestKit(node2); + rpcRegistry2Probe = new TestKit(node2); rpcInvoker2 = node2.actorOf(RpcInvoker.props(domRpcService2)); remoteRpcImpl1 = new RemoteRpcImplementation(rpcInvoker2, config1); remoteRpcImpl2 = new RemoteRpcImplementation(rpcInvoker1, config2); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java index a5158bc94d..81916c43d1 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java @@ -12,7 +12,7 @@ import static org.mockito.Mockito.mock; import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import java.util.concurrent.TimeUnit; @@ -40,7 +40,7 @@ public class RemoteRpcProviderTest { @AfterClass public static void teardown() { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); system = null; } diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java index 02d46319e9..d588736f61 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java @@ -13,7 +13,7 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.when; import akka.actor.Status.Failure; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.util.concurrent.Futures; import org.junit.Assert; import org.junit.Test; @@ -31,7 +31,7 @@ public class RpcBrokerTest extends AbstractRpcTest { @Test public void testExecuteRpc() { - new JavaTestKit(node1) { + new TestKit(node1) { { final ContainerNode invokeRpcResult = makeRPCOutput("bar"); @@ -52,7 +52,7 @@ public class RpcBrokerTest extends AbstractRpcTest { @Test public void testExecuteRpcFailureWithException() { - new JavaTestKit(node1) { + new TestKit(node1) { { when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.>any())) .thenReturn(Futures.immediateFailedCheckedFuture( diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java index fa64bbd15b..680d55da9d 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java @@ -10,7 +10,7 @@ package org.opendaylight.controller.remote.rpc; import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.ConfigFactory; import java.net.URISyntaxException; import java.util.Collections; @@ -40,16 +40,16 @@ public class RpcListenerTest { @AfterClass public static void teardown() { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); system = null; } @Test public void testRouteAdd() throws URISyntaxException, InterruptedException { - new JavaTestKit(system) { + new TestKit(system) { { // Test announcements - final JavaTestKit probeReg = new JavaTestKit(system); + final TestKit probeReg = new TestKit(system); final ActorRef rpcRegistry = probeReg.getRef(); final RpcListener rpcListener = new RpcListener(rpcRegistry); @@ -61,10 +61,10 @@ public class RpcListenerTest { @Test public void testRouteRemove() throws URISyntaxException, InterruptedException { - new JavaTestKit(system) { + new TestKit(system) { { // Test announcements - final JavaTestKit probeReg = new JavaTestKit(system); + final TestKit probeReg = new TestKit(system); final ActorRef rpcRegistry = probeReg.getRef(); final RpcListener rpcListener = new RpcListener(rpcRegistry); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcRegistrarTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcRegistrarTest.java index aecadc4eb1..dd11dd7ff5 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcRegistrarTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcRegistrarTest.java @@ -11,8 +11,8 @@ import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.Props; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.ImmutableMap; import java.util.Collections; import java.util.Map; @@ -52,7 +52,7 @@ public class RpcRegistrarTest { MockitoAnnotations.initMocks(this); system = ActorSystem.create("test"); - final JavaTestKit testKit = new JavaTestKit(system); + final TestKit testKit = new TestKit(system); final RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("system").build(); final Props props = RpcRegistrar.props(config, service); testActorRef = new TestActorRef<>(system, props, testKit.getRef(), "actorRef"); @@ -63,7 +63,7 @@ public class RpcRegistrarTest { final DOMRpcIdentifier secondEndpointId = DOMRpcIdentifier.create( SchemaPath.create(true, QName.create("second:identifier", "bar"))); - final JavaTestKit senderKit = new JavaTestKit(system); + final TestKit senderKit = new TestKit(system); firstEndpoint = new RemoteRpcEndpoint(senderKit.getRef(), Collections.singletonList(firstEndpointId)); secondEndpoint = new RemoteRpcEndpoint(senderKit.getRef(), Collections.singletonList(secondEndpointId)); @@ -78,7 +78,7 @@ public class RpcRegistrarTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system, null, Boolean.TRUE); + TestKit.shutdownActorSystem(system, true); } @Test @@ -136,4 +136,4 @@ public class RpcRegistrarTest { Mockito.verifyNoMoreInteractions(service, oldReg, newReg); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java index 807480b1b3..d9c686c9ab 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/RpcRegistryTest.java @@ -20,7 +20,7 @@ import akka.cluster.ClusterEvent.CurrentClusterState; import akka.cluster.Member; import akka.cluster.MemberStatus; import akka.cluster.UniqueAddress; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.google.common.base.Stopwatch; import com.google.common.collect.Sets; import com.google.common.util.concurrent.Uninterruptibles; @@ -63,12 +63,12 @@ public class RpcRegistryTest { private static ActorSystem node2; private static ActorSystem node3; - private JavaTestKit invoker1; - private JavaTestKit invoker2; - private JavaTestKit invoker3; - private JavaTestKit registrar1; - private JavaTestKit registrar2; - private JavaTestKit registrar3; + private TestKit invoker1; + private TestKit invoker2; + private TestKit invoker3; + private TestKit registrar1; + private TestKit registrar2; + private TestKit registrar3; private ActorRef registry1; private ActorRef registry2; private ActorRef registry3; @@ -113,21 +113,21 @@ public class RpcRegistryTest { @AfterClass public static void staticTeardown() { - JavaTestKit.shutdownActorSystem(node1); - JavaTestKit.shutdownActorSystem(node2); - JavaTestKit.shutdownActorSystem(node3); + TestKit.shutdownActorSystem(node1); + TestKit.shutdownActorSystem(node2); + TestKit.shutdownActorSystem(node3); } @Before public void setup() { - invoker1 = new JavaTestKit(node1); - registrar1 = new JavaTestKit(node1); + invoker1 = new TestKit(node1); + registrar1 = new TestKit(node1); registry1 = node1.actorOf(RpcRegistry.props(config(node1), invoker1.getRef(), registrar1.getRef())); - invoker2 = new JavaTestKit(node2); - registrar2 = new JavaTestKit(node2); + invoker2 = new TestKit(node2); + registrar2 = new TestKit(node2); registry2 = node2.actorOf(RpcRegistry.props(config(node2), invoker2.getRef(), registrar2.getRef())); - invoker3 = new JavaTestKit(node3); - registrar3 = new JavaTestKit(node3); + invoker3 = new TestKit(node3); + registrar3 = new TestKit(node3); registry3 = node3.actorOf(RpcRegistry.props(config(node3), invoker3.getRef(), registrar3.getRef())); } @@ -185,7 +185,7 @@ public class RpcRegistryTest { registry1.tell(new AddOrUpdateRoutes(addedRouteIds), ActorRef.noSender()); // Bucket store should get an update bucket message. Updated bucket contains added rpc. - final JavaTestKit testKit = new JavaTestKit(node1); + final TestKit testKit = new TestKit(node1); Map> buckets = retrieveBuckets(registry1, testKit, nodeAddress); verifyBucket(buckets.get(nodeAddress), addedRouteIds); @@ -222,7 +222,7 @@ public class RpcRegistryTest { registry1.tell(new AddOrUpdateRoutes(addedRouteIds), ActorRef.noSender()); // Bucket store on node2 should get a message to update its local copy of remote buckets - final JavaTestKit testKit = new JavaTestKit(node2); + final TestKit testKit = new TestKit(node2); Map> buckets = retrieveBuckets(registry2, testKit, node1Address); verifyBucket(buckets.get(node1Address), addedRouteIds); @@ -238,7 +238,7 @@ public class RpcRegistryTest { LOG.info("testRpcAddRemoveInCluster ending"); } - private void verifyEmptyBucket(final JavaTestKit testKit, final ActorRef registry, final Address address) + private void verifyEmptyBucket(final TestKit testKit, final ActorRef registry, final Address address) throws AssertionError { Map> buckets; int numTries = 0; @@ -263,7 +263,7 @@ public class RpcRegistryTest { */ @Test public void testRpcAddedOnMultiNodes() throws Exception { - final JavaTestKit testKit = new JavaTestKit(node3); + final TestKit testKit = new TestKit(node3); // Add rpc on node 1 List addedRouteIds1 = createRouteIds(); @@ -298,8 +298,7 @@ public class RpcRegistryTest { } - private static void assertEndpoints(final UpdateRemoteEndpoints msg, final Address address, - final JavaTestKit invoker) { + private static void assertEndpoints(final UpdateRemoteEndpoints msg, final Address address, final TestKit invoker) { final Map> endpoints = msg.getEndpoints(); Assert.assertEquals(1, endpoints.size()); @@ -316,7 +315,7 @@ public class RpcRegistryTest { Assert.assertEquals("hello", s); } - private static Map retrieveVersions(final ActorRef bucketStore, final JavaTestKit testKit) { + private static Map retrieveVersions(final ActorRef bucketStore, final TestKit testKit) { bucketStore.tell(GET_BUCKET_VERSIONS, testKit.getRef()); @SuppressWarnings("unchecked") final Map reply = testKit.expectMsgClass(Duration.create(3, TimeUnit.SECONDS), Map.class); @@ -336,7 +335,7 @@ public class RpcRegistryTest { } private static Map> retrieveBuckets(final ActorRef bucketStore, - final JavaTestKit testKit, final Address... addresses) { + final TestKit testKit, final Address... addresses) { int numTries = 0; while (true) { bucketStore.tell(GET_ALL_BUCKETS, testKit.getRef()); @@ -368,7 +367,7 @@ public class RpcRegistryTest { @Test public void testAddRoutesConcurrency() { - final JavaTestKit testKit = new JavaTestKit(node1); + final TestKit testKit = new TestKit(node1); final int nRoutes = 500; final Collection added = new ArrayList<>(nRoutes); diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreTest.java index 4898b27ec9..b9784ab390 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/BucketStoreTest.java @@ -11,8 +11,8 @@ import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.Props; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.ImmutableMap; import com.typesafe.config.ConfigFactory; import java.util.HashMap; @@ -50,7 +50,7 @@ public class BucketStoreTest { @AfterClass public static void teardown() { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } /** diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/GossiperTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/GossiperTest.java index f1e7fea6f5..b199ace2ea 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/GossiperTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/gossip/GossiperTest.java @@ -20,8 +20,8 @@ import akka.actor.ActorSelection; import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.Props; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.ConfigFactory; import java.util.Map; import org.junit.After; @@ -50,7 +50,7 @@ public class GossiperTest { @AfterClass public static void teardown() { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); } @Before diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java index b48d40bac8..8b23154232 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/registry/mbeans/RemoteRpcRegistryMXBeanImplTest.java @@ -10,8 +10,8 @@ package org.opendaylight.controller.remote.rpc.registry.mbeans; import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.actor.Props; -import akka.testkit.JavaTestKit; import akka.testkit.TestActorRef; +import akka.testkit.javadsl.TestKit; import com.google.common.collect.Lists; import com.google.common.util.concurrent.Uninterruptibles; import java.util.Collections; @@ -53,9 +53,9 @@ public class RemoteRpcRegistryMXBeanImplTest { buckets = Lists.newArrayList(emptyRpcIdentifier, localRpcIdentifier); final RemoteRpcProviderConfig config = new RemoteRpcProviderConfig.Builder("system").build(); - final JavaTestKit invoker = new JavaTestKit(system); - final JavaTestKit registrar = new JavaTestKit(system); - final JavaTestKit supervisor = new JavaTestKit(system); + final TestKit invoker = new TestKit(system); + final TestKit registrar = new TestKit(system); + final TestKit supervisor = new TestKit(system); final Props props = RpcRegistry.props(config, invoker.getRef(), registrar.getRef()); testActor = new TestActorRef<>(system, props, supervisor.getRef(), "testActor"); final RpcRegistry rpcRegistry = testActor.underlyingActor(); @@ -66,7 +66,7 @@ public class RemoteRpcRegistryMXBeanImplTest { @After public void tearDown() throws Exception { - JavaTestKit.shutdownActorSystem(system, null, Boolean.TRUE); + TestKit.shutdownActorSystem(system, Boolean.TRUE); } @Test @@ -159,4 +159,4 @@ public class RemoteRpcRegistryMXBeanImplTest { Assert.assertTrue(bucketVersions.contains(testActor.provider().getDefaultAddress().toString())); } -} \ No newline at end of file +} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/LatestEntryRoutingLogicTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/LatestEntryRoutingLogicTest.java index 0b94b546eb..a0f2b0b506 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/LatestEntryRoutingLogicTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/utils/LatestEntryRoutingLogicTest.java @@ -13,8 +13,8 @@ import static org.junit.Assert.assertTrue; import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.japi.Pair; -import akka.testkit.JavaTestKit; import akka.testkit.TestProbe; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.ConfigFactory; import java.util.ArrayList; import java.util.List; @@ -32,7 +32,7 @@ public class LatestEntryRoutingLogicTest { @AfterClass public static void teardown() { - JavaTestKit.shutdownActorSystem(system); + TestKit.shutdownActorSystem(system); system = null; }