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
8 package org.opendaylight.controller.cluster.datastore.shardstrategy;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertThrows;
13 import static org.junit.Assert.assertTrue;
15 import org.junit.Before;
16 import org.junit.Test;
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 {
23 private ShardStrategyFactory factory;
27 factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"));
31 public void testGetStrategy() {
32 ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
33 assertNotNull(strategy);
37 public void testGetStrategyForKnownModuleName() {
38 ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
39 assertTrue(strategy instanceof ModuleShardStrategy);
43 public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
44 final NullPointerException ex = assertThrows(NullPointerException.class, () -> factory.getStrategy(null));
45 assertEquals("path should not be null", ex.getMessage());