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 1a7bbb21b3867134e50e163ee429392b1da12fde..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);
 
@@ -192,4 +196,4 @@ public class IntegrationTestKit extends ShardTestKit {
             }
         }, expType);
     }
-}
\ No newline at end of file
+}