2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore.shardstrategy;
11 import static org.junit.Assert.assertEquals;
12 import org.junit.BeforeClass;
13 import org.junit.Rule;
14 import org.junit.Test;
15 import org.junit.rules.ExpectedException;
16 import org.opendaylight.controller.cluster.datastore.config.Configuration;
17 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
18 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 public class ModuleShardStrategyTest {
24 public ExpectedException expectedEx = ExpectedException.none();
26 private static Configuration configuration;
29 public static void setUpClass(){
30 configuration = new ConfigurationImpl("module-shards.conf", "modules.conf");
35 public void testFindShard() throws Exception {
36 ModuleShardStrategy moduleShardStrategy =
37 new ModuleShardStrategy("cars", configuration);
39 String shard = moduleShardStrategy.findShard(CarsModel.BASE_PATH);
41 assertEquals("cars-1", shard);
45 public void testFindShardWhenModuleConfigurationPresentInModulesButMissingInModuleShards() {
47 final QName BASE_QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test:missing", "2014-03-13",
50 final YangInstanceIdentifier BASE_PATH = YangInstanceIdentifier.of(BASE_QNAME);
52 ModuleShardStrategy moduleShardStrategy =
53 new ModuleShardStrategy("missing", configuration);
55 String shard = moduleShardStrategy.findShard(BASE_PATH);
57 assertEquals(DefaultShardStrategy.DEFAULT_SHARD, shard);