Upgrade ietf-{inet,yang}-types to 2013-07-15
[bgpcep.git] / bgp / parser-impl / src / test / java / org / opendaylight / protocol / bgp / parser / impl / BgpExtendedMessageCapabilityHandlerTest.java
1 /*
2  * Copyright (c) 2016 AT&T Services, 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
9 package org.opendaylight.protocol.bgp.parser.impl;
10
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;
19
20 public class BgpExtendedMessageCapabilityHandlerTest {
21
22     @Test
23     public void testBgpExtendedMessageCapabilityHandler() throws BGPDocumentedException, BGPParsingException {
24         final BgpExtendedMessageCapabilityHandler handler = new BgpExtendedMessageCapabilityHandler();
25
26         final byte[] bgpExeBytes = {(byte) 0x06, (byte) 0x00};
27
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);
32
33         final byte[] bgpExeBytes2 = {(byte) 0x40, (byte) 0x06};
34         buffer.clear();
35         handler.serializeCapability(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY, buffer);
36         Assert.assertNotSame(bgpExeBytes2, buffer.array());
37     }
38
39 }