2 * Copyright (c) 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.config.yang.bgp.path.selection.mode;
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;
17 public class AdvertiseNPathsModuleTest extends AbstractConfigTest {
18 private static final String FACTORY_NAME = AdvertiseNPathsModuleFactory.NAME;
19 private static final String INSTANCE_NAME = "advertise-n-paths-module";
22 public void setUp() throws Exception {
23 super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new AdvertiseNPathsModuleFactory()));
27 public void testCreateBean() throws Exception {
28 final CommitStatus status = createInstance();
29 assertBeanCount(1, FACTORY_NAME);
30 assertStatus(status, 1, 0, 0);
34 public void testReusingOldInstance() throws Exception {
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);
44 public void testReconfigureInstance() throws Exception {
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);
53 private CommitStatus createInstance() throws Exception {
54 final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
55 transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
56 return transaction.commit();