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%2Fdatabroker%2FConcurrentDOMDataBrokerTest.java;h=bef18ffe200216502fb7fc42fe10de657b6f7799;hb=9cab91f5204c0f55ee269a507269f02d5fe5e90b;hp=d86f358c31c1d92c68051940ab701ea43db08c80;hpb=5464f50be733df1bbbe31cf05665d542d3b7c5e7;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java index d86f358c31..bef18ffe20 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/ConcurrentDOMDataBrokerTest.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; +import java.util.Map; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.SynchronousQueue; @@ -45,13 +46,17 @@ import org.junit.Before; import org.junit.Test; import org.mockito.InOrder; import org.mockito.stubbing.Answer; +import org.opendaylight.controller.cluster.datastore.DistributedDataStore; import org.opendaylight.controller.cluster.datastore.exceptions.NoShardLeaderException; import org.opendaylight.controller.md.sal.common.api.data.DataStoreUnavailableException; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBrokerExtension; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; +import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeCommitCohortRegistry; import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; @@ -61,6 +66,8 @@ import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransactio import org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort; import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain; import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.mdsal.dom.api.DOMDataTreeCommitCohort; +import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; @@ -109,14 +116,11 @@ public class ConcurrentDOMDataBrokerTest { Answer> asyncCanCommit = invocation -> { final SettableFuture future = SettableFuture.create(); if (doAsync) { - new Thread() { - @Override - public void run() { - Uninterruptibles.awaitUninterruptibly(asyncCanCommitContinue, - 10, TimeUnit.SECONDS); - future.set(true); - } - }.start(); + new Thread(() -> { + Uninterruptibles.awaitUninterruptibly(asyncCanCommitContinue, + 10, TimeUnit.SECONDS); + future.set(true); + }).start(); } else { future.set(true); } @@ -570,4 +574,29 @@ public class ConcurrentDOMDataBrokerTest { } } + @Test + public void testExtensions() { + DistributedDataStore mockConfigStore = mock(DistributedDataStore.class); + DistributedDataStore mockOperStore = mock(DistributedDataStore.class); + try (ConcurrentDOMDataBroker dataBroker = new ConcurrentDOMDataBroker(ImmutableMap.of( + LogicalDatastoreType.OPERATIONAL, mockOperStore, + LogicalDatastoreType.CONFIGURATION, mockConfigStore), futureExecutor)) { + + Map, DOMDataBrokerExtension> supportedExtensions = + dataBroker.getSupportedExtensions(); + assertNotNull(supportedExtensions.get(DOMDataTreeChangeService.class)); + + DOMDataTreeCommitCohortRegistry cohortRegistry = + (DOMDataTreeCommitCohortRegistry) supportedExtensions.get(DOMDataTreeCommitCohortRegistry.class); + assertNotNull(cohortRegistry); + + DOMDataTreeCommitCohort mockCohort = mock(DOMDataTreeCommitCohort.class); + DOMDataTreeIdentifier path = new DOMDataTreeIdentifier( + org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION, + YangInstanceIdentifier.EMPTY); + cohortRegistry.registerCommitCohort(path, mockCohort); + + verify(mockConfigStore).registerCommitCohort(path, mockCohort); + } + } }