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=914f0dbb2909c5c88f01b40746f70e899ef64be4;hpb=fe4049d34de103016d11f3a9050853c6380646d3;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 914f0dbb29..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 @@ -3,7 +3,6 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import akka.actor.Props; import junit.framework.Assert; - import org.opendaylight.controller.cluster.datastore.messages.RegisterChangeListenerReply; import org.opendaylight.controller.cluster.datastore.shardstrategy.ShardStrategyFactory; import org.opendaylight.controller.cluster.datastore.utils.DoNothingActor; @@ -19,7 +18,7 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransactio import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class DistributedDataStoreTest extends AbstractActorTest{ @@ -55,19 +54,41 @@ 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>() { + distributedDataStore.registerChangeListener(TestModel.TEST_PATH, new AsyncDataChangeListener>() { @Override - public void onDataChanged(AsyncDataChangeEvent> change) { + public void onDataChanged(AsyncDataChangeEvent> change) { throw new UnsupportedOperationException("onDataChanged"); } }, 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();