Bug-194: Moved pcep configuration artifacts
[bgpcep.git] / pcep / topology-provider / src / test / java / org / opendaylight / controller / config / yang / pcep / topology / provider / Stateful07TopologySessionListenerModuleTest.java
1 /*
2  * Copyright (c) 2014 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.pcep.topology.provider;
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 Stateful07TopologySessionListenerModuleTest extends AbstractConfigTest {
18
19     private static final String FACTORY_NAME = Stateful07TopologySessionListenerModuleFactory.NAME;
20     private static final String INSTANCE_NAME = "pcep-topology-stateful07-instance";
21
22     @Before
23     public void setUp() throws Exception {
24         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(mockedContext, new Stateful07TopologySessionListenerModuleFactory()));
25     }
26
27     @Test
28     public void testCreateBean() throws Exception {
29         CommitStatus status = createInstance();
30         assertBeanCount(1, FACTORY_NAME);
31         assertStatus(status, 1, 0, 0);
32     }
33
34     @Test
35     public void testReusingOldInstance() throws Exception {
36         createInstance();
37         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
38         assertBeanCount(1, FACTORY_NAME);
39         CommitStatus status = transaction.commit();
40         assertBeanCount(1, FACTORY_NAME);
41         assertStatus(status, 0, 0, 1);
42     }
43
44     private CommitStatus createInstance() throws Exception {
45         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
46         transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
47         return transaction.commit();
48     }
49
50 }