2 * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.mode.impl.base;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.primitives.UnsignedInteger;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerId;
19 public class BaseBestPathTest {
20 private static final long PATH_ID = 0;
21 private BaseBestPath baseBestPath;
22 private static final UnsignedInteger ROUTER_ID = UnsignedInteger.valueOf(2130706433);
23 private static final PeerId PEER_ID = new PeerId("bgp://127.0.0.1");
24 private BaseBestPath baseBestPathCopy;
27 public void setUp() throws Exception {
28 final BasePathSelector selector = new BasePathSelector(20L);
29 selector.processPath(BasePathSelectorTest.ROUTER_ID2, BasePathSelectorTest.createStateFromPrefMedOriginASPath().build());
30 this.baseBestPath = selector.result();
31 this.baseBestPathCopy = selector.result();
35 public void testGetRouterId() throws Exception {
36 assertEquals(ROUTER_ID, this.baseBestPath.getRouterId());
40 public void testGetPeerId() throws Exception {
41 assertEquals(PEER_ID, this.baseBestPath.getPeerId());
45 public void testGetPathId() throws Exception {
46 assertEquals(PATH_ID, this.baseBestPath.getPathId());
50 public void testHashCodeAndEqual() throws Exception {
51 assertTrue(this.baseBestPath.equals(this.baseBestPathCopy) && this.baseBestPathCopy.equals(this.baseBestPath));
52 assertTrue(this.baseBestPath.hashCode() == this.baseBestPathCopy.hashCode());
53 assertTrue(this.baseBestPath.getPathId() == PATH_ID);
57 public void testToString() throws Exception {
58 assertTrue(this.baseBestPath.toString().equals(this.baseBestPathCopy.toString()));