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.parser.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.fail;
14 import org.junit.Ignore;
15 import org.junit.Test;
16 import org.opendaylight.protocol.bgp.parser.impl.message.update.CommunityUtil;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Community;
19 public class CommunityTest {
22 public void testCommunity() {
23 CommunityUtil.create(10, 222);
24 final Community c = CommunityUtil.create(12, 12);
25 assertEquals(12, c.getAsNumber().getValue().intValue());
26 assertEquals(12, c.getSemantics().intValue());
31 // FIXME: range is not implemented
32 public void testOverflows() {
34 CommunityUtil.create(10, -2);
35 fail("Semantics under range.");
36 } catch (final IllegalArgumentException e) {
37 assertEquals("Invalid semantics specified", e.getMessage());
40 CommunityUtil.create(10, 65536);
41 fail("Semantics above range.");
42 } catch (final IllegalArgumentException e) {
43 assertEquals("Invalid semantics specified", e.getMessage());
48 public void testToString() {
49 final Community c = CommunityUtil.create(10, 222);
50 assertNotNull(c.toString());
54 public void testValueOf() {
55 final Community comm = CommunityUtil.valueOf("12:50");
56 assertEquals(12, comm.getAsNumber().getValue().intValue());
57 assertEquals(50, comm.getSemantics().intValue());