import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
public static final long AS_MODEL = 16843009;
public static final AsNumber AS_NUMBER = new AsNumber(AS_MODEL);
public static final Integer PORT = 514;
+ public static final MplsLabel MPLS_LABEL = new MplsLabel(24001L);
+ public static final int COMMUNITY_VALUE_SIZE = 6;
public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createContBuilder(final YangInstanceIdentifier
.NodeIdentifier nid) {
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.evpn.impl.extended.communities;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.COMMUNITY_VALUE_SIZE;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321._default.gateway.extended.community.DefaultGatewayExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.EsiLabelExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+
+public class DefaultGatewayExtComTest {
+ private static final byte[] RESULT = {(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00};
+ private DefaultGatewayExtCom parser;
+
+ @Before
+ public void setUp() {
+ this.parser = new DefaultGatewayExtCom();
+ }
+
+ @Test
+ public void parserTest() throws BGPParsingException, BGPDocumentedException {
+ final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
+
+ final DefaultGatewayExtendedCommunityCase expected = new DefaultGatewayExtendedCommunityCaseBuilder().setDefaultGatewayExtendedCommunity(
+ new DefaultGatewayExtendedCommunityBuilder().build()).build();
+ this.parser.serializeExtendedCommunity(expected, buff);
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
+
+ final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(RESULT));
+ assertEquals(expected, result);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void wrongCaseTest() {
+ this.parser.serializeExtendedCommunity(new EsiLabelExtendedCommunityCaseBuilder().build(), null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void wrongSizeTest() throws BGPParsingException, BGPDocumentedException {
+ this.parser.parseExtendedCommunity(Unpooled.buffer(8));
+ }
+
+ @Test
+ public void testSubtype() {
+ assertEquals(13, this.parser.getSubType());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.evpn.impl.extended.communities;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.COMMUNITY_VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MPLS_LABEL;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.esi.label.extended.community.EsiLabelExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.EsiLabelExtendedCommunityCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.EsiLabelExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+
+public class ESILabelExtComTest {
+ private static final byte[] RESULT = {(byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x05, (byte) 0xdc, (byte) 0x10};
+ private ESILabelExtCom parser;
+
+ @Before
+ public void setUp() {
+ this.parser = new ESILabelExtCom();
+ }
+
+ @Test
+ public void parserTest() throws BGPParsingException, BGPDocumentedException {
+ final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
+
+ final EsiLabelExtendedCommunityCase expected = new EsiLabelExtendedCommunityCaseBuilder().setEsiLabelExtendedCommunity(
+ new EsiLabelExtendedCommunityBuilder().setSingleActiveMode(true).setEsiLabel(MPLS_LABEL).build()).build();
+ this.parser.serializeExtendedCommunity(expected, buff);
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
+
+ final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(RESULT));
+ assertEquals(expected, result);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void wrongCaseTest() {
+ this.parser.serializeExtendedCommunity(new DefaultGatewayExtendedCommunityCaseBuilder().build(), null);
+ }
+
+ @Test
+ public void testSubtype() {
+ assertEquals(1, this.parser.getSubType());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.evpn.impl.extended.communities;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.COMMUNITY_VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MAC;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.es._import.route.extended.community.EsImportRouteExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.EsImportRouteExtendedCommunityCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.EsImportRouteExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+
+public class ESImpRouteTargetExtComTest {
+ private static final byte[] RESULT = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7};
+ private ESImpRouteTargetExtCom parser;
+
+ @Before
+ public void setUp() {
+ this.parser = new ESImpRouteTargetExtCom();
+ }
+
+ @Test
+ public void parserTest() throws BGPParsingException, BGPDocumentedException {
+ final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
+
+ final EsImportRouteExtendedCommunityCase expected = new EsImportRouteExtendedCommunityCaseBuilder().setEsImportRouteExtendedCommunity(
+ new EsImportRouteExtendedCommunityBuilder().setEsImport(MAC).build()).build();
+ this.parser.serializeExtendedCommunity(expected, buff);
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
+
+ final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(RESULT));
+ assertEquals(expected, result);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void wrongCaseTest() {
+ this.parser.serializeExtendedCommunity(new DefaultGatewayExtendedCommunityCaseBuilder().build(), null);
+ }
+
+ @Test
+ public void testSubtype() {
+ assertEquals(2, this.parser.getSubType());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.bgp.evpn.impl.extended.communities;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.COMMUNITY_VALUE_SIZE;
+import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.LD;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.DefaultGatewayExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.MacMobilityExtendedCommunityCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.evpn.routes.evpn.routes.evpn.route.attributes.extended.communities.extended.community.MacMobilityExtendedCommunityCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev160321.mac.mobility.extended.community.MacMobilityExtendedCommunityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
+
+public class MACMobExtComTest {
+ private static final byte[] RESULT = {(byte) 0x01, (byte) 0x00, (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x02};
+ private MACMobExtCom parser;
+
+ @Before
+ public void setUp() {
+ this.parser = new MACMobExtCom();
+ }
+
+ @Test
+ public void parserTest() throws BGPParsingException, BGPDocumentedException {
+ final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
+
+ final MacMobilityExtendedCommunityCase expected = new MacMobilityExtendedCommunityCaseBuilder().setMacMobilityExtendedCommunity(
+ new MacMobilityExtendedCommunityBuilder().setStatic(true).setSeqNumber(LD).build()).build();
+ this.parser.serializeExtendedCommunity(expected, buff);
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
+
+ final ExtendedCommunity result = this.parser.parseExtendedCommunity(Unpooled.wrappedBuffer(RESULT));
+ assertEquals(expected, result);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void wrongCaseTest() {
+ this.parser.serializeExtendedCommunity(new DefaultGatewayExtendedCommunityCaseBuilder().build(), null);
+ }
+
+ @Test
+ public void testSubtype() {
+ assertEquals(0, this.parser.getSubType());
+ }
+}
\ No newline at end of file