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.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13 import org.junit.BeforeClass;
14 import org.junit.Rule;
15 import org.junit.Test;
16 import org.junit.rules.ExpectedException;
17 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
18 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
19 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
22 public class ShardStrategyFactoryTest {
25 public ExpectedException expectedEx = ExpectedException.none();
28 public static void setUpClass(){
29 ShardStrategyFactory.setConfiguration(new ConfigurationImpl("module-shards.conf", "modules.conf"));
33 public void testGetStrategy() {
34 ShardStrategy strategy =
35 ShardStrategyFactory.getStrategy(TestModel.TEST_PATH);
36 assertNotNull(strategy);
40 public void testGetStrategyForKnownModuleName() {
41 ShardStrategy strategy =
42 ShardStrategyFactory.getStrategy(
43 YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
44 assertTrue(strategy instanceof ModuleShardStrategy);
49 public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
50 expectedEx.expect(NullPointerException.class);
51 expectedEx.expectMessage("path should not be null");
53 ShardStrategyFactory.getStrategy(null);