X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fbroker%2FShardedDOMDataTreeTest.java;h=771312c05c50b46b7f921a377fd4f98fcd051b48;hb=daa4ba8ad3fcab5719257fdfc3edb4196697cec1;hp=814b3ec3e6b39801007119083454aa9cac7086c3;hpb=0f351bbc28ddf2cddfe30c8d018646d81953fa17;p=mdsal.git diff --git a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java index 814b3ec3e6..771312c05c 100644 --- a/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java +++ b/dom/mdsal-dom-broker/src/test/java/org/opendaylight/mdsal/dom/broker/ShardedDOMDataTreeTest.java @@ -57,14 +57,11 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder; import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -public class ShardedDOMDataTreeTest { - - private static final SchemaContext SCHEMA_CONTEXT = TestModel.createTestContext(); +public class ShardedDOMDataTreeTest extends AbstractDatastoreTest { private static final DOMDataTreeIdentifier ROOT_ID = - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY); + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty()); private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); @@ -72,7 +69,7 @@ public class ShardedDOMDataTreeTest { new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.INNER_CONTAINER_PATH); private static final YangInstanceIdentifier OUTER_LIST_YID = TestModel.OUTER_LIST_PATH.node( - new NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)); + NodeIdentifierWithPredicates.of(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)); private static final DOMDataTreeIdentifier OUTER_LIST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, OUTER_LIST_YID); @@ -95,7 +92,7 @@ public class ShardedDOMDataTreeTest { MockitoAnnotations.initMocks(this); rootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1); - rootShard.onGlobalContextUpdated(SCHEMA_CONTEXT); + rootShard.onModelContextUpdated(SCHEMA_CONTEXT); final ShardedDOMDataTree dataTree = new ShardedDOMDataTree(); final DOMDataTreeProducer shardRegProducer = dataTree.createProducer(Collections.singletonList(ROOT_ID)); @@ -111,20 +108,26 @@ public class ShardedDOMDataTreeTest { dataTreeService.createProducer(Collections.singletonList(TEST_ID)); } + @Test(expected = IllegalArgumentException.class) + public void testProducerPathContentionReverse() throws Exception { + dataTreeService.createProducer(Collections.singletonList(TEST_ID)); + dataTreeService.createProducer(Collections.singletonList(ROOT_ID)); + } + @Test public void testShardRegistrationClose() throws Exception { rootShardReg.close(); final InMemoryDOMDataTreeShard newRootShard = InMemoryDOMDataTreeShard.create(ROOT_ID, executor, 1); - newRootShard.onGlobalContextUpdated(SCHEMA_CONTEXT); + newRootShard.onModelContextUpdated(SCHEMA_CONTEXT); final DOMDataTreeProducer shardRegProducer = dataTreeService.createProducer(Collections.singletonList(ROOT_ID)); final ListenerRegistration newRootShardReg = - dataTreeService.registerDataTreeShard(ROOT_ID, rootShard, shardRegProducer); + dataTreeService.registerDataTreeShard(ROOT_ID, newRootShard, shardRegProducer); shardRegProducer.close(); final InMemoryDOMDataTreeShard innerShard = InMemoryDOMDataTreeShard.create(INNER_CONTAINER_ID, executor, 1); - innerShard.onGlobalContextUpdated(SCHEMA_CONTEXT); + innerShard.onModelContextUpdated(SCHEMA_CONTEXT); final DOMDataTreeProducer shardRegProducer2 = dataTreeService.createProducer(Collections.singletonList(INNER_CONTAINER_ID)); ListenerRegistration innerShardReg = @@ -207,7 +210,7 @@ public class ShardedDOMDataTreeTest { doNothing().when(mockedDataTreeListener).onDataTreeChanged(anyCollection(), anyMap()); InMemoryDOMDataTreeShard testShard = InMemoryDOMDataTreeShard.create(TEST_ID, executor, 1); - testShard.onGlobalContextUpdated(SCHEMA_CONTEXT); + testShard.onModelContextUpdated(SCHEMA_CONTEXT); final DOMDataTreeProducer regProducer = dataTreeService.createProducer(Collections.singleton(TEST_ID)); dataTreeService.registerDataTreeShard(TEST_ID, testShard, regProducer); @@ -247,14 +250,14 @@ public class ShardedDOMDataTreeTest { @Test public void testMultipleWritesIntoSingleMapEntry() throws Exception { - final YangInstanceIdentifier oid1 = TestModel.OUTER_LIST_PATH.node(new NodeIdentifierWithPredicates( + final YangInstanceIdentifier oid1 = TestModel.OUTER_LIST_PATH.node(NodeIdentifierWithPredicates.of( TestModel.OUTER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "id"), 0)); final DOMDataTreeIdentifier outerListPath = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, oid1); final DOMDataTreeProducer shardProducer = dataTreeService.createProducer( Collections.singletonList(outerListPath)); final InMemoryDOMDataTreeShard outerListShard = InMemoryDOMDataTreeShard.create(outerListPath, executor, 1000); - outerListShard.onGlobalContextUpdated(SCHEMA_CONTEXT); + outerListShard.onModelContextUpdated(SCHEMA_CONTEXT); final ListenerRegistration oid1ShardRegistration = dataTreeService.registerDataTreeShard(outerListPath, outerListShard, shardProducer); @@ -295,7 +298,7 @@ public class ShardedDOMDataTreeTest { final Collection ret = new ArrayList<>(); for (int i = 0; i < amount; i++) { ret.add(ImmutableNodes.mapEntryBuilder() - .withNodeIdentifier(new NodeIdentifierWithPredicates(TestModel.INNER_LIST_QNAME, + .withNodeIdentifier(NodeIdentifierWithPredicates.of(TestModel.INNER_LIST_QNAME, QName.create(TestModel.OUTER_LIST_QNAME, "name"), Integer.toString(i))) .withChild(ImmutableNodes .leafNode(QName.create(TestModel.INNER_LIST_QNAME, "name"), Integer.toString(i))) @@ -399,7 +402,7 @@ public class ShardedDOMDataTreeTest { public void testLargerSubshardSpace() throws Exception { final InMemoryDOMDataTreeShard outerListShard = InMemoryDOMDataTreeShard.create(OUTER_LIST_ID, executor, 1, 1); - outerListShard.onGlobalContextUpdated(SCHEMA_CONTEXT); + outerListShard.onModelContextUpdated(SCHEMA_CONTEXT); try (DOMDataTreeProducer producer = dataTreeService.createProducer(Collections.singletonList(OUTER_LIST_ID))) { @@ -420,7 +423,7 @@ public class ShardedDOMDataTreeTest { doNothing().when(listener).onDataTreeChanged(any(), any()); dataTreeService.registerListener(listener, Collections.singletonList( - new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY)), + new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty())), false, Collections.emptyList()); verify(listener, times(2)).onDataTreeChanged(any(), any());