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=a2f19d8b2b6b2477a2a71749d6c48b766c459afe;hb=d255fdd0b14660a22ff63771d954ac3fe5d0cb7e;hp=9c1ea70fdbc93a86e91b7ef2764392e23265aeba;hpb=0bdf3307bc17f562c84cceeacd29f42409bfff34;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..a2f19d8b2b 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,7 +8,10 @@ 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 org.opendaylight.controller.cluster.datastore.utils.MockClusterWrapper; +import org.opendaylight.controller.cluster.datastore.utils.MockConfiguration; import scala.concurrent.duration.Duration; public class ShardManagerTest { @@ -26,17 +29,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", new MockClusterWrapper(), new MockConfiguration()); + 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 +48,25 @@ public class ShardManagerTest { }; }}; } -} \ No newline at end of file + + @Test + public void testOnReceiveFindPrimaryForExistentShard() throws Exception { + + new JavaTestKit(system) {{ + final Props props = ShardManager.props("config", new MockClusterWrapper(), new MockConfiguration()); + 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(); + } + }; + }}; + } +}