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.mdsal.common.api.LogicalDatastoreType;
21 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
23 public class ShardStrategyFactoryTest {
24 private ShardStrategyFactory factory;
28 factory = new ShardStrategyFactory(new ConfigurationImpl("module-shards.conf", "modules.conf"),
29 LogicalDatastoreType.CONFIGURATION);
33 public void testGetStrategy() {
34 ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
35 assertNotNull(strategy);
39 public void testGetStrategyForKnownModuleName() {
40 ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
41 assertTrue(strategy instanceof ModuleShardStrategy);
45 public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
46 final NullPointerException ex = assertThrows(NullPointerException.class, () -> factory.getStrategy(null));
47 assertEquals("path should not be null", ex.getMessage());