1 package org.opendaylight.controller.cluster.datastore.shardstrategy;
3 import org.junit.BeforeClass;
6 import org.junit.rules.ExpectedException;
7 import org.opendaylight.controller.cluster.datastore.ConfigurationImpl;
8 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
9 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
10 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
12 import static junit.framework.Assert.assertNotNull;
13 import static junit.framework.Assert.assertTrue;
15 public class ShardStrategyFactoryTest {
18 public ExpectedException expectedEx = ExpectedException.none();
21 public static void setUpClass(){
22 ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf"));
26 public void testGetStrategy() {
27 ShardStrategy strategy =
28 ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
29 assertNotNull(strategy);
33 public void testGetStrategyForKnownModuleName() {
34 ShardStrategy strategy =
35 ShardStrategyFactory.getStrategy(
36 YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
37 assertTrue(strategy instanceof ModuleShardStrategy);
42 public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
43 expectedEx.expect(NullPointerException.class);
44 expectedEx.expectMessage("path should not be null");
46 ShardStrategyFactory.getStrategy(null);