X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fshardstrategy%2FShardStrategyFactoryTest.java;h=ed4467df8e055b329cbd59cf34490b8583b538f6;hb=c796596b5c46b5203c30b143e6282662e66c5642;hp=2cff981b680f99de9855db40ed68bd49ed23a2fb;hpb=daa1d3344b3394accd85152b6f0a2fcda8491759;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java index 2cff981b68..ed4467df8e 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ShardStrategyFactoryTest.java @@ -1,29 +1,55 @@ +/* + * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * 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.assertNotNull; +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 static junit.framework.Assert.assertNotNull; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ShardStrategyFactoryTest { - @Rule - public ExpectedException expectedEx = ExpectedException.none(); + ShardStrategyFactory factory; + + @Rule + public ExpectedException expectedEx = ExpectedException.none(); + + @Before + public void setUp() { + factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf")); + } + + @Test + public void testGetStrategy() { + ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH); + assertNotNull(strategy); + } + + @Test + public void testGetStrategyForKnownModuleName() { + ShardStrategy strategy = factory.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); - } + factory.getStrategy(null); + } -} \ No newline at end of file +}