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.mdsal.common.api.LogicalDatastoreType;
22 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
24 public class ShardStrategyFactoryTest {
26 ShardStrategyFactory factory;
29 public ExpectedException expectedEx = ExpectedException.none();
33 factory = new ShardStrategyFactory(
34 new ConfigurationImpl("module-shards.conf", "modules.conf"), LogicalDatastoreType.CONFIGURATION);
38 public void testGetStrategy() {
39 ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
40 assertNotNull(strategy);
44 public void testGetStrategyForKnownModuleName() {
45 ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
46 assertTrue(strategy instanceof ModuleShardStrategy);
51 public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
52 expectedEx.expect(NullPointerException.class);
53 expectedEx.expectMessage("path should not be null");
55 factory.getStrategy(null);