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%2FShardTransactionFailureTest.java;h=6375e3c7fba51fa02c077ac49d01def5eed5d22a;hb=a1878a52f1d6df37acae733430911fbce5be1d50;hp=869f47578711ea313181e4011444dc82ca35feaa;hpb=c33b2b55b2eae406df001619885a0610800cb951;p=controller.git 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 869f475787..6375e3c7fb 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 @@ -12,11 +12,10 @@ package org.opendaylight.controller.cluster.datastore; import akka.actor.ActorRef; import akka.actor.Props; +import akka.pattern.AskTimeoutException; import akka.testkit.TestActorRef; - import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; - import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; @@ -30,11 +29,9 @@ import org.opendaylight.controller.protobuff.messages.transaction.ShardTransacti import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.schema.Builders; import org.opendaylight.yangtools.yang.model.api.SchemaContext; - import scala.concurrent.Await; import scala.concurrent.Future; import scala.concurrent.duration.Duration; - import java.util.Collections; import java.util.concurrent.TimeUnit; @@ -58,7 +55,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { ShardIdentifier.builder().memberName("member-1") .shardName("inventory").type("operational").build(); - private final DatastoreContext datastoreContext = new DatastoreContext(); + private final DatastoreContext datastoreContext = DatastoreContext.newBuilder().build(); private final ShardStats shardStats = new ShardStats(SHARD_IDENTIFIER.toString(), "DataStore"); @@ -68,7 +65,8 @@ public class ShardTransactionFailureTest extends AbstractActorTest { } private ActorRef createShard(){ - return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, new DatastoreContext(), TestModel.createTestContext())); + return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext, + TestModel.createTestContext())); } @Test(expected = ReadFailedException.class) @@ -77,7 +75,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -106,7 +104,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -135,7 +133,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -158,13 +156,13 @@ public class ShardTransactionFailureTest extends AbstractActorTest { Await.result(future, Duration.create(3, TimeUnit.SECONDS)); } - @Test(expected = IllegalStateException.class) + @Test(expected = AskTimeoutException.class) public void testNegativeWriteWithTransactionReady() throws Exception { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newWriteOnlyTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -190,13 +188,13 @@ public class ShardTransactionFailureTest extends AbstractActorTest { Await.result(future, Duration.create(3, TimeUnit.SECONDS)); } - @Test(expected = IllegalStateException.class) + @Test(expected = AskTimeoutException.class) public void testNegativeReadWriteWithTransactionReady() throws Exception { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -227,13 +225,13 @@ public class ShardTransactionFailureTest extends AbstractActorTest { .serialize(Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME)).build()); } - @Test(expected = IllegalStateException.class) + @Test(expected = AskTimeoutException.class) public void testNegativeMergeTransactionReady() throws Exception { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props, "testNegativeMergeTransactionReady"); @@ -259,13 +257,13 @@ public class ShardTransactionFailureTest extends AbstractActorTest { } - @Test(expected = IllegalStateException.class) + @Test(expected = AskTimeoutException.class) public void testNegativeDeleteDataWhenTransactionReady() throws Exception { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats); + testSchemaContext, datastoreContext, shardStats, "txn"); final TestActorRef subject = TestActorRef .create(getSystem(), props,