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%2FDOMDataTreeListenerTest.java;h=edc5561679ad67f9b021c4c206b0c07eb9b356e6;hp=a6cd351f129168676d0396afaa2f630023a27bfb;hb=079163ec73e4304ebe9b6f9076f78e22e2d0e3a5;hpb=4ef15f7a7e3fb5bcaa6a3202d268a5c945e0aa71 diff --git a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java index a6cd351f12..edc5561679 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java +++ b/opendaylight/md-sal/sal-dom-broker/src/test/java/org/opendaylight/controller/md/sal/dom/broker/impl/DOMDataTreeListenerTest.java @@ -22,16 +22,15 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import javax.annotation.Nonnull; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitDeadlockException; -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.DOMDataTreeChangeListener; import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService; @@ -100,7 +99,8 @@ public class DOMDataTreeListenerTest { .build(); commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor()); - futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB"); + futureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(1, 5, "FCB", + DOMDataTreeListenerTest.class); executor = new DeadlockDetectingListeningExecutorService(commitExecutor, TransactionCommitDeadlockException .DEADLOCK_EXCEPTION_SUPPLIER, @@ -132,7 +132,7 @@ public class DOMDataTreeListenerTest { final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -148,7 +148,7 @@ public class DOMDataTreeListenerTest { } @Test - public void replaceContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException { + public void replaceContainerContainerInTreeTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -156,14 +156,14 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService .registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener); writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -187,7 +187,7 @@ public class DOMDataTreeListenerTest { } @Test - public void deleteContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException { + public void deleteContainerContainerInTreeTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -195,7 +195,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -203,7 +203,7 @@ public class DOMDataTreeListenerTest { writeTx = domBroker.newWriteOnlyTransaction(); writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -227,7 +227,7 @@ public class DOMDataTreeListenerTest { } @Test - public void replaceChildListContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException { + public void replaceChildListContainerInTreeTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -235,7 +235,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -243,7 +243,7 @@ public class DOMDataTreeListenerTest { writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH, OUTER_LIST_2); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -264,14 +264,13 @@ public class DOMDataTreeListenerTest { candidateRoot = candidate.getRootNode(); checkChange(TEST_CONTAINER, TEST_CONTAINER_2, ModificationType.SUBTREE_MODIFIED, candidateRoot); final DataTreeCandidateNode modifiedChild = candidateRoot - .getModifiedChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)); - assertNotNull(modifiedChild); + .getModifiedChild(new YangInstanceIdentifier.NodeIdentifier(TestModel.OUTER_LIST_QNAME)).get(); checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, modifiedChild); listenerReg.close(); } @Test - public void rootModificationChildListenerTest() throws InterruptedException, TransactionCommitFailedException { + public void rootModificationChildListenerTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -279,7 +278,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -287,7 +286,7 @@ public class DOMDataTreeListenerTest { writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2); - writeTx.submit().checkedGet(); + writeTx.commit().get(); latch.await(1, TimeUnit.SECONDS); @@ -311,7 +310,7 @@ public class DOMDataTreeListenerTest { } @Test - public void listEntryChangeNonRootRegistrationTest() throws InterruptedException, TransactionCommitFailedException { + public void listEntryChangeNonRootRegistrationTest() throws InterruptedException, ExecutionException { final CountDownLatch latch = new CountDownLatch(2); DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService(); @@ -319,7 +318,7 @@ public class DOMDataTreeListenerTest { DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction(); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER); - writeTx.submit().checkedGet(); + writeTx.commit().get(); final TestDataTreeListener listener = new TestDataTreeListener(latch); final ListenerRegistration listenerReg = dataTreeChangeService @@ -348,7 +347,7 @@ public class DOMDataTreeListenerTest { outerListEntry2); writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH.node(outerListEntryId3), outerListEntry3); - writeTx.submit(); + writeTx.commit(); latch.await(5, TimeUnit.SECONDS); @@ -368,11 +367,11 @@ public class DOMDataTreeListenerTest { assertNotNull(candidate); candidateRoot = candidate.getRootNode(); checkChange(OUTER_LIST, listAfter, ModificationType.SUBTREE_MODIFIED, candidateRoot); - final DataTreeCandidateNode entry1Canditate = candidateRoot.getModifiedChild(outerListEntryId1); + final DataTreeCandidateNode entry1Canditate = candidateRoot.getModifiedChild(outerListEntryId1).get(); checkChange(outerListEntry1, null, ModificationType.DELETE, entry1Canditate); - final DataTreeCandidateNode entry2Canditate = candidateRoot.getModifiedChild(outerListEntryId2); + final DataTreeCandidateNode entry2Canditate = candidateRoot.getModifiedChild(outerListEntryId2).get(); checkChange(null, outerListEntry2, ModificationType.WRITE, entry2Canditate); - final DataTreeCandidateNode entry3Canditate = candidateRoot.getModifiedChild(outerListEntryId3); + final DataTreeCandidateNode entry3Canditate = candidateRoot.getModifiedChild(outerListEntryId3).get(); checkChange(null, outerListEntry3, ModificationType.WRITE, entry3Canditate); listenerReg.close(); } @@ -433,7 +432,7 @@ public class DOMDataTreeListenerTest { } @Override - public void onDataTreeChanged(@Nonnull final Collection changes) { + public void onDataTreeChanged(final Collection changes) { receivedChanges.add(changes); latch.countDown(); }