X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fsharding%2FDistributedShardFrontendTest.java;h=a567f0a13a1a29ec3c71b1a76e0d039d838d8e40;hb=c4b4b98f56ab1d9821edb737912632c2867ae783;hp=febc929db5d4ec17768e8253ece1a8f7fd84b5ba;hpb=c1336f9b497bc6867536a24f629c3f0b002ccb2f;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java index febc929db5..a567f0a13a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/sharding/DistributedShardFrontendTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2016, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -10,7 +10,7 @@ package org.opendaylight.controller.cluster.sharding; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -29,6 +29,8 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHist import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction; import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient; import org.opendaylight.controller.cluster.datastore.DistributedDataStore; +import org.opendaylight.controller.cluster.datastore.utils.ActorUtils; +import org.opendaylight.controller.md.cluster.datastore.model.SchemaContextHelper; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.dom.api.DOMDataTreeCursorAwareTransaction; @@ -62,7 +64,7 @@ public class DistributedShardFrontendTest { private DOMDataTreeWriteCursor cursor; 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); @@ -74,7 +76,7 @@ public class DistributedShardFrontendTest { private DOMStoreThreePhaseCommitCohort commitCohort; @Before - public void setUp() throws Exception { + public void setUp() { MockitoAnnotations.initMocks(this); shardedDOMDataTree = new ShardedDOMDataTree(); client = mock(DataStoreClient.class); @@ -108,9 +110,13 @@ public class DistributedShardFrontendTest { public void testClientTransaction() throws Exception { final DistributedDataStore distributedDataStore = mock(DistributedDataStore.class); + final ActorUtils context = mock(ActorUtils.class); + doReturn(context).when(distributedDataStore).getActorUtils(); + doReturn(SchemaContextHelper.full()).when(context).getSchemaContext(); + final DistributedShardFrontend rootShard = new DistributedShardFrontend(distributedDataStore, client, ROOT); - try (final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(Collections.singletonList(ROOT))) { + try (DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(Collections.singletonList(ROOT))) { shardedDOMDataTree.registerDataTreeShard(ROOT, rootShard, producer); } @@ -136,17 +142,17 @@ public class DistributedShardFrontendTest { final DistributedShardFrontend outerListShard = new DistributedShardFrontend( distributedDataStore, outerListClient, OUTER_LIST_ID); - try (final DOMDataTreeProducer producer = + try (DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(Collections.singletonList(OUTER_LIST_ID))) { shardedDOMDataTree.registerDataTreeShard(OUTER_LIST_ID, outerListShard, producer); } final DOMDataTreeProducer producer = shardedDOMDataTree.createProducer(Collections.singletonList(ROOT)); final DOMDataTreeCursorAwareTransaction tx = producer.createTransaction(false); - final DOMDataTreeWriteCursor cursor = tx.createCursor(ROOT); + final DOMDataTreeWriteCursor txCursor = tx.createCursor(ROOT); - assertNotNull(cursor); - cursor.write(TestModel.TEST_PATH.getLastPathArgument(), createCrossShardContainer()); + assertNotNull(txCursor); + txCursor.write(TestModel.TEST_PATH.getLastPathArgument(), createCrossShardContainer()); //check the lower shard got the correct modification verify(outerListCursor, times(2)).write(pathArgumentCaptor.capture(), nodeCaptor.capture()); @@ -165,13 +171,12 @@ public class DistributedShardFrontendTest { final MapNode actualInnerListNode = (MapNode) nodeCaptor.getAllValues().get(1); assertEquals(createInnerMapNode(1), actualInnerListNode); - cursor.close(); - tx.submit().checkedGet(); + txCursor.close(); + tx.commit().get(); verify(commitCohort, times(2)).canCommit(); verify(commitCohort, times(2)).preCommit(); verify(commitCohort, times(2)).commit(); - } private static MapNode createInnerMapNode(final int id) { @@ -207,6 +212,4 @@ public class DistributedShardFrontendTest { return testContainer; } - - -} \ No newline at end of file +}