moved BGP Table type from concepts to parser-api.
[bgpcep.git] / bgp / concepts / src / test / java / org / opendaylight / protocol / bgp / concepts / ClusterIdentifierTest.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.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
13
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.BgpOrigin;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ClusterIdentifier;
17
18 public class ClusterIdentifierTest {
19
20         @Test
21         public void testClusterIdentifier() {
22                 final ClusterIdentifier id = new ClusterIdentifier(new byte[] { 13, 14, 15, 16 });
23                 // FIXME: uncomment, once the generated code has length precondition
24                 // try {
25                 // new ClusterIdentifier(new byte[] { 5, 6 });
26                 // fail("Cluster ID is invalid!");
27                 // } catch (final IllegalArgumentException e) {
28                 // assertEquals("Invalid Cluster ID", e.getMessage());
29                 // }
30
31                 final ClusterIdentifier id1 = new ClusterIdentifier(new byte[] { 13, 14, 15, 16 });
32
33                 // FIXME: BUG-80 : uncomment, once it's done
34                 // assertEquals(id1.toString(), id.toString());
35
36                 assertArrayEquals(id1.getValue(), new byte[] { 13, 14, 15, 16 });
37         }
38
39         @Test
40         public void testOrigin() {
41                 final BgpOrigin or = BgpOrigin.Egp;
42                 assertEquals(or.name(), "Egp");
43         }
44
45         @Test
46         public void testBaseBGPObjectState() {
47                 final BaseBGPObjectState state = new BaseBGPObjectState(BgpOrigin.Incomplete, null);
48                 final BaseBGPObjectState state1 = new BaseBGPObjectState(BgpOrigin.Incomplete, null);
49                 assertNull(state.getAggregator());
50                 assertEquals(BgpOrigin.Incomplete, state.getOrigin());
51                 assertEquals(state.toString(), state1.toString());
52
53                 final BaseBGPObjectState s = new BaseBGPObjectState(state);
54                 assertEquals(state, s);
55                 assertEquals(state.hashCode(), s.hashCode());
56
57                 assertEquals(s, s.newInstance());
58         }
59 }