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
9 package org.opendaylight.protocol.bgp.mvpn.impl.nlri;
11 import static org.junit.Assert.assertArrayEquals;
12 import static org.junit.Assert.assertEquals;
14 import io.netty.buffer.Unpooled;
15 import org.junit.Test;
16 import org.opendaylight.protocol.util.ByteArray;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
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.mvpn.mvpn.choice.SourceActiveADCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SourceActiveADCaseBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.source.active.a.d.grouping.SourceActiveADBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RdIpv4;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
26 public final class SourceActiveADHandlerTest {
27 private static final byte[] SOURCE_ACTIVE = new byte[]{
28 0, 1, 1, 2, 3, 4, 1, 2,
32 private static final byte[] SOURCE_ACTIVE_LENGTH = new byte[]{
34 0, 1, 1, 2, 3, 4, 1, 2,
39 private final SourceActiveADCase expected = new SourceActiveADCaseBuilder()
40 .setSourceActiveAD(new SourceActiveADBuilder()
41 .setRouteDistinguisher(new RouteDistinguisher(new RdIpv4("1.2.3.4:258")))
42 .setMulticastSource(new IpAddress(new Ipv4Address("1.0.0.1")))
43 .setMulticastGroup(new IpAddress(new Ipv4Address("2.0.0.2")))
46 private final SourceActiveADHandler handler = new SourceActiveADHandler();
49 public void testParser() {
50 assertEquals(this.expected, this.handler.parseMvpn(Unpooled.copiedBuffer(SOURCE_ACTIVE)));
54 public void testSerializer() {
55 assertArrayEquals(SOURCE_ACTIVE_LENGTH, ByteArray.getAllBytes(this.handler.serializeMvpn(this.expected)));
59 public void testGetType() {
60 assertEquals(NlriType.SourceActiveAD.getIntValue(), this.handler.getType());
64 public void testGetClazz() {
65 assertEquals(SourceActiveADCase.class, this.handler.getClazz());