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;
13 import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
15 import com.google.common.primitives.UnsignedInteger;
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
20 public class BaseBestPathTest {
21 private static final UnsignedInteger ROUTER_ID = UnsignedInteger.valueOf(2130706433);
22 private static final PeerId PEER_ID = new PeerId("bgp://127.0.0.1");
23 private BaseBestPath baseBestPath;
24 private BaseBestPath baseBestPathCopy;
28 final BasePathSelector selector = new BasePathSelector(20L);
29 selector.processPath(BasePathSelectorTest.ROUTER_ID2,
30 BasePathSelectorTest.createStateFromPrefMedOriginASPath().build());
31 this.baseBestPath = selector.result();
32 this.baseBestPathCopy = selector.result();
36 public void testGetRouterId() {
37 assertEquals(ROUTER_ID, this.baseBestPath.getRouterId());
41 public void testGetPeerId() {
42 assertEquals(PEER_ID, this.baseBestPath.getPeerId());
46 public void testGetPathId() {
47 assertEquals(NON_PATH_ID_VALUE, this.baseBestPath.getPathId());
51 public void testHashCodeAndEqual() {
52 assertTrue(this.baseBestPath.equals(this.baseBestPathCopy)
53 && this.baseBestPathCopy.equals(this.baseBestPath));
54 assertTrue(this.baseBestPath.hashCode() == this.baseBestPathCopy.hashCode());
58 public void testToString() {
59 assertTrue(this.baseBestPath.toString().equals(this.baseBestPathCopy.toString()));