X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FAbstractTransactionProxyTest.java;h=8e9d79ee5e6f54f24796455c129f4c7caded96fa;hb=0c74ca17e0d64c4c2a7555470a5737ebef148890;hp=c22b7acd386cf3c5ecc66ab8dbbf2cc1d75f7e8f;hpb=e961492cd1f235f2e74ab9b4101efe0990b0a53d;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java index c22b7acd38..8e9d79ee5e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTransactionProxyTest.java @@ -111,6 +111,8 @@ public abstract class AbstractTransactionProxyTest { @Mock protected ActorContext mockActorContext; + protected TransactionContextFactory mockComponentFactory; + private SchemaContext schemaContext; @Mock @@ -151,6 +153,8 @@ public abstract class AbstractTransactionProxyTest { doReturn(dataStoreContextBuilder.build()).when(mockActorContext).getDatastoreContext(); doReturn(10).when(mockActorContext).getTransactionOutstandingOperationLimit(); + mockComponentFactory = TransactionContextFactory.create(mockActorContext); + Timer timer = new MetricRegistry().timer("test"); doReturn(timer).when(mockActorContext).getOperationTimer(any(String.class)); @@ -260,6 +264,7 @@ public abstract class AbstractTransactionProxyTest { return Futures.successful(new BatchedModificationsReply(count)); } + @SuppressWarnings("unchecked") protected Future incompleteFuture() { return mock(Future.class); } @@ -311,18 +316,28 @@ public abstract class AbstractTransactionProxyTest { } protected Future primaryShardInfoReply(ActorSystem actorSystem, ActorRef actorRef) { + return primaryShardInfoReply(actorSystem, actorRef, DataStoreVersions.CURRENT_VERSION); + } + + protected Future primaryShardInfoReply(ActorSystem actorSystem, ActorRef actorRef, + short transactionVersion) { return Futures.successful(new PrimaryShardInfo(actorSystem.actorSelection(actorRef.path()), - Optional.absent())); + transactionVersion, Optional.absent())); } protected ActorRef setupActorContextWithoutInitialCreateTransaction(ActorSystem actorSystem, String shardName) { + return setupActorContextWithoutInitialCreateTransaction(actorSystem, shardName, DataStoreVersions.CURRENT_VERSION); + } + + protected ActorRef setupActorContextWithoutInitialCreateTransaction(ActorSystem actorSystem, String shardName, + short transactionVersion) { ActorRef actorRef = actorSystem.actorOf(Props.create(DoNothingActor.class)); log.info("Created mock shard actor {}", actorRef); doReturn(actorSystem.actorSelection(actorRef.path())). when(mockActorContext).actorSelection(actorRef.path().toString()); - doReturn(primaryShardInfoReply(actorSystem, actorRef)). + doReturn(primaryShardInfoReply(actorSystem, actorRef, transactionVersion)). when(mockActorContext).findPrimaryShardAsync(eq(shardName)); doReturn(false).when(mockActorContext).isPathLocal(actorRef.path().toString()); @@ -333,15 +348,16 @@ public abstract class AbstractTransactionProxyTest { } protected ActorRef setupActorContextWithInitialCreateTransaction(ActorSystem actorSystem, - TransactionType type, int transactionVersion, String shardName) { - ActorRef shardActorRef = setupActorContextWithoutInitialCreateTransaction(actorSystem, shardName); + TransactionType type, short transactionVersion, String shardName) { + ActorRef shardActorRef = setupActorContextWithoutInitialCreateTransaction(actorSystem, shardName, + transactionVersion); return setupActorContextWithInitialCreateTransaction(actorSystem, type, transactionVersion, memberName, shardActorRef); } protected ActorRef setupActorContextWithInitialCreateTransaction(ActorSystem actorSystem, - TransactionType type, int transactionVersion, String prefix, ActorRef shardActorRef) { + TransactionType type, short transactionVersion, String prefix, ActorRef shardActorRef) { ActorRef txActorRef; if(type == TransactionType.WRITE_ONLY && transactionVersion >= DataStoreVersions.LITHIUM_VERSION && @@ -352,11 +368,11 @@ public abstract class AbstractTransactionProxyTest { log.info("Created mock shard Tx actor {}", txActorRef); doReturn(actorSystem.actorSelection(txActorRef.path())). - when(mockActorContext).actorSelection(txActorRef.path().toString()); + when(mockActorContext).actorSelection(txActorRef.path().toString()); doReturn(Futures.successful(createTransactionReply(txActorRef, transactionVersion))).when(mockActorContext). - executeOperationAsync(eq(actorSystem.actorSelection(shardActorRef.path())), - eqCreateTransaction(prefix, type)); + executeOperationAsync(eq(actorSystem.actorSelection(shardActorRef.path())), + eqCreateTransaction(prefix, type)); } return txActorRef;