2 * Copyright (c) 2018 AT&T Intellectual Property. 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.mvpn.impl.nlri;
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
13 import io.netty.buffer.Unpooled;
14 import org.junit.Test;
15 import org.opendaylight.protocol.util.ByteArray;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.c.multicast.grouping.CMulticastBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.multicast.group.opaque.grouping.multicast.group.CGAddressCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SharedTreeJoinCase;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SharedTreeJoinCaseBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.shared.tree.join._case.SharedTreeJoinBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RdIpv4;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
27 import org.opendaylight.yangtools.yang.common.Uint32;
29 public final class SharedTreeJoinHandlerTest {
30 private static final byte[] SHARED_TREE = new byte[]{
31 0, 1, 1, 2, 3, 4, 1, 2,
36 private static final byte[] SHARED_TREE_LENGTH = new byte[]{
38 0, 1, 1, 2, 3, 4, 1, 2,
44 private final SharedTreeJoinCase expected = new SharedTreeJoinCaseBuilder()
45 .setSharedTreeJoin(new SharedTreeJoinBuilder()
46 .setCMulticast(new CMulticastBuilder()
47 .setRouteDistinguisher(new RouteDistinguisher(new RdIpv4("1.2.3.4:258")))
48 .setSourceAs(new AsNumber(Uint32.TEN))
49 .setMulticastSource(new IpAddressNoZone(new Ipv4AddressNoZone("1.0.0.1")))
50 .setMulticastGroup(new CGAddressCaseBuilder()
51 .setCGAddress(new IpAddressNoZone(new Ipv4AddressNoZone("2.0.0.2"))).build()).build())
53 private final SharedTreeJoinHandler handler = new SharedTreeJoinHandler();
56 public void testParser() {
57 assertEquals(this.expected, this.handler.parseMvpn(Unpooled.copiedBuffer(SHARED_TREE)));
61 public void testSerializer() {
62 assertArrayEquals(SHARED_TREE_LENGTH, ByteArray.getAllBytes(this.handler.serializeMvpn(this.expected)));
66 public void testGetType() {
67 assertEquals(NlriType.SharedTreeJoin.getIntValue(), this.handler.getType());
71 public void testGetClazz() {
72 assertEquals(SharedTreeJoinCase.class, this.handler.getClazz());