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.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNull;
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;
18 public class ClusterIdentifierTest {
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
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());
31 final ClusterIdentifier id1 = new ClusterIdentifier(new byte[] { 13, 14, 15, 16 });
33 // FIXME: BUG-80 : uncomment, once it's done
34 // assertEquals(id1.toString(), id.toString());
36 assertArrayEquals(id1.getValue(), new byte[] { 13, 14, 15, 16 });
40 public void testOrigin() {
41 final BgpOrigin or = BgpOrigin.Egp;
42 assertEquals(or.name(), "Egp");
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());
53 final BaseBGPObjectState s = new BaseBGPObjectState(state);
54 assertEquals(state, s);
55 assertEquals(state.hashCode(), s.hashCode());
57 assertEquals(s, s.newInstance());