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.rev180329.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.rev180329.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv;
21 public final class Ipv6BgpPrefixSidParserTest {
23 private final Ipv6BgpPrefixSidParser handler = new Ipv6BgpPrefixSidParser();
25 private final byte[] expected = new byte[]{0, (byte) 0x80, 0};
27 @Test(expected = IllegalArgumentException.class)
28 public void testWrongTlvType() {
29 this.handler.serializeBgpPrefixSidTlv(() -> BgpPrefixSidTlv.class, Unpooled.EMPTY_BUFFER);
33 public void testHandling() {
34 final Ipv6SidTlvBuilder tlv = new Ipv6SidTlvBuilder();
35 tlv.setProcessIpv6HeadAbility(Boolean.TRUE);
36 final ByteBuf serialized = Unpooled.buffer(3);
37 this.handler.serializeBgpPrefixSidTlv(tlv.build(), serialized);
38 assertArrayEquals(this.expected, serialized.array());
39 assertTrue(this.handler.parseBgpPrefixSidTlv(serialized).isProcessIpv6HeadAbility());
43 public void testType() {
44 assertEquals(2, this.handler.getType());