Bug 4105: Add dynamic module/shard config for entity-owners shard
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / shardstrategy / ShardStrategyFactoryTest.java
1 package org.opendaylight.controller.cluster.datastore.shardstrategy;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
5 import org.junit.Before;
6 import org.junit.Rule;
7 import org.junit.Test;
8 import org.junit.rules.ExpectedException;
9 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
10 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
11 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13
14 public class ShardStrategyFactoryTest {
15
16     ShardStrategyFactory factory;
17
18     @Rule
19     public ExpectedException expectedEx = ExpectedException.none();
20
21     @Before
22     public void setUp() {
23         factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"));
24     }
25
26     @Test
27     public void testGetStrategy() {
28         ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
29         assertNotNull(strategy);
30     }
31
32     @Test
33     public void testGetStrategyForKnownModuleName() {
34         ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
35         assertTrue(strategy instanceof ModuleShardStrategy);
36     }
37
38
39     @Test
40     public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
41         expectedEx.expect(NullPointerException.class);
42         expectedEx.expectMessage("path should not be null");
43
44         factory.getStrategy(null);
45     }
46
47 }