2 * Copyright (c) 2018 AT&T Intellectual Property. 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.spi.extended.community;
10 import io.netty.buffer.ByteBuf;
11 import io.netty.buffer.Unpooled;
12 import org.junit.Assert;
13 import org.junit.Test;
14 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommon;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.inet4.specific.extended.community.common.Inet4SpecificExtendedCommunityCommonBuilder;
18 public class Inet4SpecificExtendedCommunityCommonUtilTest {
19 private static final byte[] INPUT = {
24 public void testHandle() {
25 final Inet4SpecificExtendedCommunityCommon expected = new Inet4SpecificExtendedCommunityCommonBuilder()
26 .setGlobalAdministrator(new Ipv4AddressNoZone("12.51.2.5"))
27 .setLocalAdministrator(new byte[]{21, 45}).build();
29 final Inet4SpecificExtendedCommunityCommon exComm = Inet4SpecificExtendedCommunityCommonUtil
30 .parseCommon(Unpooled.copiedBuffer(INPUT));
31 Assert.assertEquals(expected, exComm);
33 final ByteBuf output = Unpooled.buffer(INPUT.length);
34 Inet4SpecificExtendedCommunityCommonUtil.serializeCommon(expected, output);
35 Assert.assertArrayEquals(INPUT, output.array());