moved BGP Table type from concepts to parser-api.
[bgpcep.git] / bgp / parser-api / src / test / java / org / opendaylight / protocol / bgp / parser / 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.parser;
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.fail;
14
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv6AddressFamily;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.MplsLabeledVpnSubsequentAddressFamily;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
20
21 public class TableTypeTest {
22
23         @Test
24         public void testTableTypes() {
25                 final BGPTableType tt1 = new BGPTableType(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
26                 final BGPTableType tt2 = new BGPTableType(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
27                 final BGPTableType tt3 = new BGPTableType(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
28
29                 try {
30                         new BGPTableType(null, MplsLabeledVpnSubsequentAddressFamily.class);
31                         fail("Null AFI!");
32                 } catch (final NullPointerException e) {
33                         assertEquals("Address family may not be null", e.getMessage());
34                 }
35
36                 try {
37                         new BGPTableType(Ipv6AddressFamily.class, null);
38                         fail("Null SAFI!");
39                 } catch (final NullPointerException e) {
40                         assertEquals("Subsequent address family may not be null", e.getMessage());
41                 }
42
43                 assertFalse(tt1.equals(tt2));
44                 assertNotSame(tt1.hashCode(), tt2.hashCode());
45                 assertEquals(tt1.toString(), tt1.toString());
46                 assertNotSame(tt1.getAddressFamily(), tt2.getAddressFamily());
47                 assertEquals(tt1.getSubsequentAddressFamily(), tt2.getSubsequentAddressFamily());
48         }
49 }