X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardTransactionChainTest.java;h=bc3a1046566b2259012916c85e70ae933d921b3d;hp=d8cb53d0836fbff17d4ece96a1f31a0a9b6a89c9;hb=ebd9aba9e844229de613a2b60b5d21119fcee968;hpb=d3d2323ad9ad332d71dc6b956e4a3d3daa525902 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java index d8cb53d083..bc3a104656 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionChainTest.java @@ -6,11 +6,14 @@ import akka.testkit.JavaTestKit; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import org.junit.Test; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChain; +import org.opendaylight.controller.cluster.datastore.messages.CloseTransactionChainReply; import org.opendaylight.controller.cluster.datastore.messages.CreateTransaction; import org.opendaylight.controller.cluster.datastore.messages.CreateTransactionReply; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; public class ShardTransactionChainTest extends AbstractActorTest { @@ -50,6 +53,38 @@ public class ShardTransactionChainTest extends AbstractActorTest { } + }; + }}; + } + + @Test + public void testOnReceiveCloseTransactionChain() throws Exception { + new JavaTestKit(getSystem()) {{ + final Props props = ShardTransactionChain.props(store.createTransactionChain()); + final ActorRef subject = getSystem().actorOf(props, "testCloseTransactionChain"); + + new Within(duration("1 seconds")) { + protected void run() { + + subject.tell(new CloseTransactionChain(), getRef()); + + final String out = new ExpectMsg("match hint") { + // do not put code outside this method, will run afterwards + protected String match(Object in) { + if (in instanceof CloseTransactionChainReply) { + return "match"; + } else { + throw noMatch(); + } + } + }.get(); // this extracts the received message + + assertEquals("match", out); + // Will wait for the rest of the 3 seconds + expectNoMsg(); + } + + }; }}; }