X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fshardstrategy%2FModuleShardStrategyTest.java;h=1e0511622a8a60b936fa535632a7a30b2b8239f9;hp=88753e4b0a56165ed6cba8e2433f9bbc0089e8dc;hb=c3ea6ff9c64bcd51e46767a18a1370a2b3819dca;hpb=c222e37f2a0f0f3f6266242fbea2d3b018f4e6e3 diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java index 88753e4b0a..1e0511622a 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/shardstrategy/ModuleShardStrategyTest.java @@ -1,6 +1,14 @@ +/* + * 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 junit.framework.Assert; +import static org.junit.Assert.assertEquals; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -8,6 +16,8 @@ import org.junit.rules.ExpectedException; import org.opendaylight.controller.cluster.datastore.Configuration; import org.opendaylight.controller.cluster.datastore.ConfigurationImpl; import org.opendaylight.controller.md.cluster.datastore.model.CarsModel; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; public class ModuleShardStrategyTest { @Rule @@ -28,6 +38,23 @@ public class ModuleShardStrategyTest { String shard = moduleShardStrategy.findShard(CarsModel.BASE_PATH); - Assert.assertEquals("cars-1", shard); + assertEquals("cars-1", shard); + } + + @Test + public void testFindShardWhenModuleConfigurationPresentInModulesButMissingInModuleShards() { + + final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:missing", "2014-03-13", + "missing"); + + final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME); + + ModuleShardStrategy moduleShardStrategy = + new ModuleShardStrategy("missing", configuration); + + String shard = moduleShardStrategy.findShard(BASE_PATH); + + assertEquals(DefaultShardStrategy.DEFAULT_SHARD, shard); + } }