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.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiADBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCaseBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RdIpv4;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteDistinguisher;
24 public final class InterASIPmsiADHandlerTest {
26 private static final byte[] INTER_AS = new byte[]{
31 private static final byte[] INTER_AS_TYPE_LENGTH = new byte[]{
38 private final InterAsIPmsiADCase expected = new InterAsIPmsiADCaseBuilder()
39 .setInterAsIPmsiAD(new InterAsIPmsiADBuilder()
40 .setSourceAs(new AsNumber(1L))
41 .setRouteDistinguisher(new RouteDistinguisher(new RdIpv4("1.2.3.4:258")))
44 private final InterASIPmsiADHandler handler = new InterASIPmsiADHandler();
48 public void testInterASIPmsiADParser() {
49 assertEquals(this.expected, this.handler.parseMvpn(Unpooled.copiedBuffer(INTER_AS)));
53 public void testInterASIPmsiADSerializer() {
54 assertArrayEquals(INTER_AS_TYPE_LENGTH, ByteArray.getAllBytes(this.handler.serializeMvpn(this.expected)));
58 public void testGetType() {
59 assertEquals(NlriType.InterAsIPmsiAD.getIntValue(), this.handler.getType());
63 public void testGetClazz() {
64 assertEquals(InterAsIPmsiADCase.class, this.handler.getClazz());