These violations have been piling up, clean most of them up.
Change-Id: I3f42f7d49028117b81b9963ab3efa750082cc7db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
protected abstract Notification parseBody(int type, ByteBuf body, int messageLength,
PeerSpecificParserConstraint constraint) throws BGPDocumentedException;
- protected abstract void serializeMessageImpl(final Notification message, final ByteBuf buffer);
+ protected abstract void serializeMessageImpl(Notification message, ByteBuf buffer);
static {
MARKER = new byte[MessageUtil.MARKER_LENGTH];
throws BGPDocumentedException, BGPParsingException {
Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes cannot be null or empty.");
Preconditions.checkArgument(buffer.readableBytes() >= MessageUtil.COMMON_HEADER_LENGTH,
- "Too few bytes in passed array. Passed: %s. Expected: >= %s.", buffer.readableBytes(), MessageUtil.COMMON_HEADER_LENGTH);
+ "Too few bytes in passed array. Passed: %s. Expected: >= %s.", buffer.readableBytes(),
+ MessageUtil.COMMON_HEADER_LENGTH);
final byte[] marker = ByteArray.readBytes(buffer, MessageUtil.MARKER_LENGTH);
if (!Arrays.equals(marker, MARKER)) {
final int messageType = UnsignedBytes.toInt(typeBytes);
if (messageLength < MessageUtil.COMMON_HEADER_LENGTH) {
- throw BGPDocumentedException.badMessageLength("Message length field not within valid range.", messageLength);
+ throw BGPDocumentedException.badMessageLength("Message length field not within valid range.",
+ messageLength);
}
if (messageLength - MessageUtil.COMMON_HEADER_LENGTH != buffer.readableBytes()) {
- throw new BGPParsingException("Size doesn't match size specified in header. Passed: " + buffer.readableBytes()
- + "; Expected: " + (messageLength - MessageUtil.COMMON_HEADER_LENGTH) + ". ");
+ throw new BGPParsingException("Size doesn't match size specified in header. Passed: "
+ + buffer.readableBytes() + "; Expected: " + (messageLength - MessageUtil.COMMON_HEADER_LENGTH)
+ + ". ");
}
final ByteBuf msgBody = buffer.readSlice(messageLength - MessageUtil.COMMON_HEADER_LENGTH);
final Notification msg = parseBody(messageType, msgBody, messageLength, constraint);
if (msg == null) {
- throw new BGPDocumentedException("Unhandled message type " + messageType, BGPError.BAD_MSG_TYPE, new byte[] { typeBytes });
+ throw new BGPDocumentedException("Unhandled message type " + messageType, BGPError.BAD_MSG_TYPE,
+ new byte[] { typeBytes });
}
return msg;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
/**
- *
+ * Attribute serializer/deserializer registry, exposing the capability to parse BGP attributes as a whole.
*/
public interface AttributeRegistry {
/**
* Parse BGP Attribute from buffer.
+ *
* @param buffer Input buffer.
* @param constraints Peer specific constraint.
* @return Decoded BGP Attribute.
/**
* Serialize BGP Attribute to buffer.
+ *
* @param attribute Input BGP Attribute.
* @param byteAggregator Output buffer.
*/
public interface AttributeSerializer {
- void serializeAttribute(final Attributes attribute,final ByteBuf byteAggregator);
+ void serializeAttribute(Attributes attribute, ByteBuf byteAggregator);
}
* Adds header to attribute value. If the length of the attribute value exceeds one-byte length field,
* set EXTENDED bit and write length as 2B field.
*
- * @param flags
+ * @param flags attribute flags
* @param type of the attribute
* @param value attribute value
* @param buffer ByteBuf where the attribute will be copied with its header
*/
public static void formatAttribute(final int flags, final int type, final ByteBuf value, final ByteBuf buffer) {
final int length = value.writerIndex();
- final boolean extended = (length > MAX_ATTR_LENGTH_FOR_SINGLE_BYTE) ? true : false;
- buffer.writeByte((extended) ? (flags | EXTENDED) : flags);
+ final boolean extended = length > MAX_ATTR_LENGTH_FOR_SINGLE_BYTE ? true : false;
+ buffer.writeByte(extended ? flags | EXTENDED : flags);
buffer.writeByte(type);
if (extended) {
buffer.writeShort(length);
AutoCloseable registerAttributeParser(int attributeType, AttributeParser parser);
- AutoCloseable registerAttributeSerializer(Class<? extends DataObject> attributeClass, AttributeSerializer serializer);
+ AutoCloseable registerAttributeSerializer(Class<? extends DataObject> attributeClass,
+ AttributeSerializer serializer);
AutoCloseable registerCapabilityParser(int capabilityType, CapabilityParser parser);
- AutoCloseable registerCapabilitySerializer(Class<? extends DataObject> capabilityClass, CapabilitySerializer serializer);
+ AutoCloseable registerCapabilitySerializer(Class<? extends DataObject> capabilityClass,
+ CapabilitySerializer serializer);
AutoCloseable registerMessageParser(int messageType, MessageParser parser);
AutoCloseable registerBgpPrefixSidTlvParser(int tlvType, BgpPrefixSidTlvParser parser);
- AutoCloseable registerBgpPrefixSidTlvSerializer(Class<? extends BgpPrefixSidTlv> tlvClass, BgpPrefixSidTlvSerializer serializer);
+ AutoCloseable registerBgpPrefixSidTlvSerializer(Class<? extends BgpPrefixSidTlv> tlvClass,
+ BgpPrefixSidTlvSerializer serializer);
AutoCloseable registerNlriParser(Class<? extends AddressFamily> afi, Class<? extends SubsequentAddressFamily> safi,
- NlriParser parser, final NextHopParserSerializer nextHopHandler, final Class<? extends CNextHop> cNextHopClass,
- final Class<? extends CNextHop>... cNextHopClassList);
+ NlriParser parser, NextHopParserSerializer nextHopHandler, Class<? extends CNextHop> cnextHopClass,
+ Class<? extends CNextHop>... cnextHopClassList);
AutoCloseable registerNlriSerializer(Class<? extends DataObject> nlriClass, NlriSerializer serializer);
AutoCloseable registerParameterParser(int parameterType, ParameterParser parser);
- AutoCloseable registerParameterSerializer(Class<? extends BgpParameters> paramClass, ParameterSerializer serializer);
+ AutoCloseable registerParameterSerializer(Class<? extends BgpParameters> paramClass,
+ ParameterSerializer serializer);
- AutoCloseable registerExtendedCommunitySerializer(final Class<? extends ExtendedCommunity> extendedCommunityClass,
- final ExtendedCommunitySerializer serializer);
+ AutoCloseable registerExtendedCommunitySerializer(Class<? extends ExtendedCommunity> extendedCommunityClass,
+ ExtendedCommunitySerializer serializer);
- AutoCloseable registerExtendedCommunityParser(final int type, final int subtype, final ExtendedCommunityParser parser);
+ AutoCloseable registerExtendedCommunityParser(int type, int subtype, ExtendedCommunityParser parser);
/**
* Get the context-wide cache for a particular object type.
*/
public interface BgpPrefixSidTlvParser {
/**
- * Method for parsing specific types of TLVs from incoming buffer
+ * Method for parsing specific types of TLVs from incoming buffer.
*
* @param buffer with TLV bytes
* @return instance of specific TLV
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv;
/**
- * BGP prefix SID TLVs registry for encoding/decoding
+ * BGP prefix SID TLVs registry for encoding/decoding.
*/
public interface BgpPrefixSidTlvRegistry {
/**
- * Decode incoming TLV
+ * Decode incoming TLV.
+ *
* @param type number of TLV
* @param buffer contains bytes of TLV
* @return instance of specific TLV
BgpPrefixSidTlv parseBgpPrefixSidTlv(int type, ByteBuf buffer);
/**
- * Encode TLV instance
+ * Encode TLV instance.
+ *
* @param tlv instance
* @param bytes encoded TLV outcome
*/
*/
public interface BgpPrefixSidTlvSerializer {
/**
- * Method for serializing specific types of TLVs from incoming buffer
+ * Method for serializing specific types of TLVs from incoming buffer.
*
* @param tlv instance
* @param bytes outcome serialized TLV
}
/**
- * Utilized method for serialization of BGP prefix SID TLV
+ * Utilized method for serialization of BGP prefix SID TLV.
*
* @param type of TLV
* @param value of TLV
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.bgp.parameters.optional.capabilities.CParameters;
public interface CapabilitySerializer {
- void serializeCapability(final CParameters capability, final ByteBuf byteAggregator);
+ void serializeCapability(CParameters capability, ByteBuf byteAggregator);
}
* @param messageLength Length of the BGP message.
* @param constraint Peer specific constraints, implementations may ignore them.
* @return Parsed BGP Message body.
- * @throws BGPDocumentedException
*/
@Nonnull Notification parseMessageBody(@Nonnull ByteBuf body, int messageLength,
@Nullable PeerSpecificParserConstraint constraint) throws BGPDocumentedException;
import org.opendaylight.yangtools.yang.binding.Notification;
/**
- * BGP Message codec registry, provides services
- * to encode/decode messages.
+ * BGP Message codec registry, provides services to encode/decode messages.
*/
public interface MessageRegistry {
/**
* @param bytes Input buffer with encoded message.
* @param constraint Peer specific constraint.
* @return Parsed BGP message.
- * @throws BGPDocumentedException
- * @throws BGPParsingException
*/
@Nonnull Notification parseMessage(@Nonnull ByteBuf bytes, @Nullable PeerSpecificParserConstraint constraint)
throws BGPDocumentedException, BGPParsingException;
* @param buffer Output buffer where message is to be written.
*/
void serializeMessage(@Nonnull Notification message, @Nonnull ByteBuf buffer);
-
}
}
/**
- * Check for NLRI attribute in Update message
+ * Check for NLRI attribute in Update message.
*
* @param message Update message
* @return true if any prefix or MP-REACH-NLRI attribute is present, false otherwise
}
/**
- * Finds MP-REACH-NLRI in Update message attributes
+ * Finds MP-REACH-NLRI in Update message attributes.
*
* @param attrs Update message attributes
* @return MP-REACH-NLRI if present in the attributes, null otherwise
}
/**
- * Finds MP-UNREACH-NLRI in Update message attributes
+ * Finds MP-UNREACH-NLRI in Update message attributes.
*
* @param attrs Update message attributes
* @return MP-UNREACH-NLRI if present in the attributes, null otherwise
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.BgpTableType;
/**
- * Holds user specific add-path constraints per AFI/SAFI (table type)
- *
+ * Holds user specific add-path constraints per AFI/SAFI (table type).
*/
public interface MultiPathSupport extends PeerConstraint {
-
/**
* Check if requested AFI/SAFI is supported.
- * @param tableType
+ *
+ * @param tableType Table type to check
* @return True if the table type is supported.
*/
boolean isTableTypeSupported(BgpTableType tableType);
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi;
import static java.util.Objects.requireNonNull;
* @param afiSafi Required AFI/SAFI
* @return True if AFI/SAFI is supported.
*/
- public static boolean isTableTypeSupported(@Nullable final PeerSpecificParserConstraint constraints, @Nonnull final BgpTableType afiSafi) {
+ public static boolean isTableTypeSupported(@Nullable final PeerSpecificParserConstraint constraints,
+ @Nonnull final BgpTableType afiSafi) {
requireNonNull(afiSafi);
if (constraints != null) {
final Optional<MultiPathSupport> peerConstraint = constraints.getPeerConstraint(MultiPathSupport.class);
return peerConstraint.isPresent() && peerConstraint.get().isTableTypeSupported(afiSafi);
}
return false;
-
}
-
}
private static final Logger LOG = LoggerFactory.getLogger(MultiprotocolCapabilitiesUtil.class);
public static final CParameters RR_CAPABILITY = new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setRouteRefreshCapability(new RouteRefreshCapabilityBuilder().build()).build()).build();
+ new CParameters1Builder().setRouteRefreshCapability(new RouteRefreshCapabilityBuilder().build()).build())
+ .build();
private static final int RESERVED = 1;
- private MultiprotocolCapabilitiesUtil() { throw new UnsupportedOperationException(); }
+ private MultiprotocolCapabilitiesUtil() {
+ throw new UnsupportedOperationException();
+ }
- public static void serializeMPAfiSafi(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg,
- final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final ByteBuf capBuffer) {
+ public static void serializeMPAfiSafi(final AddressFamilyRegistry afiReg,
+ final SubsequentAddressFamilyRegistry safiReg, final Class<? extends AddressFamily> afi,
+ final Class<? extends SubsequentAddressFamily> safi, final ByteBuf capBuffer) {
final Integer afival = afiReg.numberForClass(afi);
Preconditions.checkArgument(afival != null, "Unhandled address family " + afi);
capBuffer.writeShort(afival);
capBuffer.writeByte(safival);
}
- public static Optional<BgpTableType> parseMPAfiSafi(final ByteBuf buffer, final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
+ public static Optional<BgpTableType> parseMPAfiSafi(final ByteBuf buffer, final AddressFamilyRegistry afiReg,
+ final SubsequentAddressFamilyRegistry safiReg) {
final int afiVal = buffer.readUnsignedShort();
final Class<? extends AddressFamily> afi = afiReg.classForFamily(afiVal);
if (afi == null) {
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.next.hop.CNextHop;
/**
- * Handles Next Hop, by default use {@link NextHopUtil}
- * which is handles Ipv4 and Ipv6 Next hop.
+ * Handles Next Hop, by default use {@link NextHopUtil} which is handles Ipv4 and Ipv6 Next hop.
*/
public interface NextHopParserSerializer {
/**
- * Parse Next hop from buffer,
+ * Parse Next hop from buffer.
*
* @param buffer Encoded Next Hop in ByteBuf.
* @return CNextHop
- * @throws BGPParsingException
*/
- default CNextHop parseNextHop(@Nonnull ByteBuf buffer) throws BGPParsingException {
+ default CNextHop parseNextHop(@Nonnull final ByteBuf buffer) throws BGPParsingException {
return NextHopUtil.parseNextHop(buffer);
}
/**
- * Serialize Next Hop
+ * Serialize Next Hop.
*
- * @param cNextHop Next Hop container
+ * @param cnextHop Next Hop container
* @param byteAggregator return Encoded Next Hop in ByteBuf
*/
- default void serializeNextHop(@Nonnull CNextHop cNextHop, @Nonnull final ByteBuf byteAggregator) {
- NextHopUtil.serializeNextHop(cNextHop, byteAggregator);
+ default void serializeNextHop(@Nonnull final CNextHop cnextHop, @Nonnull final ByteBuf byteAggregator) {
+ NextHopUtil.serializeNextHop(cnextHop, byteAggregator);
}
}
* @param constraint Peer specific constraints.
* @throws BGPParsingException exception.
*/
- void parseNlri(
- @Nonnull final ByteBuf nlri,
- @Nonnull final MpReachNlriBuilder builder,
- @Nullable final PeerSpecificParserConstraint constraint)
- throws BGPParsingException;
+ void parseNlri(@Nonnull ByteBuf nlri, @Nonnull MpReachNlriBuilder builder,
+ @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
+
/**
* Parse MP UN_REACH NLRI from buffer.
*
* @param constraint Peer specific constraints.
* @throws BGPParsingException exception.
*/
- void parseNlri(
- @Nonnull final ByteBuf nlri,
- @Nonnull final MpUnreachNlriBuilder builder,
- @Nullable final PeerSpecificParserConstraint constraint)
- throws BGPParsingException;
+ void parseNlri(@Nonnull ByteBuf nlri, @Nonnull MpUnreachNlriBuilder builder,
+ @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.update.attributes.MpUnreachNlri;
/**
- * The codec registry for BGP NLRI, offers
- * services for NLRI encoding/decoding.
- *
+ * The codec registry for BGP NLRI, offers services for NLRI encoding/decoding.
*/
public interface NlriRegistry {
/**
* Decode MP REACH NLRI Attribute.
+ *
* @param buffer Input buffer.
* @param constraint Peer specific constraint.
* @return Parsed reach NLRI.
- * @throws BGPParsingException
*/
- @Nonnull MpReachNlri parseMpReach(
- @Nonnull ByteBuf buffer,
- @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
+ @Nonnull MpReachNlri parseMpReach(@Nonnull ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint)
+ throws BGPParsingException;
/**
* Decode MP REACH NLRI Attribute.
+ *
* @param buffer Input buffer.
* @param constraint Peer specific constraint.
* @return Parsed unreach NLRI.
- * @throws BGPParsingException
*/
- @Nonnull MpUnreachNlri parseMpUnreach(
- @Nonnull ByteBuf buffer,
- @Nullable PeerSpecificParserConstraint constraint) throws BGPParsingException;
+ @Nonnull MpUnreachNlri parseMpUnreach(@Nonnull ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint)
+ throws BGPParsingException;
/**
* Encode BGP MP REACH NLRI Attribute.
+ *
* @param mpReachNlri Input reach NLRI.
* @param byteAggregator Output buffer.
*/
/**
* Encode BGP MP UNREACH NLRI Attribute.
+ *
* @param mpUnreachNlri Input unreach NLRI.
* @param byteAggregator Output buffer.
*/
/**
* Get all available NLRI encoders.
+ *
* @return Iterable of NLRI serializers.
*/
Iterable<NlriSerializer> getSerializers();
package org.opendaylight.protocol.bgp.parser.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
public interface NlriSerializer {
- void serializeAttribute(final Attributes attribute, final ByteBuf byteAggregator);
-
+ void serializeAttribute(Attributes attribute, ByteBuf byteAggregator);
}
}
/**
- * Extract PathId from route change received
+ * Extract PathId from route change received.
*
* @param data Data containing the path Id
* @param pathNii Path Id NodeIdentifier specific per each Rib support
/**
* Determine Revised Error Handling from the contents of a {@link PeerSpecificParserConstraint}.
*
- * @param constraint
+ * @param constraint Peer-specific constraint
* @return Revised Error Handling treatment message/attributes should receive.
*/
public static RevisedErrorHandling from(final @Nullable PeerSpecificParserConstraint constraint) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
-public abstract class Abstract4OctetAsExtendedCommunity implements ExtendedCommunityParser, ExtendedCommunitySerializer {
+public abstract class Abstract4OctetAsExtendedCommunity implements ExtendedCommunityParser,
+ ExtendedCommunitySerializer {
private static final int TRANSITIVE_TYPE = 2;
private static final int NON_TRANSITIVE_TYPE = 66;
@Override
public int getType(final boolean isTransitive) {
- if (isTransitive) {
- return TRANSITIVE_TYPE;
- }
- return NON_TRANSITIVE_TYPE;
+ return isTransitive ? TRANSITIVE_TYPE : NON_TRANSITIVE_TYPE;
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
-
-public abstract class AbstractTwoOctetAsExtendedCommunity implements ExtendedCommunityParser, ExtendedCommunitySerializer {
+public abstract class AbstractTwoOctetAsExtendedCommunity implements ExtendedCommunityParser,
+ ExtendedCommunitySerializer {
private static final int TYPE = 0;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
import io.netty.buffer.ByteBuf;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
/**
- * The Extended Community value parser (ByteBuf to ExtendedCommunity)
- *
+ * The Extended Community value parser (ByteBuf to ExtendedCommunity).
*/
public interface ExtendedCommunityParser {
-
/**
* Parses the Extended Community value encoded in the buffer.
+ *
* @param buffer ByteBuf
* @return Decoded Extended Community value.
- * @throws BGPDocumentedException
- * @throws BGPParsingException
*/
ExtendedCommunity parseExtendedCommunity(ByteBuf buffer) throws BGPDocumentedException, BGPParsingException;
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
import io.netty.buffer.ByteBuf;
/**
* The Extended Communities registry.
- *
*/
public interface ExtendedCommunityRegistry {
-
/**
* Parses the Extended Community.
+ *
* @param buffer ByteBuf
* @return Decoded ExtendedCommunity or null if the parser for such Extended Community type/sub-type is not present.
- * @throws BGPDocumentedException
- * @throws BGPParsingException
*/
ExtendedCommunities parseExtendedCommunity(ByteBuf buffer) throws BGPDocumentedException, BGPParsingException;
/**
* Serializes the Extended Community.
+ *
* @param extendedCommunity ExtendedCommunity to be encoded.
- * @param byteAggregator ByteBuf, where the Extended Community is serialized,
- * if a serialized is not present for such Extended Community type, no bytes are written into output buffer.
+ * @param byteAggregator ByteBuf, where the Extended Community is serialized, if a serialized is not present for
+ * such Extended Community type, no bytes are written into output buffer.
*/
void serializeExtendedCommunity(ExtendedCommunities extendedCommunity, ByteBuf byteAggregator);
-
}
/**
* The utility functions related to the extended communities.
- *
*/
public final class ExtendedCommunityUtil {
/**
* Sets transitivity flag for the Extended Community type.
+ *
* @param type Extended Community Type
* @param isTransitive Extended Community transitivity
- * @return Extended Community type with a transitivity flag set if isTransitive false, otherwise returns unchanged type.
+ * @return Extended Community type with a transitivity flag set if isTransitive false, otherwise returns unchanged
+ * type.
*/
public static int setTransitivity(final int type, final boolean isTransitive) {
return isTransitive ? type : ExtendedCommunityUtil.toNonTransitiveType(type);
/**
* Check the Extended Community type for transitivity.
+ *
* @param type Extended Community Type
* @return True if input type is transitive, false if the type is non-transitive
*/
private static int toNonTransitiveType(final int type) {
return type | NON_TRANS;
}
-
}
/*
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
*
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
import static org.opendaylight.protocol.bgp.parser.spi.extended.community.AbstractIpv4ExtendedCommunity.INET_LOCAL_ADMIN_LENGTH;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import static java.util.Objects.requireNonNull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.add.path.capability.AddressFamilies;
public final class MultiPathSupportImpl implements MultiPathSupport {
-
private final Set<BgpTableType> supportedTables;
private MultiPathSupportImpl(final Set<BgpTableType> supportedTables) {
* @param addPathCapabilities The remote add-path capabilities list.
* @return MultiPathSupport instance.
*/
- public static MultiPathSupport createParserMultiPathSupport(@Nonnull final List<AddressFamilies> addPathCapabilities) {
+ public static MultiPathSupport createParserMultiPathSupport(
+ @Nonnull final List<AddressFamilies> addPathCapabilities) {
requireNonNull(addPathCapabilities);
final Set<BgpTableType> support = addPathCapabilities
.stream()
public boolean isTableTypeSupported(final BgpTableType tableType) {
return this.supportedTables.contains(tableType);
}
-
}
public final class ServiceLoaderBGPExtensionProviderContext {
private static final class Holder {
- private static final BGPExtensionProviderContext INSTANCE;
+ private static final BGPExtensionProviderContext INSTANCE = create();
private Holder() {
}
-
- static {
- try {
- INSTANCE = create();
- } catch (final Exception e) {
- throw new ExceptionInInitializerError(e);
- }
- }
}
public static BGPExtensionProviderContext create() {
final BGPExtensionProviderContext ctx = new SimpleBGPExtensionProviderContext();
- final ServiceLoader<BGPExtensionProviderActivator> loader = ServiceLoader.load(BGPExtensionProviderActivator.class);
+ final ServiceLoader<BGPExtensionProviderActivator> loader = ServiceLoader.load(
+ BGPExtensionProviderActivator.class);
for (final BGPExtensionProviderActivator a : loader) {
a.start(ctx);
}
import org.opendaylight.protocol.util.Values;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.AddressFamily;
-final class SimpleAddressFamilyRegistry extends AbstractFamilyRegistry<AddressFamily, Integer> implements AddressFamilyRegistry {
+final class SimpleAddressFamilyRegistry extends AbstractFamilyRegistry<AddressFamily, Integer>
+ implements AddressFamilyRegistry {
AutoCloseable registerAddressFamily(final Class<? extends AddressFamily> clazz, final int number) {
Preconditions.checkArgument(number >= 0 && number <= Values.UNSIGNED_SHORT_MAX_VALUE);
return super.registerFamily(clazz, number);
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.Notification;
-public class SimpleBGPExtensionProviderContext extends SimpleBGPExtensionConsumerContext implements BGPExtensionProviderContext {
+public class SimpleBGPExtensionProviderContext extends SimpleBGPExtensionConsumerContext
+ implements BGPExtensionProviderContext {
public static final int DEFAULT_MAXIMUM_CACHED_OBJECTS = 100000;
}
@Override
- public AutoCloseable registerAttributeSerializer(final Class<? extends DataObject> attributeClass, final AttributeSerializer serializer) {
+ public AutoCloseable registerAttributeSerializer(final Class<? extends DataObject> attributeClass,
+ final AttributeSerializer serializer) {
return this.getAttributeRegistry().registerAttributeSerializer(attributeClass, serializer);
}
}
@Override
- public AutoCloseable registerCapabilitySerializer(final Class<? extends DataObject> capabilityClass, final CapabilitySerializer serializer) {
+ public AutoCloseable registerCapabilitySerializer(final Class<? extends DataObject> capabilityClass,
+ final CapabilitySerializer serializer) {
return this.getCapabilityRegistry().registerCapabilitySerializer(capabilityClass, serializer);
}
}
@Override
- public AutoCloseable registerMessageSerializer(final Class<? extends Notification> messageClass, final MessageSerializer serializer) {
+ public AutoCloseable registerMessageSerializer(final Class<? extends Notification> messageClass,
+ final MessageSerializer serializer) {
return this.getMessageRegistry().registerMessageSerializer(messageClass, serializer);
}
@Override
- public AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi,
- final NlriParser parser, final NextHopParserSerializer nextHopParserSerializer, final Class<? extends
- CNextHop> cNextHopClass, final Class<? extends CNextHop>... cNextHopClassList) {
- return this.getNlriRegistry().registerNlriParser(afi, safi, parser, nextHopParserSerializer, cNextHopClass, cNextHopClassList);
+ public AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi,
+ final Class<? extends SubsequentAddressFamily> safi, final NlriParser parser,
+ final NextHopParserSerializer nextHopParserSerializer, final Class<? extends CNextHop> cnextHopClass,
+ final Class<? extends CNextHop>... cnextHopClassList) {
+ return this.getNlriRegistry().registerNlriParser(afi, safi, parser, nextHopParserSerializer, cnextHopClass,
+ cnextHopClassList);
}
@Override
- public AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final NlriSerializer serializer) {
+ public AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass,
+ final NlriSerializer serializer) {
return this.getNlriRegistry().registerNlriSerializer(nlriClass, serializer);
}
}
@Override
- public AutoCloseable registerParameterSerializer(final Class<? extends BgpParameters> paramClass, final ParameterSerializer serializer) {
+ public AutoCloseable registerParameterSerializer(final Class<? extends BgpParameters> paramClass,
+ final ParameterSerializer serializer) {
return this.getParameterRegistry().registerParameterSerializer(paramClass, serializer);
}
@Override
- public AutoCloseable registerSubsequentAddressFamily(final Class<? extends SubsequentAddressFamily> clazz, final int number) {
+ public AutoCloseable registerSubsequentAddressFamily(final Class<? extends SubsequentAddressFamily> clazz,
+ final int number) {
return this.getSubsequentAddressFamilyRegistry().registerSubsequentAddressFamily(clazz, number);
}
}
@Override
- public AutoCloseable registerExtendedCommunitySerializer(final Class<? extends ExtendedCommunity> extendedCommunityClass,
+ public AutoCloseable registerExtendedCommunitySerializer(
+ final Class<? extends ExtendedCommunity> extendedCommunityClass,
final ExtendedCommunitySerializer serializer) {
- return this.getExtendedCommunityRegistry().registerExtendedCommunitySerializer(extendedCommunityClass, serializer);
+ return this.getExtendedCommunityRegistry().registerExtendedCommunitySerializer(extendedCommunityClass,
+ serializer);
}
@Override
- public AutoCloseable registerExtendedCommunityParser(final int type, final int subtype, final ExtendedCommunityParser parser) {
+ public AutoCloseable registerExtendedCommunityParser(final int type, final int subtype,
+ final ExtendedCommunityParser parser) {
return this.getExtendedCommunityRegistry().registerExtendedCommunityParser(type, subtype, parser);
}
}
@Override
- public AutoCloseable registerBgpPrefixSidTlvSerializer(final Class<? extends BgpPrefixSidTlv> tlvClass, final BgpPrefixSidTlvSerializer serializer) {
+ public AutoCloseable registerBgpPrefixSidTlvSerializer(final Class<? extends BgpPrefixSidTlv> tlvClass,
+ final BgpPrefixSidTlvSerializer serializer) {
return this.getBgpPrefixSidTlvRegistry().registerBgpPrefixSidTlvSerializer(tlvClass, serializer);
}
}
public void start() {
LOG.debug("Starting {} BGPExtensionProviderActivator instances", this.extensionActivators.size());
- for(final BGPExtensionProviderActivator e : this.extensionActivators) {
+ for (final BGPExtensionProviderActivator e : this.extensionActivators) {
e.start(this.providerContext);
}
}
public void close() {
LOG.debug("Stopping {} BGPExtensionProviderActivator instances", this.extensionActivators.size());
- for(final BGPExtensionProviderActivator e : this.extensionActivators) {
+ for (final BGPExtensionProviderActivator e : this.extensionActivators) {
e.stop();
}
}
public final class SimpleBgpPrefixSidTlvRegistry implements BgpPrefixSidTlvRegistry {
- private final HandlerRegistry<DataContainer, BgpPrefixSidTlvParser, BgpPrefixSidTlvSerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, BgpPrefixSidTlvParser, BgpPrefixSidTlvSerializer> handlers =
+ new HandlerRegistry<>();
AutoCloseable registerBgpPrefixSidTlvParser(final int tlvType, final BgpPrefixSidTlvParser parser) {
Preconditions.checkArgument(tlvType >= 0 && tlvType <= Values.UNSIGNED_BYTE_MAX_VALUE);
return this.handlers.registerParser(tlvType, parser);
}
- AutoCloseable registerBgpPrefixSidTlvSerializer(final Class<? extends BgpPrefixSidTlv> tlvClass, final BgpPrefixSidTlvSerializer serializer) {
+ AutoCloseable registerBgpPrefixSidTlvSerializer(final Class<? extends BgpPrefixSidTlv> tlvClass,
+ final BgpPrefixSidTlvSerializer serializer) {
return this.handlers.registerSerializer(tlvClass, serializer);
}
return null;
}
final int length = buffer.readUnsignedShort();
- Preconditions.checkState(length <= buffer.readableBytes(), "Length of BGP prefix SID TLV exceeds readable bytes of income.");
+ Preconditions.checkState(length <= buffer.readableBytes(),
+ "Length of BGP prefix SID TLV exceeds readable bytes of income.");
return parser.parseBgpPrefixSidTlv(buffer.readBytes(length));
}
serializer.serializeBgpPrefixSidTlv(tlv, valueBuf);
BgpPrefixSidTlvUtil.formatBgpPrefixSidTlv(serializer.getType(), valueBuf, bytes);
}
-
}
import org.opendaylight.yangtools.yang.binding.DataObject;
final class SimpleCapabilityRegistry implements CapabilityRegistry {
- private final HandlerRegistry<DataContainer, CapabilityParser, CapabilitySerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, CapabilityParser, CapabilitySerializer> handlers =
+ new HandlerRegistry<>();
AutoCloseable registerCapabilityParser(final int messageType, final CapabilityParser parser) {
Preconditions.checkArgument(messageType >= 0 && messageType <= Values.UNSIGNED_BYTE_MAX_VALUE);
return this.handlers.registerParser(messageType, parser);
}
- AutoCloseable registerCapabilitySerializer(final Class<? extends DataObject> paramClass, final CapabilitySerializer serializer) {
+ AutoCloseable registerCapabilitySerializer(final Class<? extends DataObject> paramClass,
+ final CapabilitySerializer serializer) {
return this.handlers.registerSerializer(paramClass, serializer);
}
@Override
- public CParameters parseCapability(final int type, final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public CParameters parseCapability(final int type, final ByteBuf buffer) throws BGPDocumentedException,
+ BGPParsingException {
final CapabilityParser parser = this.handlers.getParser(type);
if (parser == null) {
return null;
}
@Override
- public void serializeCapability(final CParameters capability, ByteBuf bytes) {
+ public void serializeCapability(final CParameters capability, final ByteBuf bytes) {
for (CapabilitySerializer s : this.handlers.getAllSerializers()) {
s.serializeCapability(capability, bytes);
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import static org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityUtil.isTransitive;
private static final int EXTENDED_COMMUNITY_LENGTH = 6;
- private final HandlerRegistry<DataContainer, ExtendedCommunityParser, ExtendedCommunitySerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, ExtendedCommunityParser, ExtendedCommunitySerializer> handlers =
+ new HandlerRegistry<>();
private static int createKey(final int type, final int subtype) {
- return (type << Byte.SIZE) | subtype;
+ return type << Byte.SIZE | subtype;
}
@Override
@Override
public void serializeExtendedCommunity(final ExtendedCommunities extendedCommunity, final ByteBuf byteAggregator) {
- final ExtendedCommunitySerializer serializer = this.handlers.getSerializer(extendedCommunity.getExtendedCommunity().getImplementedInterface());
+ final ExtendedCommunitySerializer serializer = this.handlers.getSerializer(extendedCommunity
+ .getExtendedCommunity().getImplementedInterface());
if (serializer == null) {
return;
}
- ByteBufWriteUtil.writeUnsignedByte(Shorts.checkedCast(serializer.getType(extendedCommunity.isTransitive())), byteAggregator);
+ ByteBufWriteUtil.writeUnsignedByte(Shorts.checkedCast(serializer.getType(extendedCommunity.isTransitive())),
+ byteAggregator);
ByteBufWriteUtil.writeUnsignedByte(Shorts.checkedCast(serializer.getSubType()), byteAggregator);
serializer.serializeExtendedCommunity(extendedCommunity.getExtendedCommunity(), byteAggregator);
}
synchronized AutoCloseable registerExtendedCommunitySerializer(
- final Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity> extendedCommunityClass,
+ final Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329
+ .extended.community.ExtendedCommunity> extendedCommunityClass,
final ExtendedCommunitySerializer serializer) {
return this.handlers.registerSerializer(extendedCommunityClass, serializer);
}
- synchronized AutoCloseable registerExtendedCommunityParser(final int type, final int subtype, final ExtendedCommunityParser parser) {
+ synchronized AutoCloseable registerExtendedCommunityParser(final int type, final int subtype,
+ final ExtendedCommunityParser parser) {
checkTypes(type, subtype);
return this.handlers.registerParser(createKey(type, subtype), parser);
}
private static void checkTypes(final int type, final int subtype) {
Preconditions.checkArgument(type >= 0 && type <= UNSIGNED_BYTE_MAX_VALUE, "Illegal extended-community type %s",
type);
- Preconditions.checkArgument(subtype >= 0 && subtype <= UNSIGNED_BYTE_MAX_VALUE, "Illegal extended-community sub-type %s", subtype);
+ Preconditions.checkArgument(subtype >= 0 && subtype <= UNSIGNED_BYTE_MAX_VALUE,
+ "Illegal extended-community sub-type %s", subtype);
}
}
return this.handlers.registerParser(messageType, parser);
}
- AutoCloseable registerMessageSerializer(final Class<? extends Notification> messageClass, final MessageSerializer serializer) {
+ AutoCloseable registerMessageSerializer(final Class<? extends Notification> messageClass,
+ final MessageSerializer serializer) {
return this.handlers.registerSerializer(messageClass, serializer);
}
}
private final SubsequentAddressFamilyRegistry safiReg;
private final AddressFamilyRegistry afiReg;
- public SimpleNlriRegistry(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
+ SimpleNlriRegistry(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
this.afiReg = requireNonNull(afiReg);
this.safiReg = requireNonNull(safiReg);
}
return new BgpTableTypeImpl(afi, safi);
}
- synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass, final
- NlriSerializer serializer){
+ synchronized AutoCloseable registerNlriSerializer(final Class<? extends DataObject> nlriClass,
+ final NlriSerializer serializer) {
final NlriSerializer prev = this.serializers.get(nlriClass);
Preconditions.checkState(prev == null, "Serializer already bound to class " + prev);
synchronized AutoCloseable registerNlriParser(final Class<? extends AddressFamily> afi,
final Class<? extends SubsequentAddressFamily> safi, final NlriParser parser,
- final NextHopParserSerializer nextHopSerializer, final Class<? extends CNextHop> cNextHopClass,
- final Class<? extends CNextHop>... cNextHopClassList) {
+ final NextHopParserSerializer nextHopSerializer, final Class<? extends CNextHop> cnextHopClass,
+ final Class<? extends CNextHop>... cnextHopClassList) {
final BgpTableType key = createKey(afi, safi);
final NlriParser prev = this.handlers.get(key);
Preconditions.checkState(prev == null, "AFI/SAFI is already bound to parser " + prev);
this.handlers.put(key, parser);
this.nextHopParsers.put(key,nextHopSerializer);
- if (cNextHopClass != null) {
- final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cNextHopClass, key);
+ if (cnextHopClass != null) {
+ final Entry<Class<? extends CNextHop>, BgpTableType> nhKey = new SimpleEntry<>(cnextHopClass, key);
this.nextHopSerializers.put(nhKey, nextHopSerializer);
- for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
- final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cNextHop, key);
+ for (final Class<? extends CNextHop> cnextHop : cnextHopClassList) {
+ final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys = new SimpleEntry<>(cnextHop, key);
this.nextHopSerializers.put(nhKeys, nextHopSerializer);
}
}
synchronized (lock) {
SimpleNlriRegistry.this.handlers.remove(key);
SimpleNlriRegistry.this.nextHopParsers.remove(key);
- if (cNextHopClass != null) {
+ if (cnextHopClass != null) {
final Entry<Class<? extends CNextHop>, BgpTableType> nhKey
- = new SimpleEntry<>(cNextHopClass, key);
+ = new SimpleEntry<>(cnextHopClass, key);
SimpleNlriRegistry.this.nextHopSerializers.remove(nhKey);
- for (final Class<? extends CNextHop> cNextHop : cNextHopClassList) {
+ for (final Class<? extends CNextHop> cnextHop : cnextHopClassList) {
final Entry<Class<? extends CNextHop>, BgpTableType> nhKeys
- = new SimpleEntry<>(cNextHop, key);
+ = new SimpleEntry<>(cnextHop, key);
SimpleNlriRegistry.this.nextHopSerializers.remove(nhKeys);
}
}
import org.opendaylight.yangtools.yang.binding.DataContainer;
final class SimpleParameterRegistry implements ParameterRegistry {
- private final HandlerRegistry<DataContainer, ParameterParser, ParameterSerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, ParameterParser, ParameterSerializer> handlers =
+ new HandlerRegistry<>();
AutoCloseable registerParameterParser(final int messageType, final ParameterParser parser) {
Preconditions.checkArgument(messageType >= 0 && messageType <= Values.UNSIGNED_BYTE_MAX_VALUE);
return this.handlers.registerParser(messageType, parser);
}
- AutoCloseable registerParameterSerializer(final Class<? extends BgpParameters> paramClass, final ParameterSerializer serializer) {
+ AutoCloseable registerParameterSerializer(final Class<? extends BgpParameters> paramClass,
+ final ParameterSerializer serializer) {
return this.handlers.registerSerializer(paramClass, serializer);
}
@Override
- public BgpParameters parseParameter(final int parameterType, final ByteBuf buffer) throws BGPParsingException, BGPDocumentedException {
+ public BgpParameters parseParameter(final int parameterType, final ByteBuf buffer) throws BGPParsingException,
+ BGPDocumentedException {
final ParameterParser parser = this.handlers.getParser(parameterType);
if (parser == null) {
return null;
return parser.parseParameter(buffer);
}
- public void serializeParameter(final BgpParameters parameter, ByteBuf bytes) {
+ @Override
+ public void serializeParameter(final BgpParameters parameter, final ByteBuf bytes) {
final ParameterSerializer serializer = this.handlers.getSerializer(parameter.getImplementedInterface());
if (serializer == null) {
return;
*/
package org.opendaylight.protocol.bgp.parser.spi.pojo;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
import org.opendaylight.protocol.bgp.parser.spi.SubsequentAddressFamilyRegistry;
import org.opendaylight.protocol.util.Values;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.SubsequentAddressFamily;
-final class SimpleSubsequentAddressFamilyRegistry extends AbstractFamilyRegistry<SubsequentAddressFamily, Integer> implements
- SubsequentAddressFamilyRegistry {
- AutoCloseable registerSubsequentAddressFamily(final Class<? extends SubsequentAddressFamily> clazz, final int number) {
- Preconditions.checkArgument(number >= 0 && number <= Values.UNSIGNED_BYTE_MAX_VALUE);
+final class SimpleSubsequentAddressFamilyRegistry extends AbstractFamilyRegistry<SubsequentAddressFamily, Integer>
+ implements SubsequentAddressFamilyRegistry {
+ AutoCloseable registerSubsequentAddressFamily(final Class<? extends SubsequentAddressFamily> clazz,
+ final int number) {
+ checkArgument(number >= 0 && number <= Values.UNSIGNED_BYTE_MAX_VALUE);
return super.registerFamily(clazz, number);
}
public class AbstractMessageRegistryTest {
- public static final byte[] keepAliveBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
+ public static final byte[] KEEPALIVE_BMSG = new byte[] {
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0x00, (byte) 0x13, (byte) 0x04
+ };
private final AbstractMessageRegistry registry = new AbstractMessageRegistry() {
@Override
protected void serializeMessageImpl(final Notification message, final ByteBuf buffer) {
- buffer.writeBytes(keepAliveBMsg);
+ buffer.writeBytes(KEEPALIVE_BMSG);
}
@Override
final Notification keepAlive = new KeepaliveBuilder().build();
final ByteBuf buffer = Unpooled.buffer();
this.registry.serializeMessage(keepAlive, buffer);
- assertArrayEquals(keepAliveBMsg, ByteArray.getAllBytes(buffer));
+ assertArrayEquals(KEEPALIVE_BMSG, ByteArray.getAllBytes(buffer));
- final Notification not = this.registry.parseMessage(Unpooled.copiedBuffer(keepAliveBMsg), null);
+ final Notification not = this.registry.parseMessage(Unpooled.copiedBuffer(KEEPALIVE_BMSG), null);
assertTrue(not instanceof Keepalive);
}
@Test
public void testIncompleteMarker() {
- final byte[] testBytes = new byte[] { (byte) 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
+ final byte[] testBytes = new byte[] {
+ (byte) 0x00, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0x00, (byte) 0x13, (byte) 0x04
+ };
try {
this.registry.parseMessage(Unpooled.copiedBuffer(testBytes), null);
Assert.fail();
@Test
public void testInvalidLength() {
- final byte[] testBytes = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x12, (byte) 0x04 };
+ final byte[] testBytes = new byte[] {
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0x00, (byte) 0x12, (byte) 0x04
+ };
try {
this.registry.parseMessage(Unpooled.copiedBuffer(testBytes), null);
Assert.fail();
@Test
public void testInvalidSpecifiedSize() {
- final byte[] testBytes = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
- (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04, (byte) 0x04 };
+ final byte[] testBytes = new byte[] {
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+ (byte) 0x00, (byte) 0x13, (byte) 0x04, (byte) 0x04
+ };
try {
this.registry.parseMessage(Unpooled.copiedBuffer(testBytes), null);
Assert.fail();
@Test
public void testBGPHeaderParser() throws Exception {
- final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
+ final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
+ .getMessageRegistry();
try {
msgReg.parseMessage(Unpooled.copiedBuffer(new byte[] { (byte) 0, (byte) 0 }), null);
fail("Exception should have occured.");
@Test
public void testMessageParser() throws Exception {
- final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
+ final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance()
+ .getMessageRegistry();
String ex = "";
try {
msgReg.serializeMessage(null, Unpooled.EMPTY_BUFFER);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi;
import java.util.Optional;
public class MultiPathSupportUtilTest {
- private static final BgpTableType AFI_SAFI = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private static final BgpTableType AFI_SAFI = new BgpTableTypeImpl(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
@Mock
private PeerSpecificParserConstraint constraints;
Assert.assertFalse(MultiPathSupportUtil.isTableTypeSupported(null, AFI_SAFI));
}
- @Test(expected=NullPointerException.class)
+ @Test(expected = NullPointerException.class)
public void testIsTableTypeSupportedNPE() {
MultiPathSupportUtil.isTableTypeSupported(null, null);
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
@Test
public void testExtractPathId() {
- final NodeIdentifier NII = new NodeIdentifier(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet", "2015-03-05", "path-id").intern());
+ final NodeIdentifier NII = new NodeIdentifier(QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
+ "2015-03-05", "path-id").intern());
final long pathIdValue = 0;
- final ContainerNode cont = ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(NII).
- addChild(new ImmutableLeafNodeBuilder<>().withNodeIdentifier(NII).withValue(pathIdValue).build()).build();
+ final ContainerNode cont = ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(NII).addChild(
+ new ImmutableLeafNodeBuilder<>().withNodeIdentifier(NII).withValue(pathIdValue).build()).build();
Assert.assertEquals(pathIdValue, PathIdUtil.extractPathId(cont, NII).longValue());
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testReadPathIdBufferNull() {
PathIdUtil.readPathId(null);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testReadPathIdBufferEmpty() {
PathIdUtil.readPathId(this.buffer);
}
-
}
@Test
public void testMessageUtil() {
final byte[] result = new byte[] { UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
- UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
- UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
- UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, 0, 23, 3, 32, 5, 14, 21 };
+ UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
+ UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
+ UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE, UnsignedBytes.MAX_VALUE,
+ UnsignedBytes.MAX_VALUE, 0, 23, 3, 32, 5, 14, 21 };
final ByteBuf formattedMessage = Unpooled.buffer();
MessageUtil.formatMessage(3, Unpooled.wrappedBuffer(new byte[] { 32, 5, 14, 21 }), formattedMessage);
assertArrayEquals(result, ByteArray.getAllBytes(formattedMessage));
public void testMultiprotocolCapabilitiesUtil() throws BGPParsingException {
final byte[] bytes = new byte[] {0, 1, 0, 1};
final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
- final BgpTableType parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg, this.safiReg).get();
+ final BgpTableType parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg,
+ this.safiReg).get();
assertEquals(Ipv4AddressFamily.class, parsedAfiSafi.getAfi());
assertEquals(UnicastSubsequentAddressFamily.class, parsedAfiSafi.getSafi());
final ByteBuf serializedAfiSafi = Unpooled.buffer(4);
- MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, serializedAfiSafi);
+ MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, serializedAfiSafi);
assertArrayEquals(bytes, serializedAfiSafi.array());
}
public void testUnsupportedAfi() {
final byte[] bytes = new byte[] {0, 2, 0, 1};
final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
- final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg, this.safiReg);
+ final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg,
+ this.safiReg);
Assert.assertFalse(parsedAfiSafi.isPresent());
}
public void testUnsupportedSafi() {
final byte[] bytes = new byte[] {0, 1, 0, 3};
final ByteBuf bytesBuf = Unpooled.copiedBuffer(bytes);
- final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg, this.safiReg);
+ final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(bytesBuf, this.afiReg,
+ this.safiReg);
Assert.assertFalse(parsedAfiSafi.isPresent());
}
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testAttributeUtilPrivateConstructor() throws Throwable {
final Constructor<AttributeUtil> c = AttributeUtil.class.getDeclaredConstructor();
c.setAccessible(true);
}
}
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testCapabilityUtilPrivateConstructor() throws Throwable {
final Constructor<CapabilityUtil> c = CapabilityUtil.class.getDeclaredConstructor();
c.setAccessible(true);
}
}
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testMessageUtilPrivateConstructor() throws Throwable {
final Constructor<MessageUtil> c = MessageUtil.class.getDeclaredConstructor();
c.setAccessible(true);
}
}
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testParameterUtilPrivateConstructor() throws Throwable {
final Constructor<ParameterUtil> c = ParameterUtil.class.getDeclaredConstructor();
c.setAccessible(true);
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
public class AbstractIpv4ExtendedCommunityTest {
public void testGetType() {
final AbstractIpv4ExtendedCommunity abstractIpv4ExtendedCommunity = new AbstractIpv4ExtendedCommunity() {
@Override
- public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
+ public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity,
+ final ByteBuf byteAggregator) {
}
+
@Override
public int getSubType() {
return 0;
}
+
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
return null;
}
};
Assert.assertEquals(1, abstractIpv4ExtendedCommunity.getType(true));
Assert.assertEquals(65, abstractIpv4ExtendedCommunity.getType(false));
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
public class AbstractOpaqueExtendedCommunityTest {
@Test
public void testGetType() {
final AbstractOpaqueExtendedCommunity abstractOpaqueExtendedCommunity = new AbstractOpaqueExtendedCommunity() {
-
@Override
- public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
+ public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity,
+ final ByteBuf byteAggregator) {
}
+
@Override
public int getSubType() {
return 0;
}
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
return null;
}
};
Assert.assertEquals(3, abstractOpaqueExtendedCommunity.getType(true));
Assert.assertEquals(67, abstractOpaqueExtendedCommunity.getType(false));
}
-
}
import io.netty.buffer.ByteBuf;
import org.junit.Assert;
import org.junit.Test;
-import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
-import org.opendaylight.protocol.bgp.parser.BGPParsingException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.extended.community.ExtendedCommunity;
public class AbstractTwoOctetAsExtendedCommunityTest {
-
@Test
public void testGetType() {
- final AbstractTwoOctetAsExtendedCommunity abstractTwoOctetAsExtendedCommunity = new AbstractTwoOctetAsExtendedCommunity() {
+ final AbstractTwoOctetAsExtendedCommunity abstractTwoOctetAsExtendedCommunity =
+ new AbstractTwoOctetAsExtendedCommunity() {
@Override
- public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
+ public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity,
+ final ByteBuf byteAggregator) {
}
+
@Override
public int getSubType() {
return 0;
}
+
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) {
return null;
}
};
public class ExtendedCommunityUtilTest {
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testPrivateConstructor() throws Throwable {
final Constructor<ExtendedCommunityUtil> c = ExtendedCommunityUtil.class.getDeclaredConstructor();
c.setAccessible(true);
/*
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
*
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.extended.community;
import io.netty.buffer.ByteBuf;
public class Inet4SpecificExtendedCommunityCommonUtilTest {
private static final byte[] INPUT = {
- 12, 51, 2, 5, 21, 45
+ 12, 51, 2, 5, 21, 45
};
@Test
public void testHandle() {
- final Inet4SpecificExtendedCommunityCommon expected
- = new Inet4SpecificExtendedCommunityCommonBuilder()
+ final Inet4SpecificExtendedCommunityCommon expected = new Inet4SpecificExtendedCommunityCommonBuilder()
.setGlobalAdministrator(new Ipv4Address("12.51.2.5"))
.setLocalAdministrator(new byte[]{21, 45}).build();
Inet4SpecificExtendedCommunityCommonUtil.serializeCommon(expected, output);
Assert.assertArrayEquals(INPUT, output.array());
}
-
-}
\ No newline at end of file
+}
this.nextHopParserSerializer = new NextHopParserSerializer() {
@Override
public CNextHop parseNextHop(final ByteBuf buffer) throws BGPParsingException {
- return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
+ return new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
+ .setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
}
+
@Override
- public void serializeNextHop(final CNextHop cNextHop, final ByteBuf byteAggregator) {
+ public void serializeNextHop(final CNextHop cnextHop, final ByteBuf byteAggregator) {
final byte[] mpReachBytes = {
0x7f, 0x00, 0x00, 0x01
};
doReturn(null).when(this.paramParser).parseParameter(any(ByteBuf.class));
doReturn(EMPTY).when(this.paramParser).toString();
- Mockito.doNothing().when(this.paramSerializer).serializeParameter(any(BgpParameters.class), any(ByteBuf.class));
+ Mockito.doNothing().when(this.paramSerializer).serializeParameter(any(BgpParameters.class),
+ any(ByteBuf.class));
doReturn(EMPTY).when(this.paramSerializer).toString();
doReturn(null).when(this.capaParser).parseCapability(any(ByteBuf.class));
doReturn(EMPTY).when(this.capaParser).toString();
- Mockito.doNothing().when(this.capaSerializer).serializeCapability(any(CParameters.class), any(ByteBuf.class));
+ Mockito.doNothing().when(this.capaSerializer).serializeCapability(any(CParameters.class),
+ any(ByteBuf.class));
doReturn(EMPTY).when(this.capaSerializer).toString();
doReturn(null).when(this.sidTlvParser).parseBgpPrefixSidTlv(any(ByteBuf.class));
doReturn(EMPTY).when(this.sidTlvParser).toString();
- Mockito.doNothing().when(this.sidTlvSerializer).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class), any(ByteBuf.class));
+ Mockito.doNothing().when(this.sidTlvSerializer).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class),
+ any(ByteBuf.class));
doReturn(EMPTY).when(this.sidTlvSerializer).toString();
doReturn(0).when(this.sidTlvSerializer).getType();
- doReturn(mock(Notification.class)).when(this.msgParser).parseMessageBody(any(ByteBuf.class), Mockito.anyInt(),
- any(PeerSpecificParserConstraint.class));
+ doReturn(mock(Notification.class)).when(this.msgParser).parseMessageBody(any(ByteBuf.class),
+ Mockito.anyInt(), any(PeerSpecificParserConstraint.class));
doReturn(EMPTY).when(this.msgParser).toString();
- Mockito.doNothing().when(this.msgSerializer).serializeMessage(any(Notification.class), any(ByteBuf.class));
+ Mockito.doNothing().when(this.msgSerializer).serializeMessage(any(Notification.class),
+ any(ByteBuf.class));
doReturn(EMPTY).when(this.msgSerializer).toString();
- Mockito.doNothing().when(this.nlriParser).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class), any());
- Mockito.doNothing().when(this.nlriParser).parseNlri(any(ByteBuf.class), any(MpReachNlriBuilder.class), any());
+ Mockito.doNothing().when(this.nlriParser).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class),
+ any());
+ Mockito.doNothing().when(this.nlriParser).parseNlri(any(ByteBuf.class), any(MpReachNlriBuilder.class),
+ any());
doReturn(EMPTY).when(this.nlriParser).toString();
} catch (BGPDocumentedException | BGPParsingException | BGPTreatAsWithdrawException e) {
Assert.fail();
}
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import com.google.common.collect.Lists;
public class MultiPathSupportImplTest {
- @Test(expected=NullPointerException.class)
+ @Test(expected = NullPointerException.class)
public void testcreateParserMultiPathSupportNull() {
MultiPathSupportImpl.createParserMultiPathSupport(null);
}
@Test
public void testIsTableTypeSupported() {
final List<AddressFamilies> supportedTables = Lists.newArrayList();
- final BgpTableType ipv4Unicast = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- final BgpTableType ipv4L3vpn = new BgpTableTypeImpl(Ipv4AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
- final BgpTableType ipv6Unicast = new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class);
- final BgpTableType ipv6L3vpn = new BgpTableTypeImpl(Ipv6AddressFamily.class, MplsLabeledVpnSubsequentAddressFamily.class);
+ final BgpTableType ipv4Unicast = new BgpTableTypeImpl(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
+ final BgpTableType ipv4L3vpn = new BgpTableTypeImpl(Ipv4AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class);
+ final BgpTableType ipv6Unicast = new BgpTableTypeImpl(Ipv6AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
+ final BgpTableType ipv6L3vpn = new BgpTableTypeImpl(Ipv6AddressFamily.class,
+ MplsLabeledVpnSubsequentAddressFamily.class);
supportedTables.add(createAddPathCapability(ipv4Unicast, SendReceive.Send));
supportedTables.add(createAddPathCapability(ipv4L3vpn, SendReceive.Receive));
supportedTables.add(createAddPathCapability(ipv6Unicast, SendReceive.Both));
}
private static AddressFamilies createAddPathCapability(final BgpTableType afisafi, final SendReceive mode) {
- return new AddressFamiliesBuilder().setAfi(afisafi.getAfi()).setSafi(afisafi.getSafi()).setSendReceive(mode).build();
+ return new AddressFamiliesBuilder().setAfi(afisafi.getAfi()).setSafi(afisafi.getSafi()).setSendReceive(mode)
+ .build();
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import java.util.Collections;
public class PeerSpecificParserConstraintImplTest {
- private static final MultiPathSupport ADD_PATH_CONSTRAINT = MultiPathSupportImpl.createParserMultiPathSupport(Collections.emptyList());
+ private static final MultiPathSupport ADD_PATH_CONSTRAINT = MultiPathSupportImpl.createParserMultiPathSupport(
+ Collections.emptyList());
private PeerSpecificParserConstraintProvider constraints;
Assert.assertFalse(this.constraints.addPeerConstraint(MultiPathSupport.class, ADD_PATH_CONSTRAINT));
}
- @Test(expected=NullPointerException.class)
+ @Test(expected = NullPointerException.class)
public void testProviderNullInput() {
this.constraints.addPeerConstraint(MultiPathSupport.class, null);
}
final Optional<MultiPathSupport> peerConstraint = this.constraints.getPeerConstraint(MultiPathSupport.class);
Assert.assertFalse(peerConstraint.isPresent());
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import java.lang.reflect.Constructor;
public class ServiceLoaderBGPExtensionProviderContextTest {
- @Test(expected=UnsupportedOperationException.class)
+ @Test(expected = UnsupportedOperationException.class)
public void testPrivateConstructor() throws Throwable {
- final Constructor<ServiceLoaderBGPExtensionProviderContext> c = ServiceLoaderBGPExtensionProviderContext.class.getDeclaredConstructor();
+ final Constructor<ServiceLoaderBGPExtensionProviderContext> c = ServiceLoaderBGPExtensionProviderContext.class
+ .getDeclaredConstructor();
c.setAccessible(true);
try {
c.newInstance();
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import static org.junit.Assert.assertNull;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
verify(this.parser, never()).parseExtendedCommunity(any(ByteBuf.class));
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testRegisterParserOutOfRangeType() {
this.register.registerExtendedCommunityParser(1234, 0, this.parser);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testRegisterParserOutOfRangeSubType() {
this.register.registerExtendedCommunityParser(0, 1234, this.parser);
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import static org.junit.Assert.assertArrayEquals;
private static final PeerSpecificParserConstraint CONSTRAINT;
static {
- PeerSpecificParserConstraintImpl c = new PeerSpecificParserConstraintImpl();
- c.addPeerConstraint(MultiPathSupport.class, ADD_PATH_SUPPORT);
- CONSTRAINT = c;
+ PeerSpecificParserConstraintImpl peerConstraint = new PeerSpecificParserConstraintImpl();
+ peerConstraint.addPeerConstraint(MultiPathSupport.class, ADD_PATH_SUPPORT);
+ CONSTRAINT = peerConstraint;
}
protected BGPExtensionProviderContext ctx;
paramReg.serializeParameter(param, buffer);
paramReg.parseParameter(0, Unpooled.wrappedBuffer(paramBytes));
verify(this.activator.paramParser, times(1)).parseParameter(any(ByteBuf.class));
- verify(this.activator.paramSerializer, times(1)).serializeParameter(any(BgpParameters.class), any(ByteBuf.class));
+ verify(this.activator.paramSerializer, times(1)).serializeParameter(any(BgpParameters.class),
+ any(ByteBuf.class));
}
@Test
final ByteBuf buffer = Unpooled.buffer(tlvBytes.length);
sidTlvReg.serializeBgpPrefixSidTlv(tlv, buffer);
- verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class), any(ByteBuf.class));
+ verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class),
+ any(ByteBuf.class));
sidTlvReg.parseBgpPrefixSidTlv(BgpTestActivator.TYPE, Unpooled.wrappedBuffer(tlvBytes));
verify(this.activator.sidTlvParser, times(1)).parseBgpPrefixSidTlv(any(ByteBuf.class));
final MpReachNlri mpReach = new MpReachNlriBuilder()
.setAfi(Ipv4AddressFamily.class)
.setSafi(UnicastSubsequentAddressFamily.class)
- .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build())
+ .setCNextHop(new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(
+ new Ipv4Address("127.0.0.1")).build()).build())
.build();
final ByteBuf buffer = Unpooled.buffer(mpReachBytes.length);
nlriReg.serializeMpReach(mpReach, buffer);
final byte[] mpUnreachBytes = {
0x00, 0x01, 0x01
};
- final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
+ final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class)
+ .setSafi(UnicastSubsequentAddressFamily.class).build();
final ByteBuf buffer = Unpooled.buffer(mpUnreachBytes.length);
nlriReg.serializeMpUnReach(mpUnreach, buffer);
assertArrayEquals(mpUnreachBytes, buffer.array());
assertEquals(mpUnreach, nlriReg.parseMpUnreach(Unpooled.wrappedBuffer(mpUnreachBytes), CONSTRAINT));
- verify(this.activator.nlriParser, never()).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class), any());
+ verify(this.activator.nlriParser, never()).parseNlri(any(ByteBuf.class), any(MpUnreachNlriBuilder.class),
+ any());
}
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.protocol.bgp.parser.spi.pojo;
import static org.junit.Assert.assertArrayEquals;
private static final short NON_EXISTENT_TYPE = 0;
private static final int NON_VALUE_BYTES = 3;
- private static final SimpleAttributeRegistry simpleAttrReg = new SimpleAttributeRegistry();
+ private static final SimpleAttributeRegistry SIMPLE_ATTR_REG = new SimpleAttributeRegistry();
@Rule
public ExpectedException expException = ExpectedException.none();
public void testUnrecognizedAttributesWithoutOptionalFlag() throws BGPDocumentedException, BGPParsingException {
this.expException.expect(BGPDocumentedException.class);
this.expException.expectMessage("Well known attribute not recognized.");
- simpleAttrReg.parseAttributes(
+ SIMPLE_ATTR_REG.parseAttributes(
Unpooled.wrappedBuffer(new byte[] { 0x03, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 }), null);
}
@Test
public void testUnrecognizedAttributes() throws BGPDocumentedException, BGPParsingException {
final byte[] attributeBytes = { (byte)0xe0, 0x00, 0x05, 0x01, 0x02, 0x03, 0x04, 0x05 };
- final List<UnrecognizedAttributes> unrecogAttribs = simpleAttrReg
- .parseAttributes(Unpooled.wrappedBuffer(attributeBytes), null).getAttributes().getUnrecognizedAttributes();
+ final List<UnrecognizedAttributes> unrecogAttribs = SIMPLE_ATTR_REG.parseAttributes(
+ Unpooled.wrappedBuffer(attributeBytes), null).getAttributes().getUnrecognizedAttributes();
assertEquals(UNRECOGNIZED_ATTRIBUTE_COUNT, unrecogAttribs.size());
final UnrecognizedAttributes unrecogAttrib = unrecogAttribs.get(FIRST_ATTRIBUTE);
final UnrecognizedAttributesKey expectedAttribKey =