Fix junit dependencies in poms. Reuse existing from parent,
[bgpcep.git] / bgp / concepts / src / test / java / org / opendaylight / protocol / bgp / concepts / OpaqueExtendedCommunityTest.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.assertNotSame;
13 import static org.junit.Assert.assertTrue;
14 import static org.junit.Assert.fail;
15
16 import org.junit.Before;
17 import org.junit.Ignore;
18 import org.junit.Test;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.c.opaque.extended.community.OpaqueExtendedCommunity;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.extended.community.c.opaque.extended.community.OpaqueExtendedCommunityBuilder;
21
22 public class OpaqueExtendedCommunityTest {
23
24         private boolean transitive;
25         private byte[] value;
26
27         private OpaqueExtendedCommunity community;
28
29         @Before
30         public void init() {
31                 this.transitive = true;
32                 this.value = new byte[] { 1, 5, 9, 3, 5, 7 };
33                 this.community = new OpaqueExtendedCommunityBuilder().setTransitive(this.transitive).setValue(this.value).build();
34         }
35
36         @Test
37         @Ignore
38         // FIXME: when length is implemented
39         public void testOverflows() {
40                 try {
41                         new OpaqueExtendedCommunityBuilder().setTransitive(this.transitive).setValue(new byte[] { 0, 1, 2, 3, 4, 5, 6, }).build();
42                         fail("Constructor successful unexpectedly");
43                 } catch (final IllegalArgumentException e) {
44                         assertEquals("Invalid value", e.getMessage());
45                 }
46         }
47
48         @Test
49         public void testGetValue() {
50                 assertArrayEquals(new byte[] { 1, 5, 9, 3, 5, 7 }, this.community.getValue());
51         }
52
53         @Test
54         public void testIsTransitive() {
55                 assertTrue(this.community.isTransitive());
56         }
57
58         @Test
59         public void testToString() {
60                 final OpaqueExtendedCommunity c = new OpaqueExtendedCommunityBuilder().setTransitive(false).setValue(this.value).build();
61                 assertNotSame(c.toString(), this.community.toString());
62         }
63 }