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%2FDataChangeListenerRegistrationProxyTest.java;h=aaf080bdf7d8d50de4a3f31713143389994872a6;hb=4f81f4ed61cf74c4dcac48e4f7714adcda501a5f;hp=c99a7e8c8c4908133bac2a9710e3549f02e2410c;hpb=516a4b2ea78179c9bd6ebb584862e8fc686ebf08;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java index c99a7e8c8c..aaf080bdf7 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataChangeListenerRegistrationProxyTest.java @@ -17,6 +17,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import java.util.List; +import static junit.framework.TestCase.assertEquals; +import static junit.framework.TestCase.assertNotNull; +import static junit.framework.TestCase.assertTrue; + public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{ private ActorRef dataChangeListenerActor = getSystem().actorOf(Props.create(DoNothingActor.class)); @@ -62,17 +66,43 @@ public class DataChangeListenerRegistrationProxyTest extends AbstractActorTest{ ActorContext testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)),new MockClusterWrapper(), new MockConfiguration()); Object messages = testContext - .executeLocalOperation(actorRef, "messages", - ActorContext.ASK_DURATION); + .executeOperation(actorRef, "messages"); - Assert.assertNotNull(messages); + assertNotNull(messages); - Assert.assertTrue(messages instanceof List); + assertTrue(messages instanceof List); List listMessages = (List) messages; - Assert.assertEquals(1, listMessages.size()); + assertEquals(1, listMessages.size()); + + assertTrue(listMessages.get(0).getClass() + .equals(CloseDataChangeListenerRegistration.SERIALIZABLE_CLASS)); + } + + @Test + public void testCloseWhenRegistrationIsNull() throws Exception { + final Props props = Props.create(MessageCollectorActor.class); + final ActorRef actorRef = getSystem().actorOf(props); + + DataChangeListenerRegistrationProxy proxy = + new DataChangeListenerRegistrationProxy( + new MockDataChangeListener(), dataChangeListenerActor); + + proxy.close(); + + //Check if it was received by the remote actor + ActorContext + testContext = new ActorContext(getSystem(), getSystem().actorOf(Props.create(DoNothingActor.class)),new MockClusterWrapper(), new MockConfiguration()); + Object messages = testContext + .executeOperation(actorRef, "messages"); + + assertNotNull(messages); + + assertTrue(messages instanceof List); + + List listMessages = (List) messages; - Assert.assertTrue(listMessages.get(0).getClass().equals(CloseDataChangeListenerRegistration.SERIALIZABLE_CLASS)); + assertEquals(0, listMessages.size()); } }