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;
14 import org.junit.Before;
15 import org.junit.Rule;
16 import org.junit.Test;
17 import org.junit.rules.ExpectedException;
18 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
19 import org.opendaylight.controller.md.cluster.datastore.model.CarsModel;
20 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
23 public class ShardStrategyFactoryTest {
25 ShardStrategyFactory factory;
28 public ExpectedException expectedEx = ExpectedException.none();
32 factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"));
36 public void testGetStrategy() {
37 ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
38 assertNotNull(strategy);
42 public void testGetStrategyForKnownModuleName() {
43 ShardStrategy strategy = factory.getStrategy(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 factory.getStrategy(null);