2 * Copyright (c) 2013 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.rib.impl;
10 import static org.junit.Assert.assertTrue;
11 import static org.junit.Assert.fail;
12 import org.junit.Test;
13 import org.opendaylight.controller.config.api.ValidationException;
14 import org.opendaylight.controller.config.api.jmx.CommitStatus;
15 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
18 public class RIBImplModuleTest extends AbstractRIBImplModuleTest {
19 private static final int EXP_INSTANCES = 7;
20 private static final AsNumber AS_NUMBER = new AsNumber(500L);
21 private static final String INSTANCE_NAME = "rib-impl";
22 private static final String FACTORY_NAME = RIBImplModuleFactory.NAME;
25 public void testValidationExceptionRibIdNotSet() throws Exception {
27 createRIBImplModuleInstance(null, AS_NUMBER, BGP_ID, CLUSTER_ID);
29 } catch (final ValidationException e) {
30 assertTrue(e.getMessage().contains("RibId is not set."));
35 public void testValidationExceptionLocalAsNotSet() throws Exception {
37 createRIBImplModuleInstance(RIB_ID, null, BGP_ID, CLUSTER_ID);
39 } catch (final ValidationException e) {
40 assertTrue(e.getMessage().contains("LocalAs is not set."));
45 public void testValidationExceptionBgpIdNotSet() throws Exception {
47 createRIBImplModuleInstance(RIB_ID, AS_NUMBER, null, CLUSTER_ID);
49 } catch (final ValidationException e) {
50 assertTrue(e.getMessage().contains("BgpRibId is not set."));
55 public void testCreateBean() throws Exception {
56 final CommitStatus status = createInstance();
57 assertBeanCount(1, FACTORY_NAME);
58 assertStatus(status, EXP_INSTANCES, 0, 0);
62 public void testReusingOldInstance() throws Exception {
64 final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
65 assertBeanCount(1, FACTORY_NAME);
66 final CommitStatus status = transaction.commit();
67 assertBeanCount(1, FACTORY_NAME);
68 assertStatus(status, 0, 0, EXP_INSTANCES);
72 public void testReconfigure() throws Exception {
74 final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
75 assertBeanCount(1, FACTORY_NAME);
76 final RIBImplModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
77 RIBImplModuleMXBean.class);
78 mxBean.setLocalAs(new AsNumber(100L));
79 final CommitStatus status = transaction.commit();
80 assertBeanCount(1, FACTORY_NAME);
81 assertStatus(status, 0, 1, EXP_INSTANCES - 1);