Merge "Fixed unneeded wrapping of guava for karaf"
[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 org.junit.BeforeClass;
4 import org.junit.Rule;
5 import org.junit.Test;
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.InstanceIdentifier;
11
12 import static junit.framework.Assert.assertNotNull;
13 import static junit.framework.Assert.assertTrue;
14
15 public class ShardStrategyFactoryTest {
16
17     @Rule
18     public ExpectedException expectedEx = ExpectedException.none();
19
20     @BeforeClass
21     public static void setUpClass(){
22         ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf"));
23     }
24
25     @Test
26     public void testGetStrategy() {
27         ShardStrategy strategy =
28             ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
29         assertNotNull(strategy);
30     }
31
32     @Test
33     public void testGetStrategyForKnownModuleName() {
34         ShardStrategy strategy =
35             ShardStrategyFactory.getStrategy(InstanceIdentifier.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 }