Fix cluster test warnings
[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.BeforeClass;
6 import org.junit.Rule;
7 import org.junit.Test;
8 import org.junit.rules.ExpectedException;
9 import org.opendaylight.controller.cluster.datastore.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     @Rule
17     public ExpectedException expectedEx = ExpectedException.none();
18
19     @BeforeClass
20     public static void setUpClass(){
21         ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf"));
22     }
23
24     @Test
25     public void testGetStrategy() {
26         ShardStrategy strategy =
27             ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
28         assertNotNull(strategy);
29     }
30
31     @Test
32     public void testGetStrategyForKnownModuleName() {
33         ShardStrategy strategy =
34             ShardStrategyFactory.getStrategy(
35                 YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
36         assertTrue(strategy instanceof ModuleShardStrategy);
37     }
38
39
40     @Test
41     public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
42         expectedEx.expect(NullPointerException.class);
43         expectedEx.expectMessage("path should not be null");
44
45         ShardStrategyFactory.getStrategy(null);
46     }
47
48 }