/* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.protocol.bgp.parser.impl.message.update.extended.communities; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; import org.junit.Assert; import org.junit.Test; import org.opendaylight.protocol.bgp.parser.BGPDocumentedException; import org.opendaylight.protocol.bgp.parser.BGPParsingException; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.ExtendedCommunity; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.OpaqueExtendedCommunityCase; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.OpaqueExtendedCommunityCaseBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.extended.community.extended.community.opaque.extended.community._case.OpaqueExtendedCommunityBuilder; public class OpaqueEcHandlerTest { private static final byte[] INPUT = { 21, 45, 5, 4, 3, 1 }; @Test public void testHandler() throws BGPDocumentedException, BGPParsingException { final OpaqueEcHandler handler = new OpaqueEcHandler(); final OpaqueExtendedCommunityCase expected = new OpaqueExtendedCommunityCaseBuilder() .setOpaqueExtendedCommunity(new OpaqueExtendedCommunityBuilder() .setValue(new byte[] { 21, 45, 5, 4, 3, 1 }).build()).build(); final ExtendedCommunity exComm = handler.parseExtendedCommunity(Unpooled.copiedBuffer(INPUT)); Assert.assertEquals(expected, exComm); final ByteBuf output = Unpooled.buffer(INPUT.length); handler.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(INPUT, output.array()); } }