Remove prefix shard leftovers
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / shardstrategy / ShardStrategyFactoryTest.java
index e07b772c2c2e8466e4a2f947db43f5d7be846f73..a7310903a7c7d206bc96ada0affe67ae84a3fe35 100644 (file)
@@ -5,52 +5,43 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.controller.cluster.datastore.shardstrategy;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
-import org.junit.BeforeClass;
-import org.junit.Rule;
+
+import org.junit.Before;
 import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.opendaylight.controller.cluster.datastore.ConfigurationImpl;
+import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
 public class ShardStrategyFactoryTest {
+    private ShardStrategyFactory factory;
 
-    @Rule
-    public ExpectedException expectedEx = ExpectedException.none();
-
-    @BeforeClass
-    public static void setUpClass(){
-        ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf"));
+    @Before
+    public void setUp() {
+        factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"));
     }
 
     @Test
     public void testGetStrategy() {
-        ShardStrategy strategy =
-            ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
+        ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
         assertNotNull(strategy);
     }
 
     @Test
     public void testGetStrategyForKnownModuleName() {
-        ShardStrategy strategy =
-            ShardStrategyFactory.getStrategy(
-                YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
+        ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
         assertTrue(strategy instanceof ModuleShardStrategy);
     }
 
-
     @Test
     public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
-        expectedEx.expect(NullPointerException.class);
-        expectedEx.expectMessage("path should not be null");
-
-        ShardStrategyFactory.getStrategy(null);
+        final NullPointerException ex = assertThrows(NullPointerException.class, () -> factory.getStrategy(null));
+        assertEquals("path should not be null", ex.getMessage());
     }
-
 }