use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class ConcurrentTreeModificationTest method writeWrite1stLevelEmptyTreeTest.
@Test
public void writeWrite1stLevelEmptyTreeTest() throws DataValidationFailedException {
final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
modificationTree1.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
modificationTree2.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
modificationTree1.ready();
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree1);
final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree1);
inMemoryDataTree.commit(prepare1);
try {
inMemoryDataTree.validate(modificationTree2);
fail("Exception should have been thrown.");
} catch (final ConflictingModificationAppliedException ex) {
LOG.debug("ConflictingModificationAppliedException - was thrown as expected", ex);
}
final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
inMemoryDataTree.commit(prepare2);
final Optional<NormalizedNode> testNodeAfterCommits = modificationTree1.readNode(TestModel.TEST_PATH);
assertPresentAndType(testNodeAfterCommits, ContainerNode.class);
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class ConcurrentTreeModificationTest method mergeMergeFooBar1stLevelEmptyTreeTest.
@Test
public void mergeMergeFooBar1stLevelEmptyTreeTest() throws DataValidationFailedException {
final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
modificationTree1.merge(TestModel.TEST_PATH, createFooTestContainerNode());
modificationTree2.merge(TestModel.TEST_PATH, createBarTestContainerNode());
modificationTree1.ready();
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree1);
final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree1);
inMemoryDataTree.commit(prepare1);
inMemoryDataTree.validate(modificationTree2);
final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
inMemoryDataTree.commit(prepare2);
final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class ConcurrentTreeModificationTest method mergeWriteFooBar1stLevelEmptyContainerTest.
@Test
public void mergeWriteFooBar1stLevelEmptyContainerTest() throws DataValidationFailedException {
final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
initialDataTreeModification.ready();
inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
modificationTree1.merge(TestModel.TEST_PATH, createFooTestContainerNode());
modificationTree2.write(TestModel.TEST_PATH, createBarTestContainerNode());
modificationTree1.ready();
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree1);
final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree1);
inMemoryDataTree.commit(prepare1);
try {
inMemoryDataTree.validate(modificationTree2);
fail("Exception should have been thrown.");
final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
inMemoryDataTree.commit(prepare2);
} catch (final ConflictingModificationAppliedException ex) {
LOG.debug("ConflictingModificationAppliedException was thrown as expected", ex);
}
final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
assertFalse(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH).isPresent());
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class ConcurrentTreeModificationTest method writeMerge1stLevelEmptyTreeTest.
@Test
public void writeMerge1stLevelEmptyTreeTest() throws DataValidationFailedException {
final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
modificationTree1.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
modificationTree2.merge(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
modificationTree1.ready();
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree1);
final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree1);
inMemoryDataTree.commit(prepare1);
inMemoryDataTree.validate(modificationTree2);
final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
inMemoryDataTree.commit(prepare2);
final Optional<NormalizedNode> testNodeAfterCommits = modificationTree1.readNode(TestModel.TEST_PATH);
assertPresentAndType(testNodeAfterCommits, ContainerNode.class);
}
use of org.opendaylight.yangtools.yang.data.tree.api.DataTreeSnapshot in project yangtools by opendaylight.
the class ConcurrentTreeModificationTest method writeWriteFooBar1stLevelEmptyTreeTest.
@Test
public void writeWriteFooBar1stLevelEmptyTreeTest() throws DataValidationFailedException {
final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
modificationTree1.write(TestModel.TEST_PATH, createFooTestContainerNode());
modificationTree2.write(TestModel.TEST_PATH, createBarTestContainerNode());
modificationTree1.ready();
modificationTree2.ready();
inMemoryDataTree.validate(modificationTree1);
final DataTreeCandidate prepare1 = inMemoryDataTree.prepare(modificationTree1);
inMemoryDataTree.commit(prepare1);
try {
inMemoryDataTree.validate(modificationTree2);
fail("Exception should have been thrown.");
final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
inMemoryDataTree.commit(prepare2);
} catch (final ConflictingModificationAppliedException ex) {
LOG.debug("ConflictingModificationAppliedException - was thrown as expected", ex);
}
final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
assertFalse(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH).isPresent());
}
Aggregations