}
@Override
- protected void checkContentLenght(final int lenght) throws PCEPDeserializerException {
- if (lenght != CONTENT128_LENGTH) {
- throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + lenght + "; Expected: >"
+ protected void checkContentLength(final int length) throws PCEPDeserializerException {
+ if (length != CONTENT128_LENGTH) {
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + length + "; Expected: >"
+ CONTENT128_LENGTH + ".");
}
}
}
@Override
- protected void checkContentLenght(final int lenght) throws PCEPDeserializerException {
- if (lenght != CONTENT_LENGTH) {
- throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + lenght + "; Expected: >"
+ protected void checkContentLength(final int length) throws PCEPDeserializerException {
+ if (length != CONTENT_LENGTH) {
+ throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + length + "; Expected: >"
+ CONTENT_LENGTH + ".");
}
}
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <violationSeverity>warn</violationSeverity>
- </configuration>
- </plugin>
</plugins>
</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.pcep.spi;
+import static com.google.common.base.Preconditions.checkArgument;
import static org.opendaylight.protocol.util.ByteBufWriteUtil.writeUnsignedShort;
-import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder;
/**
- * Parser for {@link PathKey}
+ * Parser for {@link PathKey}.
*/
public abstract class AbstractEROPathKeySubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
protected static final int CONTENT128_LENGTH = 2 + PCE128_ID_F_LENGTH;
protected static final int CONTENT_LENGTH = 2 + PCE_ID_F_LENGTH;
- protected abstract byte[] readPceId(final ByteBuf buffer);
+ protected abstract byte[] readPceId(ByteBuf buffer);
- protected abstract void checkContentLenght(final int i) throws PCEPDeserializerException;
+ protected abstract void checkContentLength(int length) throws PCEPDeserializerException;
@Override
public final Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
- checkContentLenght(buffer.readableBytes());
+ checkArgument(buffer != null && buffer.isReadable(),
+ "Array of bytes is mandatory. Can't be null or empty.");
+ checkContentLength(buffer.readableBytes());
final int pathKey = buffer.readUnsignedShort();
final byte[] pceId = readPceId(buffer);
final PathKeyBuilder pBuilder = new PathKeyBuilder();
@Override
public final void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
- Preconditions.checkArgument(subobject.getSubobjectType() instanceof PathKeyCase, "Unknown subobject instance. Passed %s. Needed PathKey.",
- subobject.getSubobjectType().getClass());
+ checkArgument(subobject.getSubobjectType() instanceof PathKeyCase,
+ "Unknown subobject instance. Passed %s. Needed PathKey.", subobject.getSubobjectType().getClass());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route
- .subobjects.subobject.type.path.key._case.PathKey pk = ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
- Preconditions.checkArgument(pk.getPceId() != null, "PceId is mandatory.");
- Preconditions.checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
+ .subobjects.subobject.type.path.key._case.PathKey pk =
+ ((PathKeyCase) subobject.getSubobjectType()).getPathKey();
+ checkArgument(pk.getPathKey() != null, "PathKey is mandatory.");
final byte[] pceID = pk.getPceId().getValue();
- Preconditions.checkArgument(pceID.length == PCE_ID_F_LENGTH || pceID.length == PCE128_ID_F_LENGTH, "PceId 32/128 Bit required.");
+ checkArgument(pceID.length == PCE_ID_F_LENGTH || pceID.length == PCE128_ID_F_LENGTH,
+ "PceId 32/128 Bit required.");
final ByteBuf body = Unpooled.buffer();
writeUnsignedShort(pk.getPathKey().getValue(), body);
body.writeBytes(pceID);
- EROSubobjectUtil.formatSubobject(pceID.length == PCE_ID_F_LENGTH ? TYPE_32 : TYPE_128, subobject.isLoose(), body, buffer);
+ EROSubobjectUtil.formatSubobject(pceID.length == PCE_ID_F_LENGTH ? TYPE_32 : TYPE_128, subobject.isLoose(),
+ body, buffer);
}
}
final List<Object> objs = new ArrayList<>();
while (bytes.isReadable()) {
if (bytes.readableBytes() < COMMON_OBJECT_HEADER_LENGTH) {
- throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes() + " Expected: >= "
- + COMMON_OBJECT_HEADER_LENGTH + ".");
+ throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes()
+ + " Expected: >= " + COMMON_OBJECT_HEADER_LENGTH + ".");
}
final int objClass = bytes.readUnsignedByte();
final int objLength = bytes.readUnsignedShort();
if (bytes.readableBytes() < objLength - COMMON_OBJECT_HEADER_LENGTH) {
- throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes() + " Expected: >= "
- + objLength + ".");
+ throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + bytes.readableBytes()
+ + " Expected: >= " + objLength + ".");
}
// copy bytes for deeper parsing
final ByteBuf bytesToPass = bytes.readSlice(objLength - COMMON_OBJECT_HEADER_LENGTH);
if (VendorInformationUtil.isVendorInformationObject(objClass, objType)) {
final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(bytesToPass.readUnsignedInt());
- final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber, header, bytesToPass);
+ final Optional<? extends Object> obj = this.registry.parseVendorInformationObject(enterpriseNumber,
+ header, bytesToPass);
if (obj.isPresent()) {
objs.add(obj.get());
}
return objs;
}
- public static Message createErrorMsg(final PCEPErrors e, final Optional<Rp> rp) {
+ public static Message createErrorMsg(final PCEPErrors err, final Optional<Rp> rp) {
final PcerrMessageBuilder msgBuilder = new PcerrMessageBuilder();
if (rp.isPresent()) {
- msgBuilder.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(Collections.singletonList(new RpsBuilder().setRp(
- rp.get()).build())).build()).build());
+ msgBuilder.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(
+ Collections.singletonList(new RpsBuilder().setRp(rp.get()).build())).build()).build());
}
return new PcerrBuilder().setPcerrMessage(
msgBuilder.setErrors(Collections.singletonList(new ErrorsBuilder().setErrorObject(
- new ErrorObjectBuilder().setType(e.getErrorType()).setValue(
- e.getErrorValue()).build()).build())).build()).build();
+ new ErrorObjectBuilder().setType(err.getErrorType()).setValue(
+ err.getErrorValue()).build()).build())).build()).build();
}
- protected abstract Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException;
+ protected abstract Message validate(List<Object> objects, List<Message> errors) throws PCEPDeserializerException;
@Override
- public final Message parseMessage(final ByteBuf buffer, final List<Message> errors) throws PCEPDeserializerException {
+ public final Message parseMessage(final ByteBuf buffer, final List<Message> errors)
+ throws PCEPDeserializerException {
requireNonNull(buffer, "Buffer may not be null");
// Parse objects first
return validate(objs, errors);
}
- protected final void serializeVendorInformationObjects(final List<VendorInformationObject> viObjects, final ByteBuf buffer) {
+ protected final void serializeVendorInformationObjects(final List<VendorInformationObject> viObjects,
+ final ByteBuf buffer) {
if (viObjects != null) {
for (final VendorInformationObject viObject : viObjects) {
this.registry.serializeVendorInformationObject(viObject, buffer);
final int type = bytes.readUnsignedShort();
final int length = bytes.readUnsignedShort();
if (length > bytes.readableBytes()) {
- throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= " + bytes.readableBytes()
+ throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+ + bytes.readableBytes()
+ ".");
}
final ByteBuf tlvBytes = bytes.readSlice(length);
if (VendorInformationUtil.isVendorInformationTlv(type)) {
final EnterpriseNumber enterpriseNumber = new EnterpriseNumber(tlvBytes.readUnsignedInt());
- final Optional<VendorInformationTlv> viTlv = this.viTlvReg.parseVendorInformationTlv(enterpriseNumber, tlvBytes);
- if(viTlv.isPresent()) {
+ final Optional<VendorInformationTlv> viTlv = this.viTlvReg.parseVendorInformationTlv(enterpriseNumber,
+ tlvBytes);
+ if (viTlv.isPresent()) {
LOG.trace("Parsed VENDOR-INFORMATION TLV {}.", viTlv.get());
viTlvs.add(viTlv.get());
}
} else {
final Tlv tlv = this.tlvReg.parseTlv(type, tlvBytes);
- if(tlv != null) {
+ if (tlv != null) {
LOG.trace("Parsed PCEP TLV {}.", tlv);
addTlv(builder, tlv);
}
// FIXME: No TLVs by default, fallback to augments
}
- protected abstract void addVendorInformationTlvs(final T builder, final List<VendorInformationTlv> tlvs);
+ protected abstract void addVendorInformationTlvs(T builder, List<VendorInformationTlv> tlvs);
protected final void serializeVendorInformationTlvs(final List<VendorInformationTlv> tlvs, final ByteBuf buffer) {
if (tlvs != null) {
* Explicit Route Object Parser.
*/
public interface EROSubobjectParser {
- Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException;
+ Subobject parseSubobject(ByteBuf buffer, boolean loose) throws PCEPDeserializerException;
}
* @return null if the parser for this subobject could not be found
* @throws PCEPDeserializerException if the parsing did not succeed
*/
- Subobject parseSubobject(final int subobjectType, final ByteBuf buffer, final boolean loose)
- throws PCEPDeserializerException;
+ Subobject parseSubobject(int subobjectType, ByteBuf buffer, boolean loose) throws PCEPDeserializerException;
/**
* Find serializer for given subobject. Delegates parsing to found serializer.
* @param subobject to be parsed
* @param buffer buffer where the serialized subobject will be parsed
*/
- void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
+ void serializeSubobject(Subobject subobject, ByteBuf buffer);
}
* Explicit Route Object Serializer.
*/
public interface EROSubobjectSerializer {
- void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
+ void serializeSubobject(Subobject subobject, ByteBuf buffer);
}
private static final int LOOSE_BIT = 7;
private EROSubobjectUtil() {
- throw new UnsupportedOperationException();
}
public static void formatSubobject(final int type, final Boolean loose, final ByteBuf body, final ByteBuf 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.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.EnterpriseSpecificInformation;
public interface EnterpriseSpecificInformationParser {
- void serializeEnterpriseSpecificInformation(final EnterpriseSpecificInformation enterpriseSpecificInformation, final ByteBuf buffer);
+ void serializeEnterpriseSpecificInformation(EnterpriseSpecificInformation enterpriseSpecificInformation,
+ ByteBuf buffer);
- EnterpriseSpecificInformation parseEnterpriseSpecificInformation(final ByteBuf buffer) throws PCEPDeserializerException;
+ EnterpriseSpecificInformation parseEnterpriseSpecificInformation(ByteBuf buffer) throws PCEPDeserializerException;
EnterpriseNumber getEnterpriseNumber();
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
public interface LabelParser {
- LabelType parseLabel(final ByteBuf buffer) throws PCEPDeserializerException;
+ LabelType parseLabel(ByteBuf buffer) throws PCEPDeserializerException;
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
public interface LabelRegistry {
/**
* Finds parser for given label C-type in the registry. Delegates parsing to found parser.
*
- * @param cType label type, key in parser registry
+ * @param ctype label type, key in parser registry
* @param buffer label wrapped in ByteBuf
* @return null if the parser for this label could not be found
* @throws PCEPDeserializerException if the parsing did not succeed
*/
- LabelType parseLabel(final int cType, final ByteBuf buffer) throws PCEPDeserializerException;
+ LabelType parseLabel(int ctype, ByteBuf buffer) throws PCEPDeserializerException;
/**
* Find serializer for given label. Delegates parsing to found serializer.
* @param label to be parsed
* @param buffer buffer where the serialized label will be parsed
*/
- void serializeLabel(final boolean unidirectional, final boolean global, final LabelType label, final ByteBuf buffer);
+ void serializeLabel(boolean unidirectional, boolean global, LabelType label, ByteBuf buffer);
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
public interface LabelSerializer {
- void serializeLabel(boolean unidirectional, boolean global, final LabelType subobject, final ByteBuf buffer);
+ void serializeLabel(boolean unidirectional, boolean global, LabelType subobject, ByteBuf buffer);
}
private static final int GLOBAL = 7;
private LabelUtil() {
- throw new UnsupportedOperationException();
}
- public static void formatLabel(final int type, final Boolean unidirectional, final Boolean global, final ByteBuf body, final ByteBuf buffer) {
+ public static void formatLabel(final int type, final Boolean unidirectional, final Boolean global,
+ final ByteBuf body, final ByteBuf buffer) {
final BitArray reserved = new BitArray(FLAGS_SIZE);
reserved.set(UNIDIRECTIONAL, unidirectional);
reserved.set(GLOBAL, global);
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import java.util.List;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
public interface MessageParser {
- Message parseMessage(final ByteBuf buffer, final List<Message> errors) throws PCEPDeserializerException;
+ Message parseMessage(ByteBuf buffer, List<Message> errors) throws PCEPDeserializerException;
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import java.util.List;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
public interface MessageRegistry {
* @return null if the parser for this message could not be found
* @throws PCEPDeserializerException if the parsing did not succeed
*/
- Message parseMessage(final int messageType, final ByteBuf buffer, final List<Message> errors) throws PCEPDeserializerException;
+ Message parseMessage(int messageType, ByteBuf buffer, List<Message> errors) throws PCEPDeserializerException;
/**
* Find serializer for given message. Delegates parsing to found serializer.
* @param message to be parsed
* @param buffer byte buffer that will be filled with serialized message
*/
- void serializeMessage(final Message message, final ByteBuf buffer);
+ void serializeMessage(Message message, ByteBuf buffer);
}
private static final int VERSION_SF_LENGTH = 3;
private MessageUtil() {
- throw new UnsupportedOperationException();
}
public static void formatMessage(final int messageType, final ByteBuf body, final ByteBuf out) {
final int msgLength = body.writerIndex();
- out.writeByte(PCEPMessageConstants.PCEP_VERSION << (Byte.SIZE - VERSION_SF_LENGTH));
+ out.writeByte(PCEPMessageConstants.PCEP_VERSION << Byte.SIZE - VERSION_SF_LENGTH);
out.writeByte(messageType);
out.writeShort(msgLength + PCEPMessageConstants.COMMON_HEADER_LENGTH);
Preconditions.checkState(out.writerIndex() == PCEPMessageConstants.COMMON_HEADER_LENGTH);
import org.opendaylight.yangtools.yang.binding.DataContainer;
/**
- * Header parser for PCEP object
+ * Header parser for PCEP object.
*/
public class ObjectHeaderImpl implements ObjectHeader {
@Override
public String toString() {
- final String objectHeader = "ObjectHeader [objClass=" +
- ", processed=" +
- this.processed +
- ", ignored=" +
- this.ignored +
- "]";
+ final String objectHeader = "ObjectHeader [objClass="
+ + ", processed=" + this.processed
+ + ", ignored=" + this.ignored
+ + "]";
return objectHeader;
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((this.ignored == null) ? 0 : this.ignored.hashCode());
- result = prime * result + ((this.processed == null) ? 0 : this.processed.hashCode());
+ result = prime * result + (this.ignored == null ? 0 : this.ignored.hashCode());
+ result = prime * result + (this.processed == null ? 0 : this.processed.hashCode());
return result;
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
public interface ObjectParser {
- Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException;
+ Object parseObject(ObjectHeader header, ByteBuf buffer) throws PCEPDeserializerException;
int getObjectClass();
* @return null if the parser for this object could not be found
* @throws PCEPDeserializerException if the parsing did not succeed
*/
- Object parseObject(final int objectClass, final int objectType, final ObjectHeader header, final ByteBuf buffer)
+ Object parseObject(int objectClass, int objectType, ObjectHeader header, ByteBuf buffer)
throws PCEPDeserializerException;
/**
* Find serializer for given object. Delegates parsing to found serializer.
*
* @param object to be parsed
- * @param buffer ByteBuf wrapped aroung bytes representing given object
+ * @param buffer ByteBuf wrapped around bytes representing given object
*/
- void serializeObject(final Object object, final ByteBuf buffer);
+ void serializeObject(Object object, ByteBuf buffer);
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
public interface ObjectSerializer {
-
/**
* Serializes given object to bytes wrapped in given ByteBuf.
+ *
* @param object PCEP object to be serialized
* @param buffer ByteBuf wrapper around serialized object
*/
- void serializeObject(final Object object, final ByteBuf buffer);
+ void serializeObject(Object object, ByteBuf buffer);
}
private static final int IGNORED = 3;
private ObjectUtil() {
- throw new UnsupportedOperationException();
}
- public static void formatSubobject(final int objectType, final int objectClass, final Boolean processingRule, final Boolean ignore,
- final ByteBuf body, final ByteBuf out) {
+ public static void formatSubobject(final int objectType, final int objectClass, final Boolean processingRule,
+ final Boolean ignore, final ByteBuf body, final ByteBuf out) {
out.writeByte(objectClass);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(IGNORED, ignore);
flags.set(PROCESSED, processingRule);
final byte flagB = flags.toByte();
- final int typeByte = objectType << FLAGS_SIZE | (flagB & 0xff);
+ final int typeByte = objectType << FLAGS_SIZE | flagB & 0xff;
out.writeByte(typeByte);
out.writeShort(body.writerIndex() + HEADER_SIZE);
out.writeBytes(body);
private static final long serialVersionUID = 1L;
/**
- * Used when no exact error (from rfc or from draft) is specified.
+ * Used when no exact error (from an RFC or from a draft) is specified.
*
* @param err error message describing the error that occurred
*/
* Used when we want to pass also the exception that occurred.
*
* @param err error message describing the error that occurred
- * @param e specific exception that occurred
+ * @param cause specific exception that occurred
*/
- public PCEPDeserializerException(final String err, final Throwable e) {
- super(err, e);
+ public PCEPDeserializerException(final String err, final Throwable cause) {
+ super(err, cause);
}
}
import java.io.Serializable;
/**
- * Caret for combination of Error-type and Error-value
+ * Caret for combination of Error-type and Error-value.
*/
final class PCEPErrorIdentifier implements Serializable {
private static final long serialVersionUID = 2434590156751699872L;
/**
* Possible errors listed in RFC5440, RFC 5455 and stateful draft.
*
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-9.12">PCEP-ERROR Object(RFC5440)</a>, <a href=
- * "http://tools.ietf.org/html/draft-ietf-pce-stateful-pce-07#section-8.4" >PCEP-ERROR Object(stateful draft)</a>,
- * <a href="http://tools.ietf.org/html/rfc5455#section-3.6">Error Codes for CLASSTYPE Object(RFC5455)</a>, <a href=
- * "http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt#section-7.1" >PCEP-Error Object</a>
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-9.12">PCEP-ERROR Object(RFC5440)</a>
+ * @see <a href="http://tools.ietf.org/html/draft-ietf-pce-stateful-pce-07#section-8.4" >PCEP-ERROR Object</a>
+ * @see <a href="http://tools.ietf.org/html/rfc5455#section-3.6">Error Codes for CLASSTYPE Object(RFC5455)</a>
+ * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt#section-7.1" >PCEP-Error Object</a>
*/
public enum PCEPErrors {
*/
O_BIT_SET(5, 2),
/**
- * Objective function not allowed (request rejected)
+ * Objective function not allowed (request rejected).
*/
OF_NOT_ALLOWED(5, 3),
/**
- * OF bit of the RP object set (request rejected)
+ * OF bit of the RP object set (request rejected).
*/
OF_BIT_SET(5, 4),
/**
- * Global concurrent optimization not allowed (GCO extension)
+ * Global concurrent optimization not allowed (GCO extension).
*/
GCO_NOT_ALLOWED(5, 5),
/**
- * P2MP Path computation is not allowed
+ * P2MP Path computation is not allowed.
*/
P2MP_COMPUTATION_NOT_ALLOWED(5, 7),
/**
- * RP object missing
+ * RP object missing.
*/
RP_MISSING(6, 1),
/**
*/
RRO_MISSING(6, 2),
/**
- * END-POINTS object missing
+ * END-POINTS object missing.
*/
END_POINTS_MISSING(6, 3),
/**
- * LSP cleanup TLV missing
+ * LSP cleanup TLV missing.
*/
LSP_CLEANUP_TLV_MISSING(6, 13),
/**
- * SYMBOLIC-PATH-NAME TLV missing
+ * SYMBOLIC-PATH-NAME TLV missing.
*/
SYMBOLIC_PATH_NAME_MISSING(6, 14),
/**
*/
SYNC_PATH_COMP_REQ_MISSING(7, 0),
/**
- * Unknown request reference
+ * Unknown request reference.
*/
UNKNOWN_REQ_REF(8, 0),
/**
*/
P_FLAG_NOT_SET(10, 1),
/**
- * Insufficient memory (GCO extension)
+ * Insufficient memory (GCO extension).
*/
INSUFFICIENT_MEMORY(15, 1),
/**
- * Global concurrent optimization not supported (GCO extension)
+ * Global concurrent optimization not supported (GCO extension).
*/
GCO_NOT_SUPPORTED(15, 2),
/**
CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS(12, 3),
/**
- * The PCE cannot satisfy the request due to insufficient memory
+ * The PCE cannot satisfy the request due to insufficient memory.
*/
CANNOT_SATISFY_P2MP_REQUEST_DUE_TO_INSUFFISIENT_MEMMORY(16, 1),
/**
- * The PCE is not capable of P2MP computation
+ * The PCE is not capable of P2MP computation.
*/
NOT_CAPPABLE_P2MP_COMPUTATION(16, 2),
/**
- * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 2
+ * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 2.
*/
P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_LT2(17, 1),
/**
- * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 3
+ * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 3.
*/
P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_LT3(17, 2),
/**
- * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 4
+ * The PCE is not capable to satisfy the request due to no END-POINTS with leaf type 4.
*/
P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_LT4(17, 3),
/**
- * The PCE is not capable to satisfy the request due to inconsistent END-POINTS
+ * The PCE is not capable to satisfy the request due to inconsistent END-POINTS.
*/
P2MP_NOT_CAPPABLE_SATISFY_REQ_DUE_INCONSISTENT_EP(17, 4),
/**
- * P2MP Fragmented request failure
+ * P2MP Fragmented request failure.
*/
P2MP_FRAGMENTATION_FAILRUE(18, 1),
/**
*/
RESOURCE_LIMIT_EXCEEDED(19, 4),
/**
- * PCE-initiated LSP limit reached
+ * PCE-initiated LSP limit reached.
*/
LSP_LIMIT_EXCEEDED(19, 6),
/**
- * Delegation for PCE-initiated LSP cannot be revoked
+ * Delegation for PCE-initiated LSP cannot be revoked.
*/
DELEGATION_NON_REVOKABLE(19, 7),
/**
- * Non-zero PLSP-ID in LSP initiation request
+ * Non-zero PLSP-ID in LSP initiation request.
*/
NON_ZERO_PLSPID(19, 8),
/**
*/
DB_VERSION_TLV_MISSING_WHEN_SYNC_ALLOWED(20, 3),
/**
- * A PCC indicates to a PCE that it can not complete the state synchronization,
+ * A PCC indicates to a PCE that it can not complete the state synchronization.
*/
CANNOT_COMPLETE_STATE_SYNC(20, 5),
/**
- * SYMBOLIC-PATH-NAME in use
+ * SYMBOLIC-PATH-NAME in use.
*/
USED_SYMBOLIC_PATH_NAME(23, 1),
/**
- * LSP instantiation error: Unacceptable instantiation parameters
+ * LSP instantiation error: Unacceptable instantiation parameters.
*/
LSP_UNACC_INST_PARAMS(24, 1),
/**
- * LSP instantiation error: Internal error
+ * LSP instantiation error: Internal error.
*/
LSP_INTERNAL_ERROR(24, 2),
/**
- * LSP instantiation error: RSVP signaling error
+ * LSP instantiation error: RSVP signaling error.
*/
LSP_RSVP_ERROR(24, 3),
/**
- * Segment Routing error: ERO subobject with invalid SID value
+ * Segment Routing error: ERO subobject with invalid SID value.
*/
BAD_LABEL_VALUE(10, 2),
/**
- * Segment Routing error: Unsupported number of Segment ERO subobjects
+ * Segment Routing error: Unsupported number of Segment ERO subobjects.
*/
UNSUPPORTED_NUMBER_OF_SR_ERO_SUBOBJECTS(10, 3),
/**
- * Segment Routing error: Bad label format
+ * Segment Routing error: Bad label format.
*/
BAD_LABEL_FORMAT(10, 4),
/**
- * Segment Routing error: Non-identical ERO subobjects
+ * Segment Routing error: Non-identical ERO subobjects.
*/
NON_IDENTICAL_ERO_SUBOBJECTS(10, 5),
/**
*/
SID_NON_IDENTICAL_RRO_SUBOBJECTS(10, 8),
/**
- * Invalid traffic engineering path setup type: Unsupported path setup type
+ * Invalid traffic engineering path setup type: Unsupported path setup type.
*/
UNSUPPORTED_PST(21, 1),
/**
- * Invalid traffic engineering path setup type: Mismatched path setup type
+ * Invalid traffic engineering path setup type: Mismatched path setup type.
*/
MISMATCHED_PST(21, 2),
/**
- * MONITORING object missing
+ * MONITORING object missing.
*/
MONITORING_OBJECT_MISSING(6, 4),
/**
- * Reception of StartTLS after any PCEP exchange
- * TODO: error code to be assigned by IANA
+ * Reception of StartTLS after any PCEP exchange.
*/
+ // FIXME: error code to be assigned by IANA
STARTTLS_RCVD_INCORRECTLY(30, 1),
/**
- * Reception of non-StartTLS or non-PCErr message
- * TODO: error code to be assigned by IANA
+ * Reception of non-StartTLS or non-PCErr message.
*/
+ // FIXME: error code to be assigned by IANA
NON_STARTTLS_MSG_RCVD(30, 2),
/**
- * Failure, connection without TLS not possible
- * TODO: error code to be assigned by IANA
+ * Failure, connection without TLS not possible.
*/
+ // FIXME: error code to be assigned by IANA
NOT_POSSIBLE_WITHOUT_TLS(30, 3),
/**
- * Failure, connection without TLS possible
- * TODO: error code to be assigned by IANA
+ * Failure, connection without TLS possible.
*/
+ // FIXME: error code to be assigned by IANA
POSSIBLE_WITHOUT_TLS(30, 4),
/**
- * No StartTLS message before StartTLSWait timer expired
- * TODO: error code to be assigned by IANA
+ * No StartTLS message before StartTLSWait timer expired.
*/
+ // FIXME: error code to be assigned by IANA
STARTTLS_TIMER_EXP(30, 5),
/**
- * LSP is not PCE-initiated
+ * LSP is not PCE-initiated.
*/
LSP_NOT_PCE_INITIATED(19, 9),
/**
- * LSP-DB-VERSION TLV missing
+ * LSP-DB-VERSION TLV missing.
*/
LSP_DB_VERSION_MISSING(6, 12),
/**
- * Attempt to trigger a synchronization when the
- * PCE triggered synchronization capability has not been advertised.
+ * Attempt to trigger a synchronization when the PCE triggered synchronization capability has not been advertised.
*/
UNEXPECTED_SYNCHRONIZATION_ATTEMPT(20, 4),
/**
- * No sufficient LSP change information for
- * incremental LSP state synchronization.
+ * No sufficient LSP change information for incremental LSP state synchronization.
*/
NO_SUFFICIENT_LSP_CHANGE(20, 6),
/**
- * Received an invalid LSP DB Version Number
+ * Received an invalid LSP DB Version Number.
*/
INVALID_LSP_DB_VERSION(20, 7);
public interface PCEPExtensionProviderContext extends PCEPExtensionConsumerContext {
AutoCloseable registerLabelSerializer(Class<? extends LabelType> labelClass, LabelSerializer serializer);
- AutoCloseable registerLabelParser(int cType, LabelParser parser);
+ AutoCloseable registerLabelParser(int ctype, LabelParser parser);
AutoCloseable registerEROSubobjectParser(int subobjectType, EROSubobjectParser parser);
- AutoCloseable registerEROSubobjectSerializer(Class<? extends SubobjectType> subobjectClass, EROSubobjectSerializer serializer);
+ AutoCloseable registerEROSubobjectSerializer(Class<? extends SubobjectType> subobjectClass,
+ EROSubobjectSerializer serializer);
AutoCloseable registerMessageParser(int messageType, MessageParser parser);
AutoCloseable registerRROSubobjectParser(int subobjectType, RROSubobjectParser parser);
- AutoCloseable registerRROSubobjectSerializer(
- Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType> subobjectClass,
+ AutoCloseable registerRROSubobjectSerializer(Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params
+ .xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType> subobjectClass,
RROSubobjectSerializer serializer);
AutoCloseable registerTlvSerializer(Class<? extends Tlv> tlvClass, TlvSerializer serializer);
AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
- AutoCloseable registerVendorInformationTlvSerializer(Class<? extends EnterpriseSpecificInformation> esInformationClass, TlvSerializer serializer);
+ AutoCloseable registerVendorInformationTlvSerializer(
+ Class<? extends EnterpriseSpecificInformation> esInformationClass, TlvSerializer serializer);
AutoCloseable registerVendorInformationTlvParser(EnterpriseNumber enterpriseNumber, TlvParser parser);
- AutoCloseable registerXROSubobjectSerializer(Class<? extends SubobjectType> subobjectClass, XROSubobjectSerializer serializer);
+ AutoCloseable registerXROSubobjectSerializer(Class<? extends SubobjectType> subobjectClass,
+ XROSubobjectSerializer serializer);
AutoCloseable registerXROSubobjectParser(int subobjectType, XROSubobjectParser parser);
- AutoCloseable registerVendorInformationObjectSerializer(Class<? extends EnterpriseSpecificInformation> esInformationClass, ObjectSerializer serializer);
+ AutoCloseable registerVendorInformationObjectSerializer(
+ Class<? extends EnterpriseSpecificInformation> esInformationClass, ObjectSerializer serializer);
AutoCloseable registerVendorInformationObjectParser(EnterpriseNumber enterpriseNumber, ObjectParser parser);
}
*/
package org.opendaylight.protocol.pcep.spi;
-/**
- *
- */
public final class PCEPMessageConstants {
/**
* Length of the common message header, in bytes.
public static final int PCEP_VERSION = 1;
private PCEPMessageConstants() {
- throw new UnsupportedOperationException();
}
}
* 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.pcep.spi;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupType;
public final class PSTUtil {
private PSTUtil() {
- throw new UnsupportedOperationException();
}
/**
- * Check whether Path is setup via RSVP-TE signaling protocol
- * @param pst
- * @return true if setup is via RSVP-TE signaling protocol
+ * Check whether Path is setup via RSVP-TE signaling protocol.
+ *
+ * @param pst Path setup type
+ * @return true if setup is via RSVP-TE signaling protocol
*/
public static boolean isDefaultPST(final PathSetupType pst) {
if (pst != null && pst.getPst() != null && pst.getPst() != 0) {
* @return null if the parser for this subobject could not be found otherwise returns parser
* @throws PCEPDeserializerException if the parsing did not succeed
*/
- Subobject parseSubobject(final int type, final ByteBuf buffer) throws PCEPDeserializerException;
+ Subobject parseSubobject(int type, ByteBuf buffer) throws PCEPDeserializerException;
/**
* Find serializer for given subobject. Delegates parsing to found serializer.
* @param subobject to be parsed
* @param buffer buffer where the serialized subobject will be parsed
*/
- void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
+ void serializeSubobject(Subobject subobject, ByteBuf buffer);
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject;
/**
* Reported Route Object Serializer.
*/
public interface RROSubobjectSerializer {
- void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
+ void serializeSubobject(Subobject subobject, ByteBuf buffer);
}
private static final int HEADER_SIZE = 2;
private RROSubobjectUtil() {
- throw new UnsupportedOperationException();
}
public static void formatSubobject(final int type, final ByteBuf body, final ByteBuf buffer) {
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
public interface TlvParser {
- Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException;
+ Tlv parseTlv(ByteBuf buffer) throws PCEPDeserializerException;
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
public interface TlvRegistry {
- Tlv parseTlv(final int type, final ByteBuf buffer) throws PCEPDeserializerException;
+ Tlv parseTlv(int type, ByteBuf buffer) throws PCEPDeserializerException;
- void serializeTlv(final Tlv tlv, final ByteBuf buffer);
+ void serializeTlv(Tlv tlv, ByteBuf buffer);
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
public interface TlvSerializer {
- void serializeTlv(final Tlv tlv, final ByteBuf buffer);
+ void serializeTlv(Tlv tlv, ByteBuf buffer);
}
public static final int PADDED_TO = 4;
private TlvUtil() {
- throw new UnsupportedOperationException();
}
public static void formatTlv(final int type,final ByteBuf body, final ByteBuf out) {
}
public static int getPadding(final int length, final int padding) {
- return (padding - (length % padding)) % padding;
+ return (padding - length % padding) % padding;
}
}
public final class UnknownObject implements Object {
private final Object invalidObject;
private final Errors error;
- private final PCEPErrors e;
+ private final PCEPErrors err;
public UnknownObject(final PCEPErrors error) {
this(error, null);
}
public UnknownObject(final PCEPErrors error, final Object invalidObject) {
- this.e = requireNonNull(error);
+ this.err = requireNonNull(error);
this.error = new ErrorsBuilder().setErrorObject(
new ErrorObjectBuilder().setType(error.getErrorType()).setValue(
}
public PCEPErrors getError() {
- return this.e;
+ return this.err;
}
public Object getInvalidObject() {
@Override
public Boolean isIgnore() {
- return false;
+ return Boolean.FALSE;
}
@Override
public Boolean isProcessingRule() {
- return false;
+ return Boolean.FALSE;
}
-}
\ No newline at end of file
+}
* 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.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import java.util.Optional;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
public interface VendorInformationObjectRegistry {
- Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber, final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException;
-
- void serializeVendorInformationObject(final VendorInformationObject viObject, final ByteBuf buffer);
+ Optional<? extends Object> parseVendorInformationObject(EnterpriseNumber enterpriseNumber, ObjectHeader header,
+ ByteBuf buffer) throws PCEPDeserializerException;
+ void serializeVendorInformationObject(VendorInformationObject viObject, ByteBuf 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.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import java.util.Optional;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
public interface VendorInformationTlvRegistry {
+ Optional<VendorInformationTlv> parseVendorInformationTlv(EnterpriseNumber enterpriseNumber, ByteBuf buffer)
+ throws PCEPDeserializerException;
- Optional<VendorInformationTlv> parseVendorInformationTlv(final EnterpriseNumber enterpriseNumber, final ByteBuf buffer) throws PCEPDeserializerException;
-
- void serializeVendorInformationTlv(final VendorInformationTlv viTlv, final ByteBuf buffer);
-
+ void serializeVendorInformationTlv(VendorInformationTlv viTlv, ByteBuf 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.pcep.spi;
public final class VendorInformationUtil {
public static final int VENDOR_INFORMATION_OBJECT_TYPE = 1;
private VendorInformationUtil() {
- throw new UnsupportedOperationException();
}
public static boolean isVendorInformationTlv(final int type) {
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
public interface XROSubobjectParser {
- Subobject parseSubobject(final ByteBuf buffer, boolean mandatory) throws PCEPDeserializerException;
+ Subobject parseSubobject(ByteBuf buffer, boolean mandatory) throws PCEPDeserializerException;
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
public interface XROSubobjectRegistry {
* @return null if the parser for this subobject could not be found
* @throws PCEPDeserializerException if the parsing did not succeed
*/
- Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException;
+ Subobject parseSubobject(int type, ByteBuf buffer, boolean mandatory) throws PCEPDeserializerException;
/**
* Find serializer for given subobject. Delegates parsing to found serializer.
* @param subobject to be parsed
* @param buffer buffer where the serialized subobject will be parsed
*/
- void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
+ void serializeSubobject(Subobject subobject, ByteBuf buffer);
}
package org.opendaylight.protocol.pcep.spi;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
public interface XROSubobjectSerializer {
- void serializeSubobject(final Subobject subobject, final ByteBuf buffer);
+ void serializeSubobject(Subobject subobject, ByteBuf buffer);
}
private static final int MANDATORY_BIT = 7;
private XROSubobjectUtil() {
- throw new UnsupportedOperationException();
}
- public static void formatSubobject(final int type, final Boolean mandatory, final ByteBuf body, final ByteBuf buffer) {
+ public static void formatSubobject(final int type, final Boolean mandatory, final ByteBuf body,
+ final ByteBuf buffer) {
if (mandatory == null) {
buffer.writeByte(type);
} else {
*/
package org.opendaylight.protocol.pcep.spi.pojo;
+import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import java.util.List;
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
@Override
public final synchronized void start(final PCEPExtensionProviderContext context) {
- Preconditions.checkState(this.registrations == null);
+ checkState(this.registrations == null);
this.registrations = requireNonNull(startImpl(context));
}
@Override
+ @SuppressWarnings("checkstyle:illegalCatch")
public final synchronized void stop() {
if (this.registrations == null) {
return;
public final class ServiceLoaderPCEPExtensionProviderContext extends SimplePCEPExtensionProviderContext {
private static final class Holder {
- private static final PCEPExtensionProviderContext INSTANCE;
+ private static final PCEPExtensionProviderContext INSTANCE = create();
private Holder() {
}
-
- static {
- try {
- INSTANCE = create();
- } catch (final Exception e) {
- throw new ExceptionInInitializerError(e);
- }
- }
}
private ServiceLoaderPCEPExtensionProviderContext() {
public static PCEPExtensionProviderContext create() {
final PCEPExtensionProviderContext ctx = new SimplePCEPExtensionProviderContext();
- final ServiceLoader<PCEPExtensionProviderActivator> loader = ServiceLoader.load(PCEPExtensionProviderActivator.class);
+ final ServiceLoader<PCEPExtensionProviderActivator> loader =
+ ServiceLoader.load(PCEPExtensionProviderActivator.class);
for (final PCEPExtensionProviderActivator a : loader) {
a.start(ctx);
}
package org.opendaylight.protocol.pcep.spi.pojo;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
import org.opendaylight.yangtools.yang.binding.DataContainer;
public final class SimpleEROSubobjectRegistry implements EROSubobjectRegistry {
- private final HandlerRegistry<DataContainer, EROSubobjectParser, EROSubobjectSerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, EROSubobjectParser, EROSubobjectSerializer> handlers =
+ new HandlerRegistry<>();
public AutoCloseable registerSubobjectParser(final int subobjectType, final EROSubobjectParser parser) {
Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
}
@Override
- public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
+ public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean loose)
+ throws PCEPDeserializerException {
Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
final EROSubobjectParser parser = this.handlers.getParser(type);
if (parser == null) {
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
- final EROSubobjectSerializer serializer = this.handlers.getSerializer(subobject.getSubobjectType().getImplementedInterface());
+ final EROSubobjectSerializer serializer = this.handlers.getSerializer(
+ subobject.getSubobjectType().getImplementedInterface());
if (serializer == null) {
return;
}
*/
package org.opendaylight.protocol.pcep.spi.pojo;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.LabelParser;
import org.opendaylight.protocol.pcep.spi.LabelRegistry;
public class SimpleLabelRegistry implements LabelRegistry {
private final HandlerRegistry<DataContainer, LabelParser, LabelSerializer> handlers = new HandlerRegistry<>();
- public AutoCloseable registerLabelParser(final int cType, final LabelParser parser) {
- Preconditions.checkArgument(cType >= 0 && cType <= Values.UNSIGNED_BYTE_MAX_VALUE);
- return this.handlers.registerParser(cType, parser);
+ public AutoCloseable registerLabelParser(final int ctype, final LabelParser parser) {
+ checkArgument(ctype >= 0 && ctype <= Values.UNSIGNED_BYTE_MAX_VALUE);
+ return this.handlers.registerParser(ctype, parser);
}
- public AutoCloseable registerLabelSerializer(final Class<? extends LabelType> labelClass, final LabelSerializer serializer) {
+ public AutoCloseable registerLabelSerializer(final Class<? extends LabelType> labelClass,
+ final LabelSerializer serializer) {
return this.handlers.registerSerializer(labelClass, serializer);
}
@Override
- public LabelType parseLabel(final int cType, final ByteBuf buffer) throws PCEPDeserializerException {
- Preconditions.checkArgument(cType >= 0 && cType <= Values.UNSIGNED_BYTE_MAX_VALUE);
- final LabelParser parser = this.handlers.getParser(cType);
+ public LabelType parseLabel(final int ctype, final ByteBuf buffer) throws PCEPDeserializerException {
+ checkArgument(ctype >= 0 && ctype <= Values.UNSIGNED_BYTE_MAX_VALUE);
+ final LabelParser parser = this.handlers.getParser(ctype);
if (parser == null) {
return null;
}
}
@Override
- public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType label, final ByteBuf buffer) {
+ public void serializeLabel(final boolean unidirectional, final boolean global, final LabelType label,
+ final ByteBuf buffer) {
final LabelSerializer serializer = this.handlers.getSerializer(label.getImplementedInterface());
if (serializer != null) {
serializer.serializeLabel(unidirectional, global, label, buffer);
package org.opendaylight.protocol.pcep.spi.pojo;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
-
import java.util.List;
-
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.MessageParser;
import org.opendaylight.protocol.pcep.spi.MessageRegistry;
return this.handlers.registerParser(messageType, parser);
}
- public AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass, final MessageSerializer serializer) {
+ public AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass,
+ final MessageSerializer serializer) {
return this.handlers.registerSerializer(msgClass, serializer);
}
@Override
- public Message parseMessage(final int messageType, final ByteBuf buffer, final List<Message> errors) throws PCEPDeserializerException {
+ public Message parseMessage(final int messageType, final ByteBuf buffer, final List<Message> errors)
+ throws PCEPDeserializerException {
Preconditions.checkArgument(messageType >= 0 && messageType <= Values.UNSIGNED_BYTE_MAX_VALUE);
final MessageParser parser = this.handlers.getParser(messageType);
if (parser == null) {
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
final MessageSerializer serializer = this.handlers.getSerializer(message.getImplementedInterface());
if (serializer == null) {
LOG.warn("PCEP serializer for message type {} is not registered.", message.getClass());
*/
package org.opendaylight.protocol.pcep.spi.pojo;
+import static com.google.common.base.Preconditions.checkArgument;
+
import com.google.common.base.Preconditions;
import io.netty.buffer.ByteBuf;
import java.util.Optional;
private final HandlerRegistry<DataContainer, ObjectParser, ObjectSerializer> handlers = new HandlerRegistry<>();
private static final int MAX_OBJECT_TYPE = 15;
- private static final int MAX_OBJECT_CLASS = 4;
+ private static final int MAX_OBJECT_CLASS = 4;
+
private final VendorInformationObjectRegistry viRegistry;
public SimpleObjectRegistry(final VendorInformationObjectRegistry viRegistry) {
this.viRegistry = viRegistry;
-
}
private static int createKey(final int objectClass, final int objectType) {
Preconditions.checkArgument(objectClass >= 0 && objectClass <= Values.UNSIGNED_BYTE_MAX_VALUE);
Preconditions.checkArgument(objectType >= 0 && objectType <= MAX_OBJECT_TYPE);
- return (objectClass << MAX_OBJECT_CLASS) | objectType;
+ return objectClass << MAX_OBJECT_CLASS | objectType;
}
public AutoCloseable registerObjectParser(final int objectClass, final int objectType, final ObjectParser parser) {
- Preconditions.checkArgument(objectClass >= 0 && objectClass <= Values.UNSIGNED_BYTE_MAX_VALUE, "Illegal object class %s",
+ checkArgument(objectClass >= 0 && objectClass <= Values.UNSIGNED_BYTE_MAX_VALUE, "Illegal object class %s",
objectClass);
- Preconditions.checkArgument(objectType >= 0 && objectType <= MAX_OBJECT_TYPE, "Illegal object type %s", objectType);
+ checkArgument(objectType >= 0 && objectType <= MAX_OBJECT_TYPE, "Illegal object type %s", objectType);
return this.handlers.registerParser(createKey(objectClass, objectType), parser);
}
- public AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
+ public AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass,
+ final ObjectSerializer serializer) {
return this.handlers.registerSerializer(objClass, serializer);
}
@Override
- public Object parseObject(final int objectClass, final int objectType, final ObjectHeader header, final ByteBuf buffer)
- throws PCEPDeserializerException {
- Preconditions.checkArgument(objectType >= 0 && objectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
+ public Object parseObject(final int objectClass, final int objectType, final ObjectHeader header,
+ final ByteBuf buffer) throws PCEPDeserializerException {
+ checkArgument(objectType >= 0 && objectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
final ObjectParser parser = this.handlers.getParser(createKey(objectClass, objectType));
if (parser == null) {
return;
}
serializer.serializeObject(object, buffer);
- }
+ }
+
@Override
public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber,
final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
package org.opendaylight.protocol.pcep.spi.pojo;
import javax.annotation.concurrent.ThreadSafe;
-
import org.opendaylight.protocol.pcep.spi.EROSubobjectParser;
import org.opendaylight.protocol.pcep.spi.EROSubobjectRegistry;
import org.opendaylight.protocol.pcep.spi.EROSubobjectSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.LabelType;
-/**
- *
- */
@ThreadSafe
public class SimplePCEPExtensionProviderContext implements PCEPExtensionProviderContext {
private final SimpleLabelRegistry labelReg = new SimpleLabelRegistry();
}
@Override
- public final AutoCloseable registerLabelSerializer(final Class<? extends LabelType> labelClass, final LabelSerializer serializer) {
+ public final AutoCloseable registerLabelSerializer(final Class<? extends LabelType> labelClass,
+ final LabelSerializer serializer) {
return this.labelReg.registerLabelSerializer(labelClass, serializer);
}
@Override
- public final AutoCloseable registerLabelParser(final int cType, final LabelParser parser) {
- return this.labelReg.registerLabelParser(cType, parser);
+ public final AutoCloseable registerLabelParser(final int ctype, final LabelParser parser) {
+ return this.labelReg.registerLabelParser(ctype, parser);
}
@Override
}
@Override
- public final AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass, final MessageSerializer serializer) {
+ public final AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass,
+ final MessageSerializer serializer) {
return this.msgReg.registerMessageSerializer(msgClass, serializer);
}
@Override
- public final AutoCloseable registerObjectParser(final int objectClass, final int objectType, final ObjectParser parser) {
+ public final AutoCloseable registerObjectParser(final int objectClass, final int objectType,
+ final ObjectParser parser) {
return this.objReg.registerObjectParser(objectClass, objectType, parser);
}
}
@Override
- public final AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
+ public final AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass,
+ final ObjectSerializer serializer) {
return this.objReg.registerObjectSerializer(objClass, serializer);
}
}
@Override
- public final AutoCloseable registerRROSubobjectSerializer(
- final Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType> subobjectClass,
+ public final AutoCloseable registerRROSubobjectSerializer(final Class<? extends org.opendaylight.yang.gen.v1.urn
+ .opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.SubobjectType> subobjectClass,
final RROSubobjectSerializer serializer) {
return this.rroSubReg.registerSubobjectSerializer(subobjectClass, serializer);
}
}
@Override
- public final AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
+ public final AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass,
+ final TlvSerializer serializer) {
return this.tlvReg.registerTlvSerializer(tlvClass, serializer);
}
}
@Override
- public AutoCloseable registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber, final TlvParser parser) {
+ public AutoCloseable registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber,
+ final TlvParser parser) {
return this.viTlvReg.registerVendorInformationTlvParser(enterpriseNumber, parser);
}
@Override
public AutoCloseable registerVendorInformationObjectSerializer(
- final Class<? extends EnterpriseSpecificInformation> esInformationClass, final ObjectSerializer serializer) {
+ final Class<? extends EnterpriseSpecificInformation> esInformationClass,
+ final ObjectSerializer serializer) {
return this.viObjReg.registerVendorInformationObjectSerializer(esInformationClass, serializer);
}
@Override
- public AutoCloseable registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber, final ObjectParser parser) {
+ public AutoCloseable registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber,
+ final ObjectParser parser) {
return this.viObjReg.registerVendorInformationObjectParser(enterpriseNumber, parser);
}
public void start() {
LOG.debug("Starting {} PCEPExtensionProviderActivator instances", this.extensionActivators.size());
- for(final PCEPExtensionProviderActivator e : this.extensionActivators) {
+ for (final PCEPExtensionProviderActivator e : this.extensionActivators) {
e.start(this.providerContext);
}
}
public void close() {
LOG.debug("Stopping {} BGPExtensionProviderActivator instances", this.extensionActivators.size());
- for(final PCEPExtensionProviderActivator e : this.extensionActivators) {
+ for (final PCEPExtensionProviderActivator e : this.extensionActivators) {
e.stop();
}
}
*/
package org.opendaylight.protocol.pcep.spi.pojo;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.RROSubobjectParser;
import org.opendaylight.yangtools.yang.binding.DataContainer;
public final class SimpleRROSubobjectRegistry implements RROSubobjectRegistry {
- private final HandlerRegistry<DataContainer, RROSubobjectParser, RROSubobjectSerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, RROSubobjectParser, RROSubobjectSerializer> handlers =
+ new HandlerRegistry<>();
public AutoCloseable registerSubobjectParser(final int subobjectType, final RROSubobjectParser parser) {
- Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
+ checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
return this.handlers.registerParser(subobjectType, parser);
}
@Override
public Subobject parseSubobject(final int type, final ByteBuf buffer) throws PCEPDeserializerException {
- Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
+ checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
final RROSubobjectParser parser = this.handlers.getParser(type);
- if (parser == null) {
- return null;
- }
- return parser.parseSubobject(buffer);
+ return parser == null ? null : parser.parseSubobject(buffer);
}
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
- final RROSubobjectSerializer serializer = this.handlers.getSerializer(subobject.getSubobjectType().getImplementedInterface());
- if (serializer == null) {
- return;
+ final RROSubobjectSerializer serializer = this.handlers.getSerializer(
+ subobject.getSubobjectType().getImplementedInterface());
+ if (serializer != null) {
+ serializer.serializeSubobject(subobject, buffer);
}
- serializer.serializeSubobject(subobject, buffer);
}
}
package org.opendaylight.protocol.pcep.spi.pojo;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
import org.opendaylight.yangtools.yang.binding.DataContainer;
-/**
- *
- */
public final class SimpleTlvRegistry implements TlvRegistry {
private final HandlerRegistry<DataContainer, TlvParser, TlvSerializer> handlers = new HandlerRegistry<>();
* 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.pcep.spi.pojo;
import com.google.common.primitives.Ints;
-
import io.netty.buffer.ByteBuf;
-
import java.util.Optional;
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.ObjectParser;
import org.opendaylight.yangtools.yang.binding.DataContainer;
public class SimpleVendorInformationObjectRegistry implements VendorInformationObjectRegistry {
-
private final HandlerRegistry<DataContainer, ObjectParser, ObjectSerializer> handlers = new HandlerRegistry<>();
- public AutoCloseable registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber, final ObjectParser parser) {
+ public AutoCloseable registerVendorInformationObjectParser(final EnterpriseNumber enterpriseNumber,
+ final ObjectParser parser) {
return this.handlers.registerParser(Ints.checkedCast(enterpriseNumber.getValue()), parser);
}
- public AutoCloseable registerVendorInformationObjectSerializer(final Class<? extends EnterpriseSpecificInformation> esInformationClass, final ObjectSerializer serializer) {
+ public AutoCloseable registerVendorInformationObjectSerializer(
+ final Class<? extends EnterpriseSpecificInformation> esInformationClass,
+ final ObjectSerializer serializer) {
return this.handlers.registerSerializer(esInformationClass, serializer);
}
@Override
- public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber, final ObjectHeader header, final ByteBuf buffer)
+ public Optional<? extends Object> parseVendorInformationObject(final EnterpriseNumber enterpriseNumber,
+ final ObjectHeader header, final ByteBuf buffer)
throws PCEPDeserializerException {
final ObjectParser parser = this.handlers.getParser(Ints.checkedCast(enterpriseNumber.getValue()));
if (parser == null) {
@Override
public void serializeVendorInformationObject(final VendorInformationObject viObject, final ByteBuf buffer) {
- final ObjectSerializer serializer = this.handlers.getSerializer(viObject.getEnterpriseSpecificInformation().getImplementedInterface());
+ final ObjectSerializer serializer = this.handlers.getSerializer(
+ viObject.getEnterpriseSpecificInformation().getImplementedInterface());
if (serializer == null) {
return;
}
serializer.serializeObject(viObject, 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.pcep.spi.pojo;
import com.google.common.primitives.Ints;
private final HandlerRegistry<DataContainer, TlvParser, TlvSerializer> handlers = new HandlerRegistry<>();
- public AutoCloseable registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber, final TlvParser parser) {
+ public AutoCloseable registerVendorInformationTlvParser(final EnterpriseNumber enterpriseNumber,
+ final TlvParser parser) {
return this.handlers.registerParser(Ints.checkedCast(enterpriseNumber.getValue()), parser);
}
- public AutoCloseable registerVendorInformationTlvSerializer(final Class<? extends EnterpriseSpecificInformation> esInformationClass, final TlvSerializer serializer) {
+ public AutoCloseable registerVendorInformationTlvSerializer(
+ final Class<? extends EnterpriseSpecificInformation> esInformationClass, final TlvSerializer serializer) {
return this.handlers.registerSerializer(esInformationClass, serializer);
}
@Override
- public Optional<VendorInformationTlv> parseVendorInformationTlv(final EnterpriseNumber enterpriseNumber, final ByteBuf buffer) throws PCEPDeserializerException {
+ public Optional<VendorInformationTlv> parseVendorInformationTlv(final EnterpriseNumber enterpriseNumber,
+ final ByteBuf buffer) throws PCEPDeserializerException {
final TlvParser parser = this.handlers.getParser(Ints.checkedCast(enterpriseNumber.getValue()));
if (parser == null) {
return Optional.empty();
@Override
public void serializeVendorInformationTlv(final VendorInformationTlv viTlv, final ByteBuf buffer) {
- final TlvSerializer serializer = this.handlers.getSerializer(viTlv.getEnterpriseSpecificInformation().getImplementedInterface());
+ final TlvSerializer serializer = this.handlers.getSerializer(
+ viTlv.getEnterpriseSpecificInformation().getImplementedInterface());
if (serializer == null) {
return;
}
serializer.serializeTlv(viTlv, buffer);
}
-
-
}
package org.opendaylight.protocol.pcep.spi.pojo;
import com.google.common.base.Preconditions;
-
import io.netty.buffer.ByteBuf;
-
import org.opendaylight.protocol.concepts.HandlerRegistry;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
import org.opendaylight.yangtools.yang.binding.DataContainer;
public final class SimpleXROSubobjectRegistry implements XROSubobjectRegistry {
- private final HandlerRegistry<DataContainer, XROSubobjectParser, XROSubobjectSerializer> handlers = new HandlerRegistry<>();
+ private final HandlerRegistry<DataContainer, XROSubobjectParser, XROSubobjectSerializer> handlers =
+ new HandlerRegistry<>();
public AutoCloseable registerSubobjectParser(final int subobjectType, final XROSubobjectParser parser) {
Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= Values.UNSIGNED_SHORT_MAX_VALUE);
}
@Override
- public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean mandatory) throws PCEPDeserializerException {
+ public Subobject parseSubobject(final int type, final ByteBuf buffer, final boolean mandatory)
+ throws PCEPDeserializerException {
Preconditions.checkArgument(type >= 0 && type <= Values.UNSIGNED_SHORT_MAX_VALUE);
final XROSubobjectParser parser = this.handlers.getParser(type);
if (parser == null) {
@Override
public void serializeSubobject(final Subobject subobject, final ByteBuf buffer) {
- final XROSubobjectSerializer serializer = this.handlers.getSerializer(subobject.getSubobjectType().getImplementedInterface());
+ final XROSubobjectSerializer serializer = this.handlers.getSerializer(
+ subobject.getSubobjectType().getImplementedInterface());
if (serializer == null) {
return;
}
final PCEPDeserializerException e = new PCEPDeserializerException("Some error message.");
assertEquals("Some error message.", e.getMessage());
- final PCEPDeserializerException e1 = new PCEPDeserializerException("Some error message.", new IllegalArgumentException());
+ final PCEPDeserializerException e1 = new PCEPDeserializerException("Some error message.",
+ new IllegalArgumentException());
assertEquals("Some error message.", e1.getMessage());
assertTrue(e1.getCause() instanceof IllegalArgumentException);
}
assertFalse(un.isIgnore());
assertFalse(un.isProcessingRule());
assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS, un.getError());
- assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS.getErrorType(), un.getErrors().get(0).getErrorObject().getType().shortValue());
+ assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS.getErrorType(),
+ un.getErrors().get(0).getErrorObject().getType().shortValue());
final Object o = new CCloseBuilder().build();
UnknownObject unknown = new UnknownObject(PCEPErrors.LSP_RSVP_ERROR, o);
package org.opendaylight.protocol.pcep.spi;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.only;
+import static org.mockito.Mockito.verify;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcrep;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder;
+@RunWith(MockitoJUnitRunner.class)
public class AbstractMessageParserTest {
private static final EnterpriseNumber EN = new EnterpriseNumber(0L);
if (objects.get(0) instanceof VendorInformationObject) {
final RepliesBuilder repsBuilder = new RepliesBuilder();
repsBuilder.setVendorInformationObject(addVendorInformationObjects(objects));
- final PcrepBuilder builder = new PcrepBuilder();
- builder.setPcrepMessage(new PcrepMessageBuilder().setReplies(Lists.newArrayList(repsBuilder.build())).build());
- return builder.build();
+ return new PcrepBuilder().setPcrepMessage(
+ new PcrepMessageBuilder().setReplies(Arrays.asList(repsBuilder.build())).build())
+ .build();
} else if (objects.get(0) instanceof ErrorObject) {
final short errorType = ((ErrorObject) objects.get(0)).getType();
final short errorValue = ((ErrorObject) objects.get(0)).getValue();
@Before
public void setUp() throws PCEPDeserializerException {
- MockitoAnnotations.initMocks(this);
this.object = new ErrorObjectBuilder().setType((short) 1).setValue((short) 1).build();
this.viObject = new VendorInformationObjectBuilder().setEnterpriseNumber(EN).build();
- Mockito.doNothing().when(this.registry).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
- Mockito.doReturn(Optional.of(this.viObject)).when(this.registry).parseVendorInformationObject(Mockito.eq(EN), Mockito.eq(new ObjectHeaderImpl(true, true)), Mockito.any(ByteBuf.class));
- Mockito.doNothing().when(this.registry).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
- Mockito.doReturn(this.object).when(this.registry).parseObject(13, 1, new ObjectHeaderImpl(true, true), Unpooled.wrappedBuffer(new byte[] { 0, 0, 1, 1 }));
+ doNothing().when(this.registry).serializeVendorInformationObject(any(VendorInformationObject.class),
+ any(ByteBuf.class));
+ doReturn(Optional.of(this.viObject)).when(this.registry).parseVendorInformationObject(eq(EN),
+ eq(new ObjectHeaderImpl(true, true)), any(ByteBuf.class));
+ doNothing().when(this.registry).serializeObject(any(Object.class), any(ByteBuf.class));
+ doReturn(this.object).when(this.registry).parseObject(13, 1, new ObjectHeaderImpl(true, true),
+ Unpooled.wrappedBuffer(new byte[] { 0, 0, 1, 1 }));
}
@Test
final ByteBuf buffer = Unpooled.buffer();
a.serializeObject(this.object, buffer);
- Mockito.verify(this.registry, Mockito.only()).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
+ verify(this.registry, only()).serializeObject(any(Object.class), any(ByteBuf.class));
- final Message b = a.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x0D, 0x13, 0, 0x08, 0, 0, 1, 1 }), Collections.emptyList());
+ final Message b = a.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x0D, 0x13, 0, 0x08, 0, 0, 1, 1 }),
+ Collections.emptyList());
assertEquals(this.object, ((Pcerr) b).getPcerrMessage().getErrors().get(0).getErrorObject());
}
final ByteBuf buffer = Unpooled.buffer();
parser.serializeVendorInformationObjects(Lists.newArrayList(this.viObject), buffer);
- Mockito.verify(this.registry, Mockito.only()).serializeVendorInformationObject(Mockito.any(VendorInformationObject.class), Mockito.any(ByteBuf.class));
+ verify(this.registry, only()).serializeVendorInformationObject(any(VendorInformationObject.class),
+ any(ByteBuf.class));
- final Message msg = parser.parseMessage(Unpooled.wrappedBuffer(new byte[] {0x22, 0x13, 0x00, 0x08, 0, 0, 0, 0 }), Collections.emptyList());
+ final Message msg = parser.parseMessage(
+ Unpooled.wrappedBuffer(new byte[] { 0x22, 0x13, 0x00, 0x08, 0, 0, 0, 0 }), Collections.emptyList());
- assertEquals(this.viObject, ((Pcrep)msg).getPcrepMessage().getReplies().get(0).getVendorInformationObject().get(0));
+ assertEquals(this.viObject, ((Pcrep)msg).getPcrepMessage().getReplies().get(0).getVendorInformationObject()
+ .get(0));
}
}
package org.opendaylight.protocol.pcep.spi;
import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.only;
+import static org.mockito.Mockito.verify;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class AbstractObjectWithTlvsTest {
private static final EnterpriseNumber EN = new EnterpriseNumber(0L);
private class Abs extends AbstractObjectWithTlvsParser<TlvsBuilder> {
- protected Abs(TlvRegistry tlvReg, VendorInformationTlvRegistry viTlvReg) {
+ protected Abs(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
super(tlvReg, viTlvReg, 0, 0);
}
@Override
- public Object parseObject(ObjectHeader header, ByteBuf buffer) {
+ public Object parseObject(final ObjectHeader header, final ByteBuf buffer) {
return null;
}
@Override
- public void serializeObject(Object object, ByteBuf buffer) {
+ public void serializeObject(final Object object, final ByteBuf buffer) {
}
@Override
- public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
- builder.setOfList((OfList) tlv);
+ public void addTlv(final TlvsBuilder builder, final Tlv newTlv) {
+ builder.setOfList((OfList) newTlv);
}
@Override
- protected void addVendorInformationTlvs(TlvsBuilder builder, List<VendorInformationTlv> tlvs) {
+ protected void addVendorInformationTlvs(final TlvsBuilder builder, final List<VendorInformationTlv> tlvs) {
builder.setVendorInformationTlv(tlvs);
}
}
@Before
public void setUp() throws PCEPDeserializerException {
- MockitoAnnotations.initMocks(this);
- this.tlv = new OfListBuilder().setCodes(Lists.newArrayList(new OfId(10))).build();
+ this.tlv = new OfListBuilder().setCodes(Collections.singletonList(new OfId(10))).build();
this.viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(EN).build();
- Mockito.doNothing().when(this.viTlvRegistry).serializeVendorInformationTlv(Mockito.any(VendorInformationTlv.class), Mockito.any(ByteBuf.class));
- Mockito.doReturn(Optional.of(this.viTlv)).when(this.viTlvRegistry).parseVendorInformationTlv(EN, Unpooled.wrappedBuffer(new byte[0]));
- Mockito.doNothing().when(this.tlvRegistry).serializeTlv(Mockito.any(Tlv.class), Mockito.any(ByteBuf.class));
- Mockito.doReturn(this.tlv).when(this.tlvRegistry).parseTlv(4, Unpooled.wrappedBuffer(new byte[] { 5, 6 }));
+ doNothing().when(this.viTlvRegistry).serializeVendorInformationTlv(any(VendorInformationTlv.class),
+ any(ByteBuf.class));
+ doReturn(Optional.of(this.viTlv)).when(this.viTlvRegistry).parseVendorInformationTlv(EN,
+ Unpooled.wrappedBuffer(new byte[0]));
+ doNothing().when(this.tlvRegistry).serializeTlv(any(Tlv.class), any(ByteBuf.class));
+ doReturn(this.tlv).when(this.tlvRegistry).parseTlv(4, Unpooled.wrappedBuffer(new byte[] { 5, 6 }));
}
@Test
public void testParseTlvs() throws PCEPDeserializerException {
- Abs a = new Abs(this.tlvRegistry, this.viTlvRegistry);
+ Abs abs = new Abs(this.tlvRegistry, this.viTlvRegistry);
ByteBuf buffer = Unpooled.buffer();
- a.serializeTlv(this.tlv, buffer);
+ abs.serializeTlv(this.tlv, buffer);
- Mockito.verify(this.tlvRegistry, Mockito.only()).serializeTlv(Mockito.any(Tlv.class), Mockito.any(ByteBuf.class));
+ verify(this.tlvRegistry, only()).serializeTlv(any(Tlv.class), any(ByteBuf.class));
- TlvsBuilder b = new TlvsBuilder();
- a.parseTlvs(b, Unpooled.wrappedBuffer(new byte[] { 0, 4, 0, 2, 5, 6, 0, 0 }));
+ TlvsBuilder builder = new TlvsBuilder();
+ abs.parseTlvs(builder, Unpooled.wrappedBuffer(new byte[] { 0, 4, 0, 2, 5, 6, 0, 0 }));
- assertEquals(this.tlv, b.getOfList());
+ assertEquals(this.tlv, builder.getOfList());
}
@Test
final ByteBuf buffer = Unpooled.buffer();
parser.serializeVendorInformationTlvs(Lists.newArrayList(this.viTlv), buffer);
- Mockito.verify(this.viTlvRegistry, Mockito.only()).serializeVendorInformationTlv(Mockito.any(VendorInformationTlv.class), Mockito.any(ByteBuf.class));
+ verify(this.viTlvRegistry, only()).serializeVendorInformationTlv(any(VendorInformationTlv.class),
+ any(ByteBuf.class));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
- parser.parseTlvs(tlvsBuilder, Unpooled.wrappedBuffer(new byte[] { 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }));
+ parser.parseTlvs(tlvsBuilder, Unpooled.wrappedBuffer(
+ new byte[] { 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }));
assertEquals(this.viTlv, tlvsBuilder.getVendorInformationTlv().get(0));
}
}
*/
package org.opendaylight.protocol.pcep.spi;
+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 io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.LabelCase;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class RegistryTest {
@Mock
@Before
public void setUp() throws PCEPDeserializerException {
- MockitoAnnotations.initMocks(this);
- Mockito.doReturn(null).when(this.xroParser).parseSubobject(Mockito.any(ByteBuf.class), Mockito.anyBoolean());
- Mockito.doNothing().when(this.xroSerializer).serializeSubobject(Mockito.any(Subobject.class), Mockito.any(ByteBuf.class));
-
- Mockito.doReturn(null).when(this.rroParser).parseSubobject(Mockito.any(ByteBuf.class));
- Mockito.doNothing().when(this.rroSerializer).serializeSubobject(Mockito.any(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject.class), Mockito.any(ByteBuf.class));
-
- Mockito.doReturn(null).when(this.eroParser).parseSubobject(Mockito.any(ByteBuf.class), Mockito.anyBoolean());
- Mockito.doNothing().when(this.eroSerializer).serializeSubobject(Mockito.any(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject.class), Mockito.any(ByteBuf.class));
-
- Mockito.doReturn(this.viTlv).when(this.tlvParser).parseTlv(Mockito.any(ByteBuf.class));
- Mockito.doNothing().when(this.tlvSerializer).serializeTlv(Mockito.any(Tlv.class), Mockito.any(ByteBuf.class));
+ doReturn(null).when(this.xroParser).parseSubobject(any(ByteBuf.class), anyBoolean());
+ doNothing().when(this.xroSerializer).serializeSubobject(any(Subobject.class), any(ByteBuf.class));
- Mockito.doReturn(5).when(this.objectParser).getObjectClass();
- Mockito.doReturn(1).when(this.objectParser).getObjectType();
- Mockito.doReturn(new OpenBuilder().build()).when(this.objectParser).parseObject(Mockito.any(ObjectHeader.class), Mockito.any(ByteBuf.class));
- Mockito.doNothing().when(this.objectSerializer).serializeObject(Mockito.any(Object.class), Mockito.any(ByteBuf.class));
+ doReturn(this.viTlv).when(this.tlvParser).parseTlv(any(ByteBuf.class));
+ doNothing().when(this.tlvSerializer).serializeTlv(any(Tlv.class), any(ByteBuf.class));
- Mockito.doReturn(null).when(this.msgParser).parseMessage(Mockito.any(ByteBuf.class), Mockito.any(List.class));
- Mockito.doNothing().when(this.msgSerializer).serializeMessage(Mockito.any(Message.class), Mockito.any(ByteBuf.class));
+ doReturn(5).when(this.objectParser).getObjectClass();
+ doReturn(1).when(this.objectParser).getObjectType();
+ doReturn(new OpenBuilder().build()).when(this.objectParser).parseObject(any(ObjectHeader.class),
+ any(ByteBuf.class));
+ doNothing().when(this.objectSerializer).serializeObject(any(Object.class), any(ByteBuf.class));
- Mockito.doReturn(null).when(this.labelParser).parseLabel(Mockito.any(ByteBuf.class));
- Mockito.doNothing().when(this.labelSerializer).serializeLabel(Mockito.anyBoolean(), Mockito.anyBoolean(), Mockito.any(LabelType.class), Mockito.any(ByteBuf.class));
+ doReturn(null).when(this.msgParser).parseMessage(any(ByteBuf.class), any(List.class));
+ doNothing().when(this.msgSerializer).serializeMessage(any(Message.class), any(ByteBuf.class));
- Mockito.doReturn(this.es).when(this.esi).getEnterpriseSpecificInformation();
+ doNothing().when(this.labelSerializer).serializeLabel(anyBoolean(), anyBoolean(), any(LabelType.class),
+ any(ByteBuf.class));
- Mockito.doReturn(EnterpriseSpecificInformation.class).when(this.es).getImplementedInterface();
+ doReturn(this.es).when(this.esi).getEnterpriseSpecificInformation();
- Mockito.doReturn(this.es).when(this.viTlv).getEnterpriseSpecificInformation();
+ doReturn(this.es).when(this.viTlv).getEnterpriseSpecificInformation();
- Mockito.doReturn(EnterpriseSpecificInformation.class).when(this.es).getImplementedInterface();
+ doReturn(EnterpriseSpecificInformation.class).when(this.es).getImplementedInterface();
}
@Test
this.regs.add(this.ctx.registerLabelSerializer(Type1LabelCase.class, this.labelSerializer));
this.regs.add(this.ctx.registerVendorInformationObjectParser(new EnterpriseNumber(10L), this.objectParser));
- this.regs.add(this.ctx.registerVendorInformationObjectSerializer(EnterpriseSpecificInformation.class, this.objectSerializer));
+ this.regs.add(this.ctx.registerVendorInformationObjectSerializer(EnterpriseSpecificInformation.class,
+ this.objectSerializer));
this.regs.add(this.ctx.registerVendorInformationTlvParser(new EnterpriseNumber(12L), this.tlvParser));
- this.regs.add(this.ctx.registerVendorInformationTlvSerializer(EnterpriseSpecificInformation.class, this.tlvSerializer));
+ this.regs.add(this.ctx.registerVendorInformationTlvSerializer(EnterpriseSpecificInformation.class,
+ this.tlvSerializer));
final ByteBuf buffer = Unpooled.buffer();
this.ctx.getXROSubobjectHandlerRegistry().parseSubobject(2, buffer, false);
- this.ctx.getXROSubobjectHandlerRegistry().serializeSubobject(new SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
+ this.ctx.getXROSubobjectHandlerRegistry().serializeSubobject(new SubobjectBuilder()
+ .setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
this.ctx.getEROSubobjectHandlerRegistry().parseSubobject(3, buffer, true);
- this.ctx.getEROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
+ this.ctx.getEROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight
+ .params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder()
+ .setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
this.ctx.getRROSubobjectHandlerRegistry().parseSubobject(4, buffer);
- this.ctx.getRROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().build()).build(), buffer);
+ this.ctx.getRROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight
+ .params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder()
+ .setSubobjectType(new IpPrefixCaseBuilder().build()).build(), buffer);
this.ctx.getLabelHandlerRegistry().parseLabel(1, buffer);
this.ctx.getLabelHandlerRegistry().serializeLabel(true, false, new Type1LabelCaseBuilder().build(), buffer);
this.ctx.getMessageHandlerRegistry().parseMessage(6, buffer, Collections.emptyList());
this.ctx.getMessageHandlerRegistry().serializeMessage(new KeepaliveBuilder().build(), buffer);
- this.ctx.getVendorInformationObjectRegistry().parseVendorInformationObject(new EnterpriseNumber(10L), new ObjectHeaderImpl(true, false), buffer);
+ this.ctx.getVendorInformationObjectRegistry().parseVendorInformationObject(new EnterpriseNumber(10L),
+ new ObjectHeaderImpl(true, false), buffer);
this.ctx.getVendorInformationObjectRegistry().serializeVendorInformationObject(this.esi, buffer);
this.ctx.getVendorInformationTlvRegistry().parseVendorInformationTlv(new EnterpriseNumber(12L), buffer);
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.opendaylight.protocol.pcep.spi.VendorInformationUtil.VENDOR_INFORMATION_OBJECT_CLASS;
+import static org.opendaylight.protocol.pcep.spi.VendorInformationUtil.VENDOR_INFORMATION_OBJECT_TYPE;
+import static org.opendaylight.protocol.pcep.spi.VendorInformationUtil.VENDOR_INFORMATION_TLV_TYPE;
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;
@Test
public void testVendorInformationUtil() {
- assertTrue(VendorInformationUtil.isVendorInformationTlv(VendorInformationUtil.VENDOR_INFORMATION_TLV_TYPE));
- assertFalse(VendorInformationUtil.isVendorInformationTlv(VendorInformationUtil.VENDOR_INFORMATION_OBJECT_CLASS));
-
- assertTrue(VendorInformationUtil.isVendorInformationObject(VendorInformationUtil.VENDOR_INFORMATION_OBJECT_CLASS, VendorInformationUtil.VENDOR_INFORMATION_OBJECT_TYPE));
- assertFalse(VendorInformationUtil.isVendorInformationObject(VendorInformationUtil.VENDOR_INFORMATION_OBJECT_CLASS, VendorInformationUtil.VENDOR_INFORMATION_TLV_TYPE));
- assertFalse(VendorInformationUtil.isVendorInformationObject(VendorInformationUtil.VENDOR_INFORMATION_TLV_TYPE, VendorInformationUtil.VENDOR_INFORMATION_OBJECT_TYPE));
- assertFalse(VendorInformationUtil.isVendorInformationObject(VendorInformationUtil.VENDOR_INFORMATION_OBJECT_TYPE, VendorInformationUtil.VENDOR_INFORMATION_OBJECT_CLASS));
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testVendorInformationUtilPrivateConstructor() throws Throwable {
- final Constructor<VendorInformationUtil> c = VendorInformationUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testEROSubobjectUtilPrivateConstructor() throws Throwable {
- final Constructor<EROSubobjectUtil> c = EROSubobjectUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testRROSubobjectUtilPrivateConstructor() throws Throwable {
- final Constructor<RROSubobjectUtil> c = RROSubobjectUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testTlvUtilPrivateConstructor() throws Throwable {
- final Constructor<TlvUtil> c = TlvUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testXROSubobjectUtilPrivateConstructor() throws Throwable {
- final Constructor<XROSubobjectUtil> c = XROSubobjectUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testObjectUtilPrivateConstructor() throws Throwable {
- final Constructor<ObjectUtil> c = ObjectUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testMessageUtilPrivateConstructor() throws Throwable {
- final Constructor<MessageUtil> c = MessageUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testLabelUtilPrivateConstructor() throws Throwable {
- final Constructor<LabelUtil> c = LabelUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testPCEPMessageConstantsPrivateConstructor() throws Throwable {
- final Constructor<PCEPMessageConstants> c = PCEPMessageConstants.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
+ assertTrue(VendorInformationUtil.isVendorInformationTlv(VENDOR_INFORMATION_TLV_TYPE));
+ assertFalse(VendorInformationUtil.isVendorInformationTlv(VENDOR_INFORMATION_OBJECT_CLASS));
+
+ assertTrue(VendorInformationUtil.isVendorInformationObject(VENDOR_INFORMATION_OBJECT_CLASS,
+ VENDOR_INFORMATION_OBJECT_TYPE));
+ assertFalse(VendorInformationUtil.isVendorInformationObject(VENDOR_INFORMATION_OBJECT_CLASS,
+ VENDOR_INFORMATION_TLV_TYPE));
+ assertFalse(VendorInformationUtil.isVendorInformationObject(VENDOR_INFORMATION_TLV_TYPE,
+ VENDOR_INFORMATION_OBJECT_TYPE));
+ assertFalse(VendorInformationUtil.isVendorInformationObject(VENDOR_INFORMATION_OBJECT_TYPE,
+ VENDOR_INFORMATION_OBJECT_CLASS));
}
}