Add blueprint XML for bgp-evpn
[bgpcep.git] / bgp / labeled-unicast / src / test / java / org / opendaylight / controller / config / yang / bgp / labeled / unicast / LabeledUnicastModuleTest.java
1 /*
2  * Copyright (c) 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 package org.opendaylight.controller.config.yang.bgp.labeled.unicast;
9
10 import com.google.common.collect.Lists;
11 import javax.management.ObjectName;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.controller.config.api.jmx.CommitStatus;
15 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
16 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
17 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
18 import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleFactory;
19 import org.opendaylight.controller.config.yang.bgp.parser.spi.SimpleBGPExtensionProviderContextModuleTest;
20 import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleFactory;
21 import org.opendaylight.controller.config.yang.bgp.rib.spi.RIBExtensionsImplModuleTest;
22
23 public class LabeledUnicastModuleTest extends AbstractConfigTest {
24
25     private static final String FACTORY_NAME = LabeledUnicastModuleFactory.NAME;
26     private static final String INSTANCE_NAME = "bgp-labeled-unicast-impl";
27
28     @Before
29     public void setUp() {
30         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new LabeledUnicastModuleFactory(),
31             new SimpleBGPExtensionProviderContextModuleFactory(), new RIBExtensionsImplModuleFactory()));
32     }
33
34     @Test
35     public void testLSTypeDefaultValue() throws Exception {
36         final CommitStatus status = createLabeledUnicastModuleInstance();
37         assertBeanCount(1, FACTORY_NAME);
38         assertStatus(status, 3, 0, 0);
39     }
40
41     @Test
42     public void testCreateBean() throws Exception {
43         final CommitStatus status = createLabeledUnicastModuleInstance();
44         assertBeanCount(1, FACTORY_NAME);
45         assertStatus(status, 3, 0, 0);
46     }
47
48     @Test
49     public void testReusingOldInstance() throws Exception {
50         createLabeledUnicastModuleInstance();
51         final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
52         assertBeanCount(1, FACTORY_NAME);
53         final CommitStatus status = transaction.commit();
54         assertBeanCount(1, FACTORY_NAME);
55         assertStatus(status, 0, 0, 3);
56     }
57
58     @Test
59     public void testReconfigureInstance() throws Exception {
60         createLabeledUnicastModuleInstance();
61         final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
62         assertBeanCount(1, FACTORY_NAME);
63         final CommitStatus status = transaction.commit();
64         assertBeanCount(1, FACTORY_NAME);
65         assertStatus(status, 0, 0, 3);
66     }
67
68     private CommitStatus createLabeledUnicastModuleInstance() throws Exception {
69         final ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
70         final ObjectName LabeledUnicastON = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
71
72         SimpleBGPExtensionProviderContextModuleTest.createBGPExtensionsModuleInstance(transaction, Lists.newArrayList(LabeledUnicastON));
73         RIBExtensionsImplModuleTest.createRIBExtensionsModuleInstance(transaction, Lists.newArrayList(LabeledUnicastON));
74         return transaction.commit();
75     }
76
77 }