use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService in project controller by opendaylight.
the class DOMDataTreeListenerTest method writeContainerEmptyTreeTest.
@Test
public void writeContainerEmptyTreeTest() throws InterruptedException {
CountDownLatch latch = new CountDownLatch(1);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService.registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
final DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit();
latch.await(5, TimeUnit.SECONDS);
assertEquals(1, listener.getReceivedChanges().size());
final Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
listenerReg.close();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService in project controller by opendaylight.
the class DOMDataTreeListenerTest method rootModificationChildListenerTest.
@Test
public void rootModificationChildListenerTest() throws InterruptedException, TransactionCommitFailedException {
final CountDownLatch latch = new CountDownLatch(2);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit().checkedGet();
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService.registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener);
writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER_2);
writeTx.submit().checkedGet();
latch.await(1, TimeUnit.SECONDS);
assertEquals(2, listener.getReceivedChanges().size());
Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, OUTER_LIST, ModificationType.WRITE, candidateRoot);
changes = listener.getReceivedChanges().get(1);
assertEquals(1, changes.size());
candidate = changes.iterator().next();
assertNotNull(candidate);
candidateRoot = candidate.getRootNode();
checkChange(OUTER_LIST, OUTER_LIST_2, ModificationType.WRITE, candidateRoot);
listenerReg.close();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService in project controller by opendaylight.
the class DOMDataTreeListenerTest method getDOMDataTreeChangeService.
private DOMDataTreeChangeService getDOMDataTreeChangeService() {
final DOMDataBrokerExtension extension = domBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
if (extension == null) {
return null;
}
DOMDataTreeChangeService dataTreeChangeService = null;
if (extension instanceof DOMDataTreeChangeService) {
dataTreeChangeService = (DOMDataTreeChangeService) extension;
}
return dataTreeChangeService;
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService in project bgpcep by opendaylight.
the class RibImplTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
Mockito.doReturn(mock(GeneratedClassLoadingStrategy.class)).when(this.extension).getClassLoadingStrategy();
Mockito.doReturn(this.ribSupport).when(this.extension).getRIBSupport(any(TablesKey.class));
final NodeIdentifier nii = new NodeIdentifier(QName.create("", "test").intern());
Mockito.doReturn(nii).when(this.ribSupport).routeAttributesIdentifier();
Mockito.doReturn(ImmutableSet.of()).when(this.ribSupport).cacheableAttributeObjects();
final ChoiceNode choiceNode = mock(ChoiceNode.class);
Mockito.doReturn(choiceNode).when(this.ribSupport).emptyRoutes();
Mockito.doReturn(nii).when(choiceNode).getIdentifier();
Mockito.doReturn(QName.create("", "test").intern()).when(choiceNode).getNodeType();
Mockito.doReturn(this.domTx).when(this.domDataBroker).createTransactionChain(any());
final DOMDataTreeChangeService dOMDataTreeChangeService = mock(DOMDataTreeChangeService.class);
Mockito.doReturn(Collections.singletonMap(DOMDataTreeChangeService.class, dOMDataTreeChangeService)).when(this.domDataBroker).getSupportedExtensions();
Mockito.doReturn(this.dataTreeRegistration).when(this.domSchemaService).registerSchemaContextListener(any());
Mockito.doNothing().when(this.dataTreeRegistration).close();
Mockito.doReturn(mock(ListenerRegistration.class)).when(dOMDataTreeChangeService).registerDataTreeChangeListener(any(), any());
Mockito.doNothing().when(this.serviceRegistration).unregister();
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService in project controller by opendaylight.
the class DOMDataTreeListenerTest method deleteContainerContainerInTreeTest.
@Test
public void deleteContainerContainerInTreeTest() throws InterruptedException, TransactionCommitFailedException {
final CountDownLatch latch = new CountDownLatch(2);
DOMDataTreeChangeService dataTreeChangeService = getDOMDataTreeChangeService();
assertNotNull("DOMDataTreeChangeService not found, cannot continue with test!", dataTreeChangeService);
DOMDataWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH, TEST_CONTAINER);
writeTx.submit().checkedGet();
final TestDataTreeListener listener = new TestDataTreeListener(latch);
final ListenerRegistration<TestDataTreeListener> listenerReg = dataTreeChangeService.registerDataTreeChangeListener(ROOT_DATA_TREE_ID, listener);
writeTx = domBroker.newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH);
writeTx.submit();
latch.await(5, TimeUnit.SECONDS);
assertEquals(2, listener.getReceivedChanges().size());
Collection<DataTreeCandidate> changes = listener.getReceivedChanges().get(0);
assertEquals(1, changes.size());
DataTreeCandidate candidate = changes.iterator().next();
assertNotNull(candidate);
DataTreeCandidateNode candidateRoot = candidate.getRootNode();
checkChange(null, TEST_CONTAINER, ModificationType.WRITE, candidateRoot);
changes = listener.getReceivedChanges().get(1);
assertEquals(1, changes.size());
candidate = changes.iterator().next();
assertNotNull(candidate);
candidateRoot = candidate.getRootNode();
checkChange(TEST_CONTAINER, null, ModificationType.DELETE, candidateRoot);
listenerReg.close();
}
Aggregations