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 this.testBARE.updateBestPaths(this.entryDep, ROUTE_ID_PA_ADD_PATH, this.tx);
41 final Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
42 assertEquals(3, yiiCount.size());
43 assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
44 assertEquals(1, (long) yiiCount.get(this.routeAddRiboutYii));
45 assertEquals(1, (long) yiiCount.get(this.routeAddRiboutAttYii));
48 private void testRemoveRoute() {
49 Map<YangInstanceIdentifier, Long> yiiCount = collectInfo();
50 assertEquals(3, yiiCount.size());
51 assertEquals(1, (long) yiiCount.get(this.routePaAddPathYii));
52 assertTrue(this.testBARE.removeRoute(ROUTER_ID, REMOTE_PATH_ID));
53 assertTrue(this.testBARE.selectBest(AS));
54 this.testBARE.updateBestPaths(this.entryDep, ROUTE_ID_PA_ADD_PATH, this.tx);
55 yiiCount = collectInfo();
56 assertEquals(0, yiiCount.size());
57 assertFalse(yiiCount.containsKey(this.routePaAddPathYii));
58 assertFalse(yiiCount.containsKey(this.routeAddRiboutYii));