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%2FShardManagerTest.java;h=fa436c16053bc42ad9835e7ecbccd1cb202fc4b8;hb=996ab3e41386da6b27cf21f6464ef1e55363e1ca;hp=9c1ea70fdbc93a86e91b7ef2764392e23265aeba;hpb=ceec41033ab311600969e595191a952ab4e6047d;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java index 9c1ea70fdb..fa436c1605 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardManagerTest.java @@ -8,6 +8,7 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.messages.FindPrimary; +import org.opendaylight.controller.cluster.datastore.messages.PrimaryFound; import org.opendaylight.controller.cluster.datastore.messages.PrimaryNotFound; import scala.concurrent.duration.Duration; @@ -26,17 +27,13 @@ public class ShardManagerTest { } @Test - public void testOnReceiveFindPrimary() throws Exception { + public void testOnReceiveFindPrimaryForNonExistentShard() throws Exception { new JavaTestKit(system) {{ - final Props props = Props.create(ShardManager.class); - final TestActorRef subject = TestActorRef.create(system, props, "test"); + final Props props = ShardManager.props("config"); + final TestActorRef subject = TestActorRef.create(system, props); - // can also use JavaTestKit “from the outside” - final JavaTestKit probe = new JavaTestKit(system); - - // the run() method needs to finish within 3 seconds - new Within(duration("3 seconds")) { + new Within(duration("1 seconds")) { protected void run() { subject.tell(new FindPrimary("inventory"), getRef()); @@ -49,4 +46,25 @@ public class ShardManagerTest { }; }}; } + + @Test + public void testOnReceiveFindPrimaryForExistentShard() throws Exception { + + new JavaTestKit(system) {{ + final Props props = ShardManager.props("config"); + final TestActorRef subject = TestActorRef.create(system, props); + + // the run() method needs to finish within 3 seconds + new Within(duration("1 seconds")) { + protected void run() { + + subject.tell(new FindPrimary(Shard.DEFAULT_NAME), getRef()); + + expectMsgClass(PrimaryFound.class); + + expectNoMsg(); + } + }; + }}; + } } \ No newline at end of file