import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-
import java.io.IOException;
-import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPReplyMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageParser;
-import org.opendaylight.protocol.pcep.impl.message.PcinitiateMessageParser;
-import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
-import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
+import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
+import org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator;
+import org.opendaylight.protocol.pcep.parser.message.PCEPCloseMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPErrorMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPKeepAliveMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringReplyMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPMonitoringRequestMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPNotificationMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPOpenMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPReplyMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPRequestMessageParser;
+import org.opendaylight.protocol.pcep.parser.message.PCEPStartTLSMessageParser;
+import org.opendaylight.protocol.pcep.spi.ObjectRegistry;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+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.ieee754.rev130819.Float32;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcinitiateBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrepBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrptBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcupdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OperationalStatus;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PlspId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpIdNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.BandwidthBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.CCloseMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.EroBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.Iro;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.IroBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobjects;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.SubobjectsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.MetricsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.db.version.tlv.LspDbVersionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.Lsp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.LspBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.MetricBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotificationBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.Of;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.OfBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.RequestBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.PcinitiateMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.Requests;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.RequestsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.NotificationsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Rps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.RpsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.PcrepMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.Replies;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.RepliesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.FailureBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.SuccessBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.NoPath;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.NoPathBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success.Paths;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.success.PathsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.PcrptMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.pcrpt.message.Reports;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.pcrpt.message.ReportsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.pcrpt.message.reports.PathBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.PcupdMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.pcupd.message.Updates;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.pcupd.message.UpdatesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.Rro;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.RroBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.Srp;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.Stateful.Flags;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.stateful.capability.tlv.StatefulBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AttributeFilter;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.Unnumbered;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.record.route.subobjects.subobject.type.UnnumberedBuilder;
-
-import com.google.common.collect.Lists;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.CloseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.KeepaliveBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcerrBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonrepBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcmonreqBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcntfBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcrepBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcreqBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.StarttlsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.P2mpLeaves;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bnc.object.branch.node.type.BranchNodeCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.message.CCloseMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.c.close.TlvsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObj;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.Iro;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.IroBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.keepalive.message.KeepaliveMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.MetricsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.Lspa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.LspaBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPce;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.metrics.MetricPceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.MonitoringBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.GeneralMetricsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.SpecificMetricsListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.response.monitoring.metrics.list.specific.metrics.list.SpecificMetricsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotification;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotificationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.Of;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.OfBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.message.OpenMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.Overload;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.OverloadBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReqBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.RequestCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.request._case.RequestBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.session._case.SessionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcmonrep.message.PcmonrepMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.PcntfMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.Notifications;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.NotificationsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Rps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.RpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.PcrepMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.Replies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.RepliesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.FailureCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.SuccessCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.SuccessBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.Paths;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.success._case.success.PathsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.PcreqMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.MonitoringRequestBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.monitoring.request.PceIdListBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.SegmentComputationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2mpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2pBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.EndpointRroPairBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.RrosBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.ReportedRouteObjectCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.endpoint.rro.pair.rros.route.object.SecondaryReportedRouteObjectCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.p2mp.iro.bnc.choice.BncCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTime;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTimeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.Rp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.secondary.reported.route.object.SrroBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.start.tls.message.StartTlsMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.Svec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder;
+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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder;
+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.ip.prefix._case.IpPrefixBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint8;
public class PCEPValidatorTest {
- private ObjectHandlerRegistry objectRegistry;
-
- private Rp rp;
- private Open open;
- private NoPath noPath;
- private Lspa lspa;
- private Bandwidth bandwidth;
- private Metrics metrics;
- private Iro iro;
- private Ero ero;
- private Rro rro;
- private Of of;
- private Srp srp;
- private Lsp lsp;
-
- private AsNumber eroASSubobject;
- private Unnumbered rroUnnumberedSub;
-
- @Before
- public void setUp() throws Exception {
- this.objectRegistry = ServiceLoaderPCEPExtensionProviderContext.create().getObjectHandlerRegistry();
- final RpBuilder rpBuilder = new RpBuilder();
- rpBuilder.setProcessingRule(false);
- rpBuilder.setIgnore(false);
- rpBuilder.setReoptimization(false);
- rpBuilder.setBiDirectional(false);
- rpBuilder.setLoose(true);
- rpBuilder.setMakeBeforeBreak(false);
- rpBuilder.setOrder(false);
- rpBuilder.setSupplyOf(false);
- rpBuilder.setFragmentation(false);
- rpBuilder.setP2mp(false);
- rpBuilder.setEroCompression(false);
- rpBuilder.setPriority((short) 1);
- rpBuilder.setRequestId(new RequestId(10L));
- this.rp = rpBuilder.build();
-
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder openBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
- openBuilder.setProcessingRule(false);
- openBuilder.setIgnore(false);
- openBuilder.setDeadTimer((short) 1);
- openBuilder.setKeepalive((short) 1);
- openBuilder.setSessionId((short) 0);
- openBuilder.setVersion(new ProtocolVersion((short) 1));
- openBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build());
- this.open = openBuilder.build();
-
- final NoPathBuilder npbuilder = new NoPathBuilder();
- npbuilder.setProcessingRule(false);
- npbuilder.setIgnore(false);
- npbuilder.setNatureOfIssue((short) 0);
- npbuilder.setUnsatisfiedConstraints(false);
- this.noPath = npbuilder.build();
-
- final LspaBuilder lspaBuilder = new LspaBuilder();
- lspaBuilder.setProcessingRule(false);
- lspaBuilder.setIgnore(false);
- lspaBuilder.setLocalProtectionDesired(false);
- lspaBuilder.setHoldPriority((short) 0);
- lspaBuilder.setSetupPriority((short) 0);
- lspaBuilder.setExcludeAny(new AttributeFilter(0L));
- lspaBuilder.setIncludeAll(new AttributeFilter(0L));
- lspaBuilder.setIncludeAny(new AttributeFilter(0L));
- this.lspa = lspaBuilder.build();
-
- final BandwidthBuilder bBuilder = new BandwidthBuilder();
- bBuilder.setIgnore(false);
- bBuilder.setProcessingRule(false);
- bBuilder.setBandwidth(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth(new Float32(new byte[4])));
- this.bandwidth = bBuilder.build();
-
- final MetricBuilder mBuilder = new MetricBuilder();
- mBuilder.setIgnore(false);
- mBuilder.setProcessingRule(false);
- mBuilder.setComputed(false);
- mBuilder.setBound(false);
- mBuilder.setMetricType((short) 1);
- mBuilder.setValue(new Float32(new byte[4]));
- this.metrics = new MetricsBuilder().setMetric(mBuilder.build()).build();
-
- this.eroASSubobject = new AsNumberBuilder().setAsNumber(
- new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber(0xFFFFL)).build();
-
- this.rroUnnumberedSub = new UnnumberedBuilder().setRouterId(0x00112233L).setInterfaceId(0x00ff00ffL).build();
-
- final IroBuilder iroBuilder = new IroBuilder();
- iroBuilder.setIgnore(false);
- iroBuilder.setProcessingRule(false);
- final List<Subobjects> iroSubs = Lists.newArrayList();
- iroSubs.add(new SubobjectsBuilder().setSubobjectType(this.eroASSubobject).build());
- iroBuilder.setSubobjects(iroSubs);
- this.iro = iroBuilder.build();
-
- final EroBuilder eroBuilder = new EroBuilder();
- eroBuilder.setIgnore(false);
- eroBuilder.setProcessingRule(false);
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobjects> eroSubs = Lists.newArrayList();
- eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectsBuilder().setSubobjectType(
- this.eroASSubobject).setLoose(false).build());
- eroBuilder.setSubobjects(eroSubs);
- this.ero = eroBuilder.build();
-
- final RroBuilder rroBuilder = new RroBuilder();
- rroBuilder.setIgnore(false);
- rroBuilder.setProcessingRule(false);
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.Subobjects> rroSubs = Lists.newArrayList();
- rroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectsBuilder().setSubobjectType(
- this.rroUnnumberedSub).setProtectionAvailable(false).setProtectionInUse(false).build());
- rroBuilder.setSubobjects(rroSubs);
- this.rro = rroBuilder.build();
-
- final OfBuilder ofBuilder = new OfBuilder();
- ofBuilder.setIgnore(false);
- ofBuilder.setProcessingRule(false);
- ofBuilder.setCode(new OfId(0));
- this.of = ofBuilder.build();
-
- final SrpBuilder srpBuilder = new SrpBuilder();
- srpBuilder.setIgnore(false);
- srpBuilder.setProcessingRule(false);
- srpBuilder.setOperationId(new SrpIdNumber(1L));
- this.srp = srpBuilder.build();
-
- final LspBuilder lspBuilder = new LspBuilder();
- lspBuilder.setIgnore(false);
- lspBuilder.setProcessingRule(false);
- lspBuilder.setAdministrative(false);
- lspBuilder.setDelegate(false);
- lspBuilder.setPlspId(new PlspId(0L));
- lspBuilder.setOperational(OperationalStatus.Down);
- lspBuilder.setSync(false);
- lspBuilder.setRemove(false);
- lspBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.lsp.TlvsBuilder().build());
- this.lsp = lspBuilder.build();
- }
-
- @Test
- public void testOpenMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin");
- final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.objectRegistry);
- final OpenMessageBuilder builder = new OpenMessageBuilder();
-
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
- b.setProcessingRule(false);
- b.setIgnore(false);
- b.setVersion(new ProtocolVersion((short) 1));
- b.setKeepalive((short) 30);
- b.setDeadTimer((short) 120);
- b.setSessionId((short) 1);
- final Stateful tlv1 = new StatefulBuilder().setFlags(new Flags(true, false, true)).build();
- final LspDbVersion tlv2 = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0x80L)).build();
- b.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().setStateful(
- tlv1).setLspDbVersion(tlv2).build());
- builder.setOpen(b.build());
-
- assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- final ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testKeepAliveMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] result = new byte[] { };
- final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
- final KeepaliveBuilder builder = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build());
-
- assertEquals(builder.build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- final ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(builder.build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testCloseMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin");
-
- final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
- final CloseBuilder builder = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(
- new CCloseBuilder().setIgnore(false).setProcessingRule(false).setReason((short) 5).build()).build());
-
- assertEquals(builder.build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- final ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(builder.build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- // @Test
- // public void testRequestMessageValidationFromBin() throws IOException, PCEPDeserializerException,
- // PCEPDocumentedException,
- // DeserializerException, DocumentedException {
- // List<CompositeRequestObject> requests = new ArrayList<CompositeRequestObject>();
- // final byte[] ipAdress = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- // requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false,
- // false, false, (short) 5, 0xDEADBEEFL, true, false), new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress), new IPv4Address(ipAdress))));
- // PCEPRequestMessage specMessage = new PCEPRequestMessage(requests);
- // List<Message> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
- // final List<Message> specMessages = Lists.newArrayList();
- // specMessages.add(specMessage);
- //
- // assertEquals(deserMsgs.toString(), specMessages.toString());
- //
- // requests = new ArrayList<CompositeRequestObject>();
- // final byte[] ipAdress2 = { (byte) 0x7F, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress2), new IPv4Address(ipAdress2))));
- // specMessage = new PCEPRequestMessage(requests);
- // deserMsgs = deserMsg("src/test/resources/PCReq.1.bin");
- // specMessages.clear();
- // specMessages.add(specMessage);
- // assertEquals(deserMsgs.toString(), specMessages.toString());
- //
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, new
- // PCEPLoadBalancingObject(3, new Bandwidth(ByteArray.floatToBytes((float) 1024.75)), false)));
- // specMessage = new PCEPRequestMessage(requests);
- // deserMsgs = deserMsg("src/test/resources/PCReq.2.bin");
- // specMessages.clear();
- // specMessages.add(specMessage);
- // assertEquals(deserMsgs.toString(), specMessages.toString());
- //
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, new PCEPLspObject(1, false, false, true, false),
- // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false,
- // false), new ArrayList<PCEPMetricObject>() {
- // private static final long serialVersionUID = 1L;
- //
- // {
- // this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
- // }
- // }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new
- // Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false,
- // false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3)), false)));
- //
- // List<CompositeRequestSvecObject> svecList = new ArrayList<CompositeRequestSvecObject>();
- // svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(true, false, false, false, false, this.requestIds,
- // false)));
- //
- // specMessage = new PCEPRequestMessage(svecList, requests);
- // deserMsgs = deserMsg("src/test/resources/PCReq.3.bin");
- // specMessages.clear();
- // specMessages.add(specMessage);
- // // FIXME BUG-89
- // // assertEquals(deserMsgs, specMessages);
- //
- // specMessages.clear();
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, null));
- // specMessages.add(new PCEPRequestMessage(requests));
- //
- // final byte[] ipAdress3 = { (byte) 0x7F, (byte) 0x00, (byte) 0x30, (byte) 0x01 };
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(false, false, false, false, false, false,
- // false, false, (short) 4, 1, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress3), new
- // IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, null));
- // specMessages.add(new PCEPRequestMessage(requests));
- //
- // final byte[] ipAdress4 = { (byte) 0x7F, (byte) 0x30, (byte) 0x00, (byte) 0x01 };
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress2), new IPv4Address(ipAdress4)), null, null, null, null, null, null, null, null, null));
- // specMessages.add(new PCEPRequestMessage(requests));
- //
- // final byte[] ipAdress5 = { (byte) 0x7F, (byte) 0xd0, (byte) 0x00, (byte) 0x01 };
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false,
- // false, false, (short) 1, 1, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress5), new
- // IPv4Address(ipAdress5)), null, null, null, null, null, null, null, null, null));
- //
- // specMessages.add(new PCEPRequestMessage(requests));
- // deserMsgs = deserMsg("src/test/resources/PCReq.4.bin");
- // assertEquals(deserMsgs.toString(), specMessages.toString());
- //
- // specMessages.clear();
- // svecList = new ArrayList<CompositeRequestSvecObject>();
- // svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(true, false, false, false, false, this.requestIds,
- // false)));
- // svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(false, true, true, false, false, this.requestIds,
- // false), new PCEPObjectiveFunctionObject(PCEPOFCodes.MCC, true, false), new PCEPGlobalConstraintsObject((short)
- // 0x55, (short) 1, (short) 100, (short) 0x26, true, false), new PCEPExcludeRouteObject(new
- // ArrayList<ExcludeRouteSubobject>() {
- // private static final long serialVersionUID = 1L;
- //
- // {
- // this.add(new XROAsNumberSubobject(new AsNumber((long) 0x12), true));
- // }
- // }, true, true, false), new ArrayList<PCEPMetricObject>() {
- // private static final long serialVersionUID = 1L;
- //
- // {
- // this.add(new PCEPMetricObject(true, true, new TEMetric(123456L), true, false));
- // }
- // }));
- //
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, PCEPValidatorTest.lspa, new
- // PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new
- // ArrayList<PCEPMetricObject>() {
- // private static final long serialVersionUID = 1L;
- //
- // {
- // this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
- // this.add(new PCEPMetricObject(true, true, new IGPMetric(5335L), false, false));
- // this.add(new PCEPMetricObject(true, true, new IGPMetric(128256), false, false));
- // }
- // }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new
- // Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false,
- // false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3)), false)));
- //
- // final byte[] ipAdress6 = { (byte) 0x7F, (byte) 0xF0, (byte) 0x00, (byte) 0x01 };
- // specMessages.add(new PCEPRequestMessage(svecList, requests));
- //
- // requests = new ArrayList<CompositeRequestObject>();
- // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
- // IPv4Address(ipAdress6), new IPv4Address(ipAdress6)), null, null, PCEPValidatorTest.lspa, new
- // PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new
- // ArrayList<PCEPMetricObject>() {
- // private static final long serialVersionUID = 1L;
- //
- // {
- // this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
- // }
- // }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new
- // Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false,
- // false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3f)), false)));
- // deserMsgs = deserMsg("src/test/resources/PCReq.5.bin");
- // specMessages.add(new PCEPRequestMessage(svecList, requests));
- // // FIXME
- // // assertEquals(deserMsgs, specMessages);
- //
- // // FIXME: need construct with invalid processed parameter
- // // assertEquals(deserMsg("src/test/resources/PCReq.6.invalid.bin"),
- // // asList(
- // // new PCEPErrorMessage(new CompositeErrorObject(new
- // // PCEPRequestParameterObject(true, false, false, false, false, false,
- // // false, false, (short) 3,
- // // 1L, false, false), new PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))),
- // // new PCEPRequestMessage(asList(new
- // // CompositeRequestObject(this.requestParameter, new
- // // PCEPEndPointsObject<IPv4Address>(IPv4Address
- // // .getNetworkAddressFactory().getNetworkAddressForBytes(new byte[] {
- // // 127, 0, 0, 1 }), IPv4Address.getNetworkAddressFactory()
- // // .getNetworkAddressForBytes(new byte[] { 127, 0, 0, 1 })), null, null,
- // // null, null, null, null, null, null, new PCEPLoadBalancingObject(
- // // 3, new Bandwidth(1024.75), false))))));
- //
- // }
- //
- // @Test
- // public void testRequestMessageValidationFromRawMsg() throws PCEPDeserializerException {
- // List<PCEPObject> objs = new ArrayList<PCEPObject>();
- // List<Message> msgs;
- // PCEPRequestParameterObject tmpRP;
- //
- // // test unrecognized object in svec list
- // objs.add(this.svecObj);
- // objs.add(new UnknownObject(true, false, PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
- // objs.add(new PCEPSvecObject(true, true, true, false, false, PCEPValidatorTest.this.requestIds, true));
- //
- // msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
- //
- // assertEquals(msgs.get(0).toString(), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
- // private static final long serialVersionUID = 1L;
- //
- // {
- // this.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
- // }
- // }).toString());
- //
- // // test with request p flag not set and ignoracion of more than one
- // // end-points objects
- // objs = new ArrayList<PCEPObject>();
- // objs.add(this.svecObj);
- // objs.add(this.svecObj);
- // tmpRP = new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1,
- // false, false);
- // objs.add(tmpRP);
- // objs.add(this.endPoints);
- //
- // objs.add(this.requestParameter);
- // objs.add(this.endPoints);
- // objs.add(this.endPoints);
- // // FIXME:mv use object constructor with set processed flag
- // // objs.add(this.classTypeProvider);
- // // objs.add(this.requestParameter);
- // // objs.add(this.endPointsProvider);
- // // objs.add(new PCEPClassTypeObjectProvider((short) 7, false));
- //
- // msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
- // // FIXME:mv use object constructor with set processed flag
- // // assertEquals(msgs.get(0), new PCEPErrorMessage(new
- // // CompositeErrorObject(tmpRP, new
- // // PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))));
- // // assertEquals(
- // // msgs.get(1),
- // // new PCEPRequestMessage(asList(new
- // // CompositeRequestSvecObject(this.svecObj), new
- // // CompositeRequestSvecObject(this.svecObj)), Util
- // // .asList(new CompositeRequestObject(this.requestParameter,
- // // this.endPoints, this.classType, null, null, null, null, null, null,
- // // null,
- // // null))));
- // // assertEquals(msgs.get(2), new PCEPErrorMessage(new
- // // CompositeErrorObject(tmpRP, new
- // // PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))));
- // }
- //
-
- @Test
- public void testReplyMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- // only RP
- byte[] result = ByteArray.fileToBytes("src/test/resources/PCRep.1.bin");
-
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
-
- final PcrepMessageBuilder builder = new PcrepMessageBuilder();
- RepliesBuilder rBuilder = new RepliesBuilder();
-
- final List<Replies> replies1 = Lists.newArrayList();
- rBuilder.setRp(this.rp);
- replies1.add(rBuilder.build());
- builder.setReplies(replies1);
-
- assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- // simple Failure
- result = ByteArray.fileToBytes("src/test/resources/PCRep.2.bin");
- final List<Replies> replies2 = Lists.newArrayList();
- rBuilder = new RepliesBuilder();
- rBuilder.setRp(this.rp);
- replies2.add(rBuilder.build());
- final RepliesBuilder rBuilder2 = new RepliesBuilder();
- rBuilder2.setRp(this.rp);
- rBuilder2.setResult(new FailureBuilder().setNoPath(this.noPath).build());
- replies2.add(rBuilder2.build());
- builder.setReplies(replies2);
-
- assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- // Failure with attributes
- result = ByteArray.fileToBytes("src/test/resources/PCRep.3.bin");
- final List<Replies> replies3 = Lists.newArrayList();
- rBuilder = new RepliesBuilder();
- rBuilder.setRp(this.rp);
- rBuilder.setResult(new FailureBuilder().setNoPath(this.noPath).setLspa(this.lspa).setMetrics(Lists.newArrayList(this.metrics)).setIro(
- this.iro).build());
- replies3.add(rBuilder.build());
- builder.setReplies(replies3);
-
- assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- // Success
- result = ByteArray.fileToBytes("src/test/resources/PCRep.5.bin");
- final List<Replies> replies4 = Lists.newArrayList();
- rBuilder = new RepliesBuilder();
- rBuilder.setRp(this.rp);
- final List<Paths> paths = Lists.newArrayList();
- final PathsBuilder paBuilder = new PathsBuilder();
- paBuilder.setEro(this.ero);
- paBuilder.setLspa(this.lspa);
- paBuilder.setMetrics(Lists.newArrayList(this.metrics));
- paBuilder.setIro(this.iro);
- paBuilder.setOf(this.of);
- paths.add(paBuilder.build());
- rBuilder.setResult(new SuccessBuilder().setPaths(paths).build()).build();
- replies4.add(rBuilder.build());
- builder.setReplies(replies4);
-
- assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testUpdMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- byte[] result = ByteArray.fileToBytes("src/test/resources/PCUpd.2.bin");
-
- final PCEPUpdateRequestMessageParser parser = new PCEPUpdateRequestMessageParser(this.objectRegistry);
-
- final PcupdMessageBuilder builder = new PcupdMessageBuilder();
-
- final List<Updates> updates = Lists.newArrayList();
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.pcupd.message.updates.PathBuilder pBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.pcupd.message.updates.PathBuilder();
- pBuilder.setEro(this.ero);
- pBuilder.setLspa(this.lspa);
- updates.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder.build()).build());
- builder.setUpdates(updates);
-
- assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- result = ByteArray.fileToBytes("src/test/resources/PCUpd.5.bin");
-
- final List<Updates> updates1 = Lists.newArrayList();
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.pcupd.message.updates.PathBuilder pBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcupd.message.pcupd.message.updates.PathBuilder();
- pBuilder1.setEro(this.ero);
- pBuilder1.setLspa(this.lspa);
- updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder.build()).build());
- updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder1.build()).build());
- builder.setUpdates(updates1);
-
- assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testRptMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- byte[] result = ByteArray.fileToBytes("src/test/resources/PCRpt.1.bin");
-
- final PCEPReportMessageParser parser = new PCEPReportMessageParser(this.objectRegistry);
-
- final PcrptMessageBuilder builder = new PcrptMessageBuilder();
-
- final List<Reports> reports = Lists.newArrayList();
- reports.add(new ReportsBuilder().setLsp(this.lsp).build());
- builder.setReports(reports);
-
- assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- result = ByteArray.fileToBytes("src/test/resources/PCRpt.2.bin");
-
- final List<Reports> reports1 = Lists.newArrayList();
- reports1.add(new ReportsBuilder().setLsp(this.lsp).setPath(new PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build());
- builder.setReports(reports1);
-
- assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- result = ByteArray.fileToBytes("src/test/resources/PCRpt.3.bin");
-
- final List<Reports> reports2 = Lists.newArrayList();
- final PathBuilder pBuilder = new PathBuilder();
- pBuilder.setEro(this.ero);
- pBuilder.setLspa(this.lspa);
- pBuilder.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
- pBuilder.setRro(this.rro);
- reports2.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder.build()).build());
- builder.setReports(reports2);
-
- assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- result = ByteArray.fileToBytes("src/test/resources/PCRpt.5.bin");
-
- final List<Reports> reports3 = Lists.newArrayList();
- final PathBuilder pBuilder1 = new PathBuilder();
- pBuilder1.setEro(this.ero);
- pBuilder1.setLspa(this.lspa);
- pBuilder1.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
- pBuilder1.setRro(this.rro);
- reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder.build()).build());
- reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder1.build()).build());
- builder.setReports(reports3);
-
- assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testPcinitMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final byte[] result = ByteArray.fileToBytes("src/test/resources/Pcinit.bin");
-
- final PcinitiateMessageParser parser = new PcinitiateMessageParser(this.objectRegistry);
-
- final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
- final RequestsBuilder rBuilder = new RequestsBuilder();
-
- final List<Requests> reqs = Lists.newArrayList();
- rBuilder.setSrp(this.srp);
- rBuilder.setLsp(this.lsp);
- rBuilder.setEro(this.ero);
- rBuilder.setLspa(this.lspa);
- rBuilder.setMetrics(Lists.newArrayList(this.metrics));
- rBuilder.setIro(this.iro);
- reqs.add(rBuilder.build());
- builder.setRequests(reqs);
-
- assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- final ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testNotificationMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- final CNotification cn1 = new CNotificationBuilder().setIgnore(false).setProcessingRule(false).setType((short) 1).setValue(
- (short) 1).build();
-
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> innerNot = Lists.newArrayList();
- innerNot.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(
- cn1).build());
- final List<Rps> rps = Lists.newArrayList();
- rps.add(new RpsBuilder().setRp(this.rp).build());
-
- final byte[] result = ByteArray.fileToBytes("src/test/resources/PCNtf.5.bin");
-
- final PCEPNotificationMessageParser parser = new PCEPNotificationMessageParser(this.objectRegistry);
- final PcntfMessageBuilder builder = new PcntfMessageBuilder();
-
- final List<Notifications> nots = Lists.newArrayList();
- final NotificationsBuilder b = new NotificationsBuilder();
- b.setNotifications(innerNot);
- b.setRps(rps);
- nots.add(b.build());
-
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> innerNot1 = Lists.newArrayList();
- innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(
- cn1).build());
- innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(
- cn1).build());
- final List<Rps> rps1 = Lists.newArrayList();
- rps1.add(new RpsBuilder().setRp(this.rp).build());
- rps1.add(new RpsBuilder().setRp(this.rp).build());
-
- b.setNotifications(innerNot1);
- b.setRps(rps1);
- nots.add(b.build());
- builder.setNotifications(nots);
-
- assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- final ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
-
- @Test
- public void testErrorMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
- byte[] result = ByteArray.fileToBytes("src/test/resources/PCErr.3.bin");
-
- final ErrorObject error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false).setType((short) 3).setValue((short) 1).build();
-
- final PCEPErrorMessageParser parser = new PCEPErrorMessageParser(this.objectRegistry);
-
- List<Errors> innerErr = Lists.newArrayList();
- innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
-
- final PcerrMessageBuilder builder = new PcerrMessageBuilder();
- builder.setErrors(innerErr);
- builder.setErrorType(new SessionBuilder().setOpen(this.open).build());
-
- assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- ByteBuf buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
-
- result = ByteArray.fileToBytes("src/test/resources/PCErr.5.bin");
-
- final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request.Rps> rps = Lists.newArrayList();
- rps.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request.RpsBuilder().setRp(
- this.rp).build());
-
- innerErr = Lists.newArrayList();
- innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
-
- builder.setErrors(innerErr);
- builder.setErrorType(new RequestBuilder().setRps(rps).build());
-
- assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
- buf = Unpooled.buffer(result.length);
- parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
- assertArrayEquals(result, buf.array());
- }
+ private ObjectRegistry objectRegistry;
+
+ private Open open;
+ private Rp rpTrue;
+ private Rp rpFalse;
+ private NoPath noPath;
+ private Lspa lspa;
+ private Metrics metrics;
+ private Iro iro;
+ private Ero ero;
+ private Of of;
+ private EndpointsObj endpoints;
+ private Svec svec;
+ private List<VendorInformationObject> viObjects;
+ private Monitoring monitoring;
+ private PccIdReq pccIdReq;
+ private PceId pceId;
+ private ProcTime procTime;
+ private Overload overload;
+
+ private AsNumberCase eroASSubobject;
+
+ private SimplePCEPExtensionProviderContext ctx;
+ private BaseParserExtensionActivator act;
+ private TestVendorInformationActivator viObjAct;
+
+ @Before
+ public void setUp() {
+ this.ctx = new SimplePCEPExtensionProviderContext();
+ this.act = new BaseParserExtensionActivator();
+ this.viObjAct = new TestVendorInformationActivator();
+ this.act.start(this.ctx);
+ this.viObjAct.start(this.ctx);
+ this.objectRegistry = this.ctx.getObjectHandlerRegistry();
+ final RpBuilder rpBuilder = new RpBuilder()
+ .setProcessingRule(true)
+ .setIgnore(false)
+ .setReoptimization(false)
+ .setBiDirectional(false)
+ .setLoose(true)
+ .setMakeBeforeBreak(false)
+ .setOrder(false)
+ .setPathKey(false)
+ .setSupplyOf(false)
+ .setFragmentation(false)
+ .setP2mp(false)
+ .setEroCompression(false)
+ .setPriority(Uint8.ONE)
+ .setRequestId(new RequestId(Uint32.TEN))
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
+ .object.rp.TlvsBuilder().build());
+ this.rpTrue = rpBuilder.build();
+ this.rpFalse = rpBuilder.setProcessingRule(false).build();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object
+ .OpenBuilder openBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types
+ .rev181109.open.object.OpenBuilder()
+ .setProcessingRule(false)
+ .setIgnore(false)
+ .setDeadTimer(Uint8.ONE)
+ .setKeepalive(Uint8.ONE)
+ .setSessionId(Uint8.ZERO)
+ .setVersion(new ProtocolVersion(Uint8.ONE))
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .open.object.open.TlvsBuilder().build());
+ // TODO get rid of previous superfluous openBuilder
+ this.open = openBuilder.build();
+
+ this.noPath = new NoPathBuilder()
+ .setProcessingRule(false)
+ .setIgnore(false)
+ .setNatureOfIssue(Uint8.ZERO)
+ .setUnsatisfiedConstraints(false)
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build())
+ .build();
+
+ this.lspa = new LspaBuilder()
+ .setProcessingRule(false)
+ .setIgnore(false)
+ .setLocalProtectionDesired(false)
+ .setHoldPriority(Uint8.ZERO)
+ .setSetupPriority(Uint8.ZERO)
+ .setExcludeAny(new AttributeFilter(Uint32.ZERO))
+ .setIncludeAll(new AttributeFilter(Uint32.ZERO))
+ .setIncludeAny(new AttributeFilter(Uint32.ZERO))
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .lspa.object.lspa.TlvsBuilder().build())
+ .build();
+
+ this.metrics = new MetricsBuilder()
+ .setMetric(new MetricBuilder()
+ .setIgnore(false)
+ .setProcessingRule(false)
+ .setComputed(false)
+ .setBound(false)
+ .setMetricType(Uint8.ONE)
+ .setValue(new Float32(new byte[4]))
+ .build())
+ .build();
+
+ this.eroASSubobject = new AsNumberCaseBuilder()
+ .setAsNumber(new AsNumberBuilder()
+ .setAsNumber(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715
+ .AsNumber(Uint32.valueOf(0xFFFF)))
+ .build())
+ .build();
+
+ final IroBuilder iroBuilder = new IroBuilder();
+ iroBuilder.setIgnore(false);
+ iroBuilder.setProcessingRule(false);
+ final List<Subobject> iroSubs = new ArrayList<>();
+ iroSubs.add(new SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
+ iroBuilder.setSubobject(iroSubs);
+ this.iro = iroBuilder.build();
+
+ final EroBuilder eroBuilder = new EroBuilder();
+ eroBuilder.setIgnore(false);
+ eroBuilder.setProcessingRule(false);
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route
+ .object.ero.Subobject> eroSubs = new ArrayList<>();
+ eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
+ .route.object.ero.SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
+ eroBuilder.setSubobject(eroSubs);
+ this.ero = eroBuilder.build();
+
+ this.of = new OfBuilder()
+ .setIgnore(false)
+ .setProcessingRule(false)
+ .setCode(new OfId(Uint16.ZERO))
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of
+ .object.of.TlvsBuilder().build())
+ .build();
+
+ this.endpoints = new EndpointsObjBuilder()
+ .setIgnore(false)
+ .setProcessingRule(true)
+ .setAddressFamily(new Ipv4CaseBuilder()
+ .setIpv4(new Ipv4Builder()
+ .setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255"))
+ .setDestinationIpv4Address(new Ipv4AddressNoZone("255.255.255.255"))
+ .build())
+ .build())
+ .build();
+
+ this.svec = new SvecBuilder()
+ .setIgnore(false)
+ .setProcessingRule(false)
+ .setLinkDiverse(false)
+ .setNodeDiverse(false)
+ .setSrlgDiverse(false)
+ .setLinkDirectionDiverse(false)
+ .setPartialPathDiverse(false)
+ .setRequestsIds(Lists.newArrayList(new RequestId(Uint32.ONE)))
+ .build();
+
+ this.viObjects = new ArrayList<>();
+ final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
+ final VendorInformationObject viObj = new VendorInformationObjectBuilder()
+ .setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO))
+ .setEnterpriseSpecificInformation(esInfo)
+ .build();
+ this.viObjects.add(viObj);
+
+ this.monitoring = new MonitoringBuilder()
+ .setMonitoringId(Uint32.valueOf(100))
+ .setFlags(new Flags(false, false, false, false, false))
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .monitoring.object.monitoring.TlvsBuilder().build()).build();
+ this.pccIdReq = new PccIdReqBuilder()
+ .setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1")))
+ .build();
+ this.pceId = new PceIdBuilder()
+ .setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.2")))
+ .build();
+
+ this.procTime = new ProcTimeBuilder()
+ .setEstimated(false)
+ .setCurrentProcTime(Uint32.ONE)
+ .setMinProcTime(Uint32.TWO)
+ .setMaxProcTime(Uint32.valueOf(3))
+ .setAverageProcTime(Uint32.valueOf(4))
+ .setVarianceProcTime(Uint32.valueOf(5))
+ .build();
+ this.overload = new OverloadBuilder().setDuration(Uint16.valueOf(120)).build();
+ }
+
+ @Test
+ public void testOpenMsg() throws IOException, PCEPDeserializerException {
+ final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin"));
+ final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.ctx.getObjectHandlerRegistry());
+ final OpenMessageBuilder builder = new OpenMessageBuilder();
+
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object
+ .OpenBuilder b = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .open.object.OpenBuilder()
+ .setProcessingRule(false)
+ .setIgnore(false)
+ .setVersion(new ProtocolVersion(Uint8.ONE))
+ .setKeepalive(Uint8.valueOf(30))
+ .setDeadTimer(Uint8.valueOf(120))
+ .setSessionId(Uint8.ONE)
+ .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .open.object.open.TlvsBuilder().build());
+ builder.setOpen(b.build());
+
+ assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ try {
+ parser.serializeMessage(new OpenBuilder().setOpenMessage(new OpenMessageBuilder().build()).build(), null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Open Object must be present in Open Message.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testKeepAliveMsg() throws PCEPDeserializerException {
+ final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { 32, 2, 0, 4 });
+ final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
+ final KeepaliveBuilder builder = new KeepaliveBuilder()
+ .setKeepaliveMessage(new KeepaliveMessageBuilder().build());
+
+ assertEquals(
+ builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(builder.build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testStartTLSMsg() throws Exception {
+ final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { 32, 20, 0, 4 });
+ final PCEPStartTLSMessageParser parser = new PCEPStartTLSMessageParser(this.objectRegistry);
+ final StarttlsBuilder builder = new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build());
+
+ assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4),
+ Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(builder.build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testCloseMsg() throws IOException, PCEPDeserializerException {
+ final ByteBuf result =
+ Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin"));
+
+ final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
+ final CloseBuilder builder = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder()
+ .setCClose(new CCloseBuilder()
+ .setIgnore(false)
+ .setProcessingRule(false)
+ .setReason(Uint8.valueOf(5))
+ .setTlvs(new TlvsBuilder().build())
+ .build())
+ .build());
+
+ assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4),
+ Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(builder.build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ try {
+ parser.serializeMessage(new CloseBuilder()
+ .setCCloseMessage(new CCloseMessageBuilder().build())
+ .build(), null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Close Object must be present in Close Message.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testRequestMsg() throws IOException, PCEPDeserializerException {
+
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
+
+ final PcreqMessageBuilder builder = new PcreqMessageBuilder();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.Requests> reqs1 = new ArrayList<>();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder rBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder();
+ rBuilder.setRp(this.rpTrue);
+ rBuilder.setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder()
+ .setEndpointsObj(this.endpoints).build()).build());
+ reqs1.add(rBuilder.build());
+ builder.setRequests(reqs1);
+
+ ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRequestMessage1.bin"));
+ assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+
+ assertArrayEquals(result.array(), buf.array());
+
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.3.bin"));
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.Requests> reqs2 = new ArrayList<>();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder rBuilder1 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder();
+ rBuilder1.setRp(this.rpTrue);
+ final P2pBuilder p2pBuilder = new P2pBuilder()
+ .setEndpointsObj(this.endpoints)
+ .setMetrics(Lists.newArrayList(this.metrics))
+ .setIro(this.iro);
+ rBuilder1.setSegmentComputation(new SegmentComputationBuilder().setP2p(p2pBuilder.build()).build());
+ reqs2.add(rBuilder1.build());
+ builder.setRequests(reqs2)
+ .setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
+ .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec).build()));
+
+ assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.9.bin"));
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.Requests> reqs3 = new ArrayList<>();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder rBuilder2 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder();
+ rBuilder2.setRp(new RpBuilder(this.rpTrue).setP2mp(true).build());
+ final EndpointsObjBuilder epBuilder = new EndpointsObjBuilder()
+ .setIgnore(false)
+ .setProcessingRule(true)
+ .setAddressFamily(new P2mpIpv4CaseBuilder()
+ .setP2mpIpv4(new P2mpIpv4Builder()
+ .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
+ .setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255"))
+ .setDestinationIpv4Address(Arrays.asList(new Ipv4AddressNoZone("255.255.255.254"),
+ new Ipv4AddressNoZone("255.255.255.253")))
+ .build()).build());
+
+ final P2mpBuilder p2mpBuilder = new P2mpBuilder();
+ p2mpBuilder.setEndpointRroPair(Collections.singletonList(new EndpointRroPairBuilder()
+ .setEndpointsObj(epBuilder.build())
+ .setRros(Arrays.asList(new RrosBuilder()
+ .setRouteObject(new ReportedRouteObjectCaseBuilder()
+ .setRro(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
+ .reported.route.object.RroBuilder()
+ .setIgnore(false)
+ .setProcessingRule(true)
+ .setSubobject(Arrays.asList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder()
+ .setProtectionAvailable(false)
+ .setProtectionInUse(false)
+ .setSubobjectType(new IpPrefixCaseBuilder()
+ .setIpPrefix(new IpPrefixBuilder()
+ .setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.252/32")))
+ .build())
+ .build())
+ .build()))
+ .build())
+ .build())
+ .build(),
+ new RrosBuilder()
+ .setRouteObject(new SecondaryReportedRouteObjectCaseBuilder()
+ .setSrro(new SrroBuilder()
+ .setIgnore(false)
+ .setProcessingRule(true)
+ .setSubobject(Arrays.asList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder()
+ .setProtectionInUse(false)
+ .setProtectionAvailable(false)
+ .setSubobjectType(new IpPrefixCaseBuilder()
+ .setIpPrefix(new IpPrefixBuilder()
+ .setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.251/32")))
+ .build())
+ .build())
+ .build()))
+ .build())
+ .build())
+ .build()))
+ .build()));
+ p2mpBuilder.setIroBncChoice(new BncCaseBuilder()
+ .setBranchNodeType(new BranchNodeCaseBuilder()
+ .setBranchNodeList(new BranchNodeListBuilder()
+ .setIgnore(false)
+ .setProcessingRule(true)
+ .setSubobject(Arrays.asList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .pcep.types.rev181109.bnc.SubobjectBuilder()
+ .setLoose(false)
+ .setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.252/32")))
+ .build()))
+ .build())
+ .build())
+ .build());
+ rBuilder2.setSegmentComputation(new SegmentComputationBuilder().setP2mp(p2mpBuilder.build()).build());
+ reqs3.add(rBuilder2.build());
+ builder.setRequests(reqs3).setSvec(null);
+
+ assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ try {
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(new PcreqMessageBuilder().build()).build(),
+ null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Requests cannot be null or empty.", e.getMessage());
+ }
+ try {
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(new PcreqMessageBuilder()
+ .setRequests(Collections.emptyList()).build()).build(), null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Requests cannot be null or empty.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testReplyMsg() throws IOException, PCEPDeserializerException {
+ // only RP
+
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+
+ final PcrepMessageBuilder builder = new PcrepMessageBuilder();
+ RepliesBuilder repliesBuilder = new RepliesBuilder();
+
+ final List<Replies> replies1 = new ArrayList<>();
+ repliesBuilder.setRp(this.rpTrue);
+ replies1.add(repliesBuilder.build());
+ builder.setReplies(replies1);
+
+ ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.1.bin"));
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ // simple Failure
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.2.bin"));
+ final List<Replies> replies2 = new ArrayList<>();
+ repliesBuilder = new RepliesBuilder();
+ repliesBuilder.setRp(this.rpTrue);
+ replies2.add(repliesBuilder.build());
+ final RepliesBuilder repliesBuilder2 = new RepliesBuilder();
+ repliesBuilder2.setRp(this.rpTrue);
+ repliesBuilder2.setResult(new FailureCaseBuilder().setNoPath(this.noPath).build());
+ replies2.add(repliesBuilder2.build());
+ builder.setReplies(replies2);
+
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ // Failure with attributes
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.3.bin"));
+ final List<Replies> replies3 = new ArrayList<>();
+ repliesBuilder = new RepliesBuilder();
+ repliesBuilder.setRp(this.rpTrue);
+ repliesBuilder.setResult(new FailureCaseBuilder().setNoPath(this.noPath).setLspa(this.lspa)
+ .setMetrics(Lists.newArrayList(this.metrics)).setIro(this.iro).build());
+ replies3.add(repliesBuilder.build());
+ builder.setReplies(replies3);
+
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ // Success
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.5.bin"));
+ final List<Replies> replies4 = new ArrayList<>();
+ repliesBuilder = new RepliesBuilder();
+ repliesBuilder.setRp(this.rpTrue);
+ final List<Paths> paths = new ArrayList<>();
+ final PathsBuilder paBuilder = new PathsBuilder()
+ .setEro(this.ero)
+ .setLspa(this.lspa)
+ .setMetrics(Lists.newArrayList(this.metrics))
+ .setIro(this.iro)
+ .setOf(this.of);
+ paths.add(paBuilder.build());
+ repliesBuilder.setResult(new SuccessCaseBuilder()
+ .setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
+ replies4.add(repliesBuilder.build());
+ builder.setReplies(replies4);
+
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ try {
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().build()).build(),
+ null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Replies cannot be null or empty.", e.getMessage());
+ }
+ try {
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder()
+ .setReplies(Collections.emptyList()).build()).build(), null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Replies cannot be null or empty.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testNotificationMsg() throws IOException, PCEPDeserializerException {
+ final CNotification cn1 = new CNotificationBuilder().setIgnore(false).setProcessingRule(false)
+ .setType(Uint8.ONE).setValue(Uint8.ONE).build();
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.Notifications> innerNot = new ArrayList<>();
+ innerNot.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
+ final List<Rps> rps = new ArrayList<>();
+ rps.add(new RpsBuilder().setRp(this.rpFalse).build());
+
+ final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCNtf.5.bin"));
+
+ final PCEPNotificationMessageParser parser = new PCEPNotificationMessageParser(this.objectRegistry);
+ final PcntfMessageBuilder builder = new PcntfMessageBuilder();
+
+ final List<Notifications> nots = new ArrayList<>();
+ final NotificationsBuilder b = new NotificationsBuilder();
+ b.setNotifications(innerNot);
+ b.setRps(rps);
+ nots.add(b.build());
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.Notifications> innerNot1 = new ArrayList<>();
+ innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
+ innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
+ .message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
+ final List<Rps> rps1 = new ArrayList<>();
+ rps1.add(new RpsBuilder().setRp(this.rpFalse).build());
+ rps1.add(new RpsBuilder().setRp(this.rpFalse).build());
+
+ b.setNotifications(innerNot1);
+ b.setRps(rps1);
+ nots.add(b.build());
+ builder.setNotifications(nots);
+
+ assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testErrorMsg() throws IOException, PCEPDeserializerException {
+
+ ErrorObject error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false)
+ .setType(Uint8.valueOf(3)).setValue(Uint8.ONE).build();
+
+ final PCEPErrorMessageParser parser = new PCEPErrorMessageParser(this.ctx.getObjectHandlerRegistry());
+
+ List<Errors> innerErr = new ArrayList<>();
+
+ final PcerrMessageBuilder builder = new PcerrMessageBuilder();
+
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message
+ .pcerr.message.error.type.request._case.request.Rps> rps = new ArrayList<>();
+ rps.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message
+ .pcerr.message.error.type.request._case.request.RpsBuilder().setRp(this.rpFalse).build());
+
+ innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
+
+ builder.setErrors(innerErr);
+ builder.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(rps).build()).build());
+
+ ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCErr.5.bin"));
+ assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCErr.3.bin"));
+
+ error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false).setType(Uint8.valueOf(3))
+ .setValue(Uint8.ONE).build();
+
+ innerErr = new ArrayList<>();
+ innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
+
+ builder.setErrors(innerErr);
+ builder.setErrorType(
+ new SessionCaseBuilder().setSession(new SessionBuilder().setOpen(this.open).build()).build());
+
+ assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ try {
+ parser.serializeMessage(new PcerrBuilder()
+ .setPcerrMessage(new PcerrMessageBuilder().build()).build(), null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Errors should not be empty.", e.getMessage());
+ }
+ try {
+ parser.serializeMessage(new PcerrBuilder().setPcerrMessage(new PcerrMessageBuilder()
+ .setErrors(Collections.emptyList()).build()).build(), null);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Errors should not be empty.", e.getMessage());
+ }
+ }
+
+ @Test
+ public void testReqMsgWithVendorInfoObjects() throws IOException, PCEPDeserializerException {
+ final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.7.bin"));
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
+
+ final PcreqMessageBuilder builder = new PcreqMessageBuilder();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.Requests> reqs1 = new ArrayList<>();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq
+ .message.RequestsBuilder rBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder();
+ rBuilder.setRp(this.rpTrue);
+ rBuilder.setVendorInformationObject(this.viObjects);
+ final SegmentComputationBuilder sBuilder = new SegmentComputationBuilder();
+ sBuilder.setP2p(
+ new P2pBuilder().setEndpointsObj(this.endpoints).setVendorInformationObject(this.viObjects).build());
+ rBuilder.setSegmentComputation(sBuilder.build());
+ reqs1.add(rBuilder.build());
+ builder.setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
+ .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec)
+ .setVendorInformationObject(this.viObjects).build()));
+ builder.setRequests(reqs1);
+
+ assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testRepMsgWithVendorInforObjects() throws IOException, PCEPDeserializerException {
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+
+ final PcrepMessageBuilder builder = new PcrepMessageBuilder();
+ RepliesBuilder repliesBuilder = new RepliesBuilder();
+ final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.6.bin"));
+ final List<Replies> replies = new ArrayList<>();
+ repliesBuilder = new RepliesBuilder()
+ .setRp(this.rpTrue)
+ .setVendorInformationObject(this.viObjects);
+ final List<Paths> paths = new ArrayList<>();
+ final PathsBuilder paBuilder = new PathsBuilder();
+ paBuilder.setEro(this.ero);
+ paths.add(paBuilder.build());
+ repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths)
+ .setVendorInformationObject(this.viObjects).build()).build()).build();
+ replies.add(repliesBuilder.build());
+ builder.setReplies(replies);
+
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testMonRepMsg() throws PCEPDeserializerException, IOException {
+ final PCEPMonitoringReplyMessageParser parser = new PCEPMonitoringReplyMessageParser(this.objectRegistry);
+ final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
+ builder.setMonitoring(this.monitoring)
+ .setMonitoringMetricsList(new GeneralMetricsListBuilder()
+ .setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build())).build());
+
+ final byte[] msgBytes = {
+ 0x20, 0x09, 0x00, 0x18,
+ /* monitoring object */
+ 0x13, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64,
+ /* pce-id object */
+ 0x19, 0x10, 0x00, 0x08, 0x7f, 0x00, 0x00, 0x02
+ };
+
+ ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
+ assertEquals(
+ new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(),
+ parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
+ ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ builder.setMonitoring(this.monitoring);
+ builder.setPccIdReq(this.pccIdReq);
+ final SpecificMetricsBuilder smBuilder = new SpecificMetricsBuilder();
+ smBuilder.setRp(this.rpTrue);
+ final List<MetricPce> metricPces = new ArrayList<>();
+ metricPces.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId)
+ .setProcTime(this.procTime).build());
+ metricPces.add(new MetricPceBuilder().setPceId(this.pceId).setProcTime(this.procTime).build());
+ smBuilder.setMetricPce(metricPces);
+ final SpecificMetricsBuilder smBuilder2 = new SpecificMetricsBuilder();
+ final List<MetricPce> metricPces2 = new ArrayList<>();
+ smBuilder2.setRp(this.rpTrue);
+ metricPces2.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId).build());
+ smBuilder2.setMetricPce(metricPces2);
+ builder.setMonitoringMetricsList(new SpecificMetricsListBuilder()
+ .setSpecificMetrics(Lists.newArrayList(smBuilder.build(), smBuilder2.build())).build());
+
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonRep.bin"));
+ assertEquals(
+ new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testRepWithMonitoring() throws IOException, PCEPDeserializerException {
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+
+ final PcrepMessageBuilder builder = new PcrepMessageBuilder();
+ RepliesBuilder repliesBuilder = new RepliesBuilder();
+
+ final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRepMon.5.bin"));
+ final List<Replies> replies4 = new ArrayList<>();
+ repliesBuilder = new RepliesBuilder()
+ .setRp(this.rpTrue)
+ .setMonitoring(this.monitoring)
+ .setPccIdReq(this.pccIdReq)
+ .setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build()));
+ final List<Paths> paths = new ArrayList<>();
+ final PathsBuilder paBuilder = new PathsBuilder()
+ .setEro(this.ero)
+ .setLspa(this.lspa)
+ .setMetrics(Lists.newArrayList(this.metrics))
+ .setIro(this.iro)
+ .setOf(this.of);
+ paths.add(paBuilder.build());
+ repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build())
+ .build()).build();
+ replies4.add(repliesBuilder.build());
+ builder.setReplies(replies4);
+
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testReqWithMonitoring() throws IOException, PCEPDeserializerException {
+ final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.8.bin"));
+
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
+
+ final PcreqMessageBuilder builder = new PcreqMessageBuilder();
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.Requests> reqs1 = new ArrayList<>();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq
+ .message.RequestsBuilder rBuilder =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder();
+ rBuilder.setRp(this.rpTrue)
+ .setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder()
+ .setEndpointsObj(this.endpoints).build()).build());
+ reqs1.add(rBuilder.build());
+ final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder()
+ .setMonitoring(this.monitoring)
+ .setPccIdReq(this.pccIdReq)
+ .setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
+ builder.setMonitoringRequest(monReqBuilder.build()).setRequests(reqs1);
+
+ assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ final ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testMonReqMsg() throws PCEPDeserializerException, IOException {
+ final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(this.objectRegistry);
+
+ final PcreqMessageBuilder builder = new PcreqMessageBuilder();
+ final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder()
+ .setMonitoring(this.monitoring)
+ .setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
+ builder.setMonitoringRequest(monReqBuilder.build());
+ final byte[] msgBytes = {
+ 0x20, 0x08, 0x00, 0x18,
+ /* monitoring object */
+ 0x13, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64,
+ /* pce-id object */
+ 0x19, 0x10, 0x00, 0x08, 0x7f, 0x00, 0x00, 0x02
+ };
+ ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
+ assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+
+ result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonReq.bin"));
+ final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.Requests> reqs2 = new ArrayList<>();
+ final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq
+ .message.RequestsBuilder rBuilder1 =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
+ .pcreq.message.RequestsBuilder();
+ rBuilder1.setRp(this.rpTrue);
+ final P2pBuilder p2pBuilder = new P2pBuilder()
+ .setEndpointsObj(this.endpoints)
+ .setMetrics(Lists.newArrayList(this.metrics))
+ .setIro(this.iro);
+ rBuilder1.setSegmentComputation(new SegmentComputationBuilder().setP2p(p2pBuilder.build()).build());
+ reqs2.add(rBuilder1.build());
+ builder.setRequests(reqs2)
+ .setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
+ .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec).build()));
+ monReqBuilder.setMonitoring(this.monitoring).setPccIdReq(this.pccIdReq);
+ final PceIdList pceIdList = new PceIdListBuilder().setPceId(this.pceId).build();
+ monReqBuilder.setPceIdList(Lists.newArrayList(pceIdList, pceIdList));
+ builder.setMonitoringRequest(monReqBuilder.build());
+
+ assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
+
+ @Test
+ public void testReplyMsgWithTwoEros() throws IOException, PCEPDeserializerException {
+ // Success Reply with two EROs: the first one is followed by Bandwidth Object and one Metric Object
+
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+
+ final PcrepMessageBuilder builder = new PcrepMessageBuilder();
+
+ final List<Replies> replies = new ArrayList<>();
+
+ final BandwidthBuilder bwBuilder = new BandwidthBuilder();
+ bwBuilder.setIgnore(false);
+ bwBuilder.setProcessingRule(false);
+ bwBuilder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x47, (byte) 0x74, (byte) 0x24, (byte) 0x00 }));
+
+ RepliesBuilder repliesBuilder = new RepliesBuilder();
+ repliesBuilder = new RepliesBuilder();
+ repliesBuilder.setRp(this.rpTrue);
+ final List<Paths> paths = new ArrayList<>();
+ final PathsBuilder paBuilder1 = new PathsBuilder()
+ .setEro(this.ero)
+ .setBandwidth(bwBuilder.build())
+ .setMetrics(Lists.newArrayList(this.metrics));
+ paths.add(paBuilder1.build());
+ final PathsBuilder paBuilder2 = new PathsBuilder();
+ paBuilder2.setEro(this.ero);
+ paths.add(paBuilder2.build());
+ repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build())
+ .build()).build();
+ replies.add(repliesBuilder.build());
+ builder.setReplies(replies);
+
+ ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.7.bin"));
+ assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
+ result.readableBytes() - 4), Collections.emptyList()));
+ ByteBuf buf = Unpooled.buffer(result.readableBytes());
+ parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
+ assertArrayEquals(result.array(), buf.array());
+ }
}