Create common parent for extensions families
[bgpcep.git] / bgp / extensions / l3vpn / src / test / java / org / opendaylight / protocol / bgp / l3vpn / mcast / nlri / L3vpnMcastNlriSerializerTest.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.l3vpn.mcast.nlri;
10
11 import static org.junit.Assert.assertArrayEquals;
12
13 import io.netty.buffer.ByteBuf;
14 import io.netty.buffer.Unpooled;
15 import java.util.Collections;
16 import org.junit.Test;
17 import org.opendaylight.protocol.util.ByteArray;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestination;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.l3vpn.mcast.rev180417.l3vpn.mcast.destination.L3vpnMcastDestinationBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RdIpv4;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
24
25 public class L3vpnMcastNlriSerializerTest {
26     private static final byte[] EXPECTED = new byte[]{
27         (byte) 0x80,
28         0, 1, 1, 2, 3, 4, 1, 2, //RD
29         32, 1, 13, (byte) 0xb8, 0, 1, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 64, // Prefix
30         0, 0, 0, 0, 0, 0, 0 //trailing bits
31     };
32     private static final RouteDistinguisher RD = new RouteDistinguisher(new RdIpv4("1.2.3.4:258"));
33     private static final IpPrefix IPV6_PREFIX = new IpPrefix(new Ipv6Prefix("2001:db8:1:2::/64"));
34     private static final L3vpnMcastDestination MCAST_L3VPN_DESTINATION = new L3vpnMcastDestinationBuilder()
35             .setRouteDistinguisher(RD)
36             .setPrefix(IPV6_PREFIX)
37             .build();
38
39     @Test
40     public void testL3vpnMcastNlriSerializer() {
41         ByteBuf actual = Unpooled.buffer();
42         L3vpnMcastNlriSerializer.serializeNlri(Collections.singletonList(MCAST_L3VPN_DESTINATION), actual);
43         assertArrayEquals(EXPECTED, ByteArray.getAllBytes(actual));
44     }
45 }