BUG-50 : added test for Notification message. 65/2365/1
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 4 Nov 2013 16:12:34 +0000 (17:12 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Mon, 4 Nov 2013 16:12:34 +0000 (17:12 +0100)
Change-Id: I6d33aa764e7ff13d17a4ea04393366786c894f9b
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
15 files changed:
pcep/api/src/main/yang/pcep-types.yang
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Activator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPErrorMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPNotificationMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPNotificationObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPRequestParameterObjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPValidatorTest.java
pcep/impl/src/test/resources/PCNtf.1.bin [deleted file]
pcep/impl/src/test/resources/PCNtf.2.bin [deleted file]
pcep/impl/src/test/resources/PCNtf.3.bin [deleted file]
pcep/impl/src/test/resources/PCNtf.4.bin [deleted file]
pcep/impl/src/test/resources/PCNtf.5.bin
pcep/impl/src/test/resources/PCNtf.invalid.bin [deleted file]

index 2fe8cc1a95decb64da12a418f318463193f61d56..f773f7e78b1eb696252034f27d91d73419808eac 100644 (file)
@@ -393,78 +393,79 @@ module pcep-types {
        grouping rp-object {
                description "RP Object";
                reference "https://tools.ietf.org/html/rfc5440#section-7.4";
-
-               uses object;
-               container "tlvs" {
-                       uses order-tlv;
-               }
-
-               leaf priority {
-                       type uint8 {
-                               range 1..7;
+               container rp {
+                       uses object;
+                       container "tlvs" {
+                               uses order-tlv;
+                       }
+       
+                       leaf priority {
+                               type uint8 {
+                                       range 1..7;
+                               }
+                       }
+       
+                       leaf request-id {
+                               type request-id;
+                               mandatory true;
+                       }
+       
+                       leaf reoptimization {
+                               type boolean;
+                               default false;
+                       }
+       
+                       leaf bi-directional {
+                               type boolean;
+                               default false;
+                       }
+       
+                       leaf loose {
+                               type boolean;
+                               default false;
+                       }
+       
+                       leaf path-key {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc5520#section-3.2.1";
+                       }
+       
+                       leaf fragmentation {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
+                       }
+       
+                       leaf p2mp {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
+                       }
+       
+                       leaf ero-compression {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
+                       }
+       
+                       leaf supply-of {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc5541#section-3.3";
+                       }
+       
+                       leaf order {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc5557#section-5.3";
+                       }
+       
+                       leaf make-before-break {
+                               type boolean;
+                               default false;
+                               reference "https://tools.ietf.org/html/rfc5557#section-5.3";
                        }
-               }
-
-               leaf request-id {
-                       type request-id;
-                       mandatory true;
-               }
-
-               leaf reoptimization {
-                       type boolean;
-                       default false;
-               }
-
-               leaf bi-directional {
-                       type boolean;
-                       default false;
-               }
-
-               leaf loose {
-                       type boolean;
-                       default false;
-               }
-
-               leaf path-key {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc5520#section-3.2.1";
-               }
-
-               leaf fragmentation {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
-               }
-
-               leaf p2mp {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
-               }
-
-               leaf ero-compression {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc6006#section-3.3.1";
-               }
-
-               leaf supply-of {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc5541#section-3.3";
-               }
-
-               leaf order {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc5557#section-5.3";
-               }
-
-               leaf make-before-break {
-                       type boolean;
-                       default false;
-                       reference "https://tools.ietf.org/html/rfc5557#section-5.3";
                }
        }
 
@@ -697,22 +698,23 @@ module pcep-types {
        grouping notification-object {
                description "NOTIFICATION Object";
                reference "https://tools.ietf.org/html/rfc5440#section-7.14";
-
-               uses object;
-               container "tlvs" {
-                       when "../type = 2 and ../value = 1";
-
-                       uses overload-duration-tlv;
-               }
-
-               leaf type {
-                       type uint8;
-                       mandatory true;
-               }
-
-               leaf value {
-                       type uint8;
-                       mandatory true;
+               container c-notification {
+                       uses object;
+                       container "tlvs" {
+                               when "../type = 2 and ../value = 1";
+       
+                               uses overload-duration-tlv;
+                       }
+       
+                       leaf type {
+                               type uint8;
+                               mandatory true;
+                       }
+       
+                       leaf value {
+                               type uint8;
+                               mandatory true;
+                       }
                }
        }
 
@@ -1016,9 +1018,7 @@ module pcep-types {
                        uses message-header;
 
                        list requests {
-                               container rp {
-                                       uses rp-object;
-                               }
+                               uses rp-object;
 
                                container path-key-expansion {
                                        when "rp/path-key = true";
@@ -1096,9 +1096,7 @@ module pcep-types {
                        uses message-header;
 
                        list replies {
-                               container rp {
-                                       uses rp-object;
-                               }
+                               uses rp-object;
 
                                container lsp {
                                        reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-6.5";
index dbb4acc5ea2768b0a71eeaca0365f3459c76e889..0c25bdb88ad5f7ee59a1fc1c32a19a23731b8842 100644 (file)
@@ -1,6 +1,5 @@
 package org.opendaylight.protocol.pcep.impl;
 
-import java.util.Arrays;
 import java.util.BitSet;
 import java.util.List;
 
@@ -95,27 +94,31 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                                                + COMMON_OBJECT_HEADER_LENGTH + ".");
                        }
 
-                       final int objClass = UnsignedBytes.toInt(bytes[OC_F_OFFSET]);
+                       final int objClass = UnsignedBytes.toInt(bytes[offset]);
 
-                       final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(bytes[OT_FLAGS_MF_OFFSET], OT_SF_OFFSET, OT_SF_LENGTH));
+                       offset += OC_F_LENGTH;
 
-                       final int objLength = ByteArray.bytesToInt(Arrays.copyOfRange(bytes, OBJ_LENGTH_F_OFFSET, OBJ_LENGTH_F_OFFSET
-                                       + OBJ_LENGTH_F_LENGTH));
+                       final int objType = UnsignedBytes.toInt(ByteArray.copyBitsRange(bytes[offset], OT_SF_OFFSET, OT_SF_LENGTH));
 
-                       final byte[] flagsBytes = { ByteArray.copyBitsRange(bytes[OT_FLAGS_MF_OFFSET], FLAGS_SF_OFFSET, FLAGS_SF_LENGTH) };
+                       final byte[] flagsBytes = { ByteArray.copyBitsRange(bytes[offset], FLAGS_SF_OFFSET, FLAGS_SF_LENGTH) };
 
                        final BitSet flags = ByteArray.bytesToBitSet(flagsBytes);
 
-                       if (bytes.length - offset < objLength) {
+                       offset += OT_FLAGS_MF_LENGTH;
+
+                       final int objLength = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset, OBJ_LENGTH_F_LENGTH));
+
+                       if (bytes.length - offset < objLength - COMMON_OBJECT_HEADER_LENGTH) {
                                throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + (bytes.length - offset) + " Expected: >= "
                                                + objLength + ".");
                        }
 
+                       offset += OBJ_LENGTH_F_LENGTH;
+
                        // copy bytes for deeper parsing
-                       final byte[] bytesToPass = ByteArray.subByte(bytes, offset + COMMON_OBJECT_HEADER_LENGTH, objLength
-                                       - COMMON_OBJECT_HEADER_LENGTH);
+                       final byte[] bytesToPass = ByteArray.subByte(bytes, offset, objLength - COMMON_OBJECT_HEADER_LENGTH);
 
-                       offset += objLength;
+                       offset += objLength - COMMON_OBJECT_HEADER_LENGTH;
 
                        final ObjectParser parser = this.registry.getObjectParser(objClass, objType);
 
index e986664b1bf15d52a9a082bf1016ff2c5345f691..99ed4321b64ff7c4858c314460c87cd44a9e21d5 100644 (file)
@@ -93,7 +93,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
@@ -106,7 +105,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CClose;
@@ -114,6 +112,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 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.error.code.tlv.LspErrorCode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiers;
+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.of.list.tlv.OfList;
 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.order.tlv.Order;
@@ -121,6 +120,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure.no.path.tlvs.NoPathVector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing;
+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.rsvp.error.spec.tlv.RsvpErrorSpec;
 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.symbolic.path.name.tlv.SymbolicPathName;
@@ -276,7 +276,7 @@ public final class Activator implements PCEPExtensionProviderActivator {
                                new PCEPExcludeRouteObjectParser(xroSubReg));
 
                context.registerObjectSerializer(Open.class, new PCEPOpenObjectParser(tlvReg));
-               context.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(tlvReg));
+               context.registerObjectSerializer(Rp.class, new PCEPRequestParameterObjectParser(tlvReg));
                context.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(tlvReg));
                context.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(tlvReg));
                context.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(tlvReg));
@@ -286,7 +286,7 @@ public final class Activator implements PCEPExtensionProviderActivator {
                context.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(tlvReg));
                context.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(eroSubReg));
                context.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(tlvReg));
-               context.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(tlvReg));
+               context.registerObjectSerializer(CNotification.class, new PCEPNotificationObjectParser(tlvReg));
                context.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(tlvReg));
                context.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(tlvReg));
                context.registerObjectSerializer(CClose.class, new PCEPCloseObjectParser(tlvReg));
index 1ffa80a35347b86ab057af5ae285de01d9e9d013..efe4fb1d8b9813e5b4b3f05e1ee165674ab2621b 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
 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.pcerr.message.PcerrMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors;
@@ -35,6 +34,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.Session;
 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.pcerr.message.pcerr.message.error.type.request.Rps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request.RpsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
 
 import com.google.common.collect.Lists;
 
@@ -64,7 +65,7 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                if (err.getErrorType() instanceof Request) {
                        final List<Rps> rps = ((Request) err.getErrorType()).getRps();
                        for (final Rps r : rps) {
-                               buffer.writeBytes(serializeObject(r));
+                               buffer.writeBytes(serializeObject(r.getRp()));
                        }
                }
 
@@ -134,12 +135,12 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                                        switch (state) {
                                        case 1:
                                                state = 2;
-                                               if (obj instanceof RpObject) {
-                                                       final RpObject o = ((RpObject) obj);
+                                               if (obj instanceof Rp) {
+                                                       final Rp o = ((Rp) obj);
                                                        if (o.isProcessingRule()) {
                                                                throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
                                                        }
-                                                       requestParameters.add((Rps) o);
+                                                       requestParameters.add(new RpsBuilder().setRp(o).build());
                                                        state = 1;
                                                        break;
                                                }
index a157b1e703af38c1db81fbbe96791beabf4c5cc4..958549a6948727bfa530c8ed2889dfb37753a522 100644 (file)
@@ -22,15 +22,17 @@ import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 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.PcntfBuilder;
 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.NotificationObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcntfMessage;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
+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.pcerr.message.PcerrMessageBuilder;
 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.pcntf.message.PcntfMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.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.rp.object.Rp;
 
 import com.google.common.collect.Lists;
 
@@ -56,14 +58,14 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications n : msg.getNotifications()) {
                        if (n.getRps() != null && !n.getRps().isEmpty()) {
                                for (final Rps rps : n.getRps()) {
-                                       buffer.writeBytes(serializeObject(rps));
+                                       buffer.writeBytes(serializeObject(rps.getRp()));
                                }
                        }
                        if (n.getNotifications() == null || n.getNotifications().isEmpty()) {
                                throw new IllegalArgumentException("Message must contain at least one notification object");
                        } else {
                                for (final Notifications not : n.getNotifications()) {
-                                       buffer.writeBytes(serializeObject(not));
+                                       buffer.writeBytes(serializeObject(not.getCNotification()));
                                }
                        }
                }
@@ -107,7 +109,7 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                }
 
                if (compositeNotifications.isEmpty()) {
-                       throw new PCEPDeserializerException("Atleast one CompositeNotifiObject is mandatory.");
+                       throw new PCEPDeserializerException("Atleast one Notifications is mandatory.");
                }
 
                if (!objects.isEmpty()) {
@@ -134,19 +136,19 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                        switch (state) {
                        case 1:
                                state = 2;
-                               if (obj instanceof RpObject) {
-                                       final RpObject rp = (RpObject) obj;
+                               if (obj instanceof Rp) {
+                                       final Rp rp = (Rp) obj;
                                        if (rp.isProcessingRule()) {
                                                throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
                                        }
-                                       requestParameters.add((Rps) rp);
+                                       requestParameters.add(new RpsBuilder().setRp(rp).build());
                                        state = 1;
                                        break;
                                }
                        case 2:
-                               if (obj instanceof NotificationObject) {
-                                       final NotificationObject n = (NotificationObject) obj;
-                                       notifications.add((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications) n);
+                               if (obj instanceof CNotification) {
+                                       final CNotification n = (CNotification) obj;
+                                       notifications.add(new NotificationsBuilder().setCNotification(n).build());
                                        state = 2;
                                        break;
                                }
index fa121cb0af9b3434cc44afb81f6141d47b9e97d2..6fe0abcebcb496aa80bc261c21e6fa7a2f7908fb 100644 (file)
@@ -11,21 +11,21 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.TlvsBuilder;
+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.notification.object.c.notification.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDuration;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder;
 
 import com.google.common.primitives.UnsignedBytes;
 
 /**
- * Parser for {@link NotificationObject}
+ * Parser for {@link CNotification}
  */
-public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<NotificationsBuilder> {
+public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<CNotificationBuilder> {
 
        public static final int CLASS = 12;
 
@@ -51,12 +51,12 @@ public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<N
        }
 
        @Override
-       public NotificationObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
+       public CNotification parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
                        PCEPDocumentedException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
-               final NotificationsBuilder builder = new NotificationsBuilder();
+               final CNotificationBuilder builder = new CNotificationBuilder();
                builder.setIgnore(header.isIgnore());
                builder.setProcessingRule(header.isProcessingRule());
                builder.setType((short) UnsignedBytes.toInt(bytes[NT_F_OFFSET]));
@@ -66,7 +66,7 @@ public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<N
        }
 
        @Override
-       public void addTlv(final NotificationsBuilder builder, final Tlv tlv) {
+       public void addTlv(final CNotificationBuilder builder, final Tlv tlv) {
                if (tlv instanceof OverloadDuration && builder.getType() == 2 && builder.getValue() == 1) {
                        builder.setTlvs(new TlvsBuilder().setOverloadDuration((OverloadDuration) tlv).build());
                }
@@ -74,10 +74,10 @@ public class PCEPNotificationObjectParser extends AbstractObjectWithTlvsParser<N
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof NotificationObject)) {
+               if (!(object instanceof CNotification)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NotificationObject.");
                }
-               final NotificationObject notObj = (NotificationObject) object;
+               final CNotification notObj = (CNotification) object;
 
                final byte[] tlvs = serializeTlvs(notObj.getTlvs());
 
index edc74a28415180724f34e640213c3759b51ed25c..29a9d3c496d4d12cd3a07ebde311dda7a5316aa2 100644 (file)
@@ -18,15 +18,15 @@ import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 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.RpObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.Order;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.RpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.TlvsBuilder;
+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.rp.object.rp.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder;
 
 /**
- * Parser for {@link RpObject}
+ * Parser for {@link Rp}
  */
 public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsParser<RpBuilder> {
 
@@ -93,7 +93,7 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
        }
 
        @Override
-       public RpObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
+       public Rp parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
@@ -134,10 +134,10 @@ public class PCEPRequestParameterObjectParser extends AbstractObjectWithTlvsPars
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof RpObject)) {
+               if (!(object instanceof Rp)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed RpObject.");
                }
-               final RpObject rPObj = (RpObject) object;
+               final Rp rPObj = (Rp) object;
                final BitSet flags = new BitSet(FLAGS_PRI_MF_LENGTH * Byte.SIZE);
 
                flags.set(R_FLAG_OFFSET, rPObj.isReoptimization());
index f2479770a0c59667c298bdc75f3b5533e6b44bd9..2f92113843747fa45d373c6cdfcd8fe59a2c762e 100644 (file)
@@ -72,6 +72,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 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.error.code.tlv.LspErrorCode;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.error.code.tlv.LspErrorCodeBuilder;
+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.open.object.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.overload.duration.tlv.OverloadDurationBuilder;
@@ -83,11 +84,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.requests.EndpointsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.requests.LspBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.requests.SrpBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder;
 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.failure.no.path.tlvs.NoPathVectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.SvecBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.RpBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.path.key.expansion.PathKeyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.LoadBalancingBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.requests.segment.computation.p2p.ReportedRouteBuilder;
@@ -98,6 +97,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder;
+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.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;
@@ -461,7 +461,7 @@ public class PCEPObjectParserTest {
                final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin");
 
-               final NotificationsBuilder builder = new NotificationsBuilder();
+               final CNotificationBuilder builder = new CNotificationBuilder();
                builder.setProcessingRule(true);
                builder.setIgnore(true);
                builder.setType((short) 0xff);
@@ -474,7 +474,7 @@ public class PCEPObjectParserTest {
 
                builder.setType((short) 2);
                builder.setValue((short) 1);
-               builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.TlvsBuilder().setOverloadDuration(
+               builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder().setOverloadDuration(
                                new OverloadDurationBuilder().setDuration(0xff0000a2L).build()).build());
 
                assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
@@ -514,7 +514,7 @@ public class PCEPObjectParserTest {
                b.setDelete(0xffffffffL);
                b.setSetup(1L);
 
-               builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.TlvsBuilder().setOrder(
+               builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setOrder(
                                b.build()).build());
 
                assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result));
index 0d4d9e0757b7964f75acae57f3174df994e7b00f..05b1e4b8de33fa075ab761ceafb950aaee4d63ca 100644 (file)
@@ -14,15 +14,15 @@ import io.netty.buffer.Unpooled;
 
 import java.io.IOException;
 import java.math.BigInteger;
+import java.util.List;
 
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 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.PCEPKeepAliveMessageParser;
+import org.opendaylight.protocol.pcep.impl.message.PCEPNotificationMessageParser;
 import org.opendaylight.protocol.pcep.impl.message.PCEPOpenMessageParser;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.pojo.PCEPExtensionProviderContextImpl;
@@ -30,24 +30,54 @@ import org.opendaylight.protocol.util.ByteArray;
 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.PcntfBuilder;
 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.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.keepalive.message.KeepaliveMessageBuilder;
 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.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.open.message.OpenMessageBuilder;
+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.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.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 com.google.common.collect.Lists;
+
 public class PCEPValidatorTest {
 
        private ObjectHandlerRegistry objectRegistry;
 
+       private Rp rp;
+
        @Before
        public void setUp() throws Exception {
                this.objectRegistry = PCEPExtensionProviderContextImpl.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();
        }
 
        // private static final LspaObject lspa = new PCEPLspaObject(0L, 0L, 0L, (short) 0, (short) 0, false, false, false,
@@ -80,8 +110,7 @@ public class PCEPValidatorTest {
        //
 
        @Test
-       public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
-                       PCEPDeserializerException {
+       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();
@@ -106,8 +135,7 @@ public class PCEPValidatorTest {
        }
 
        @Test
-       public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
-                       DeserializerException, DocumentedException {
+       public void testKeepAliveMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
                final byte[] result = new byte[] { 0, 0, 0, 0 };
                final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
                final KeepaliveBuilder builder = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build());
@@ -119,8 +147,7 @@ public class PCEPValidatorTest {
        }
 
        @Test
-       public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException, DeserializerException,
-                       DocumentedException {
+       public void testCloseMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin");
 
                final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
@@ -132,6 +159,7 @@ public class PCEPValidatorTest {
                parser.serializeMessage(builder.build(), buf);
                assertArrayEquals(result, buf.array());
        }
+
        // @Test
        // public void testRequestMessageValidationFromBin() throws IOException, PCEPDeserializerException,
        // PCEPDocumentedException,
@@ -706,66 +734,47 @@ public class PCEPValidatorTest {
        // asList((Message) msg).toString());
        // }
        //
-       // @Test
-       // public void testNotificationValidatorFromBin() throws IOException, PCEPDeserializerException,
-       // PCEPDocumentedException,
-       // DeserializerException, DocumentedException {
-       // List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>();
-       // List<PCEPNotificationObject> notificationsList = new ArrayList<PCEPNotificationObject>();
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // notifications.add(new CompositeNotifyObject(notificationsList));
-       // PCEPNotificationMessage specMessage = new PCEPNotificationMessage(notifications);
-       // assertEquals(deserMsg("src/test/resources/PCNtf.1.bin").toString(), asList((Message) specMessage).toString());
-       //
-       // notifications = new ArrayList<CompositeNotifyObject>();
-       // notificationsList = new ArrayList<PCEPNotificationObject>();
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // List<PCEPRequestParameterObject> requestsList = new ArrayList<PCEPRequestParameterObject>();
-       // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3,
-       // 1, false, false));
-       // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
-       // specMessage = new PCEPNotificationMessage(notifications);
-       // assertEquals(deserMsg("src/test/resources/PCNtf.2.bin").toString(), asList((Message) specMessage).toString());
-       //
-       // notifications = new ArrayList<CompositeNotifyObject>();
-       // notificationsList = new ArrayList<PCEPNotificationObject>();
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // requestsList = new ArrayList<PCEPRequestParameterObject>();
-       // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
-       // 10, false, false));
-       // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
-       // specMessage = new PCEPNotificationMessage(notifications);
-       // assertEquals(deserMsg("src/test/resources/PCNtf.3.bin").toString(), asList((Message) specMessage).toString());
-       //
-       // notifications = new ArrayList<CompositeNotifyObject>();
-       // notificationsList = new ArrayList<PCEPNotificationObject>();
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 2));
-       // notificationsList.add(new PCEPNotificationObject((short) 2, (short) 1));
-       // notificationsList.add(new PCEPNotificationObject((short) 2, (short) 2));
-       // notifications.add(new CompositeNotifyObject(notificationsList));
-       // specMessage = new PCEPNotificationMessage(notifications);
-       // assertEquals(deserMsg("src/test/resources/PCNtf.4.bin").toString(), asList((Message) specMessage).toString());
-       //
-       // notifications = new ArrayList<CompositeNotifyObject>();
-       // notificationsList = new ArrayList<PCEPNotificationObject>();
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // requestsList = new ArrayList<PCEPRequestParameterObject>();
-       // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
-       // 10, false, false));
-       // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
-       // notificationsList = new ArrayList<PCEPNotificationObject>();
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
-       // requestsList = new ArrayList<PCEPRequestParameterObject>();
-       // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
-       // 10, false, false));
-       // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
-       // 10, false, false));
-       // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
-       // specMessage = new PCEPNotificationMessage(notifications);
-       // assertEquals(deserMsg("src/test/resources/PCNtf.5.bin").toString(), asList((Message) specMessage).toString());
-       // }
+       @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));
+               final ByteBuf buf = Unpooled.buffer(result.length);
+               parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
+               assertArrayEquals(result, buf.array());
+       }
        //
        // @Test
        // public void testErrorMessageValidatoinFromBin() throws IOException, PCEPDeserializerException,
diff --git a/pcep/impl/src/test/resources/PCNtf.1.bin b/pcep/impl/src/test/resources/PCNtf.1.bin
deleted file mode 100644 (file)
index fb42ee1..0000000
Binary files a/pcep/impl/src/test/resources/PCNtf.1.bin and /dev/null differ
diff --git a/pcep/impl/src/test/resources/PCNtf.2.bin b/pcep/impl/src/test/resources/PCNtf.2.bin
deleted file mode 100644 (file)
index 1f2b169..0000000
Binary files a/pcep/impl/src/test/resources/PCNtf.2.bin and /dev/null differ
diff --git a/pcep/impl/src/test/resources/PCNtf.3.bin b/pcep/impl/src/test/resources/PCNtf.3.bin
deleted file mode 100644 (file)
index 38c90ea..0000000
Binary files a/pcep/impl/src/test/resources/PCNtf.3.bin and /dev/null differ
diff --git a/pcep/impl/src/test/resources/PCNtf.4.bin b/pcep/impl/src/test/resources/PCNtf.4.bin
deleted file mode 100644 (file)
index d4ab600..0000000
Binary files a/pcep/impl/src/test/resources/PCNtf.4.bin and /dev/null differ
index 166578cd55d3e20dfd229921156fb92b4fed6f3e..77aa81d30d9c126fac9c0942cf3abd9e99b40afe 100644 (file)
Binary files a/pcep/impl/src/test/resources/PCNtf.5.bin and b/pcep/impl/src/test/resources/PCNtf.5.bin differ
diff --git a/pcep/impl/src/test/resources/PCNtf.invalid.bin b/pcep/impl/src/test/resources/PCNtf.invalid.bin
deleted file mode 100644 (file)
index ff6596f..0000000
Binary files a/pcep/impl/src/test/resources/PCNtf.invalid.bin and /dev/null differ