Bug 4149: Implement per-shard DatastoreContext settings
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / IntegrationTestKit.java
index 0eedc78bb41b248d67c9a9a69fb0efc550433238..9c07a61e604486a5f04d0488c4393c9dfecf9396 100644 (file)
@@ -18,6 +18,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.util.concurrent.Callable;
 import java.util.concurrent.TimeUnit;
+import org.mockito.Mockito;
 import org.opendaylight.controller.cluster.datastore.DatastoreContext.Builder;
 import org.opendaylight.controller.cluster.datastore.config.Configuration;
 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
@@ -64,8 +65,11 @@ public class IntegrationTestKit extends ShardTestKit {
         datastoreContextBuilder.dataStoreType(typeName);
 
         DatastoreContext datastoreContext = datastoreContextBuilder.build();
+        DatastoreContextFactory mockContextFactory = Mockito.mock(DatastoreContextFactory.class);
+        Mockito.doReturn(datastoreContext).when(mockContextFactory).getBaseDatastoreContext();
+        Mockito.doReturn(datastoreContext).when(mockContextFactory).getShardDatastoreContext(Mockito.anyString());
 
-        DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster, config, datastoreContext);
+        DistributedDataStore dataStore = new DistributedDataStore(getSystem(), cluster, config, mockContextFactory);
 
         dataStore.onGlobalContextUpdated(schemaContext);
 
@@ -95,7 +99,7 @@ public class IntegrationTestKit extends ShardTestKit {
         }
     }
 
-    private ActorRef findLocalShard(ActorContext actorContext, String shardName) {
+    private static ActorRef findLocalShard(ActorContext actorContext, String shardName) {
         ActorRef shard = null;
         for(int i = 0; i < 20 * 5 && shard == null; i++) {
             Uninterruptibles.sleepUninterruptibly(50, TimeUnit.MILLISECONDS);
@@ -192,4 +196,4 @@ public class IntegrationTestKit extends ShardTestKit {
             }
         }, expType);
     }
-}
\ No newline at end of file
+}