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
+}