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%2Fshardstrategy%2FShardStrategyFactoryTest.java;h=10e832780d26ca7e8603e14ef82fbeac0e57b16e;hb=d34ede1cf156e28abcba1c7ca6e7e8f908999755;hp=2cff981b680f99de9855db40ed68bd49ed23a2fb;hpb=c2fd5f62f3b80a7e7b4b7e167349ede433e785d6;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java index 2cff981b68..10e832780d 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java @@ -1,29 +1,48 @@ package org.opendaylight.controller.cluster.datastore.shardstrategy; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; +import org.opendaylight.controller.cluster.datastore.ConfigurationImpl; +import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; - -import static junit.framework.Assert.assertNotNull; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ShardStrategyFactoryTest { - @Rule - public ExpectedException expectedEx = ExpectedException.none(); + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @BeforeClass + public static void setUpClass(){ + ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf")); + } + + @Test + public void testGetStrategy() { + ShardStrategy strategy = + ShardStrategyFactory.getStrategy(TestModel.TEST_PATH); + assertNotNull(strategy); + } + + @Test + public void testGetStrategyForKnownModuleName() { + ShardStrategy strategy = + ShardStrategyFactory.getStrategy( + YangInstanceIdentifier.of(CarsModel.BASE_QNAME)); + assertTrue(strategy instanceof ModuleShardStrategy); + } - @Test - public void testGetStrategy(){ - ShardStrategy strategy = ShardStrategyFactory.getStrategy(TestModel.TEST_PATH); - assertNotNull(strategy); - } - @Test - public void testGetStrategyNullPointerExceptionWhenPathIsNull(){ - expectedEx.expect(NullPointerException.class); - expectedEx.expectMessage("path should not be null"); + @Test + public void testGetStrategyNullPointerExceptionWhenPathIsNull() { + expectedEx.expect(NullPointerException.class); + expectedEx.expectMessage("path should not be null"); - ShardStrategyFactory.getStrategy(null); - } + ShardStrategyFactory.getStrategy(null); + } -} \ No newline at end of file +}