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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
23 public class TableTypeTest {
26 public void testTableTypes() {
27 final BGPTableType tt1 = new BGPTableType(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
28 final BGPTableType tt2 = new BGPTableType(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
29 final BGPTableType tt3 = new BGPTableType(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
32 new BGPTableType(null, MplsLabeledVpnSubsequentAddressFamily.class);
34 } catch (final NullPointerException e) {
35 assertEquals("Address family may not be null", e.getMessage());
39 new BGPTableType(Ipv6AddressFamily.class, null);
41 } catch (final NullPointerException e) {
42 assertEquals("Subsequent address family may not be null", e.getMessage());
45 assertFalse(tt1.equals(tt2));
46 assertNotSame(tt1.hashCode(), tt2.hashCode());
47 assertEquals(tt1.toString(), tt1.toString());
48 assertNotSame(tt1.getAddressFamily(), tt2.getAddressFamily());
49 assertEquals(tt1.getSubsequentAddressFamily(), tt2.getSubsequentAddressFamily());
53 public void testOrigin() {
54 final BgpOrigin or = BgpOrigin.Egp;
55 assertEquals(or.name(), "Egp");
59 public void testBaseBGPObjectState() {
60 final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Incomplete, null);
61 final BaseBGPObjectState state1 = new BaseBGPObjectState(BgpOrigin.Incomplete, null);
62 assertNull(state.getAggregator());
63 assertEquals(BgpOrigin.Incomplete, state.getOrigin());
64 assertEquals(state.toString(), state1.toString());
66 final BaseBGPObjectState s = new BaseBGPObjectState(state);
67 assertEquals(state, s);
68 assertEquals(state.hashCode(), s.hashCode());
70 assertEquals(s, s.newInstance());