Code Clean Up
[bgpcep.git] / bgp / path-selection-mode / src / test / java / org / opendaylight / controller / config / yang / bgp / path / selection / mode / AdvertiseAllPathsModuleTest.java
1 /*
2  * Copyright (c) 2016 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.path.selection.mode;
9
10 import org.junit.Before;
11 import org.junit.Test;
12 import org.opendaylight.controller.config.api.jmx.CommitStatus;
13 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
14 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
15 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
16
17 public class AdvertiseAllPathsModuleTest extends AbstractConfigTest {
18     private static final String FACTORY_NAME = AdvertiseAllPathsModuleFactory.NAME;
19     private static final String INSTANCE_NAME = "advertise-all-paths-module";
20
21     @Before
22     public void setUp() throws Exception {
23         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new AdvertiseAllPathsModuleFactory()));
24     }
25
26     @Test
27     public void testCreateBean() throws Exception {
28         final CommitStatus status = createInstance();
29         assertBeanCount(1, FACTORY_NAME);
30         assertStatus(status, 1, 0, 0);
31     }
32
33     @Test
34     public void testReusingOldInstance() throws Exception {
35         createInstance();
36         final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
37         assertBeanCount(1, FACTORY_NAME);
38         final CommitStatus status = transaction.commit();
39         assertBeanCount(1, FACTORY_NAME);
40         assertStatus(status, 0, 0, 1);
41     }
42
43     @Test
44     public void testReconfigureInstance() throws Exception {
45         createInstance();
46         ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
47         assertBeanCount(1, FACTORY_NAME);
48         CommitStatus status = transaction.commit();
49         assertBeanCount(1, FACTORY_NAME);
50         assertStatus(status, 0, 0, 1);
51     }
52
53     private CommitStatus createInstance() throws Exception {
54         final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
55         transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
56         return transaction.commit();
57     }
58 }