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.protocol.bgp.concepts;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotSame;
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.fail;
16 import org.junit.Test;
17 import org.opendaylight.protocol.bgp.concepts.BGPAddressFamily;
18 import org.opendaylight.protocol.bgp.concepts.BGPOrigin;
19 import org.opendaylight.protocol.bgp.concepts.BGPSubsequentAddressFamily;
20 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
21 import org.opendaylight.protocol.bgp.concepts.BaseBGPObjectState;
23 import org.opendaylight.protocol.concepts.IPv6;
25 public class TableTypeTest {
28 public void testTableTypes() {
29 final BGPTableType tt1 = new BGPTableType(BGPAddressFamily.IPv4, BGPSubsequentAddressFamily.MPLSLabeledVPN);
30 final BGPTableType tt2 = new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.valueOf("MPLSLabeledVPN"));
31 final BGPTableType tt3 = new BGPTableType(BGPAddressFamily.IPv6, BGPSubsequentAddressFamily.Unicast);
33 assertEquals(IPv6.FAMILY, BGPAddressFamily.IPv6.getAddressFamily());
34 assertNull(BGPAddressFamily.LinkState.getAddressFamily());
37 new BGPTableType(null, BGPSubsequentAddressFamily.MPLSLabeledVPN);
39 } catch (final NullPointerException e) {
40 assertEquals("Address family may not be null", e.getMessage());
44 new BGPTableType(BGPAddressFamily.valueOf("IPv6"), null);
46 } catch (final NullPointerException e) {
47 assertEquals("Subsequent address family may not be null", e.getMessage());
50 assertFalse(tt1.equals(tt2));
51 assertNotSame(tt1.hashCode(), tt2.hashCode());
52 assertEquals(1, tt2.compareTo(tt1));
53 assertEquals(1, tt2.compareTo(tt3));
54 assertEquals(tt1.toString(), tt1.toString());
55 assertNotSame(tt1.getAddressFamily(), tt2.getAddressFamily());
56 assertEquals(tt1.getSubsequentAddressFamily(), tt2.getSubsequentAddressFamily());
60 public void testOrigin() {
61 final BGPOrigin or = BGPOrigin.EGP;
62 assertEquals(or.name(), "EGP");
66 public void testBaseBGPObjectState() {
67 final BaseBGPObjectState state = new BaseBGPObjectState(BGPOrigin.INCOMPLETE, null);
68 final BaseBGPObjectState state1 = new BaseBGPObjectState(BGPOrigin.INCOMPLETE, null);
69 assertNull(state.getAggregator());
70 assertEquals(BGPOrigin.INCOMPLETE, state.getOrigin());
71 assertEquals(state.toString(), state1.toString());
73 final BaseBGPObjectState s = new BaseBGPObjectState(state);
74 assertEquals(state, s);
75 assertEquals(state.hashCode(), s.hashCode());
77 assertEquals(s, s.newInstance());