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%2Fdatastore%2FThreePhaseCommitCohortFailureTest.java;h=4e4c34bcbc75fe0e74369ae407d83624c3438ae0;hb=9b3246b5f5ed82559bf0c75141731dc3376125f9;hp=e39b9abd65a711e333f9c0315b25de2e3457266a;hpb=2dc333588d0c15eb7f2df6223dcdcc15e05b077e;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortFailureTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortFailureTest.java index e39b9abd65..4e4c34bcbc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortFailureTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ThreePhaseCommitCohortFailureTest.java @@ -23,6 +23,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; +import org.opendaylight.controller.cluster.datastore.jmx.mbeans.shard.ShardStats; import org.opendaylight.controller.cluster.datastore.messages.ForwardedCommitTransaction; import org.opendaylight.controller.cluster.datastore.modification.CompositeModification; import org.opendaylight.controller.cluster.datastore.modification.Modification; @@ -66,6 +67,7 @@ public class ThreePhaseCommitCohortFailureTest extends AbstractActorTest { private final DatastoreContext datastoreContext = new DatastoreContext(); + private final ShardStats shardStats = new ShardStats(SHARD_IDENTIFIER.toString(), "DataStore"); @BeforeClass public static void staticSetup() { @@ -74,18 +76,20 @@ public class ThreePhaseCommitCohortFailureTest extends AbstractActorTest { private final FiniteDuration ASK_RESULT_DURATION = Duration.create(5000, TimeUnit.MILLISECONDS); + private ActorRef createShard(){ + return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext, TestModel.createTestContext())); + } @Test(expected = TestException.class) public void testNegativeAbortResultsInException() throws Exception { - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, - Collections.EMPTY_MAP, datastoreContext)); + final ActorRef shard = createShard(); final DOMStoreThreePhaseCommitCohort mockCohort = Mockito .mock(DOMStoreThreePhaseCommitCohort.class); final CompositeModification mockComposite = Mockito.mock(CompositeModification.class); final Props props = - ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString()); + ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite, shardStats); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -107,14 +111,13 @@ public class ThreePhaseCommitCohortFailureTest extends AbstractActorTest { @Test(expected = OptimisticLockFailedException.class) public void testNegativeCanCommitResultsInException() throws Exception { - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, - Collections.EMPTY_MAP, datastoreContext)); + final ActorRef shard = createShard(); final DOMStoreThreePhaseCommitCohort mockCohort = Mockito .mock(DOMStoreThreePhaseCommitCohort.class); final CompositeModification mockComposite = Mockito.mock(CompositeModification.class); final Props props = - ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString()); + ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite, shardStats); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -139,14 +142,13 @@ public class ThreePhaseCommitCohortFailureTest extends AbstractActorTest { @Test(expected = TestException.class) public void testNegativePreCommitResultsInException() throws Exception { - final ActorRef shard = getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, - Collections.EMPTY_MAP, datastoreContext)); + final ActorRef shard = createShard(); final DOMStoreThreePhaseCommitCohort mockCohort = Mockito .mock(DOMStoreThreePhaseCommitCohort.class); final CompositeModification mockComposite = Mockito.mock(CompositeModification.class); final Props props = - ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite,SHARD_IDENTIFIER.toString()); + ThreePhaseCommitCohort.props(mockCohort, shard, mockComposite, shardStats); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -170,12 +172,12 @@ public class ThreePhaseCommitCohortFailureTest extends AbstractActorTest { public void testNegativeCommitResultsInException() throws Exception { final TestActorRef subject = TestActorRef.create(getSystem(), - Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext), + Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext, TestModel.createTestContext()), "testNegativeCommitResultsInException"); final ActorRef shardTransaction = getSystem().actorOf(ShardTransaction.props(store.newReadWriteTransaction(), subject, - testSchemaContext, datastoreContext,SHARD_IDENTIFIER.toString())); + testSchemaContext, datastoreContext, shardStats)); ShardTransactionMessages.WriteData writeData = ShardTransactionMessages.WriteData.newBuilder()