X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fbroker%2Fimpl%2FDOMTransactionChainTest.java;h=38f08b30f94ea37d4e73e3537c5c7bd798eb12ed;hb=79202e1fd05d2606b35e163f608fad9cce84b5d4;hp=b360cb1694eab7224980ed6ed078f39a51942e1e;hpb=88080e729f2bb13c704665fe72f99e9aad9dfb12;p=controller.git 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 b360cb1694..38f08b30f9 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 @@ -71,8 +71,8 @@ public class DOMTransactionChainTest { /** * We alocate new read-write transaction and write /test - * - * + * + * */ DOMDataReadWriteTransaction firstTx = allocateAndWrite(txChain); @@ -88,44 +88,45 @@ public class DOMTransactionChainTest { DOMDataReadTransaction secondReadTx = txChain.newReadOnlyTransaction(); /** - * + * * We test if we are able to read data from tx, read should not fail * since we are using chained transaction. - * - * + * + * */ assertTestContainerExists(secondReadTx); /** - * + * * We alocate next transaction, which is still based on first one, but * is read-write. - * + * */ 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.commit(); assertCommitSuccessful(thirdDeleteTxFuture); /** @@ -144,8 +145,8 @@ public class DOMTransactionChainTest { /** * We alocate new read-write transaction and write /test - * - * + * + * */ allocateAndWrite(txChain); @@ -155,21 +156,21 @@ public class DOMTransactionChainTest { * IllegalStateException. */ try { - DOMDataReadTransaction secondReadTx = txChain.newReadOnlyTransaction(); + txChain.newReadOnlyTransaction(); fail("Allocation of secondReadTx should fail with IllegalStateException"); } catch (Exception e) { assertTrue(e instanceof IllegalStateException); } } - private static DOMDataReadWriteTransaction allocateAndDelete(DOMTransactionChain txChain) + private static DOMDataReadWriteTransaction allocateAndDelete(final DOMTransactionChain txChain) throws InterruptedException, ExecutionException { DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction(); /** * We test existence of /test in third transaction container should * still be visible from first one (which is still uncommmited). - * + * */ assertTestContainerExists(tx); @@ -180,28 +181,28 @@ public class DOMTransactionChainTest { return tx; } - private static DOMDataReadWriteTransaction allocateAndWrite(DOMTransactionChain txChain) + private static DOMDataReadWriteTransaction allocateAndWrite(final DOMTransactionChain txChain) throws InterruptedException, ExecutionException { DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction(); assertTestContainerWrite(tx); return tx; } - private static void assertCommitSuccessful(ListenableFuture> future) + private static void assertCommitSuccessful(final ListenableFuture> future) throws InterruptedException, ExecutionException { RpcResult rpcResult = future.get(); assertTrue(rpcResult.isSuccessful()); assertEquals(TransactionStatus.COMMITED, rpcResult.getResult()); } - private static void assertTestContainerExists(DOMDataReadTransaction readTx) throws InterruptedException, + private static void assertTestContainerExists(final DOMDataReadTransaction readTx) throws InterruptedException, ExecutionException { ListenableFuture>> readFuture = readTx.read(OPERATIONAL, TestModel.TEST_PATH); Optional> readedData = readFuture.get(); assertTrue(readedData.isPresent()); } - private static void assertTestContainerWrite(DOMDataReadWriteTransaction tx) throws InterruptedException, + private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx) throws InterruptedException, ExecutionException { tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); assertTestContainerExists(tx);