X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Futils%2FActorContextTest.java;h=2cc33e49cc6bfe6c5d2ca4119f16e04451c48946;hb=bd11e415d86b815a30e3559e199f1ad4637bd02b;hp=cb0864ffaf8d04d2fa59813dc4b6fe553e4ca8a2;hpb=b47ffc2df37ef67559274068d651c86aa666cbc3;p=controller.git 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 cb0864ffaf..2cc33e49cc 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; @@ -57,7 +57,7 @@ import org.opendaylight.controller.cluster.datastore.messages.PrimaryShardInfo; import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound; import org.opendaylight.controller.cluster.raft.utils.EchoActor; import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -73,7 +73,7 @@ public class ActorContextTest extends AbstractActorTest { private static class TestMessage { } - private static class MockShardManager extends UntypedActor { + private static final class MockShardManager extends UntypedActor { private final boolean found; private final ActorRef actorRef; @@ -110,11 +110,11 @@ public class ActorContextTest extends AbstractActorTest { } private static Props props(final boolean found, final ActorRef actorRef) { - return Props.create(new MockShardManagerCreator(found, actorRef) ); + return Props.create(new MockShardManagerCreator(found, actorRef)); } private static Props props() { - return Props.create(new MockShardManagerCreator() ); + return Props.create(new MockShardManagerCreator()); } @SuppressWarnings("serial") @@ -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() @@ -349,8 +346,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testFindPrimaryShardAsyncRemotePrimaryFound() throws Exception { - TestActorRef shardManager = TestActorRef.create(getSystem(), - Props.create(MessageCollectorActor.class)); + ActorRef shardManager = getSystem().actorOf(MessageCollectorActor.props()); DatastoreContext dataStoreContext = DatastoreContext.newBuilder() .logicalStoreType(LogicalDatastoreType.CONFIGURATION) @@ -391,8 +387,7 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testFindPrimaryShardAsyncLocalPrimaryFound() throws Exception { - TestActorRef shardManager = TestActorRef.create(getSystem(), - Props.create(MessageCollectorActor.class)); + ActorRef shardManager = getSystem().actorOf(MessageCollectorActor.props()); DatastoreContext dataStoreContext = DatastoreContext.newBuilder() .logicalStoreType(LogicalDatastoreType.CONFIGURATION) @@ -443,8 +438,7 @@ public class ActorContextTest extends AbstractActorTest { @SuppressWarnings("checkstyle:IllegalCatch") private static void testFindPrimaryExceptions(final Object expectedException) throws Exception { - TestActorRef shardManager = - TestActorRef.create(getSystem(), Props.create(MessageCollectorActor.class)); + ActorRef shardManager = getSystem().actorOf(MessageCollectorActor.props()); DatastoreContext dataStoreContext = DatastoreContext.newBuilder() .logicalStoreType(LogicalDatastoreType.CONFIGURATION) @@ -477,10 +471,10 @@ public class ActorContextTest extends AbstractActorTest { @Test public void testBroadcast() { - new JavaTestKit(getSystem()) { + new TestKit(getSystem()) { { - ActorRef shardActorRef1 = getSystem().actorOf(Props.create(MessageCollectorActor.class)); - ActorRef shardActorRef2 = getSystem().actorOf(Props.create(MessageCollectorActor.class)); + ActorRef shardActorRef1 = getSystem().actorOf(MessageCollectorActor.props()); + ActorRef shardActorRef2 = getSystem().actorOf(MessageCollectorActor.props()); TestActorRef shardManagerActorRef = TestActorRef.create(getSystem(), MockShardManager.props());