BUG-2138: Create DistributedShardFrontend
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / shardstrategy / ShardStrategyFactoryTest.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.datastore.shardstrategy;
10
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
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;
23
24 public class ShardStrategyFactoryTest {
25
26     ShardStrategyFactory factory;
27
28     @Rule
29     public ExpectedException expectedEx = ExpectedException.none();
30
31     @Before
32     public void setUp() {
33         factory = new ShardStrategyFactory(
34                 new ConfigurationImpl("module-shards.conf", "modules.conf"), LogicalDatastoreType.CONFIGURATION);
35     }
36
37     @Test
38     public void testGetStrategy() {
39         ShardStrategy strategy = factory.getStrategy(TestModel.TEST_PATH);
40         assertNotNull(strategy);
41     }
42
43     @Test
44     public void testGetStrategyForKnownModuleName() {
45         ShardStrategy strategy = factory.getStrategy(YangInstanceIdentifier.of(CarsModel.BASE_QNAME));
46         assertTrue(strategy instanceof ModuleShardStrategy);
47     }
48
49
50     @Test
51     public void testGetStrategyNullPointerExceptionWhenPathIsNull() {
52         expectedEx.expect(NullPointerException.class);
53         expectedEx.expectMessage("path should not be null");
54
55         factory.getStrategy(null);
56     }
57 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.