X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FDOMTransactionChainTest.java;h=aba78f755912275c1cf001e8225fe02ac7b9b0f6;hp=2a955e5f4215e6dccc0c397ca9c0850ccb159aa3;hb=3997099eb61b0f2adc47f7a85952c324e9de223f;hpb=bc1e703ab2d257b450fe6eb3fe0fe5333783bc69 diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java index 2a955e5f42..aba78f7559 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMTransactionChainTest.java @@ -7,21 +7,22 @@ */ package org.opendaylight.controller.md.sal.dom.broker.impl; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION; import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL; - +import com.google.common.base.Optional; +import com.google.common.collect.ImmutableMap; +import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.ListeningExecutorService; +import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; - import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction; import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction; @@ -29,26 +30,19 @@ import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain; import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; import org.opendaylight.controller.md.sal.dom.store.impl.TestModel; import org.opendaylight.controller.sal.core.spi.data.DOMStore; -import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import com.google.common.base.Optional; -import com.google.common.collect.ImmutableMap; -import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.ListeningExecutorService; -import com.google.common.util.concurrent.MoreExecutors; - public class DOMTransactionChainTest { private SchemaContext schemaContext; - private DOMDataBrokerImpl domBroker; + private AbstractDOMDataBroker domBroker; @Before public void setupStore() { - InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor()); - InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor()); + InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService()); + InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService()); schemaContext = TestModel.createTestContext(); operStore.onGlobalContextUpdated(schemaContext); @@ -60,7 +54,7 @@ public class DOMTransactionChainTest { .build(); ListeningExecutorService executor = MoreExecutors.listeningDecorator(Executors.newSingleThreadExecutor()); - domBroker = new DOMDataBrokerImpl(stores, executor); + domBroker = new SerializedDOMDataBroker(stores, executor); } @Test @@ -80,7 +74,7 @@ public class DOMTransactionChainTest { * First transaction is marked as ready, we are able to allocate chained * transactions */ - ListenableFuture> firstWriteTxFuture = firstTx.commit(); + ListenableFuture firstWriteTxFuture = firstTx.submit(); /** * We alocate chained transaction - read transaction. @@ -104,28 +98,29 @@ public class DOMTransactionChainTest { */ DOMDataReadWriteTransaction thirdDeleteTx = allocateAndDelete(txChain); - /** - * third transaction is sealed. - */ - ListenableFuture> thirdDeleteTxFuture = thirdDeleteTx.commit(); - /** * We commit first transaction * */ assertCommitSuccessful(firstWriteTxFuture); - // Alocates store transaction + /** + * + * Allocates transaction from data store. + * + */ DOMDataReadTransaction storeReadTx = domBroker.newReadOnlyTransaction(); + /** * We verify transaction is commited to store, container should exists * in datastore. */ assertTestContainerExists(storeReadTx); + /** - * We commit third transaction - * + * third transaction is sealed and commited */ + ListenableFuture thirdDeleteTxFuture = thirdDeleteTx.submit(); assertCommitSuccessful(thirdDeleteTxFuture); /** @@ -187,11 +182,9 @@ public class DOMTransactionChainTest { return tx; } - private static void assertCommitSuccessful(final ListenableFuture> future) + private static void assertCommitSuccessful(final ListenableFuture future) throws InterruptedException, ExecutionException { - RpcResult rpcResult = future.get(); - assertTrue(rpcResult.isSuccessful()); - assertEquals(TransactionStatus.COMMITED, rpcResult.getResult()); + future.get(); } private static void assertTestContainerExists(final DOMDataReadTransaction readTx) throws InterruptedException,