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=c3fef611e348a2a446ef2bfff87024425063f3ba;hb=edcc020c8fda4b13f22a31d79c13feef0b53b0ee;hp=17731de5cd48918a1d03d04ec6dece68b9321e5a;hpb=0eba94d9411ea40945ddc8c732640c0cc004599f;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 17731de5cd..c3fef611e3 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,9 +12,11 @@ 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 java.util.Collections; +import java.util.concurrent.TimeUnit; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier; @@ -31,8 +33,6 @@ 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; /** * Covers negative test cases @@ -40,12 +40,8 @@ import java.util.concurrent.TimeUnit; * @author Basheeruddin Ahmed */ public class ShardTransactionFailureTest extends AbstractActorTest { - private static ListeningExecutorService storeExecutor = - MoreExecutors.listeningDecorator(MoreExecutors.sameThreadExecutor()); - private static final InMemoryDOMDataStore store = - new InMemoryDOMDataStore("OPER", storeExecutor, - MoreExecutors.sameThreadExecutor()); + new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor()); private static final SchemaContext testSchemaContext = TestModel.createTestContext(); @@ -64,7 +60,7 @@ public class ShardTransactionFailureTest extends AbstractActorTest { } private ActorRef createShard(){ - return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.EMPTY_MAP, datastoreContext, + return getSystem().actorOf(Shard.props(SHARD_IDENTIFIER, Collections.emptyMap(), datastoreContext, TestModel.createTestContext())); } @@ -74,7 +70,8 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadOnlyTransaction(), shard, - testSchemaContext, datastoreContext, shardStats, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -103,7 +100,8 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -132,7 +130,8 @@ public class ShardTransactionFailureTest extends AbstractActorTest { final ActorRef shard = createShard(); final Props props = ShardTransaction.props(store.newReadWriteTransaction(), shard, - testSchemaContext, datastoreContext, shardStats, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -155,13 +154,14 @@ 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, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -187,13 +187,14 @@ 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, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props, @@ -224,13 +225,14 @@ 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, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props, "testNegativeMergeTransactionReady"); @@ -256,13 +258,14 @@ 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, "txn"); + testSchemaContext, datastoreContext, shardStats, "txn", + DataStoreVersions.CURRENT_VERSION); final TestActorRef subject = TestActorRef .create(getSystem(), props,