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%2FDatastoreContextIntrospectorTest.java;h=2d6e4ebcbcaa02736c43f339a8fcb3a0f651c7e0;hb=b9711f17a53a4fad48197df6c39b58e4faadc862;hp=cca8eb6198f2453a919ef53e43e04009265ccec2;hpb=b65f82f3c6e6e4c53ea2efa4dba30ddf82d61616;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java index cca8eb6198..2d6e4ebcbc 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DatastoreContextIntrospectorTest.java @@ -10,8 +10,6 @@ package org.opendaylight.controller.cluster.datastore; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_HEARTBEAT_INTERVAL_IN_MILLIS; import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_OPERATION_TIMEOUT_IN_MS; import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEFAULT_SHARD_INITIALIZATION_TIMEOUT; @@ -21,44 +19,22 @@ import static org.opendaylight.controller.cluster.datastore.DatastoreContext.DEF import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION; import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL; -import java.util.Arrays; import java.util.HashMap; import java.util.Map; import org.junit.Test; -import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.mdsal.dom.api.DOMSchemaService; +import org.opendaylight.binding.runtime.spi.BindingRuntimeHelpers; +import org.opendaylight.mdsal.binding.dom.codec.impl.BindingCodecContext; import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStoreConfigProperties; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.distributed.datastore.provider.rev140612.DataStorePropertiesContainer; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** * Unit tests for DatastoreContextIntrospector. * * @author Thomas Pantelis */ -@SuppressWarnings("checkstyle:IllegalCatch") public class DatastoreContextIntrospectorTest { - - static SchemaContext SCHEMA_CONTEXT; - static DatastoreContextIntrospectorFactory INTROSPECTOR_FACTORY; - - static { - final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create(); - try { - moduleContext.addModuleInfos(Arrays.asList( - BindingReflections.getModuleInfo(DataStorePropertiesContainer.class))); - } catch (Exception e) { - throw new RuntimeException(e); - } - SCHEMA_CONTEXT = moduleContext.tryToCreateSchemaContext().get(); - - DOMSchemaService mockSchemaService = mock(DOMSchemaService.class); - doReturn(SCHEMA_CONTEXT).when(mockSchemaService).getGlobalContext(); - INTROSPECTOR_FACTORY = new DatastoreContextIntrospectorFactory(mockSchemaService, - GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy()); - } + static final DatastoreContextIntrospectorFactory INTROSPECTOR_FACTORY = new DatastoreContextIntrospectorFactory( + new BindingCodecContext(BindingRuntimeHelpers.createRuntimeContext(DataStorePropertiesContainer.class))); @Test public void testYangDefaults() { @@ -241,6 +217,7 @@ public class DatastoreContextIntrospectorTest { properties.put("operational.shard-transaction-idle-timeout-in-minutes", "33"); // operational override properties.put("config.shard-transaction-idle-timeout-in-minutes", "44"); // config override properties.put("topology.shard-transaction-idle-timeout-in-minutes", "55"); // global shard override + properties.put("config.topology.persistent", "false"); // per-shard config override final DatastoreContextIntrospector operIntrospector = INTROSPECTOR_FACTORY.newInstance(OPERATIONAL); @@ -261,6 +238,7 @@ public class DatastoreContextIntrospectorTest { shardContext = configIntrospector.newContextFactory().getShardDatastoreContext("topology"); assertEquals(55, shardContext.getShardTransactionIdleTimeout().toMinutes()); + assertFalse(shardContext.isPersistent()); // operational shard override properties.put("operational.topology.shard-transaction-idle-timeout-in-minutes", "66"); @@ -277,5 +255,6 @@ public class DatastoreContextIntrospectorTest { shardContext = configIntrospector.newContextFactory().getShardDatastoreContext("default"); assertEquals(44, shardContext.getShardTransactionIdleTimeout().toMinutes()); + assertTrue(shardContext.isPersistent()); } }