BUG-45 : migrated Keepalive message to generated source code.
[bgpcep.git] / bgp / concepts / src / test / java / org / opendaylight / protocol / bgp / concepts / TableTypeTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.concepts;
9
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;
15
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;
22
23 public class TableTypeTest {
24
25         @Test
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);
30
31                 try {
32                         new BGPTableType(null, MplsLabeledVpnSubsequentAddressFamily.class);
33                         fail("Null AFI!");
34                 } catch (final NullPointerException e) {
35                         assertEquals("Address family may not be null", e.getMessage());
36                 }
37
38                 try {
39                         new BGPTableType(Ipv6AddressFamily.class, null);
40                         fail("Null SAFI!");
41                 } catch (final NullPointerException e) {
42                         assertEquals("Subsequent address family may not be null", e.getMessage());
43                 }
44
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());
50         }
51
52         @Test
53         public void testOrigin() {
54                 final BgpOrigin or = BgpOrigin.Egp;
55                 assertEquals(or.name(), "Egp");
56         }
57
58         @Test
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());
65
66                 final BaseBGPObjectState s = new BaseBGPObjectState(state);
67                 assertEquals(state, s);
68                 assertEquals(state.hashCode(), s.hashCode());
69
70                 assertEquals(s, s.newInstance());
71         }
72 }