2 * Copyright (c) 2016 AT&T Services, 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
9 package org.opendaylight.protocol.bgp.parser.impl;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.Unpooled;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
16 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
17 import org.opendaylight.protocol.bgp.parser.BgpExtendedMessageUtil;
18 import org.opendaylight.protocol.bgp.parser.impl.message.open.BgpExtendedMessageCapabilityHandler;
20 public class BgpExtendedMessageCapabilityHandlerTest {
23 public void testBgpExtendedMessageCapabilityHandler() throws BGPDocumentedException, BGPParsingException {
24 final BgpExtendedMessageCapabilityHandler handler = new BgpExtendedMessageCapabilityHandler();
26 final byte[] bgpExeBytes = {(byte) 0x06, (byte) 0x00};
28 final ByteBuf buffer = Unpooled.buffer(bgpExeBytes.length);
29 handler.serializeCapability(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY, buffer);
30 Assert.assertArrayEquals(bgpExeBytes, buffer.array());
31 Assert.assertEquals(handler.parseCapability(Unpooled.wrappedBuffer(bgpExeBytes)), BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY);
33 final byte[] bgpExeBytes2 = {(byte) 0x40, (byte) 0x06};
35 handler.serializeCapability(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY, buffer);
36 Assert.assertNotSame(bgpExeBytes2, buffer.array());