2 * Copyright (c) 2016 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.inet;
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
14 import io.netty.buffer.ByteBuf;
15 import io.netty.buffer.Unpooled;
16 import org.junit.Test;
17 import org.opendaylight.protocol.bgp.inet.codec.Ipv6BgpPrefixSidParser;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.Ipv6SidTlvBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv;
20 import org.opendaylight.yangtools.yang.binding.DataContainer;
22 public final class Ipv6BgpPrefixSidParserTest {
24 private final Ipv6BgpPrefixSidParser handler = new Ipv6BgpPrefixSidParser();
26 private final byte[] expected = new byte[] {0, (byte)0x80, 0};
28 @Test(expected=IllegalArgumentException.class)
29 public void testWrongTlvType() {
30 this.handler.serializeBgpPrefixSidTlv(() -> BgpPrefixSidTlv.class, Unpooled.EMPTY_BUFFER);
34 public void testHandling() {
35 final Ipv6SidTlvBuilder tlv = new Ipv6SidTlvBuilder();
36 tlv.setProcessIpv6HeadAbility(Boolean.TRUE);
37 final ByteBuf serialized = Unpooled.buffer(3);
38 this.handler.serializeBgpPrefixSidTlv(tlv.build(), serialized);
39 assertArrayEquals(this.expected, serialized.array());
40 assertTrue(this.handler.parseBgpPrefixSidTlv(serialized).isProcessIpv6HeadAbility());
44 public void testType() {
45 assertEquals(2, this.handler.getType());