* 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 org.junit.BeforeClass;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.opendaylight.controller.cluster.datastore.config.Configuration;
import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
public class ModuleShardStrategyTest {
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
private static Configuration configuration;
@BeforeClass
configuration = new ConfigurationImpl("module-shards.conf", "modules.conf");
}
-
@Test
public void testFindShard() {
- ModuleShardStrategy moduleShardStrategy =
- new ModuleShardStrategy("cars", configuration);
-
+ ModuleShardStrategy moduleShardStrategy = new ModuleShardStrategy("cars", configuration);
String shard = moduleShardStrategy.findShard(CarsModel.BASE_PATH);
-
assertEquals("cars-1", shard);
}
final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(baseQName);
- ModuleShardStrategy moduleShardStrategy =
- new ModuleShardStrategy("missing", configuration);
-
+ ModuleShardStrategy moduleShardStrategy = new ModuleShardStrategy("missing", configuration);
String shard = moduleShardStrategy.findShard(BASE_PATH);
-
assertEquals(DefaultShardStrategy.DEFAULT_SHARD, shard);
-
}
}
* 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.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
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 {
-
- ShardStrategyFactory factory;
-
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
+ private ShardStrategyFactory factory;
@Before
public void setUp() {
- factory = new ShardStrategyFactory(
- new ConfigurationImpl("module-shards.conf", "modules.conf"), LogicalDatastoreType.CONFIGURATION);
+ factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"),
+ LogicalDatastoreType.CONFIGURATION);
}
@Test
assertTrue(strategy instanceof ModuleShardStrategy);
}
-
@Test
public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
- expectedEx.expect(NullPointerException.class);
- expectedEx.expectMessage("path should not be null");
-
- factory.getStrategy(null);
+ final NullPointerException ex = assertThrows(NullPointerException.class, () -> factory.getStrategy(null));
+ assertEquals("path should not be null", ex.getMessage());
}
}