X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FShardTransactionFailureTest.java;h=6ccede2776bc6a58b8857e79c17c747c3e6745e6;hp=ae4426e35b8281f4c88f1ec6a4b162da67be9ba3;hb=20f8f30f4bbf1e982672c1f883a6a18b0e4539de;hpb=e448e4e5f1f071aa61152b2f49b239d878c0a580 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java index ae4426e35b..6ccede2776 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/ShardTransactionFailureTest.java @@ -13,6 +13,8 @@ import akka.actor.Props; import akka.testkit.TestActorRef; import java.util.concurrent.TimeUnit; import org.junit.Test; +import org.mockito.Mockito; +import org.opendaylight.controller.cluster.access.concepts.MemberName; 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.DataExists; @@ -27,40 +29,39 @@ import scala.concurrent.Future; import scala.concurrent.duration.Duration; /** - * Covers negative test cases + * Covers negative test cases. * - * @author Basheeruddin Ahmed + * @author Basheeruddin Ahmed */ public class ShardTransactionFailureTest extends AbstractActorTest { - private static final SchemaContext testSchemaContext = - TestModel.createTestContext(); + private static final SchemaContext TEST_SCHEMA_CONTEXT = TestModel.createTestContext(); private static final TransactionType RO = TransactionType.READ_ONLY; private static final TransactionType RW = TransactionType.READ_WRITE; - private static final TransactionType WO = TransactionType.WRITE_ONLY; - private static final ShardDataTree store = new ShardDataTree(testSchemaContext, TreeType.OPERATIONAL); + private static final Shard MOCK_SHARD = Mockito.mock(Shard.class); + + private static final ShardDataTree STORE = new ShardDataTree(MOCK_SHARD, TEST_SCHEMA_CONTEXT, TreeType.OPERATIONAL); private static final ShardIdentifier SHARD_IDENTIFIER = - ShardIdentifier.builder().memberName("member-1") - .shardName("inventory").type("operational").build(); + ShardIdentifier.create("inventory", MemberName.forName("member-1"), "operational"); private final DatastoreContext datastoreContext = DatastoreContext.newBuilder().build(); - private final ShardStats shardStats = new ShardStats(SHARD_IDENTIFIER.toString(), "DataStore"); + private final ShardStats shardStats = new ShardStats(SHARD_IDENTIFIER.toString(), "DataStore", null); - private ActorRef createShard(){ - ActorRef shard = getSystem().actorOf(Shard.builder().id(SHARD_IDENTIFIER).datastoreContext(datastoreContext). - schemaContext(TestModel.createTestContext()).props()); + private ActorRef createShard() { + ActorRef shard = getSystem().actorOf(Shard.builder().id(SHARD_IDENTIFIER).datastoreContext(datastoreContext) + .schemaContext(TestModel.createTestContext()).props()); ShardTestKit.waitUntilLeader(shard); return shard; } @Test(expected = ReadFailedException.class) - public void testNegativeReadWithReadOnlyTransactionClosed() throws Throwable { + public void testNegativeReadWithReadOnlyTransactionClosed() throws Exception { final ActorRef shard = createShard(); - final Props props = ShardTransaction.props(RO, store.newReadOnlyTransaction("test-txn", null), shard, - datastoreContext, shardStats, "txn", DataStoreVersions.CURRENT_VERSION); + final Props props = ShardTransaction.props(RO, STORE.newReadOnlyTransaction(nextTransactionId()), shard, + datastoreContext, shardStats); final TestActorRef subject = TestActorRef.create(getSystem(), props, "testNegativeReadWithReadOnlyTransactionClosed"); @@ -78,11 +79,11 @@ public class ShardTransactionFailureTest extends AbstractActorTest { @Test(expected = ReadFailedException.class) - public void testNegativeReadWithReadWriteTransactionClosed() throws Throwable { + public void testNegativeReadWithReadWriteTransactionClosed() throws Exception { final ActorRef shard = createShard(); - final Props props = ShardTransaction.props(RW, store.newReadWriteTransaction("test-txn", null), shard, - datastoreContext, shardStats, "txn", DataStoreVersions.CURRENT_VERSION); + final Props props = ShardTransaction.props(RW, STORE.newReadWriteTransaction(nextTransactionId()), shard, + datastoreContext, shardStats); final TestActorRef subject = TestActorRef.create(getSystem(), props, "testNegativeReadWithReadWriteTransactionClosed"); @@ -99,11 +100,11 @@ public class ShardTransactionFailureTest extends AbstractActorTest { } @Test(expected = ReadFailedException.class) - public void testNegativeExistsWithReadWriteTransactionClosed() throws Throwable { + public void testNegativeExistsWithReadWriteTransactionClosed() throws Exception { final ActorRef shard = createShard(); - final Props props = ShardTransaction.props(RW, store.newReadWriteTransaction("test-txn", null), shard, - datastoreContext, shardStats, "txn", DataStoreVersions.CURRENT_VERSION); + final Props props = ShardTransaction.props(RW, STORE.newReadWriteTransaction(nextTransactionId()), shard, + datastoreContext, shardStats); final TestActorRef subject = TestActorRef.create(getSystem(), props, "testNegativeExistsWithReadWriteTransactionClosed");