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%2FDistributedDataStoreTest.java;h=d1beab904984262cd1f83de56a039c5970dc0742;hb=8e42b08cb626a60919c145b2a46d94114c3905d6;hp=23a1ed49315ec827baa95c41b51dfe4d23159d4e;hpb=c222e37f2a0f0f3f6266242fbea2d3b018f4e6e3;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java index 23a1ed4931..d1beab9049 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DistributedDataStoreTest.java @@ -54,8 +54,8 @@ public class DistributedDataStoreTest extends AbstractActorTest{ } @org.junit.Test - public void testRegisterChangeListener() throws Exception { - mockActorContext.setExecuteShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path()).toSerializable()); + public void testRegisterChangeListenerWhenShardIsNotLocal() throws Exception { + ListenerRegistration registration = distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener>() { @Override @@ -64,9 +64,31 @@ public class DistributedDataStoreTest extends AbstractActorTest{ } }, AsyncDataBroker.DataChangeScope.BASE); + // Since we do not expect the shard to be local registration will return a NoOpRegistration + Assert.assertTrue(registration instanceof NoOpDataChangeListenerRegistration); + + Assert.assertNotNull(registration); + } + + @org.junit.Test + public void testRegisterChangeListenerWhenShardIsLocal() throws Exception { + + mockActorContext.setExecuteLocalShardOperationResponse(new RegisterChangeListenerReply(doNothingActorRef.path())); + + ListenerRegistration registration = + distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener>() { + @Override + public void onDataChanged(AsyncDataChangeEvent> change) { + throw new UnsupportedOperationException("onDataChanged"); + } + }, AsyncDataBroker.DataChangeScope.BASE); + + Assert.assertTrue(registration instanceof DataChangeListenerRegistrationProxy); + Assert.assertNotNull(registration); } + @org.junit.Test public void testCreateTransactionChain() throws Exception { final DOMStoreTransactionChain transactionChain = distributedDataStore.createTransactionChain();