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.protocol.bgp.mode.impl.add.all.paths;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.protocol.bgp.mode.impl.AbstractRouteEntryTest;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 public final class SimpleRouteEntryTest extends AbstractRouteEntryTest {
21 private SimpleRouteEntry testBARE;
29 public void testSimpleRouteEntry() throws Exception {
30 this.testBARE = (SimpleRouteEntry) new AllPathSelection().createRouteEntry(false);
31 testAddRouteSelectBestAndWriteOnDS();
35 private void testAddRouteSelectBestAndWriteOnDS() {
36 this.testBARE.addRoute(ROUTER_ID, REMOTE_PATH_ID, this.ribSupport
37 .routeAttributesIdentifier(), this.attributes);
38 assertFalse(this.testBARE.isEmpty());
39 assertTrue(this.testBARE.selectBest(AS));
40 /** Add AddPath Route **/
41 this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport,
42 this.tx, ROUTE_ID_PA_ADD_PATH);
43 final Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
44 assertEquals(3, yiiCount.size());
45 assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
46 assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
47 assertEquals(1, (long) yiiCount.get(this.routeAddRiboutAttYii));
50 private void testRemoveRoute() {
51 Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
52 assertEquals(3, yiiCount.size());
53 assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
54 assertTrue(this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID));
55 assertTrue(this.testBARE.selectBest(AS));
56 this.testBARE.updateRoute(TABLES_KEY, this.peerPT, LOC_RIB_TARGET, this.ribSupport,
57 this.tx, ROUTE_ID_PA_ADD_PATH);
58 yiiCount = collectInfo();
59 assertEquals(0, yiiCount.size());
60 assertFalse(yiiCount.containsKey(this.routePaAddPathYii));
61 assertFalse(yiiCount.containsKey(this.routeAddRiboutYii));