</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
package org.opendaylight.protocol.bgp.evpn.impl;
+import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.List;
import org.opendaylight.protocol.bgp.evpn.impl.attributes.PMSITunnelAttributeHandler;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCase;
public final class BGPActivator extends AbstractBGPExtensionProviderActivator {
- private static final int L2VPN_AFI = 25;
- private static final int EVPN_SAFI = 70;
+ @VisibleForTesting
+ static final int L2VPN_AFI = 25;
+ @VisibleForTesting
+ static final int EVPN_SAFI = 70;
@Override
protected List<AutoCloseable> startImpl(final BGPExtensionProviderContext context) {
return regs;
}
- private static void registerAttributesHandler(final BGPExtensionProviderContext context, final List<AutoCloseable> regs) {
- final PMSITunnelAttributeHandler pmsiParser = new PMSITunnelAttributeHandler(context.getAddressFamilyRegistry());
+ private static void registerAttributesHandler(final BGPExtensionProviderContext context,
+ final List<AutoCloseable> regs) {
+ final PMSITunnelAttributeHandler pmsiParser =
+ new PMSITunnelAttributeHandler(context.getAddressFamilyRegistry());
regs.add(context.registerAttributeParser(pmsiParser.getType(), pmsiParser));
regs.add(context.registerAttributeSerializer(pmsiParser.getClazz(), pmsiParser));
}
regs.add(context.registerNlriSerializer(EvpnRoutes.class, nlriHandler));
}
- private static void registerExtendedCommunities(final BGPExtensionProviderContext context, final List<AutoCloseable> regs) {
+ private static void registerExtendedCommunities(final BGPExtensionProviderContext context,
+ final List<AutoCloseable> regs) {
final DefaultGatewayExtCom defGEC = new DefaultGatewayExtCom();
regs.add(context.registerExtendedCommunityParser(defGEC.getType(true), defGEC.getSubType(), defGEC));
regs.add(context.registerExtendedCommunitySerializer(DefaultGatewayExtendedCommunityCase.class, defGEC));
regs.add(context.registerExtendedCommunitySerializer(EsiLabelExtendedCommunityCase.class, esiLEC));
final ESImpRouteTargetExtCom esImpEC = new ESImpRouteTargetExtCom();
- regs.add(context.registerExtendedCommunityParser(esImpEC.getType(true), esImpEC.getSubType(), esImpEC));
+ regs.add(context.registerExtendedCommunityParser(esImpEC.getType(true),
+ esImpEC.getSubType(), esImpEC));
regs.add(context.registerExtendedCommunitySerializer(EsImportRouteExtendedCommunityCase.class, esImpEC));
final MACMobExtCom macEC = new MACMobExtCom();
private static final NodeIdentifier NLRI_ROUTES_LIST = NodeIdentifier.create(EvpnDestination.QNAME);
private EvpnRibSupport() {
- super(EvpnRoutesCase.class, EvpnRoutes.class, EvpnRoute.class, L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, DestinationEvpn.QNAME);
+ super(EvpnRoutesCase.class, EvpnRoutes.class, EvpnRoute.class,
+ L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class, DestinationEvpn.QNAME);
}
static EvpnRibSupport getInstance() {
@Nonnull
@Override
protected DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes) {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.reach.nlri.advertized
- .routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.
- ns.yang.bgp.evpn.rev171213.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination.evpn._case.
- DestinationEvpnBuilder().setEvpnDestination(extractRoutes(routes)).build()).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update
+ .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationEvpnCaseBuilder()
+ .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
+ .rev171213.update.attributes.mp.reach.nlri.advertized.routes.destination.type.destination
+ .evpn._case.DestinationEvpnBuilder().setEvpnDestination(extractRoutes(routes)).build()).build();
}
@Nonnull
@Override
protected DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes) {
- return new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(extractRoutes(routes)).build()).build();
+ return new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder()
+ .setEvpnDestination(extractRoutes(routes)).build()).build();
}
private static List<EvpnDestination> extractRoutes(final Collection<MapEntryNode> routes) {
protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
final ContainerNode destination, final ContainerNode attributes, final ApplyRoute function) {
if (destination != null) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination.getChild(NLRI_ROUTES_LIST);
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = destination
+ .getChild(NLRI_ROUTES_LIST);
if (maybeRoutes.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> routes = maybeRoutes.get();
if (routes instanceof UnkeyedListNode) {
private static void parseMpls(final PmsiTunnelBuilder pmsiTunnelBuilder, final ByteBuf buffer) {
final MplsLabel mpls = MplsLabelUtil.mplsLabelForByteBuf(buffer);
- if(mpls.getValue() != 0) {
+ if (mpls.getValue() != 0) {
pmsiTunnelBuilder.setMplsLabel(mpls);
}
}
}
private static void serializeMpls(final MplsLabel mplsLabel, final ByteBuf body) {
- if(mplsLabel == null) {
+ if (mplsLabel == null) {
body.writeZero(MPLS_LENGTH);
}
body.writeBytes(MplsLabelUtil.byteBufForMplsLabel(mplsLabel));
final class BidirPimTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof BidirPimTree, "The tunnelIdentifier %s is not BidirPimTree type.", tunnelIdentifier);
- PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((BidirPimTree) tunnelIdentifier).getBidirPimTree(), buffer);
+ Preconditions.checkArgument(tunnelIdentifier instanceof BidirPimTree,
+ "The tunnelIdentifier %s is not BidirPimTree type.", tunnelIdentifier);
+ PAddressPMulticastGroupUtil
+ .serializeSenderPMulticastGroup(((BidirPimTree) tunnelIdentifier).getBidirPimTree(), buffer);
return TunnelType.BIDIR_PIM_TREE.getIntValue();
}
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree.
- BidirPimTreeBuilder bidirPimTree = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree.
- BidirPimTreeBuilder(PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(buffer));
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder bidirPimTree =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(PAddressPMulticastGroupUtil
+ .parseSenderPMulticastGroup(buffer));
return new BidirPimTreeBuilder().setBidirPimTree(bidirPimTree.build()).build();
}
}
final class IngressReplicationParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof IngressReplication, "The tunnelIdentifier %s is not IngressReplication type.", tunnelIdentifier);
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication.
- IngressReplication ingressReplication = ((IngressReplication) tunnelIdentifier).getIngressReplication();
+ Preconditions.checkArgument(tunnelIdentifier instanceof IngressReplication,
+ "The tunnelIdentifier %s is not IngressReplication type.", tunnelIdentifier);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.ingress.replication.IngressReplication ingressReplication =
+ ((IngressReplication) tunnelIdentifier).getIngressReplication();
serializeIpAddress(ingressReplication.getReceivingEndpointAddress(), buffer);
return TunnelType.INGRESS_REPLICATION.getIntValue();
}
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier
- .ingress.replication.IngressReplication builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi
- .tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
- .setReceivingEndpointAddress(parseIpAddress(buffer.readableBytes(), buffer)).build();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.ingress.replication.IngressReplication builder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
+ .setReceivingEndpointAddress(parseIpAddress(buffer.readableBytes(), buffer)).build();
return new IngressReplicationBuilder().setIngressReplication(builder).build();
}
}
final class MldpMp2mpLspParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof MldpMp2mpLsp, "The tunnelIdentifier %s is not MldpMp2mpLsp type.", tunnelIdentifier);
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.
- MldpMp2mpLsp mldpMp2mpLsp = ((MldpMp2mpLsp) tunnelIdentifier).getMldpMp2mpLsp();
+ Preconditions.checkArgument(tunnelIdentifier instanceof MldpMp2mpLsp,
+ "The tunnelIdentifier %s is not MldpMp2mpLsp type.", tunnelIdentifier);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp =
+ ((MldpMp2mpLsp) tunnelIdentifier).getMldpMp2mpLsp();
if (!OpaqueUtil.serializeOpaque(mldpMp2mpLsp, buffer)) {
return NO_TUNNEL_INFORMATION_PRESENT;
}
if (opaque == null) {
return null;
}
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.
- MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.
- MldpMp2mpLspBuilder(opaque).build();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();
}
}
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp
- .p2mp.lsp.MldpP2mpLsp mldpP2mpLsp = ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp();
+ Preconditions.checkArgument(tunnelIdentifier instanceof MldpP2mpLsp,
+ "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLsp mldpP2mpLsp =
+ ((MldpP2mpLsp) tunnelIdentifier).getMldpP2mpLsp();
final ByteBuf opaqueValues = Unpooled.buffer();
final int addressFamily = getAddressFamilyValue(mldpP2mpLsp.getAddressFamily());
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp
- .p2mp.lsp.MldpP2mpLspBuilder mldpP2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp
- .p2mp.lsp.MldpP2mpLspBuilder();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder mldpP2mpLsp =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder();
buffer.skipBytes(RESERVED);
- final Class<? extends AddressFamily> addressFamily = this.addressFamilyRegistry.classForFamily(buffer.readUnsignedShort());
+ final Class<? extends AddressFamily> addressFamily = this.addressFamilyRegistry
+ .classForFamily(buffer.readUnsignedShort());
if (addressFamily == null) {
- LOG.debug("Skipping serialization of TunnelIdentifier {}, address family type supported", ByteBufUtil.hexDump(buffer));
+ LOG.debug("Skipping serialization of TunnelIdentifier {}, address family type supported",
+ ByteBufUtil.hexDump(buffer));
return null;
}
mldpP2mpLsp.setAddressFamily(addressFamily);
static boolean serializeOpaque(final Opaque opaque, final ByteBuf byteBuf) {
final Short type = opaque.getOpaqueType();
switch (type) {
- case GENERIC_LSP_IDENTIFIER:
- ByteBufWriteUtil.writeUnsignedByte(type, byteBuf);
- writeGeneric(opaque.getOpaque(), byteBuf);
- break;
- case EXTENDED_TYPE:
- ByteBufWriteUtil.writeUnsignedByte(type, byteBuf);
- writeExtended(opaque.getOpaque(), opaque.getOpaqueExtendedType(), byteBuf);
- break;
- default:
- LOG.debug("Skipping serialization of Opaque Value {}", opaque);
- return false;
+ case GENERIC_LSP_IDENTIFIER:
+ ByteBufWriteUtil.writeUnsignedByte(type, byteBuf);
+ writeGeneric(opaque.getOpaque(), byteBuf);
+ break;
+ case EXTENDED_TYPE:
+ ByteBufWriteUtil.writeUnsignedByte(type, byteBuf);
+ writeExtended(opaque.getOpaque(), opaque.getOpaqueExtendedType(), byteBuf);
+ break;
+ default:
+ LOG.debug("Skipping serialization of Opaque Value {}", opaque);
+ return false;
}
return true;
}
final short type = buffer.readUnsignedByte();
final OpaqueValueBuilder builder = new OpaqueValueBuilder();
switch (type) {
- case GENERIC_LSP_IDENTIFIER:
- builder.setOpaque(buildOpaqueValue(buffer));
- break;
- case EXTENDED_TYPE:
- buildExtended(builder, buffer);
- break;
- default:
- final int length = buffer.readUnsignedShort();
- buffer.skipBytes(length);
- LOG.debug("Skipping parsing of Opaque Value {}", buffer);
- return null;
+ case GENERIC_LSP_IDENTIFIER:
+ builder.setOpaque(buildOpaqueValue(buffer));
+ break;
+ case EXTENDED_TYPE:
+ buildExtended(builder, buffer);
+ break;
+ default:
+ final int length = buffer.readUnsignedShort();
+ buffer.skipBytes(length);
+ LOG.debug("Skipping parsing of Opaque Value {}", buffer);
+ return null;
}
builder.setOpaqueType(type);
return builder.build();
package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
-
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
final class PimSmTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof PimSmTree, "The tunnelIdentifier %s is not PimSmTree type.", tunnelIdentifier);
- PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((PimSmTree) tunnelIdentifier).getPimSmTree(), buffer);
+ Preconditions.checkArgument(tunnelIdentifier instanceof PimSmTree,
+ "The tunnelIdentifier %s is not PimSmTree type.", tunnelIdentifier);
+ PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((PimSmTree) tunnelIdentifier)
+ .getPimSmTree(), buffer);
return TunnelType.PIM_SM_TREE.getIntValue();
}
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree.
- PimSmTreeBuilder pimSmTree = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree.
- PimSmTreeBuilder(PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(buffer));
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder pimSmTree =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder(PAddressPMulticastGroupUtil
+ .parseSenderPMulticastGroup(buffer));
return new PimSmTreeBuilder().setPimSmTree(pimSmTree.build()).build();
}
}
final class PimSsmTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof PimSsmTree, "The tunnelIdentifier %s is not PimSsmTree type.", tunnelIdentifier);
- PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(((PimSsmTree) tunnelIdentifier).getPimSsmTree(), buffer);
+ Preconditions.checkArgument(tunnelIdentifier instanceof PimSsmTree,
+ "The tunnelIdentifier %s is not PimSsmTree type.", tunnelIdentifier);
+ PAddressPMulticastGroupUtil
+ .serializeSenderPMulticastGroup(((PimSsmTree) tunnelIdentifier).getPimSsmTree(), buffer);
return TunnelType.PIM_SSM_TREE.getIntValue();
}
@Override
public TunnelIdentifier parse(final ByteBuf buffer) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree.
- PimSsmTreeBuilder pimSsmTree = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree.
- PimSsmTreeBuilder(PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(buffer));
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder pimSsmTree =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder(PAddressPMulticastGroupUtil
+ .parseSenderPMulticastGroup(buffer));
return new PimSsmTreeBuilder().setPimSsmTree(pimSsmTree.build()).build();
}
}
@Override
public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
- Preconditions.checkArgument(tunnelIdentifier instanceof RsvpTeP2mpLsp, "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
+ Preconditions.checkArgument(tunnelIdentifier instanceof RsvpTeP2mpLsp,
+ "The tunnelIdentifier %s is not RsvpTeP2mpLps type.", tunnelIdentifier);
final RsvpTeP2mpLps rsvpTeP2mpLsp = ((RsvpTeP2mpLsp) tunnelIdentifier).getRsvpTeP2mpLps();
ByteBufWriteUtil.writeUnsignedInt(rsvpTeP2mpLsp.getP2mpId(), buffer);
buffer.writeZero(RESERVED);
private static final Logger LOG = LoggerFactory.getLogger(TunnelIdentifierHandler.class);
private static final String SKIP_SERIALIZATION = "Skipping serialization of PMSI Tunnel Attribute {}";
private static final String SKIP_PARSE = "Skipping parsing of PMSI Tunnel Attribute type {}";
- private final HandlerRegistry<DataContainer, TunnelIdentifierParser, TunnelIdentifierSerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, TunnelIdentifierParser, TunnelIdentifierSerializer> handlers =
+ new HandlerRegistry<>();
public TunnelIdentifierHandler(final AddressFamilyRegistry addressFamilyRegistry) {
final RsvpTeP2MpLspParser rsvpTeP2MpLspParser = new RsvpTeP2MpLspParser();
package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
import io.netty.buffer.ByteBuf;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
interface TunnelIdentifierParser {
/**
* Parse Tunnel Identifier from buffer.
+ *
* @param buffer Encoded Tunnel Identifier in ByteBuf.
* @return Parsed Tunnel Identifier body
*/
- TunnelIdentifier parse(ByteBuf buffer);
+ @Nullable
+ TunnelIdentifier parse(@Nonnull ByteBuf buffer);
}
package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
import io.netty.buffer.ByteBuf;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
interface TunnelIdentifierSerializer {
/**
- * Serialize tunnel identifier
+ * Serialize tunnel identifier.
+ *
* @param tunnelIdentifier Tunnel Identifier body
- * @param buffer Encoded Tunnel Identifier in ByteBuf
+ * @param buffer Encoded Tunnel Identifier in ByteBuf
* @return Tunnel identifier Type
*/
- int serialize(TunnelIdentifier tunnelIdentifier, ByteBuf buffer);
+ int serialize(@Nonnull TunnelIdentifier tunnelIdentifier, @Nonnull ByteBuf buffer);
}
@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
- Preconditions.checkArgument(esi instanceof AsGeneratedCase, "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi.getClass());
+ Preconditions.checkArgument(esi instanceof AsGeneratedCase,
+ "Unknown esi instance. Passed %s. Needed AsGeneratedCase.", esi.getClass());
final AsGenerated asGen = ((AsGeneratedCase) esi).getAsGenerated();
writeUnsignedInt(asGen.getAs().getValue(), body);
writeUnsignedInt(asGen.getLocalDiscriminator(), body);
buffer.writeBytes(body);
}
- protected abstract void serializeBody(final Esi esi, final ByteBuf buffer);
+ protected abstract void serializeBody(Esi esi, ByteBuf buffer);
protected abstract EsiType getType();
}
@Override
public void serializeBody(final Esi esiCase, final ByteBuf body) {
- Preconditions.checkArgument(esiCase instanceof ArbitraryCase, "Unknown esi instance. Passed %s. Needed ArbitraryCase.", esiCase.getClass());
+ Preconditions.checkArgument(esiCase instanceof ArbitraryCase,
+ "Unknown esi instance. Passed %s. Needed ArbitraryCase.", esiCase.getClass());
body.writeBytes(((ArbitraryCase) esiCase).getArbitrary().getArbitrary());
}
@Override
public Esi parseEsi(final ByteBuf body) {
- return new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ByteArray.readBytes(body, ARBITRARY_LENGTH)).build()).build();
+ return new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder()
+ .setArbitrary(ByteArray.readBytes(body, ARBITRARY_LENGTH)).build()).build();
}
}
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
final class EsiModelUtil {
- static final NodeIdentifier LD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "local-discriminator").intern());
- static final NodeIdentifier ARB_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "arbitrary").intern());
- static final NodeIdentifier AS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "as").intern());
- static final NodeIdentifier LACP_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ce-lacp-mac-address").intern());
- static final NodeIdentifier PK_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ce-lacp-port-key").intern());
- static final NodeIdentifier BRIDGE_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "root-bridge-mac-address").intern());
- static final NodeIdentifier RBP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "root-bridge-priority").intern());
- static final NodeIdentifier SYSTEM_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "system-mac-address").intern());
- static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "router-id").intern());
+ static final NodeIdentifier LD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "local-discriminator").intern());
+ static final NodeIdentifier ARB_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "arbitrary").intern());
+ static final NodeIdentifier AS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "as").intern());
+ static final NodeIdentifier LACP_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "ce-lacp-mac-address").intern());
+ static final NodeIdentifier PK_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "ce-lacp-port-key").intern());
+ static final NodeIdentifier BRIDGE_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "root-bridge-mac-address").intern());
+ static final NodeIdentifier RBP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "root-bridge-priority").intern());
+ static final NodeIdentifier SYSTEM_MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "system-mac-address").intern());
+ static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "router-id").intern());
private EsiModelUtil() {
throw new UnsupportedOperationException();
static Arbitrary extractArbitrary(final ContainerNode esi) {
final byte[] arbitrary = (byte[]) esi.getChild(ARB_NID).get().getValue();
- Preconditions.checkArgument(arbitrary.length == ArbitraryParser.ARBITRARY_LENGTH, "Wrong length of array of bytes. Expected: %s Passed: %s " +
- ";", ArbitraryParser.ARBITRARY_LENGTH, arbitrary.length);
+ Preconditions.checkArgument(arbitrary.length == ArbitraryParser.ARBITRARY_LENGTH,
+ "Wrong length of array of bytes. Expected: %s Passed: %s "
+ + ";", ArbitraryParser.ARBITRARY_LENGTH, arbitrary.length);
return new ArbitraryBuilder().setArbitrary(arbitrary).build();
}
@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
- Preconditions.checkArgument(esi instanceof LacpAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi.getClass());
+ Preconditions.checkArgument(esi instanceof LacpAutoGeneratedCase,
+ "Unknown esi instance. Passed %s. Needed LacpAutoGeneratedCase.", esi.getClass());
final LacpAutoGenerated lacp = ((LacpAutoGeneratedCase) esi).getLacpAutoGenerated();
body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lacp.getCeLacpMacAddress()));
ByteBufWriteUtil.writeUnsignedShort(lacp.getCeLacpPortKey(), body);
@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
- Preconditions.checkArgument(esi instanceof LanAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed LanAutoGeneratedCase.", esi.getClass());
+ Preconditions.checkArgument(esi instanceof LanAutoGeneratedCase,
+ "Unknown esi instance. Passed %s. Needed LanAutoGeneratedCase.", esi.getClass());
final LanAutoGenerated lan = ((LanAutoGeneratedCase) esi).getLanAutoGenerated();
body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(lan.getRootBridgeMacAddress()));
ByteBufWriteUtil.writeUnsignedShort(lan.getRootBridgePriority(), body);
@Override
public Esi parseEsi(final ByteBuf buffer) {
final LanAutoGenerated t2 = new LanAutoGeneratedBuilder()
- .setRootBridgeMacAddress(IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
+ .setRootBridgeMacAddress(IetfYangUtil.INSTANCE
+ .macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH)))
.setRootBridgePriority(buffer.readUnsignedShort()).build();
return new LanAutoGeneratedCaseBuilder().setLanAutoGenerated(t2).build();
}
@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
- Preconditions.checkArgument(esi instanceof MacAutoGeneratedCase, "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass());
+ Preconditions.checkArgument(esi instanceof MacAutoGeneratedCase,
+ "Unknown esi instance. Passed %s. Needed MacAutoGeneratedCase.", esi.getClass());
final MacAutoGenerated macAuto = ((MacAutoGeneratedCase) esi).getMacAutoGenerated();
body.writeBytes(IetfYangUtil.INSTANCE.bytesFor(macAuto.getSystemMacAddress()));
ByteBufWriteUtil.writeMedium(macAuto.getLocalDiscriminator().getValue().intValue(), body);
@Override
public void serializeBody(final Esi esi, final ByteBuf body) {
- Preconditions.checkArgument(esi instanceof RouterIdGeneratedCase, "Unknown esi instance. Passed %s. Needed RouterIdGeneratedCase.", esi.getClass());
+ Preconditions.checkArgument(esi instanceof RouterIdGeneratedCase,
+ "Unknown esi instance. Passed %s. Needed RouterIdGeneratedCase.", esi.getClass());
final RouterIdGenerated routerID = ((RouterIdGeneratedCase) esi).getRouterIdGenerated();
ByteBufWriteUtil.writeIpv4Address(routerID.getRouterId(), body);
ByteBufWriteUtil.writeUnsignedInt(routerID.getLocalDiscriminator(), body);
@Override
public Esi parseEsi(final ByteBuf buffer) {
- final RouterIdGenerated routerID = new RouterIdGeneratedBuilder().setRouterId(Ipv4Util.addressForByteBuf(buffer))
+ final RouterIdGenerated routerID = new RouterIdGeneratedBuilder()
+ .setRouterId(Ipv4Util.addressForByteBuf(buffer))
.setLocalDiscriminator(buffer.readUnsignedInt()).build();
return new RouterIdGeneratedCaseBuilder().setRouterIdGenerated(routerID).build();
}
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
-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.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
private static final int MAC_ADDRESS_LENGTH = 6;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
final MacAddress mac = IetfYangUtil.INSTANCE.macAddressFor(ByteArray.readBytes(buffer, MAC_ADDRESS_LENGTH));
return new EsImportRouteExtendedCommunityCaseBuilder().setEsImportRouteExtendedCommunity(
- new EsImportRouteExtendedCommunityBuilder().setEsImport(mac).build()).build();
+ new EsImportRouteExtendedCommunityBuilder().setEsImport(mac).build()).build();
}
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof EsImportRouteExtendedCommunityCase,
- "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity);
- final EsImportRouteExtendedCommunity extCom = ((EsImportRouteExtendedCommunityCase) extendedCommunity).getEsImportRouteExtendedCommunity();
+ "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.",
+ extendedCommunity);
+ final EsImportRouteExtendedCommunity extCom = ((EsImportRouteExtendedCommunityCase) extendedCommunity)
+ .getEsImportRouteExtendedCommunity();
byteAggregator.writeBytes(IetfYangUtil.INSTANCE.bytesFor(extCom.getEsImport()));
}
import com.google.common.base.Preconditions;
import com.google.common.primitives.UnsignedBytes;
import io.netty.buffer.ByteBuf;
-import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.protocol.util.BitArray;
import org.opendaylight.protocol.util.ByteBufWriteUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NormalizationType;
private static final int THREE_BITS_SHIFT = 3;
private static final int FIVE_BITS_SHIFT = 5;
+ private static short getFlagShort(final BitArray flags, final int index) {
+ short opMode = 0;
+ opMode |= flags.get(index + 1) ? 1 : 0;
+ opMode |= (flags.get(index) ? 1 : 0) << 1;
+ return opMode;
+ }
+
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) {
final Layer2AttributesExtendedCommunityBuilder builder = new Layer2AttributesExtendedCommunityBuilder();
final BitArray flags = BitArray.valueOf(body, FLAGS_SIZE);
builder.setBackupPe(flags.get(BACKUP_PE_OFFSET));
builder.setL2Mtu(body.readUnsignedShort());
body.skipBytes(RESERVED);
return new Layer2AttributesExtendedCommunityCaseBuilder()
- .setLayer2AttributesExtendedCommunity(builder.build()).build();
- }
-
- private static short getFlagShort(final BitArray flags, final int index) {
- short opMode= 0;
- opMode |= flags.get(index + 1) ? 1 : 0;
- opMode |= (flags.get(index) ? 1 : 0) << 1;
- return opMode;
+ .setLayer2AttributesExtendedCommunity(builder.build()).build();
}
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof Layer2AttributesExtendedCommunityCase,
- "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.", extendedCommunity);
- final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity).getLayer2AttributesExtendedCommunity();
+ "The extended community %s is not EsImportRouteExtendedCommunityCaseCase type.",
+ extendedCommunity);
+ final Layer2AttributesExtendedCommunity extCom = ((Layer2AttributesExtendedCommunityCase) extendedCommunity)
+ .getLayer2AttributesExtendedCommunity();
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(PRIMARY_PE_OFFSET, extCom.isPrimaryPe());
flags.set(BACKUP_PE_OFFSET, extCom.isBackupPe());
final byte[] res = flags.array();
byte aux = 0;
final OperationalMode modeOfOperation = extCom.getModeOfOperation();
- if ( modeOfOperation != null) {
+ if (modeOfOperation != null) {
aux = UnsignedBytes.checkedCast(modeOfOperation.getIntValue());
aux = (byte) (aux << THREE_BITS_SHIFT);
- res[res.length -1] = (byte) (res[res.length -1] | aux);
+ res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
final NormalizationType normalizationType = extCom.getOperatingPer();
- if ( normalizationType != null) {
+ if (normalizationType != null) {
aux = UnsignedBytes.checkedCast(normalizationType.getIntValue());
aux = (byte) (aux << FIVE_BITS_SHIFT);
- res[res.length -1] = (byte) (res[res.length -1] | aux);
+ res[res.length - 1] = (byte) (res[res.length - 1] | aux);
}
ByteBufWriteUtil.writeUnsignedShort((int) res[res.length - 1], body);
ByteBufWriteUtil.writeUnsignedShort(extCom.getL2Mtu(), body);
protected abstract NlriType getType();
- protected abstract ByteBuf serializeBody(final EvpnChoice evpn);
+ protected abstract ByteBuf serializeBody(EvpnChoice evpn);
protected static Esi serializeEsi(final ContainerNode evpn) {
return SimpleEsiTypeRegistry.getInstance().parseEsiModel((ChoiceNode) evpn.getChild(ESI_NID).get());
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
final class EthADRParser extends AbstractEvpnNlri {
- protected static final NodeIdentifier ETH_AD_ROUTE_NID = new NodeIdentifier(EthernetADRoute.QNAME);
+ static final NodeIdentifier ETH_AD_ROUTE_NID = new NodeIdentifier(EthernetADRoute.QNAME);
private static final int CONTENT_LENGTH = 17;
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
- Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, "Wrong length of array of bytes. Passed: %s ;", buffer);
+ Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH,
+ "Wrong length of array of bytes. Passed: %s ;", buffer);
final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
final MplsLabel label = mplsLabelForByteBuf(buffer);
- final EthernetADRouteBuilder builder = new EthernetADRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMplsLabel(label);
+ final EthernetADRouteBuilder builder = new EthernetADRouteBuilder()
+ .setEsi(esi).setEthernetTagId(eti).setMplsLabel(label);
return new EthernetADRouteCaseBuilder().setEthernetADRoute(builder.build()).build();
}
}
@Override
- public ByteBuf serializeBody(final EvpnChoice evpn) {
- Preconditions.checkArgument(evpn instanceof EthernetADRouteCase, "Unknown evpn instance. Passed %s. Needed EthernetADRouteCase.", evpn.getClass());
- return serializeBody(((EthernetADRouteCase) evpn).getEthernetADRoute());
+ public ByteBuf serializeBody(final EvpnChoice evpnChoice) {
+ Preconditions.checkArgument(evpnChoice instanceof EthernetADRouteCase,
+ "Unknown evpn instance. Passed %s. Needed EthernetADRouteCase.", evpnChoice.getClass());
+
+ final EthernetADRoute evpn = ((EthernetADRouteCase) evpnChoice).getEthernetADRoute();
+ final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
+ SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
+ ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
+
+ final MplsLabel mpls = evpn.getMplsLabel();
+ if (mpls != null) {
+ body.writeBytes(byteBufForMplsLabel(evpn.getMplsLabel()));
+ }
+ return body;
}
@Override
builder.setEthernetTagId(extractETI(evpn));
return builder;
}
-
- private static ByteBuf serializeBody(final EthernetADRoute evpn) {
- final ByteBuf body = Unpooled.buffer(CONTENT_LENGTH);
- SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
- ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
-
- final MplsLabel mpls = evpn.getMplsLabel();
- if (mpls != null) {
- body.writeBytes(byteBufForMplsLabel(evpn.getMplsLabel()));
- }
- return body;
- }
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
final class EthSegRParser extends AbstractEvpnNlri {
- protected static final NodeIdentifier ES_ROUTE_NID = new NodeIdentifier(EsRoute.QNAME);
+ static final NodeIdentifier ES_ROUTE_NID = new NodeIdentifier(EsRoute.QNAME);
private static final int CONTENT_LENGTH = 15;
private static final int CONTENT_LENGTH2 = 27;
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
- Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH || buffer.readableBytes() == CONTENT_LENGTH2,
+ Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH
+ || buffer.readableBytes() == CONTENT_LENGTH2,
"Wrong length of array of bytes. Passed: %s ;", buffer);
final Esi esi = SimpleEsiTypeRegistry.getInstance().parseEsi(buffer.readSlice(ESI_SIZE));
@Override
public ByteBuf serializeBody(final EvpnChoice evpnInput) {
- Preconditions.checkArgument(evpnInput instanceof EsRouteCase, "Unknown evpn instance. Passed %s. Needed EsRouteCase.",
- evpnInput.getClass());
- return serializeBody(((EsRouteCase) evpnInput).getEsRoute());
+ Preconditions.checkArgument(evpnInput instanceof EsRouteCase,
+ "Unknown evpn instance. Passed %s. Needed EsRouteCase.", evpnInput.getClass());
+ final EsRoute evpn = ((EsRouteCase) evpnInput).getEsRoute();
+ final ByteBuf body = Unpooled.buffer();
+ SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
+ final ByteBuf orig = serializeOrigRouteIp(evpn.getOrigRouteIp());
+ Preconditions.checkArgument(orig.readableBytes() > 0);
+ body.writeBytes(orig);
+ return body;
}
@Override
return new EsRouteCaseBuilder().setEsRoute(builder.build()).build();
}
- private static ByteBuf serializeBody(final EsRoute evpn) {
- final ByteBuf body = Unpooled.buffer();
- SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
- final ByteBuf orig = serializeOrigRouteIp(evpn.getOrigRouteIp());
- Preconditions.checkArgument(orig.readableBytes() > 0);
- body.writeBytes(orig);
- return body;
- }
-
- public static IpAddress parseOrigRouteIp(final ByteBuf buffer) {
+ static IpAddress parseOrigRouteIp(final ByteBuf buffer) {
final int ipLength = buffer.readUnsignedByte();
if (ipLength == Ipv6Util.IPV6_BITS_LENGTH) {
return new IpAddress(Ipv6Util.addressForByteBuf(buffer));
return extractDestination(evpnChoice, EvpnRegistry::serializeEvpnModel);
}
- private static EvpnDestination extractDestination(final DataContainerNode<? extends PathArgument> evpnChoice, final ExtractionInterface extract) {
+ private static EvpnDestination extractDestination(final DataContainerNode<? extends PathArgument> evpnChoice,
+ final ExtractionInterface extract) {
final EvpnRegistry reg = SimpleEvpnNlriRegistry.getInstance();
final ChoiceNode cont = (ChoiceNode) evpnChoice.getChild(EVPN_CHOICE_NID).get();
final EvpnChoice evpnValue = extract.check(reg, cont);
LOG.warn("Unrecognized Nlri {}", cont);
return null;
}
- return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(evpnChoice)).setEvpnChoice(evpnValue).build();
+ return new EvpnDestinationBuilder().setRouteDistinguisher(extractRouteDistinguisher(evpnChoice))
+ .setEvpnChoice(evpnValue).build();
}
- public static EvpnDestination extractRouteKeyDestination(final DataContainerNode<? extends PathArgument> evpnChoice) {
+ public static EvpnDestination extractRouteKeyDestination(
+ final DataContainerNode<? extends PathArgument> evpnChoice) {
return extractDestination(evpnChoice, EvpnRegistry::serializeEvpnRouteKey);
}
final List<EvpnDestination> dst = parseNlri(nlri);
builder.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.
- routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.
- yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder()
- .setEvpnDestination(dst).build()).build()).build());
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes
+ .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder()
+ .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
+ .rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination
+ .evpn._case.DestinationEvpnBuilder().setEvpnDestination(dst).build()).build()).build());
}
@Override
final List<EvpnDestination> dst = parseNlri(nlri);
builder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
- new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(dst).build()).build()).build());
+ new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder()
+ .setEvpnDestination(dst).build()).build()).build());
}
@Nullable
} else if (pathAttributes2 != null) {
final MpUnreachNlri mpUnreachNlri = pathAttributes2.getMpUnreachNlri();
final WithdrawnRoutes withdrawnRoutes = mpUnreachNlri.getWithdrawnRoutes();
- if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
- .ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.
- routes.destination.type.DestinationEvpnCase evpnCase = (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
- .ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
+ if (withdrawnRoutes != null && withdrawnRoutes.getDestinationType()
+ instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213
+ .update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase) {
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase evpnCase =
+ (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationEvpnCase) mpUnreachNlri.getWithdrawnRoutes().getDestinationType();
serializeNlri(evpnCase.getDestinationEvpn().getEvpnDestination(), byteAggregator);
}
}
}
- public static void serializeNlri(final List<EvpnDestination> cEvpn, final ByteBuf output) {
+ public static void serializeNlri(final List<EvpnDestination> destinationList, final ByteBuf output) {
ByteBuf nlriOutput = null;
- for (final EvpnDestination dest : cEvpn) {
+ for (final EvpnDestination dest : destinationList) {
final ByteBuf nlriCommon = Unpooled.buffer();
serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriCommon);
nlriOutput = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(dest.getEvpnChoice(), nlriCommon);
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
final class IncMultEthTagRParser extends AbstractEvpnNlri {
- protected static final NodeIdentifier INC_MULT_ROUTE_NID = new NodeIdentifier(IncMultiEthernetTagRes.QNAME);
+ static final NodeIdentifier INC_MULT_ROUTE_NID = new NodeIdentifier(IncMultiEthernetTagRes.QNAME);
private static final int CONTENT_LENGTH = 9;
private static final int CONTENT_LENGTH2 = 21;
+ private static EvpnChoice serializeModel(final ContainerNode evpn) {
+ final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder();
+ builder.setEthernetTagId(extractETI(evpn));
+ builder.setOrigRouteIp(extractOrigRouteIp(evpn));
+ return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build();
+ }
+
@Override
public EvpnChoice parseEvpn(final ByteBuf buffer) {
- Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH || buffer.readableBytes() == CONTENT_LENGTH2,
- "Wrong length of array of bytes. Passed: %s ;", buffer);
+ Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH
+ || buffer.readableBytes() == CONTENT_LENGTH2,
+ "Wrong length of array of bytes. Passed: %s ;", buffer);
final EthernetTagId eti = new EthernetTagIdBuilder().setVlanId(buffer.readUnsignedInt()).build();
IpAddress ip = requireNonNull(EthSegRParser.parseOrigRouteIp(buffer));
- final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder().setEthernetTagId(eti).setOrigRouteIp(ip);
+ final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder()
+ .setEthernetTagId(eti).setOrigRouteIp(ip);
return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build();
}
}
@Override
- public ByteBuf serializeBody(final EvpnChoice evpn) {
- Preconditions.checkArgument(evpn instanceof IncMultiEthernetTagResCase, "Unknown evpn instance. Passed %s. Needed IncMultiEthernetTagResCase.",
- evpn.getClass());
- return serializeBody(((IncMultiEthernetTagResCase) evpn).getIncMultiEthernetTagRes());
+ public ByteBuf serializeBody(final EvpnChoice evpnChoice) {
+ Preconditions.checkArgument(evpnChoice instanceof IncMultiEthernetTagResCase,
+ "Unknown evpn instance. Passed %s. Needed IncMultiEthernetTagResCase.",
+ evpnChoice.getClass());
+
+ final IncMultiEthernetTagRes evpn = ((IncMultiEthernetTagResCase) evpnChoice).getIncMultiEthernetTagRes();
+ final ByteBuf body = Unpooled.buffer();
+ ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
+ final ByteBuf orig = EthSegRParser.serializeOrigRouteIp(evpn.getOrigRouteIp());
+ Preconditions.checkArgument(orig.readableBytes() > 0);
+ body.writeBytes(orig);
+ return body;
}
@Override
public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
- return createRouteKey(evpn);
+ return serializeModel(evpn);
}
@Override
public EvpnChoice createRouteKey(final ContainerNode evpn) {
- final IncMultiEthernetTagResBuilder builder = new IncMultiEthernetTagResBuilder();
- builder.setEthernetTagId(extractETI(evpn));
- builder.setOrigRouteIp(extractOrigRouteIp(evpn));
- return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(builder.build()).build();
- }
-
- private static ByteBuf serializeBody(final IncMultiEthernetTagRes evpn) {
- final ByteBuf body = Unpooled.buffer();
- ByteBufWriteUtil.writeUnsignedInt(evpn.getEthernetTagId().getVlanId(), body);
- final ByteBuf orig = EthSegRParser.serializeOrigRouteIp(evpn.getOrigRouteIp());
- Preconditions.checkArgument(orig.readableBytes() > 0);
- body.writeBytes(orig);
- return body;
+ return serializeModel(evpn);
}
}
} else {
label2 = null;
}
- final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti).setMacAddress(mac).setIpAddress(ip)
+ final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder().setEsi(esi).setEthernetTagId(eti)
+ .setMacAddress(mac).setIpAddress(ip)
.setMplsLabel1(label1).setMplsLabel2(label2);
return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
}
}
@Override
- public ByteBuf serializeBody(final EvpnChoice evpn) {
- Preconditions.checkArgument(evpn instanceof MacIpAdvRouteCase, "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpn.getClass());
- return serializeBody((MacIpAdvRouteCase) evpn);
- }
-
- @Override
- public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
- final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn);
- builder.setEsi(serializeEsi(evpn));
- builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID));
- builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID));
- return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
- }
-
- @Override
- public EvpnChoice createRouteKey(final ContainerNode evpn) {
- return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(serializeKeyModel(evpn).build()).build();
- }
-
- private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) {
- final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder();
- builder.setEthernetTagId(extractETI(evpn));
- builder.setMacAddress(extractMAC(evpn));
- builder.setIpAddress(extractIp(evpn));
- return builder;
- }
+ public ByteBuf serializeBody(final EvpnChoice evpnChoice) {
+ Preconditions.checkArgument(evpnChoice instanceof MacIpAdvRouteCase,
+ "Unknown evpn instance. Passed %s. Needed MacIpAdvRouteCase.", evpnChoice.getClass());
- private static ByteBuf serializeBody(final MacIpAdvRouteCase evpnCase) {
final ByteBuf body = Unpooled.buffer();
- final MacIpAdvRoute evpn = evpnCase.getMacIpAdvRoute();
+ final MacIpAdvRoute evpn = ((MacIpAdvRouteCase) evpnChoice).getMacIpAdvRoute();
final Esi esi = evpn.getEsi();
if (esi != null) {
SimpleEsiTypeRegistry.getInstance().serializeEsi(evpn.getEsi(), body);
return body;
}
+ @Override
+ public EvpnChoice serializeEvpnModel(final ContainerNode evpn) {
+ final MacIpAdvRouteBuilder builder = serializeKeyModel(evpn);
+ builder.setEsi(serializeEsi(evpn));
+ builder.setMplsLabel1(extractMplsLabel(evpn, MPLS1_NID));
+ builder.setMplsLabel2(extractMplsLabel(evpn, MPLS2_NID));
+ return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(builder.build()).build();
+ }
+
+ @Override
+ public EvpnChoice createRouteKey(final ContainerNode evpn) {
+ return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(serializeKeyModel(evpn).build()).build();
+ }
+
+ private static MacIpAdvRouteBuilder serializeKeyModel(final ContainerNode evpn) {
+ final MacIpAdvRouteBuilder builder = new MacIpAdvRouteBuilder();
+ builder.setEthernetTagId(extractETI(evpn));
+ builder.setMacAddress(extractMAC(evpn));
+ builder.setIpAddress(extractIp(evpn));
+ return builder;
+ }
+
private static ByteBuf serializeIp(final IpAddress ipAddress) {
final ByteBuf body = Unpooled.buffer();
if (ipAddress != null) {
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
final class NlriModelUtil {
- static final NodeIdentifier ETI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ethernet-tag-id").intern());
- static final NodeIdentifier VLAN_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "vlan-id").intern());
- static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "route-distinguisher").intern());
- static final NodeIdentifier ORI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "orig-route-ip").intern());
- static final NodeIdentifier MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mac-address").intern());
- static final NodeIdentifier IP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "ip-address").intern());
- static final NodeIdentifier MPLS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mpls-label").intern());
- static final NodeIdentifier MPLS1_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mpls-label1").intern());
- static final NodeIdentifier MPLS2_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME, "mpls-label2").intern());
+ static final NodeIdentifier ETI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "ethernet-tag-id").intern());
+ static final NodeIdentifier VLAN_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "vlan-id").intern());
+ static final NodeIdentifier RD_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "route-distinguisher").intern());
+ static final NodeIdentifier ORI_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "orig-route-ip").intern());
+ static final NodeIdentifier MAC_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "mac-address").intern());
+ static final NodeIdentifier IP_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "ip-address").intern());
+ static final NodeIdentifier MPLS_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "mpls-label").intern());
+ static final NodeIdentifier MPLS1_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "mpls-label1").intern());
+ static final NodeIdentifier MPLS2_NID = NodeIdentifier.create(QName.create(EvpnChoice.QNAME,
+ "mpls-label2").intern());
private NlriModelUtil() {
throw new UnsupportedOperationException();
return null;
}
- static MplsLabel extractMplsLabel(final DataContainerNode<? extends PathArgument> evpn, final NodeIdentifier mplsNid) {
+ static MplsLabel extractMplsLabel(final DataContainerNode<? extends PathArgument> evpn,
+ final NodeIdentifier mplsNid) {
if (evpn.getChild(mplsNid).isPresent()) {
return new MplsLabel((Long) evpn.getChild(mplsNid).get().getValue());
}
public interface EsiParser {
/**
- * Parse Ethernet Segment Identifier
+ * Parse Ethernet Segment Identifier.
*
* @param buffer encoded ESI body in Bytebuf
* @return Ethernet Segment Identifier
import io.netty.buffer.ByteBuf;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.esi.Esi;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
public interface EsiRegistry {
/**
- * Parse Esi
+ * Parse Esi.
*
* @param buffer encoded ESI body in Bytebuf
* @return Ethernet Segment Identifier
*/
- @Nonnull
+ @Nullable
Esi parseEsi(@Nonnull ByteBuf buffer);
/**
- * Parse Esi Model
+ * Parse Esi Model.
*
* @param esi ChoiceNode containing ESI
* @return Ethernet Segment Identifier
*/
- @Nonnull
+ @Nullable
Esi parseEsiModel(@Nonnull ChoiceNode esi);
/**
- * Serialize Esi
+ * Serialize Esi.
*
* @param esi Ethernet Segment Identifier
* @param buffer write in Bytebuf encoded ESI body
public interface EsiSerializer {
/**
- * Serialize Ethernet Segment Identifier
+ * Serialize Ethernet Segment Identifier.
*
* @param esi Ethernet Segment Identifier
* @param buffer write in Bytebuf encoded ESI body
void serializeEsi(@Nonnull Esi esi, @Nonnull ByteBuf buffer);
/**
- * Serialize Ethernet Segment Identifier Model
+ * Serialize Ethernet Segment Identifier Model.
*
* @param esi Ethernet Segment Identifier Model
* @return Ethernet Segment Identifier
@Nullable EvpnChoice parseEvpn(@Nonnull NlriType type, @Nonnull ByteBuf buffer);
/**
- * Encode input BGP Evpn to output buffer
+ * Encode input BGP Evpn to output buffer.
*
* @param evpn EvpnChoice
* @param common encoded common Evpn
* @param evpnChoice ChoiceNode containing Evpn
* @return EvpnChoice
*/
- @Nonnull EvpnChoice serializeEvpnModel(@Nonnull ChoiceNode evpnChoice);
+ @Nullable EvpnChoice serializeEvpnModel(@Nonnull ChoiceNode evpnChoice);
/**
- * Create Route key from Evpn model
+ * Create Route key from Evpn model.
*
* @param evpnChoice ChoiceNode containing Evpn
* @return EvpnChoice
*/
- @Nonnull EvpnChoice serializeEvpnRouteKey(@Nonnull ChoiceNode evpnChoice);
+ @Nullable EvpnChoice serializeEvpnRouteKey(@Nonnull ChoiceNode evpnChoice);
}
public interface EvpnSerializer {
/**
+ * Serialize Evpn.
+ *
* @param evpn Evpn
* @param buffer Encode common Evpn parts to output buffer
* @return Encode Evpn to output buffer
ByteBuf serializeEvpn(@Nonnull EvpnChoice evpn, @Nonnull ByteBuf buffer);
/**
- * Serialize Evpn
+ * Serialize Evpn Model.
*
* @param evpn ChoiceNode containing Evpn
* @return Evpn
EvpnChoice serializeEvpnModel(@Nonnull ContainerNode evpn);
/**
- * create Route key from Evpn model
+ * create Route key from Evpn model.
*
* @param evpn ContainerNode containing Evpn
* @return Evpn
return this.handlers.registerSerializer(esiType, serializer);
}
- public AutoCloseable registerEsiModelSerializer(final QName qName, final EsiSerializer serializer) {
- return this.modelHandlers.register(new NodeIdentifier(qName), serializer);
+ public AutoCloseable registerEsiModelSerializer(final QName qname, final EsiSerializer serializer) {
+ return this.modelHandlers.register(new NodeIdentifier(qname), serializer);
}
@Override
public Esi parseEsi(final ByteBuf buffer) {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
- Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH, "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
+ Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ "Array of bytes is mandatory. Can't be null or empty.");
+ Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH,
+ "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ";");
final EsiParser parser = this.handlers.getParser(EsiType.forValue(buffer.readByte()).getIntValue());
if (parser == null) {
@Override
public Esi parseEsiModel(final ChoiceNode esiChoice) {
- Preconditions.checkArgument(esiChoice != null && !esiChoice.getValue().isEmpty(), "ESI is mandatory. Can't be null or empty.");
+ Preconditions.checkArgument(esiChoice != null && !esiChoice.getValue().isEmpty(),
+ "ESI is mandatory. Can't be null or empty.");
final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(esiChoice.getValue());
final EsiSerializer serializer = this.modelHandlers.get(cont.getIdentifier());
if (serializer != null) {
return this.handlers.registerParser(esiType.getIntValue(), parser);
}
- public AutoCloseable registerNlriSerializer(final Class<? extends EvpnChoice> evpnClass, final EvpnSerializer serializer) {
+ public AutoCloseable registerNlriSerializer(final Class<? extends EvpnChoice> evpnClass,
+ final EvpnSerializer serializer) {
return this.handlers.registerSerializer(evpnClass, serializer);
}
- public AutoCloseable registerNlriModelSerializer(final QName qName, final EvpnSerializer serializer) {
- return this.modelHandlers.register(new NodeIdentifier(qName), serializer);
+ public AutoCloseable registerNlriModelSerializer(final QName qname, final EvpnSerializer serializer) {
+ return this.modelHandlers.register(new NodeIdentifier(qname), serializer);
}
@Override
public EvpnChoice parseEvpn(final NlriType type, final ByteBuf buffer) {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
+ Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ "Array of bytes is mandatory. Can't be null or empty.");
final EvpnParser parser = this.handlers.getParser(type.getIntValue());
if (parser == null) {
return null;
}
private EvpnChoice getEvpnCase(final ChoiceNode evpnChoice, final SerializerInterface serializerInterface) {
- Preconditions.checkArgument(evpnChoice != null && !evpnChoice.getValue().isEmpty(), "Evpn case is mandatory. Can't be null or empty.");
+ Preconditions.checkArgument(evpnChoice != null && !evpnChoice.getValue().isEmpty(),
+ "Evpn case is mandatory. Can't be null or empty.");
final ContainerNode cont = (ContainerNode) Iterables.getOnlyElement(evpnChoice.getValue());
final EvpnSerializer serializer = this.modelHandlers.get(cont.getIdentifier());
if (serializer == null) {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import static org.opendaylight.protocol.bgp.evpn.impl.BGPActivator.EVPN_SAFI;
+import static org.opendaylight.protocol.bgp.evpn.impl.BGPActivator.L2VPN_AFI;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
public void testActivator() throws Exception {
final BGPActivator act = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
- assertNull(context.getAddressFamilyRegistry().classForFamily(25));
- assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(70));
+ assertNull(context.getAddressFamilyRegistry().classForFamily(L2VPN_AFI));
+ assertNull(context.getSubsequentAddressFamilyRegistry().classForFamily(EVPN_SAFI));
act.start(context);
- assertEquals(L2vpnAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(25));
- assertEquals(EvpnSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry().classForFamily(70));
+ assertEquals(L2vpnAddressFamily.class, context.getAddressFamilyRegistry().classForFamily(L2VPN_AFI));
+ assertEquals(EvpnSubsequentAddressFamily.class, context.getSubsequentAddressFamilyRegistry()
+ .classForFamily(EVPN_SAFI));
act.close();
}
}
\ No newline at end of file
*/
package org.opendaylight.protocol.bgp.evpn.impl;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD;
private static final EvpnRibSupport RIB_SUPPORT = EvpnRibSupport.getInstance();
private static final EvpnRoute ROUTE;
private static final EvpnRouteKey ROUTE_KEY;
- private static final EvpnDestination EVPN_DESTINATION = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build();
- private static final DestinationEvpnCase REACH_NLRI = new DestinationEvpnCaseBuilder().setDestinationEvpn(new DestinationEvpnBuilder()
- .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build();
- private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase UNREACH_NLRI =
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.
- DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.
- DestinationEvpnBuilder().setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build();
+ private static final EvpnDestination EVPN_DESTINATION = new EvpnDestinationBuilder().setRouteDistinguisher(RD)
+ .setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build();
+ private static final DestinationEvpnCase REACH_NLRI = new DestinationEvpnCaseBuilder()
+ .setDestinationEvpn(new DestinationEvpnBuilder()
+ .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build();
+ private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase UNREACH_NLRI =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes
+ .mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder()
+ .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
+ .rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.evpn._case.DestinationEvpnBuilder()
+ .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build();
private static final EvpnRoutes EVPN_ROUTES;
+
static {
final BGPActivator act = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
final ByteBuf buffer = Unpooled.buffer();
- EvpnNlriParser.serializeNlri(Collections.singletonList(new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE_KEY).build()), buffer);
+ EvpnNlriParser.serializeNlri(Collections.singletonList(new EvpnDestinationBuilder()
+ .setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE_KEY).build()), buffer);
ROUTE_KEY = new EvpnRouteKey(ByteArray.encodeBase64(buffer));
- ROUTE = new EvpnRouteBuilder().setRouteKey(ROUTE_KEY.getRouteKey()).setAttributes(ATTRIBUTES).setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build();
+ ROUTE = new EvpnRouteBuilder().setRouteKey(ROUTE_KEY.getRouteKey())
+ .setAttributes(ATTRIBUTES).setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build();
EVPN_ROUTES = new EvpnRoutesBuilder().setEvpnRoute(Collections.singletonList(ROUTE)).build();
}
@Test
public void testDeleteRoutes() {
RIB_SUPPORT.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<EvpnRoute> instanceIdentifier = (InstanceIdentifier<EvpnRoute>) this.deletedRoutes.get(0);
+ @SuppressWarnings("unchecked") final InstanceIdentifier<EvpnRoute> instanceIdentifier =
+ (InstanceIdentifier<EvpnRoute>) this.deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(EvpnRoute.class));
}
@Test
public void testEmptyRoute() throws Exception {
- final Routes empty = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().setEvpnRoute(Collections.emptyList()).build()).build();
+ final Routes empty = new EvpnRoutesCaseBuilder().setEvpnRoutes(
+ new EvpnRoutesBuilder().setEvpnRoute(Collections.emptyList()).build()).build();
final ChoiceNode emptyRoutes = RIB_SUPPORT.emptyRoutes();
assertEquals(createRoutes(empty), emptyRoutes);
}
@Test
public void testBuildMpUnreachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(Collections.emptyList(), createRoutes(EVPN_ROUTES), ATTRIBUTES);
- assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
+ assertEquals(UNREACH_NLRI, update.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri()
+ .getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes1.class));
}
@Test
public void testBuildMpReachNlriUpdate() {
final Update update = RIB_SUPPORT.buildUpdate(createRoutes(EVPN_ROUTES), Collections.emptyList(), ATTRIBUTES);
- assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri().getAdvertizedRoutes().getDestinationType());
+ assertEquals(REACH_NLRI, update.getAttributes().getAugmentation(Attributes1.class).getMpReachNlri()
+ .getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().getAugmentation(Attributes2.class));
}
@Test
public void testCacheableNlriObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), RIB_SUPPORT.cacheableAttributeObjects());
}
@Test
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(EVPN_ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii),
+ RIB_SUPPORT.routePath(getTablePath().node(Routes.QNAME), prefixNii));
}
@Test
public void testExtractPathId() {
- Assert.assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null));
+ assertEquals((Long) NON_PATH_ID, RIB_SUPPORT.extractPathId(null));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(EvpnRoutes.QNAME, Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT
- .routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(EvpnRoutes.QNAME,
+ Attributes.QNAME.getLocalName().intern())), RIB_SUPPORT.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(EvpnRoutesCase.class, RIB_SUPPORT.routesCaseClass());
+ assertEquals(EvpnRoutesCase.class, RIB_SUPPORT.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(EvpnRoutes.class, RIB_SUPPORT.routesContainerClass());
+ assertEquals(EvpnRoutes.class, RIB_SUPPORT.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(EvpnRoute.class, RIB_SUPPORT.routesListClass());
+ assertEquals(EvpnRoute.class, RIB_SUPPORT.routesListClass());
}
@Test
public void testChangedRoutes() {
final Routes emptyCase = new EvpnRoutesCaseBuilder().build();
- DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyCase)).getRootNode();
+ DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
+ createRoutes(emptyCase)).getRootNode();
Assert.assertTrue(RIB_SUPPORT.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().build()).build();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisher;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.RouteDistinguisherBuilder;
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.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeSchemaAwareBuilder;
public static final String RD_MODEL = "1.2.3.4:258";
public static final RouteDistinguisher RD = RouteDistinguisherBuilder.getDefaultInstance(RD_MODEL);
- public static DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, ContainerNode> createContBuilder(final YangInstanceIdentifier
- .NodeIdentifier nid) {
+ public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createContBuilder(
+ final NodeIdentifier nid) {
return ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(nid);
}
- public static <T> ImmutableLeafNodeBuilder<T> createValueBuilder(final T value, YangInstanceIdentifier.NodeIdentifier nid) {
+ public static <T> ImmutableLeafNodeBuilder<T> createValueBuilder(final T value, NodeIdentifier nid) {
final ImmutableLeafNodeBuilder<T> valueBuilder = new ImmutableLeafNodeBuilder<>();
valueBuilder.withNodeIdentifier(nid).withValue(value);
return valueBuilder;
public class TableTypeActivatorTest {
- private static final BgpTableType EVPN = new BgpTableTypeImpl(L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class);
+ private static final BgpTableType EVPN = new BgpTableTypeImpl(
+ L2vpnAddressFamily.class, EvpnSubsequentAddressFamily.class);
@Test
public void testActivator() {
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.mldp.p2mp.lsp.OpaqueValueBuilder;
public class OpaqueUtilTest {
- private static final byte[] OPAQUE_WRONG= {
+ private static final byte[] OPAQUE_WRONG = {
(byte) 0xfc, (byte) 0x00, (byte) 0x03, // Opaque Type - Length
(byte) 0xb5, (byte) 0xeb, (byte) 0x2d, //Value
};
};
static final HexString OPAQUE_TEST = new HexString("07:00:0b:00:00:01:00:00:00:01:00:00:00:00");
- static final HexString OPAQUE_TEST2 = new HexString ("07:00:0b:00:00:01:00:00:00:01:00:00:00:00:01:02");
- private static final Opaque OPAQUE = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build();
- private static final Opaque OPAQUE_EXTENDED = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2).setOpaqueType((short) 2)
- .setOpaqueType(OpaqueUtil.EXTENDED_TYPE).setOpaqueExtendedType(4).build();
- private static final List<OpaqueValue> OPAQUE_VALUE_LIST = Arrays.asList((OpaqueValue) OPAQUE, (OpaqueValue) OPAQUE_EXTENDED);
+ static final HexString OPAQUE_TEST2 = new HexString("07:00:0b:00:00:01:00:00:00:01:00:00:00:00:01:02");
+ private static final Opaque OPAQUE = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST)
+ .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build();
+ private static final Opaque OPAQUE_EXTENDED = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2)
+ .setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE).setOpaqueExtendedType(4).build();
+ private static final List<OpaqueValue> OPAQUE_VALUE_LIST = Arrays.asList((OpaqueValue) OPAQUE,
+ (OpaqueValue) OPAQUE_EXTENDED);
@Test
- public void serializeOpaque() throws Exception {
+ public void serializeOpaque() {
final ByteBuf actualOpaque = Unpooled.buffer();
OpaqueUtil.serializeOpaque(OPAQUE, actualOpaque);
assertArrayEquals(OPAQUE_EXPECTED, ByteArray.readAllBytes(actualOpaque));
}
@Test
- public void parseOpaqueList() throws Exception {
+ public void parseOpaqueList() {
final ByteBuf opaqueValues = Unpooled.buffer();
OpaqueUtil.serializeOpaqueList(OPAQUE_VALUE_LIST, opaqueValues);
assertArrayEquals(OPAQUE_VALUES_EXPECTED, ByteArray.readAllBytes(opaqueValues));
assertEquals(OPAQUE_VALUE_LIST, OpaqueUtil.parseOpaqueList(Unpooled.wrappedBuffer(OPAQUE_VALUES_EXPECTED)));
}
-
- @Test(expected = UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<OpaqueUtil> c = OpaqueUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.IPV6;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.P_ADDRESS;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.IP_ADDRESS;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.P_MULTICAST;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import org.junit.Test;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.protocol.util.Ipv4Util;
private static class MyPAddressPMulticastGroup implements PAddressPMulticastGroup {
@Override
public IpAddress getPAddress() {
- return P_ADDRESS;
+ return IP_ADDRESS;
}
@Override
@Test
public void parseIpAddress() throws Exception {
final ByteBuf ipv4Actual = Unpooled.buffer();
- PAddressPMulticastGroupUtil.serializeIpAddress(P_ADDRESS, ipv4Actual);
+ PAddressPMulticastGroupUtil.serializeIpAddress(IP_ADDRESS, ipv4Actual);
assertArrayEquals(IPV4_ADDRESS_EXPECTED, ByteArray.readAllBytes(ipv4Actual));
final ByteBuf ipv6Actual = Unpooled.buffer();
PAddressPMulticastGroupUtil.serializeIpAddress(IPV6, ipv6Actual);
assertArrayEquals(IPV6_ADDRESS_EXPECTED, ByteArray.readAllBytes(ipv6Actual));
- assertEquals(P_ADDRESS, PAddressPMulticastGroupUtil.parseIpAddress(Ipv4Util.IP4_LENGTH, Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED)));
- assertEquals(IPV6, PAddressPMulticastGroupUtil.parseIpAddress(Ipv6Util.IPV6_LENGTH, Unpooled.wrappedBuffer(IPV6_ADDRESS_EXPECTED)));
- assertNull(PAddressPMulticastGroupUtil.parseIpAddress(6, Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED)));
+ assertEquals(IP_ADDRESS, PAddressPMulticastGroupUtil.parseIpAddress(Ipv4Util.IP4_LENGTH,
+ Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED)));
+ assertEquals(IPV6, PAddressPMulticastGroupUtil.parseIpAddress(Ipv6Util.IPV6_LENGTH,
+ Unpooled.wrappedBuffer(IPV6_ADDRESS_EXPECTED)));
+ assertNull(PAddressPMulticastGroupUtil.parseIpAddress(6,
+ Unpooled.wrappedBuffer(IPV4_ADDRESS_EXPECTED)));
}
@Test
public void parseIpAddressPMulticastGroup() throws Exception {
final PAddressPMulticastGroup pAddressPMulticastGroup = new MyPAddressPMulticastGroup();
final ByteBuf pAddressPMulticastGroupActual = Unpooled.buffer();
- PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(pAddressPMulticastGroup, pAddressPMulticastGroupActual);
+ PAddressPMulticastGroupUtil.serializeSenderPMulticastGroup(pAddressPMulticastGroup,
+ pAddressPMulticastGroupActual);
assertArrayEquals(SENDER_P_MULTICAST_GROUP_EXPECTED, ByteArray.readAllBytes(pAddressPMulticastGroupActual));
- final PAddressPMulticastGroup actual = PAddressPMulticastGroupUtil.parseSenderPMulticastGroup(Unpooled.wrappedBuffer
- (SENDER_P_MULTICAST_GROUP_EXPECTED));
- assertEquals(pAddressPMulticastGroup.getPAddress(), actual.getPAddress());
- assertEquals(pAddressPMulticastGroup.getPMulticastGroup(), actual.getPMulticastGroup());
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<PAddressPMulticastGroupUtil> constructor = PAddressPMulticastGroupUtil.class.getDeclaredConstructor();
- constructor.setAccessible(true);
- try {
- constructor.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
+ final PAddressPMulticastGroup actual = PAddressPMulticastGroupUtil
+ .parseSenderPMulticastGroup(Unpooled.wrappedBuffer(SENDER_P_MULTICAST_GROUP_EXPECTED));
+ assertEquals(IP_ADDRESS, actual.getPAddress());
+ assertEquals(P_MULTICAST, actual.getPMulticastGroup());
}
}
\ No newline at end of file
package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
-
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.PIM_SSM_TREE_EXPECTED;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.RSVP_TE_P2MP_LSP_LSP_EXPECTED;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildBidirPimTreeAttribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildINGRESSREPLICATIONAttribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPMP2MPLSPAttribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPMP2MPLSPWrongAttribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPP2MPLSPIpv4Attribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPP2MPLSPIpv6Attribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDPP2MPLSPL2vpnAttribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildIngressReplicationAttribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMLDpMp2mPLspAttribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpMP2mpLspWrongAttribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpP2mpLspIpv4Attribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpP2mpLspIpv6Attribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildMldpp2MPLspL2vpnAttribute;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildNoSupportedFamilyAttribute;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildNoSupportedOpaqueAttribute;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildPimSMTreeAttribute;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildPimSSMTreeAttribute;
-import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildRSVPTEP2MPLSPLSPAttribute;
+import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildRsvpTep2MPLspAttribute;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.PMSITunnelAttributeHandlerTestUtil.buildWOTunnelInfAttribute;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.TunnelIdentifierHandler.NO_TUNNEL_INFORMATION_PRESENT;
public void setUp() {
final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext();
- final org.opendaylight.protocol.bgp.parser.impl.BGPActivator inetActivator = new org.opendaylight.protocol.bgp.parser.impl.BGPActivator();
+ final org.opendaylight.protocol.bgp.parser.impl.BGPActivator inetActivator =
+ new org.opendaylight.protocol.bgp.parser.impl.BGPActivator();
inetActivator.start(ctx);
final BGPActivator bgpActivator = new BGPActivator();
bgpActivator.start(ctx);
this.handler.serializeAttribute(attributes, actual);
assertArrayEquals(BIDIR_PIM_EXPECTED, ByteArray.readAllBytes(actual));
final Attributes expected = buildBidirPimTreeAttribute();
- final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(BIDIR_PIM_EXPECTED), null);
+ final Attributes actualAttr = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(BIDIR_PIM_EXPECTED), null);
assertEquals(expected, actualAttr);
}
this.handler.serializeAttribute(attributes, actual);
assertArrayEquals(PIM_SM_TREE_EXPECTED, ByteArray.readAllBytes(actual));
final Attributes expected = buildPimSMTreeAttribute();
- final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(PIM_SM_TREE_EXPECTED), null);
+ final Attributes actualAttr = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(PIM_SM_TREE_EXPECTED), null);
assertEquals(expected, actualAttr);
}
@Test
public void parsePimSSMTree() throws Exception {
final Attributes expected = buildPimSSMTreeAttribute();
- final Attributes actual = this.handler.parseAttributes(Unpooled.wrappedBuffer(PIM_SSM_TREE_EXPECTED), null);
+ final Attributes actual = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(PIM_SSM_TREE_EXPECTED), null);
assertEquals(expected, actual);
}
@Test
public void testMldpP2MpLsp() throws Exception {
final ByteBuf actualIpv4 = Unpooled.buffer();
- final Attributes expectedIpv4Att = buildMLDPP2MPLSPIpv4Attribute();
+ final Attributes expectedIpv4Att = buildMldpP2mpLspIpv4Attribute();
- final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance();
+ final BGPExtensionProviderContext providerContext = ServiceLoaderBGPExtensionProviderContext
+ .getSingletonInstance();
providerContext.getAttributeRegistry().serializeAttribute(expectedIpv4Att, actualIpv4);
assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV4, ByteArray.readAllBytes(actualIpv4));
- final Attributes actualIpv4Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV4_2), null);
+ final Attributes actualIpv4Attribute = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV4_2), null);
assertEquals(expectedIpv4Att, actualIpv4Attribute);
- final Attributes expectedIpv6Att = buildMLDPP2MPLSPIpv6Attribute();
+ final Attributes expectedIpv6Att = buildMldpP2mpLspIpv6Attribute();
final ByteBuf actualIpv6 = Unpooled.buffer();
this.handler.serializeAttribute(expectedIpv6Att, actualIpv6);
assertArrayEquals(M_LDP_P2MP_LSP_EXPECTED_IPV6, ByteArray.readAllBytes(actualIpv6));
- final Attributes actualIpv6Attribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV6), null);
+ final Attributes actualIpv6Attribute = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_IPV6), null);
assertEquals(expectedIpv6Att, actualIpv6Attribute);
final ByteBuf actualL2vpn = Unpooled.buffer();
assertArrayEquals(new byte[0], ByteArray.readAllBytes(actualIpv4));
- final Attributes actualWrongFamily = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY), null);
+ final Attributes actualWrongFamily = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_WRONG_FAMILY), null);
assertEquals(buildWOTunnelInfAttribute(), actualWrongFamily);
- final Attributes expectedL2vpnAtt = buildMLDPP2MPLSPL2vpnAttribute();
- final Attributes actualL2vpnAttribute = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_L2VPN), null);
+ final Attributes expectedL2vpnAtt = buildMldpp2MPLspL2vpnAttribute();
+ final Attributes actualL2vpnAttribute = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(M_LDP_P2MP_LSP_EXPECTED_L2VPN), null);
assertEquals(expectedL2vpnAtt, actualL2vpnAttribute);
final ByteBuf actualL2vp = Unpooled.buffer();
@Test
public void testRsvpteP2MplspLsp() throws Exception {
- final Attributes expected = buildRSVPTEP2MPLSPLSPAttribute();
+ final Attributes expected = buildRsvpTep2MPLspAttribute();
final ByteBuf actual = Unpooled.buffer();
this.handler.serializeAttribute(expected, actual);
assertArrayEquals(RSVP_TE_P2MP_LSP_LSP_EXPECTED, ByteArray.readAllBytes(actual));
- final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(RSVP_TE_P2MP_LSP_LSP_EXPECTED), null);
+ final Attributes actualAttr = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(RSVP_TE_P2MP_LSP_LSP_EXPECTED), null);
assertEquals(expected, actualAttr);
}
@Test
public void testIngressReplication() throws Exception {
- final Attributes expected = buildINGRESSREPLICATIONAttribute();
+ final Attributes expected = buildIngressReplicationAttribute();
final ByteBuf actual = Unpooled.buffer();
this.handler.serializeAttribute(expected, actual);
assertArrayEquals(INGRESS_REPLICATION_EXPECTED, ByteArray.readAllBytes(actual));
- final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(INGRESS_REPLICATION_EXPECTED), null);
+ final Attributes actualAttr = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(INGRESS_REPLICATION_EXPECTED), null);
assertEquals(expected, actualAttr);
}
@Test
public void testMldpmP2MpLsp() throws Exception {
- final Attributes expected = buildMLDPMP2MPLSPAttribute();
+ final Attributes expected = buildMLDpMp2mPLspAttribute();
final ByteBuf actual = Unpooled.buffer();
this.handler.serializeAttribute(expected, actual);
assertArrayEquals(M_LDP_MP_2_MP_LSP_EXPECTED, ByteArray.readAllBytes(actual));
- final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_EXPECTED), null);
+ final Attributes actualAttr = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_EXPECTED), null);
assertEquals(expected, actualAttr);
- final Attributes actualWrong = this.handler.parseAttributes(Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_WRONG), null);
+ final Attributes actualWrong = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(M_LDP_MP_2_MP_LSP_WRONG), null);
assertEquals(buildWOTunnelInfAttribute(), actualWrong);
- final Attributes wrongAttribute = buildMLDPMP2MPLSPWrongAttribute();
+ final Attributes wrongAttribute = buildMldpMP2mpLspWrongAttribute();
final ByteBuf actualWrongBuf = Unpooled.buffer();
this.handler.serializeAttribute(wrongAttribute, actualWrongBuf);
assertArrayEquals(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED, ByteArray.readAllBytes(actualWrongBuf));
this.handler.serializeAttribute(attributes, actual);
assertArrayEquals(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED, ByteArray.readAllBytes(actual));
final Attributes expected = buildWOTunnelInfAttribute();
- final Attributes actualAttr = this.handler.parseAttributes(Unpooled.wrappedBuffer(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED), null);
+ final Attributes actualAttr = this.handler.parseAttributes(
+ Unpooled.wrappedBuffer(NO_TUNNEL_INFORMATION_PRESENT_EXPECTED), null);
assertEquals(expected, actualAttr);
}
@Test
- public void testTunnelIdentifierUtil() throws Throwable {
- final TunnelIdentifierHandler tunnelIdentifierHandler = new TunnelIdentifierHandler(ServiceLoaderBGPExtensionProviderContext
- .getSingletonInstance().getAddressFamilyRegistry());
+ public void testTunnelIdentifierUtil() {
+ final TunnelIdentifierHandler tunnelIdentifierHandler =
+ new TunnelIdentifierHandler(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
+ .getAddressFamilyRegistry());
assertNull(tunnelIdentifierHandler.parse(1, Unpooled.buffer()));
assertNull(tunnelIdentifierHandler.parse(125, Unpooled.buffer()));
- assertEquals(NO_TUNNEL_INFORMATION_PRESENT, tunnelIdentifierHandler.serialize(new MockTunnelIdentifier(), Unpooled.buffer()));
+ assertEquals(NO_TUNNEL_INFORMATION_PRESENT, tunnelIdentifierHandler
+ .serialize(new MockTunnelIdentifier(), Unpooled.buffer()));
}
@Test
- public void testPMSITunnelAttributeParser() throws Throwable {
- final PMSITunnelAttributeHandler pmsiHandler = new PMSITunnelAttributeHandler(ServiceLoaderBGPExtensionProviderContext
- .getSingletonInstance().getAddressFamilyRegistry());
+ public void testPMSITunnelAttributeParser() {
+ final PMSITunnelAttributeHandler pmsiHandler =
+ new PMSITunnelAttributeHandler(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
+ .getAddressFamilyRegistry());
assertEquals(22, pmsiHandler.getType());
final AttributesBuilder builder = new AttributesBuilder();
final ByteBuf emptyBuffer = Unpooled.buffer();
package org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier;
+import static java.util.Collections.singletonList;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.IPV6;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.MPLS_LABEL;
import static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.OpaqueUtilTest.OPAQUE_TEST;
final class PMSITunnelAttributeHandlerTestUtil {
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 0- MPLS LABEL
* No tunnel information present
*/
(byte) 0x01, (byte) 0x00, (byte) 0x05, (byte) 0xdc, (byte) 0x10
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 1- MPLS LABEL
* mLDP P2MP LSP
*/
(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01,
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 2- MPLS LABEL
* mLDP P2MP LSP
*/
(byte) 0x02
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 2- MPLS LABEL
* mLDP P2MP LSP
*/
(byte) 0xb5, (byte) 0xeb, (byte) 0x2d, (byte) 0xd7, (byte) 0x6d, (byte) 0xf8, //Value
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 2- MPLS LABEL
* mLDP P2MP LSP L2VPN
*/
(byte) 0x02
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 2- MPLS LABEL
* mLDP P2MP LSP IPV4
*/
(byte) 0x02
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 2- MPLS LABEL
* mLDP P2MP LSP IPV6
*/
(byte) 0x02
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 3- MPLS LABEL
* PIM-SSM Tree
*/
(byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 4- MPLS LABEL
* PIM-SM Tree
*/
(byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 5- MPLS LABEL
* BIDIR-PIM Tree
*/
(byte) 0x17, (byte) 0x01, (byte) 0x01, (byte) 0x01
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 6- MPLS LABEL
* Ingress Replication
*/
(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 7- MPLS LABEL
* mLDP MP2MP LSP
*/
(byte) 0x00, (byte) 0x00
};
/**
- * ATT - TYPE - ATT LENGTH
+ * ATT - TYPE - ATT LENGTH.
* PMSI FLAG - PMSI TYPE 7- MPLS LABEL
* mLDP MP2MP LSP
*/
};
static final IpAddress P_MULTICAST = new IpAddress(new Ipv4Address("23.1.1.1"));
- static final IpAddress P_ADDRESS = new IpAddress(new Ipv4Address("1.1.1.1"));
+ static final IpAddress IP_ADDRESS = new IpAddress(new Ipv4Address("1.1.1.1"));
private static final Short NO_SUPPORTED_OPAQUE = 200;
static class MockTunnelIdentifier implements TunnelIdentifier {
}
}
- static abstract class NonSupportedAddressFamily extends AddressFamily {
+ private abstract static class NonSupportedAddressFamily extends AddressFamily {
}
private static PAddressPMulticastGroup buildPAddressPMulticastGroup() {
- return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier
- .bidir.pim.tree.BidirPimTreeBuilder().setPAddress(P_ADDRESS).setPMulticastGroup(P_MULTICAST).build();
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
+ .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder()
+ .setPAddress(IP_ADDRESS).setPMulticastGroup(P_MULTICAST).build();
}
private static PmsiTunnelBuilder getPmsiTunnelBuilder() {
}
private static Attributes buildAttribute(final PmsiTunnelBuilder pmsiTunnelBuilder) {
- return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList()).addAugmentation(PmsiTunnelAugmentation.class,
+ return new AttributesBuilder().setUnrecognizedAttributes(Collections.emptyList())
+ .addAugmentation(PmsiTunnelAugmentation.class,
new PmsiTunnelAugmentationBuilder().setPmsiTunnel(pmsiTunnelBuilder.build()).build()).build();
}
static Attributes buildBidirPimTreeAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder().setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
- .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new BidirPimTreeBuilder()
+ .setBidirPimTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel
+ .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.bidir.pim.tree
+ .BidirPimTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
static Attributes buildPimSMTreeAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
- .yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new PimSmTreeBuilder().setPimSmTree(new org.opendaylight.yang.gen.v1
+ .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
+ .identifier.pim.sm.tree.PimSmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
static Attributes buildPimSSMTreeAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
- .yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new PimSsmTreeBuilder().setPimSsmTree(new org.opendaylight.yang.gen.v1
+ .urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
+ .identifier.pim.ssm.tree.PimSsmTreeBuilder(buildPAddressPMulticastGroup()).build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
static Attributes buildNoSupportedOpaqueAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- final List<OpaqueValue> nonSupported = Collections.singletonList(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build());
- pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, Ipv4AddressFamily.class, nonSupported));
+ final List<OpaqueValue> nonSupported = singletonList(new OpaqueValueBuilder()
+ .setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, nonSupported));
return buildAttribute(pmsiTunnelBuilder);
}
static Attributes buildNoSupportedFamilyAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, NonSupportedAddressFamily.class, createOpaqueList()));
+ pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(IP_ADDRESS, NonSupportedAddressFamily.class,
+ createOpaqueList()));
return buildAttribute(pmsiTunnelBuilder);
}
- static Attributes buildMLDPP2MPLSPIpv4Attribute() {
+ static Attributes buildMldpP2mpLspIpv4Attribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, Ipv4AddressFamily.class, createOpaqueList()));
+ pmsiTunnelBuilder.setTunnelIdentifier(
+ buildMldpP2mpLsp(IP_ADDRESS, Ipv4AddressFamily.class, createOpaqueList()));
return buildAttribute(pmsiTunnelBuilder);
}
- static Attributes buildMLDPP2MPLSPIpv6Attribute() {
+ static Attributes buildMldpP2mpLspIpv6Attribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = new PmsiTunnelBuilder();
pmsiTunnelBuilder.setLeafInformationRequired(true);
pmsiTunnelBuilder.setMplsLabel(MPLS_LABEL);
return buildAttribute(pmsiTunnelBuilder);
}
- static Attributes buildMLDPP2MPLSPL2vpnAttribute() {
+ static Attributes buildMldpp2MPLspL2vpnAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(buildMldpP2mpLsp(P_ADDRESS, L2vpnAddressFamily.class, createOpaqueList()));
+ pmsiTunnelBuilder.setTunnelIdentifier(
+ buildMldpP2mpLsp(IP_ADDRESS, L2vpnAddressFamily.class, createOpaqueList()));
return buildAttribute(pmsiTunnelBuilder);
}
- private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress pAddress, final Class<? extends AddressFamily> family, final List<OpaqueValue> opaqueList) {
+ private static TunnelIdentifier buildMldpP2mpLsp(final IpAddress ipAddress,
+ final Class<? extends AddressFamily> family, final List<OpaqueValue> opaqueList) {
return new MldpP2mpLspBuilder().setMldpP2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.p2mp.lsp.MldpP2mpLspBuilder()
- .setRootNodeAddress(pAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build();
+ .setRootNodeAddress(ipAddress).setAddressFamily(family).setOpaqueValue(opaqueList).build()).build();
}
- static Attributes buildRSVPTEP2MPLSPLSPAttribute() {
+ static Attributes buildRsvpTep2MPLspAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder().setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
- .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder()
- .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(P_ADDRESS).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new RsvpTeP2mpLspBuilder()
+ .setRsvpTeP2mpLps(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel
+ .rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLpsBuilder()
+ .setP2mpId(3458L).setTunnelId(15).setExtendedTunnelId(IP_ADDRESS).build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
- static Attributes buildINGRESSREPLICATIONAttribute() {
+ static Attributes buildIngressReplicationAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org.opendaylight.yang.gen.v1.urn
- .opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
- .setReceivingEndpointAddress(P_ADDRESS).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new IngressReplicationBuilder().setIngressReplication(new org
+ .opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
+ .tunnel.tunnel.identifier.ingress.replication.IngressReplicationBuilder()
+ .setReceivingEndpointAddress(IP_ADDRESS).build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
- static Attributes buildMLDPMP2MPLSPWrongAttribute() {
+ static Attributes buildMldpMP2mpLspWrongAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
- .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp
- .MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen
+ .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier
+ .mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(NO_SUPPORTED_OPAQUE)
+ .build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
- static Attributes buildMLDPMP2MPLSPAttribute() {
+ static Attributes buildMLDpMp2mPLspAttribute() {
final PmsiTunnelBuilder pmsiTunnelBuilder = getPmsiTunnelBuilder();
- pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen.v1.urn.opendaylight.params
- .xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp
- .MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build());
+ pmsiTunnelBuilder.setTunnelIdentifier(new MldpMp2mpLspBuilder().setMldpMp2mpLsp(new org.opendaylight.yang.gen
+ .v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel
+ .identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder().setOpaque(OPAQUE_TEST)
+ .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build()).build());
return buildAttribute(pmsiTunnelBuilder);
}
private static List<OpaqueValue> createOpaqueList() {
final List<OpaqueValue> opaqueValues = new ArrayList<>();
- opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST).setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build());
- opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2).setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE)
+ opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST)
+ .setOpaqueType(OpaqueUtil.GENERIC_LSP_IDENTIFIER).build());
+ opaqueValues.add(new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2)
+ .setOpaqueType((short) 2).setOpaqueType(OpaqueUtil.EXTENDED_TYPE)
.setOpaqueExtendedType(4).build());
return opaqueValues;
}
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
public final class ASGenParserTest {
- private static final byte[] VALUE = {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
- private static final byte[] RESULT = {(byte) 0x05, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
+ private static final byte[] VALUE = {(byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x02,
+ (byte) 0x02, (byte) 0x02, (byte) 0x00};
+ private static final byte[] RESULT = {(byte) 0x05, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x01, (byte) 0x02,
+ (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x00};
private ASGenParser parser;
@Before
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
- final AsGeneratedCase asGen = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder().setAs(AS_NUMBER).setLocalDiscriminator(LD)
- .build()).build();
+ final AsGeneratedCase asGen = new AsGeneratedCaseBuilder().setAsGenerated(new AsGeneratedBuilder()
+ .setAs(AS_NUMBER).setLocalDiscriminator(LD).build()).build();
this.parser.serializeEsi(asGen, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(asGen, acResult);
- final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME)).addChild(createValueBuilder(AS_MODEL, AS_NID).build())
+ final ContainerNode cont = createContBuilder(new NodeIdentifier(AsGenerated.QNAME))
+ .addChild(createValueBuilder(AS_MODEL, AS_NID).build())
.addChild(createValueBuilder(LD, LD_NID).build()).build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(asGen, acmResult);
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
public final class ArbitraryParserTest {
- private static final byte[] ARB_VALUE = {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07,
- (byte) 0x08, (byte) 0x09};
- private static final byte[] ARB_RESULT = {(byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06,
- (byte) 0x07, (byte) 0x08, (byte) 0x09};
+ private static final byte[] ARB_VALUE = {(byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05,
+ (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09};
+ private static final byte[] ARB_RESULT = {(byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04,
+ (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x09};
private ArbitraryParser parser;
@Before
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
- final ArbitraryCase arbitrary = new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder().setArbitrary(ARB_VALUE).build()).build();
+ final ArbitraryCase arbitrary = new ArbitraryCaseBuilder().setArbitrary(new ArbitraryBuilder()
+ .setArbitrary(ARB_VALUE).build()).build();
this.parser.serializeEsi(arbitrary, buff);
assertArrayEquals(ARB_RESULT, ByteArray.getAllBytes(buff));
assertEquals(arbitrary, acResult);
final ContainerNode cont = createContBuilder(new NodeIdentifier(Arbitrary.QNAME))
- .addChild(createValueBuilder(ARB_VALUE, ARB_NID).build()).build();
+ .addChild(createValueBuilder(ARB_VALUE, ARB_NID).build()).build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(arbitrary, acmResult);
}
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
public final class LacpParserTest {
- private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
- private static final byte[] RESULT = {(byte) 0x01, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
+ private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7,
+ (byte) 0x02, (byte) 0x02, (byte) 0x00};
+ private static final byte[] RESULT = {(byte) 0x01, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f,
+ (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00};
private LacpParser parser;
@Before
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
- final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder().setLacpAutoGenerated(new LacpAutoGeneratedBuilder()
- .setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build();
+ final LacpAutoGeneratedCase lanAuto = new LacpAutoGeneratedCaseBuilder()
+ .setLacpAutoGenerated(new LacpAutoGeneratedBuilder()
+ .setCeLacpMacAddress(MAC).setCeLacpPortKey(PORT).build()).build();
this.parser.serializeEsi(lanAuto, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(lanAuto, acResult);
- final ContainerNode cont = createContBuilder( new NodeIdentifier(LacpAutoGenerated.QNAME))
- .addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build())
- .addChild(createValueBuilder(PORT, PK_NID).build())
- .build();
+ final ContainerNode cont = createContBuilder(new NodeIdentifier(LacpAutoGenerated.QNAME))
+ .addChild(createValueBuilder(MAC_MODEL, LACP_MAC_NID).build())
+ .addChild(createValueBuilder(PORT, PK_NID).build())
+ .build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(lanAuto, acmResult);
}
public class LanParserTest {
private static final Integer PRIORITY = 514;
- public static final LanAutoGeneratedCase LAN_AUT_GEN_CASE = new LanAutoGeneratedCaseBuilder().setLanAutoGenerated(new LanAutoGeneratedBuilder()
+ public static final LanAutoGeneratedCase LAN_AUT_GEN_CASE = new LanAutoGeneratedCaseBuilder()
+ .setLanAutoGenerated(new LanAutoGeneratedBuilder()
.setRootBridgeMacAddress(MAC).setRootBridgePriority(PRIORITY).build()).build();
- private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
- private static final byte[] RESULT = {(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
+ private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7,
+ (byte) 0x02, (byte) 0x02, (byte) 0x00};
+ private static final byte[] RESULT = {(byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f,
+ (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00};
private LanParser parser;
@Before
}
private static ContainerNode createLanCont() {
- return createContBuilder(new NodeIdentifier(LanAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, BRIDGE_MAC_NID).build())
- .addChild(createValueBuilder(PRIORITY, RBP_NID).build()).build();
+ return createContBuilder(new NodeIdentifier(LanAutoGenerated.QNAME))
+ .addChild(createValueBuilder(MAC_MODEL, BRIDGE_MAC_NID).build())
+ .addChild(createValueBuilder(PRIORITY, RBP_NID).build()).build();
}
}
\ No newline at end of file
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
public final class MacParserTest {
- private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
- private static final byte[] RESULT = {(byte) 0x03, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
+ private static final byte[] VALUE = {(byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7,
+ (byte) 0x02, (byte) 0x02, (byte) 0x00};
+ private static final byte[] RESULT = {(byte) 0x03, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f,
+ (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00};
private static final long UINT24_LD_MODEL = 131584L;
private static final Uint24 UINT24_LD = new Uint24(UINT24_LD_MODEL);
private MacParser parser;
public void parserTest() {
final ByteBuf buff = Unpooled.buffer(VALUE_SIZE);
- final MacAutoGeneratedCase macAuto = new MacAutoGeneratedCaseBuilder().setMacAutoGenerated(new MacAutoGeneratedBuilder()
- .setLocalDiscriminator(UINT24_LD).setSystemMacAddress(MAC).build()).build();
+ final MacAutoGeneratedCase macAuto = new MacAutoGeneratedCaseBuilder()
+ .setMacAutoGenerated(new MacAutoGeneratedBuilder()
+ .setLocalDiscriminator(UINT24_LD)
+ .setSystemMacAddress(MAC).build()).build();
this.parser.serializeEsi(macAuto, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
final Esi acResult = this.parser.parseEsi(Unpooled.wrappedBuffer(VALUE));
assertEquals(macAuto, acResult);
- final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME)).addChild(createValueBuilder(MAC_MODEL, SYSTEM_MAC_NID).build())
- .addChild(createValueBuilder(UINT24_LD_MODEL, LD_NID).build()).build();
+ final ContainerNode cont = createContBuilder(new NodeIdentifier(MacAutoGenerated.QNAME))
+ .addChild(createValueBuilder(MAC_MODEL, SYSTEM_MAC_NID).build())
+ .addChild(createValueBuilder(UINT24_LD_MODEL, LD_NID).build()).build();
final Esi acmResult = this.parser.serializeEsi(cont);
assertEquals(macAuto, acmResult);
}
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
public class RouterIdParserTest {
- public static final byte[] RESULT = {(byte) 0x04, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
- private static final byte[] VALUE = {(byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02, (byte) 0x02,
- (byte) 0x02, (byte) 0x00};
+ public static final byte[] RESULT = {(byte) 0x04, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02,
+ (byte) 0x02, (byte) 0x02, (byte) 0x02, (byte) 0x00};
+ private static final byte[] VALUE = {(byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x2A, (byte) 0x02, (byte) 0x02,
+ (byte) 0x02, (byte) 0x02, (byte) 0x00};
private static final Ipv4Address ROUTE_ID = new Ipv4Address("42.42.42.42");
- public static final RouterIdGeneratedCase ROUTE_ID_CASE = new RouterIdGeneratedCaseBuilder().setRouterIdGenerated(new RouterIdGeneratedBuilder()
- .setLocalDiscriminator(LD).setRouterId(ROUTE_ID).build()).build();
+ public static final RouterIdGeneratedCase ROUTE_ID_CASE = new RouterIdGeneratedCaseBuilder()
+ .setRouterIdGenerated(new RouterIdGeneratedBuilder()
+ .setLocalDiscriminator(LD).setRouterId(ROUTE_ID).build()).build();
private static final String ROUTE_ID_MODEL = "42.42.42.42";
private RouterIdParser parser;
public void parserTest() throws BGPParsingException, BGPDocumentedException {
final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
- final DefaultGatewayExtendedCommunityCase expected = new DefaultGatewayExtendedCommunityCaseBuilder().setDefaultGatewayExtendedCommunity(
- new DefaultGatewayExtendedCommunityBuilder().build()).build();
+ final DefaultGatewayExtendedCommunityCase expected = new DefaultGatewayExtendedCommunityCaseBuilder()
+ .setDefaultGatewayExtendedCommunity(
+ new DefaultGatewayExtendedCommunityBuilder().build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
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();
+ 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));
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();
+ final EsImportRouteExtendedCommunityCase expected = new EsImportRouteExtendedCommunityCaseBuilder()
+ .setEsImportRouteExtendedCommunity(
+ new EsImportRouteExtendedCommunityBuilder().setEsImport(MAC).build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.extended.community.ExtendedCommunity;
public class Layer2AttributesExtComTest {
- private static final byte[] EXPECTEDS = {(byte) 0x00, (byte) 0x07, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00};
- private static final byte[] EVPN_VPWS = {(byte) 0x00, (byte) 0x2f, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00};
- private static final byte[] EVPN_VPWS_2 = {(byte) 0x00, (byte) 0x57, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00};
+ private static final byte[] EXPECTEDS = {(byte) 0x00, (byte) 0x07, (byte) 0x01, (byte) 0x01,
+ (byte) 0x00, (byte) 0x00};
+ private static final byte[] EVPN_VPWS = {(byte) 0x00, (byte) 0x2f, (byte) 0x01, (byte) 0x01,
+ (byte) 0x00, (byte) 0x00};
+ private static final byte[] EVPN_VPWS_2 = {(byte) 0x00, (byte) 0x57, (byte) 0x01, (byte) 0x01,
+ (byte) 0x00, (byte) 0x00};
private Layer2AttributesExtCom parser;
@Before
final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
final Layer2AttributesExtendedCommunityCase expected = new Layer2AttributesExtendedCommunityCaseBuilder()
- .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true)
- .setControlWord(true).setPrimaryPe(true).setL2Mtu(257).build()).build();
+ .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true)
+ .setControlWord(true).setPrimaryPe(true).setL2Mtu(257).build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
final byte[] resultByte = ByteArray.getAllBytes(buff);
assertArrayEquals(EXPECTEDS, resultByte);
final ByteBuf buff = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
final Layer2AttributesExtendedCommunityCase expected = new Layer2AttributesExtendedCommunityCaseBuilder()
- .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true)
- .setControlWord(true).setPrimaryPe(true).setL2Mtu(257)
- .setModeOfOperation(OperationalMode.VlanAwareFxc)
- .setOperatingPer(NormalizationType.SingleVid)
- .build()).build();
+ .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true)
+ .setControlWord(true).setPrimaryPe(true).setL2Mtu(257)
+ .setModeOfOperation(OperationalMode.VlanAwareFxc)
+ .setOperatingPer(NormalizationType.SingleVid)
+ .build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
final byte[] resultByte = ByteArray.getAllBytes(buff);
assertArrayEquals(EVPN_VPWS, resultByte);
final ByteBuf buff2 = Unpooled.buffer(COMMUNITY_VALUE_SIZE);
final Layer2AttributesExtendedCommunityCase expected2 = new Layer2AttributesExtendedCommunityCaseBuilder()
- .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true)
- .setControlWord(true).setPrimaryPe(true).setL2Mtu(257)
- .setModeOfOperation(OperationalMode.VlanUnawareFxc)
- .setOperatingPer(NormalizationType.DoubleVid)
- .build()).build();
+ .setLayer2AttributesExtendedCommunity(new Layer2AttributesExtendedCommunityBuilder().setBackupPe(true)
+ .setControlWord(true).setPrimaryPe(true).setL2Mtu(257)
+ .setModeOfOperation(OperationalMode.VlanUnawareFxc)
+ .setOperatingPer(NormalizationType.DoubleVid)
+ .build()).build();
this.parser.serializeExtendedCommunity(expected2, buff2);
final byte[] resultByte2 = ByteArray.getAllBytes(buff2);
assertArrayEquals(EVPN_VPWS_2, resultByte2);
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();
+ final MacMobilityExtendedCommunityCase expected = new MacMobilityExtendedCommunityCaseBuilder()
+ .setMacMobilityExtendedCommunity(new MacMobilityExtendedCommunityBuilder()
+ .setStatic(true).setSeqNumber(LD).build()).build();
this.parser.serializeExtendedCommunity(expected, buff);
assertArrayEquals(RESULT, ByteArray.getAllBytes(buff));
public static final byte[] RESULT = {
(byte) 0x01, (byte) 0x19,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x05, (byte) 0xdc, (byte) 0x10
};
public static final byte[] ROUDE_DISTIN = {
};
static final EthernetTagId ETI = new EthernetTagIdBuilder().setVlanId(VLAN).build();
public static final EthernetADRouteCase ETHERNET_AD_ROUTE_CASE_KEY = new EthernetADRouteCaseBuilder()
- .setEthernetADRoute(new EthernetADRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).build()).build();
- public static final EthernetADRouteCase ETHERNET_AD_ROUTE_CASE = new EthernetADRouteCaseBuilder().setEthernetADRoute(new EthernetADRouteBuilder()
+ .setEthernetADRoute(new EthernetADRouteBuilder().setEsi(LAN_AUT_GEN_CASE)
+ .setEthernetTagId(ETI).build()).build();
+ public static final EthernetADRouteCase ETHERNET_AD_ROUTE_CASE = new EthernetADRouteCaseBuilder()
+ .setEthernetADRoute(new EthernetADRouteBuilder()
.setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).setMplsLabel(MPLS_LABEL).build()).build();
static final byte[] WRONG_VALUE = {(byte) 0x00};
private static final byte[] VALUE = {
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x05, (byte) 0xdc, (byte) 0x10
};
private EthADRParser parser;
public class EthSegRParserTest {
private static final byte[] VALUE = {
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
- (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00, (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
};
private static final byte[] RESULT = {
(byte) 0x04, (byte) 0x17,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
- (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00, (byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01
};
private static final byte[] VALUE2 = {
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x80,//IPV6
(byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
private static final byte[] RESULT2 = {
(byte) 0x04, (byte) 0x23,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x80,//IPV6
(byte) 0x20, (byte) 0x01, (byte) 0x00, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
@Test
public void parserTest() {
- final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IP).build()).build();
- assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
+ final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder()
+ .setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IP).build()).build();
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected,
+ Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
assertEquals(expected, result);
- final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
+ final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders
+ .choiceBuilder();
choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID);
- final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice())
- .addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build();
+ final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID)
+ .addChild(LanParserTest.createLanChoice())
+ .addChild(createValueBuilder(IP_MODEL, ORI_NID).build()).build();
final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC);
assertEquals(expected, modelResult);
@Test
public void parser2Test() {
- final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IPV6).build()).build();
- assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
+ final EsRouteCase expected = new EsRouteCaseBuilder().setEsRoute(new EsRouteBuilder()
+ .setEsi(LAN_AUT_GEN_CASE).setOrigRouteIp(IPV6).build()).build();
+ assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected,
+ Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2));
assertEquals(expected, result);
- final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
+ final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders
+ .choiceBuilder();
choice.withNodeIdentifier(EthSegRParser.ES_ROUTE_NID);
- final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID).addChild(LanParserTest.createLanChoice())
- .addChild(createValueBuilder(IPV6_MODEL, ORI_NID).build()).build();
+ final ContainerNode arbitraryC = createContBuilder(EthSegRParser.ES_ROUTE_NID)
+ .addChild(LanParserTest.createLanChoice())
+ .addChild(createValueBuilder(IPV6_MODEL, ORI_NID).build()).build();
final EvpnChoice modelResult = this.parser.serializeEvpnModel(arbitraryC);
assertEquals(expected, modelResult);
*/
package org.opendaylight.protocol.bgp.evpn.impl.nlri;
-import static org.junit.Assert.assertArrayEquals;
+import static java.util.Collections.singletonList;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
-import java.util.Collections;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.evpn.impl.esi.types.ESIActivator;
final Attributes att = new AttributesBuilder().addAugmentation(Attributes1.class,
new Attributes1Builder().setMpReachNlri(createReach()).build()).build();
this.parser.serializeAttribute(att, buffer);
- assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
+ Assert.assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
}
private static MpReachNlri createReach() {
final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder();
final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder()
- .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(Collections.singletonList(new EvpnDestinationBuilder()
- .setRouteDistinguisher(RD).setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build())).build()).build()).build();
+ .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(
+ singletonList(new EvpnDestinationBuilder()
+ .setRouteDistinguisher(RD)
+ .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase())
+ .build())).build()).build()).build();
return mpReachExpected.setAdvertizedRoutes(wd).build();
}
final Attributes att = new AttributesBuilder().addAugmentation(Attributes2.class,
new Attributes2Builder().setMpUnreachNlri(createUnreach()).build()).build();
this.parser.serializeAttribute(att, buffer);
- assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
+ Assert.assertArrayEquals(IncMultEthTagRParserTest.RESULT, ByteArray.getAllBytes(buffer));
}
private static MpUnreachNlri createUnreach() {
final MpUnreachNlriBuilder mpReachExpected = new MpUnreachNlriBuilder();
- final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder()
- .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.evpn._case.DestinationEvpnBuilder().setEvpnDestination(Collections.singletonList(new EvpnDestinationBuilder()
- .setRouteDistinguisher(RD).setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build())).build()).build()).build();
+ final WithdrawnRoutes wd = new WithdrawnRoutesBuilder()
+ .setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn
+ .rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .DestinationEvpnCaseBuilder().setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn
+ .routes.destination.type.destination.evpn._case.DestinationEvpnBuilder()
+ .setEvpnDestination(singletonList(new EvpnDestinationBuilder()
+ .setRouteDistinguisher(RD).setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase())
+ .build())).build()).build()).build();
return mpReachExpected.setWithdrawnRoutes(wd).build();
}
private List<EvpnDestination> dest;
private EvpnNlriParser parser;
+ static ChoiceNode createMACIpAdvChoice() {
+ final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
+ choice.withNodeIdentifier(EVPN_CHOICE_NID);
+ return choice.addChild(MACIpAdvRParserTest.createMacIpCont()).build();
+ }
+
@Before
public void setUp() {
ESIActivator.registerEsiTypeParsers(new ArrayList<>());
NlriActivator.registerNlriParsers(new ArrayList<>());
this.dest = Collections.singletonList(new EvpnDestinationBuilder()
- .setRouteDistinguisher(RD)
- .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build());
+ .setRouteDistinguisher(RD)
+ .setEvpnChoice(IncMultEthTagRParserTest.createIncMultiCase()).build());
this.parser = new EvpnNlriParser();
}
private MpUnreachNlri createUnreach() {
final MpUnreachNlriBuilder mpReachExpected = new MpUnreachNlriBuilder();
- final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.
- bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder().setDestinationEvpn(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.
- destination.type.destination.evpn._case.DestinationEvpnBuilder().setEvpnDestination(this.dest).build()).build()).build();
+ final WithdrawnRoutes wd = new WithdrawnRoutesBuilder().setDestinationType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.update
+ .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCaseBuilder()
+ .setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
+ .evpn.rev171213.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
+ .destination.evpn._case.DestinationEvpnBuilder()
+ .setEvpnDestination(this.dest).build()).build()).build();
return mpReachExpected.setWithdrawnRoutes(wd).build();
}
this.parser.parseNlri(Unpooled.wrappedBuffer(IncMultEthTagRParserTest.RESULT), mpReach);
final MpReachNlriBuilder mpReachExpected = new MpReachNlriBuilder();
- final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder().setDestinationEvpn(
- new DestinationEvpnBuilder().setEvpnDestination(this.dest).build()).build()).build();
+ final AdvertizedRoutes wd = new AdvertizedRoutesBuilder().setDestinationType(new DestinationEvpnCaseBuilder()
+ .setDestinationEvpn(new DestinationEvpnBuilder().setEvpnDestination(this.dest).build())
+ .build()).build();
mpReachExpected.setAdvertizedRoutes(wd);
assertEquals(mpReachExpected.build(), mpReach.build());
}
@Test
public void testExtractEvpnDestination() throws BGPParsingException {
- final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI =
+ ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_NID);
evpnBI.withChild(createMACIpAdvChoice());
evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build());
final EvpnDestination destResult = EvpnNlriParser.extractEvpnDestination(evpnBI.build());
- final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build();
+ final EvpnDestination expected = new EvpnDestinationBuilder()
+ .setRouteDistinguisher(RD)
+ .setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build();
assertEquals(expected, destResult);
}
-
- public static ChoiceNode createMACIpAdvChoice() {
- final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
- choice.withNodeIdentifier(EVPN_CHOICE_NID);
- return choice.addChild(MACIpAdvRParserTest.createMacIpCont()).build();
- }
-
@Test
public void testExtractRouteKey() throws BGPParsingException {
- final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create();
+ final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI =
+ ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_CHOICE_NID);
evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build());
evpnBI.withChild(createMACIpAdvChoice());
final EvpnDestination destResult = EvpnNlriParser.extractRouteKeyDestination(evpnBI.build());
- final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedRouteKey()).build();
+ final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD)
+ .setEvpnChoice(MACIpAdvRParserTest.createdExpectedRouteKey()).build();
assertEquals(expected, destResult);
}
}
\ No newline at end of file
public void parserTest() {
final IncMultiEthernetTagResCase expected = IncMultEthTagRParserTest.createIncMultiCase();
- assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected,
+ Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
assertEquals(expected, result);
assertEquals(expected, keyResult);
}
- public static IncMultiEthernetTagResCase createIncMultiCase() {
- return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(new IncMultiEthernetTagResBuilder().setEthernetTagId(ETI)
- .setOrigRouteIp(IP).build()).build();
+ static IncMultiEthernetTagResCase createIncMultiCase() {
+ return new IncMultiEthernetTagResCaseBuilder().setIncMultiEthernetTagRes(
+ new IncMultiEthernetTagResBuilder().setEthernetTagId(ETI).setOrigRouteIp(IP).build()).build();
}
@Test(expected = IllegalArgumentException.class)
public class MACIpAdvRParserTest {
private static final byte[] VALUE = {
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a,
(byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7,
(byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01,
private static final byte[] RESULT = {
(byte) 0x02, (byte) 0x28,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02,
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a,
(byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7,
(byte) 0x20, (byte) 0x7f, (byte) 0x00, (byte) 0x00, (byte) 0x01,
(byte) 0x05, (byte) 0xdc, (byte) 0x20
};
private static final byte[] VALUE2 = {
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00,
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00,
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a,
(byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7,
- (byte) 0x80, 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
- (byte) 0x05, (byte) 0xdc, (byte) 0x10,
+ (byte) 0x80, 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, (byte) 0x05, (byte) 0xdc, (byte) 0x10,
};
private static final byte[] RESULT2 = {
(byte) 0x02, (byte) 0x31,
(byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x01, (byte) 0x02, //RD
- (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02, (byte) 0x02, (byte) 0x00, //ESI
+ (byte) 0x02, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, (byte) 0x02,
+ (byte) 0x02, (byte) 0x00, //ESI
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, // ETI
(byte) 0x30, (byte) 0xf2, (byte) 0x0c, (byte) 0xdd, (byte) 0x80, (byte) 0x9f, (byte) 0xf7, // MAC
(byte) 0x80,//IPV6
@Test
public void parserCase1Test() {
final MacIpAdvRouteCase expected = createdExpectedResult();
- assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
+ assertArrayEquals(RESULT, ByteArray.getAllBytes(this.parser.serializeEvpn(expected,
+ Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE));
assertEquals(expected, result);
}
static MacIpAdvRouteCase createdExpectedResult() {
- return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI)
- .setMacAddress(MAC).setIpAddress(IP).setMplsLabel1(MPLS_LABEL).setMplsLabel2(MPLS_LABEL2).build()).build();
+ return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE)
+ .setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IP).setMplsLabel1(MPLS_LABEL)
+ .setMplsLabel2(MPLS_LABEL2).build()).build();
}
static MacIpAdvRouteCase createdExpectedRouteKey() {
- return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEthernetTagId(ETI).setMacAddress(MAC)
- .setIpAddress(IP).build()).build();
+ return new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEthernetTagId(ETI)
+ .setMacAddress(MAC).setIpAddress(IP).build()).build();
}
static ContainerNode createMacIpCont() {
@Test
public void parserCase2Test() {
- final MacIpAdvRouteCase expected = new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder().setEsi(LAN_AUT_GEN_CASE)
- .setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IPV6).setMplsLabel1(MPLS_LABEL).build()).build();
- assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected, Unpooled.wrappedBuffer(ROUDE_DISTIN))));
+ final MacIpAdvRouteCase expected = new MacIpAdvRouteCaseBuilder().setMacIpAdvRoute(new MacIpAdvRouteBuilder()
+ .setEsi(LAN_AUT_GEN_CASE).setEthernetTagId(ETI).setMacAddress(MAC).setIpAddress(IPV6)
+ .setMplsLabel1(MPLS_LABEL).build()).build();
+ assertArrayEquals(RESULT2, ByteArray.getAllBytes(this.parser.serializeEvpn(expected,
+ Unpooled.wrappedBuffer(ROUDE_DISTIN))));
final EvpnChoice result = this.parser.parseEvpn(Unpooled.wrappedBuffer(VALUE2));
assertEquals(expected, result);
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder();
choice.withNodeIdentifier(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID);
- final ContainerNode macIp = createContBuilder(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID).addChild(LanParserTest.createLanChoice()).addChild(createEti())
- .addChild(createValueBuilder(MAC_MODEL, MAC_NID).build()).addChild(createValueBuilder(IPV6_MODEL, IP_NID).build())
+ final ContainerNode macIp = createContBuilder(MACIpAdvRParser.MAC_IP_ADV_ROUTE_NID)
+ .addChild(LanParserTest.createLanChoice()).addChild(createEti())
+ .addChild(createValueBuilder(MAC_MODEL, MAC_NID).build())
+ .addChild(createValueBuilder(IPV6_MODEL, IP_NID).build())
.addChild(createValueBuilder(MPLS_LABEL_MODEL, MPLS1_NID).build()).build();
final EvpnChoice modelResult = this.parser.serializeEvpnModel(macIp);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.routes.evpn.routes.EvpnRoute;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
public class SimpleEsiTypeRegistryTest {
private static final int ESI_TYPE_LENGTH = 10;
- private class notRegistered implements Esi {
+ private class NotRegistered implements Esi {
@Override
public Class<? extends DataContainer> getImplementedInterface() {
- return notRegistered.class;
+ return NotRegistered.class;
}
}
@Test
public void registryTest() {
final ByteBuf buff = Unpooled.buffer(ESI_TYPE_LENGTH);
+
+ final SimpleEsiTypeRegistry reg = SimpleEsiTypeRegistry.getInstance();
SimpleEsiTypeRegistry.getInstance().serializeEsi(ROUTE_ID_CASE, buff);
assertArrayEquals(RouterIdParserTest.RESULT, ByteArray.getAllBytes(buff));
- assertEquals(ROUTE_ID_CASE, SimpleEsiTypeRegistry.getInstance().parseEsiModel(RouterIdParserTest.createRouterIdCase()));
- assertEquals(RouterIdParserTest.ROUTE_ID_CASE, SimpleEsiTypeRegistry.getInstance().parseEsi(Unpooled.wrappedBuffer(buff)));
+ assertEquals(ROUTE_ID_CASE, reg.parseEsiModel(RouterIdParserTest.createRouterIdCase()));
+ assertEquals(RouterIdParserTest.ROUTE_ID_CASE, reg.parseEsi(Unpooled.wrappedBuffer(buff)));
}
@Test(expected = IllegalArgumentException.class)
@Test
public void registryNullTest() {
final ByteBuf body = Unpooled.buffer();
- SimpleEsiTypeRegistry.getInstance().serializeEsi(new notRegistered(), body);
+ SimpleEsiTypeRegistry.getInstance().serializeEsi(new NotRegistered(), body);
assertEquals(0, body.readableBytes());
}
@Test(expected = IllegalArgumentException.class)
public void registryNullModelTest() {
- final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> noRegister = Builders.choiceBuilder();
- noRegister.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(EvpnRoute.QNAME, "no-register").intern()));
+ final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> noRegister =
+ Builders.choiceBuilder();
+ noRegister.withNodeIdentifier(new NodeIdentifier(QName.create(EvpnRoute.QNAME,
+ "no-register").intern()));
assertNull(SimpleEsiTypeRegistry.getInstance().parseEsiModel(noRegister.build()));
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.evpn.EvpnChoice;
import org.opendaylight.yangtools.yang.binding.DataContainer;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
public final class SimpleEvpnNlriRegistryTest {
- public static final YangInstanceIdentifier.NodeIdentifier EVPN_NID = new YangInstanceIdentifier.NodeIdentifier(EvpnChoice.QNAME);
+ public static final NodeIdentifier EVPN_NID = new NodeIdentifier(EvpnChoice.QNAME);
private class NotRegistered implements EvpnChoice {
@Override
@Test
public void registryTest() {
- final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE, Unpooled.wrappedBuffer(ROUDE_DISTIN));
+ final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE,
+ Unpooled.wrappedBuffer(ROUDE_DISTIN));
assertArrayEquals(EthADRParserTest.RESULT, ByteArray.getAllBytes(buff));
final EvpnChoice resultModel = SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(createEthADRModel());
assertEquals(ETHERNET_AD_ROUTE_CASE, resultModel);
@Test
public void registryNullModelTest() {
- final DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder().withNodeIdentifier(EVPN_NID);
- choice.addChild(createContBuilder(new YangInstanceIdentifier.NodeIdentifier(QName.create(Evpn.QNAME, "test").intern())).build()).build();
+ final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> choice = Builders.choiceBuilder()
+ .withNodeIdentifier(EVPN_NID);
+ choice.addChild(createContBuilder(new NodeIdentifier(QName.create(Evpn.QNAME, "test").intern()))
+ .build()).build();
assertNull(SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(choice.build()));
}
}
\ No newline at end of file