BUG-50 : added test for Open Object. 28/2328/1
authorDana Kutenicsova <dkutenic@cisco.com>
Sun, 3 Nov 2013 07:45:01 +0000 (08:45 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Sun, 3 Nov 2013 07:45:01 +0000 (08:45 +0100)
Change-Id: I496c75e58e6b6e2c759d5ba5ef4da58a6a7cb2e1
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/Activator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionProposalFactoryImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPOpenObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/LspDbVersionTlvParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/OFListTlvParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/PCEStatefulCapabilityTlvParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/tlv/PredundancyGroupTlvParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPTlvParserTest.java
pcep/impl/src/test/resources/PCEPOpenObject1.bin
pcep/impl/src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin [deleted file]
pcep/impl/src/test/resources/PCEPOpenObject3.bin [deleted file]
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/PCCMock.java
topology/provider-pcep/src/main/java/org/opendaylight/bgpcep/topology/provider/pcep/ServerSessionManager.java

index d3ecf7ea548579e14bd365f766e5c72bd2a3f08f..0dfaa6fe4fa36e90a9e89bda939f64e885bd3299 100644 (file)
@@ -168,20 +168,22 @@ module pcep-types {
                description "Stateful PCE Capability TLV";
                reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-7.1.1";
 
-               uses tlv;
-               leaf flags {
-                       type bits {
-                               bit lsp-update-capability {
-                                       position 31;
-                               }
-                               bit include-db-version {
-                                       position 30;
-                               }
-                               bit initiation {
-                                       position 29;
+               container stateful {
+                       uses tlv;
+                       leaf flags {
+                               type bits {
+                                       bit lsp-update-capability {
+                                               position 31;
+                                       }
+                                       bit include-db-version {
+                                               position 30;
+                                       }
+                                       bit initiation {
+                                               position 29;
+                                       }
                                }
+                               mandatory true;
                        }
-                       mandatory true;
                }
        }
 
@@ -189,10 +191,12 @@ module pcep-types {
                description "LSP State Database Version TLV";
                reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-7.1.2";
 
-               uses tlv;
-               leaf version {
-                       type uint64;
-                       mandatory true;
+               container lsp-db-version {
+                       uses tlv;
+                       leaf version {
+                               type uint64;
+                               mandatory true;
+                       }
                }
        }
 
@@ -200,10 +204,12 @@ module pcep-types {
                description "PCE Redundancy Group Identifier TLV";
                reference "https://tools.ietf.org/html/draft-ietf-pce-stateful-pce-05#section-7.1.3";
 
-               uses tlv;
-               leaf identifier {
-                       type binary;
-                       mandatory true;
+               container predundancy-group-id {
+                       uses tlv;
+                       leaf identifier {
+                               type binary;
+                               mandatory true;
+                       }
                }
        }
 
@@ -295,10 +301,11 @@ module pcep-types {
        grouping of-list-tlv {
                description "OF-List TLV";
                reference "https://tools.ietf.org/html/rfc5541#section-2.1";
-
-               uses tlv;
-               leaf-list codes {
-                       type of-id;
+               container of-list {
+                       uses tlv;
+                       leaf-list codes {
+                               type of-id;
+                       }
                }
        }
 
@@ -346,20 +353,13 @@ module pcep-types {
 
                uses object;
                container "tlvs" {
-                       container of-list {
-                               uses of-list-tlv;
-                       }
-                       container stateful {
-                               uses stateful-capability-tlv;
-                       }
+                       uses of-list-tlv;
+                       
+                       uses stateful-capability-tlv;
 
-                       container predundancy-group-id {
-                               uses predundancy-group-id-tlv;
-                       }
+                       uses predundancy-group-id-tlv;
 
-                       container lsp-db-version {
-                               uses lsp-db-version-tlv;
-                       }
+                       uses lsp-db-version-tlv;
                }
 
                leaf version {
index 66050aa89e30d7a574b052ac61c43ec4e1698f67..8a251138ddda20f51e7088aa5d4c7f9082721b3f 100644 (file)
@@ -90,13 +90,11 @@ 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.IncludeRouteObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
 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.OfListTlv;
 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.OpenObject;
@@ -110,19 +108,21 @@ 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.PcreqMessage;
 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.PredundancyGroupIdTlv;
 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.StatefulCapabilityTlv;
 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.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.of.list.tlv.OfList;
 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.overload.duration.tlv.OverloadDuration;
 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.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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
@@ -216,15 +216,15 @@ public final class Activator implements PCEPExtensionProviderActivator {
                context.registerTlvSerializer(NoPathVector.class, new NoPathVectorTlvParser());
                context.registerTlvSerializer(OverloadDuration.class, new OverloadedDurationTlvParser());
                context.registerTlvSerializer(ReqMissing.class, new ReqMissingTlvParser());
-               context.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
+               context.registerTlvSerializer(OfList.class, new OFListTlvParser());
                context.registerTlvSerializer(Order.class, new OrderTlvParser());
-               context.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
+               context.registerTlvSerializer(Stateful.class, new PCEStatefulCapabilityTlvParser());
                context.registerTlvSerializer(SymbolicPathName.class, new LspSymbolicNameTlvParser());
                context.registerTlvSerializer(LspIdentifiers.class, new LSPIdentifierTlvParser());
                context.registerTlvSerializer(LspErrorCode.class, new LspUpdateErrorTlvParser());
                context.registerTlvSerializer(RsvpErrorSpec.class, new RSVPErrorSpecTlvParser());
-               context.registerTlvSerializer(LspDbVersionTlv.class, new LspDbVersionTlvParser());
-               context.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
+               context.registerTlvSerializer(LspDbVersion.class, new LspDbVersionTlvParser());
+               context.registerTlvSerializer(PredundancyGroupId.class, new PredundancyGroupTlvParser());
 
                final ObjectHandlerRegistry objReg = context.getObjectHandlerRegistry();
                context.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(tlvReg));
index 79b623f59e9846e6fef22e52b4289b6c6342ed29..9444921aa2ce354c6cac521e5e223c1746fe4bf4 100644 (file)
@@ -11,11 +11,11 @@ import java.net.InetSocketAddress;
 
 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 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.StatefulCapabilityTlv.Flags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
+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;
 
 public class PCEPSessionProposalFactoryImpl implements PCEPSessionProposalFactory {
 
index bba35a4ffc7833e8e8f824a2b86e1b85d5b37986..bac945ed63feee33884912a64825c3dde68ed1af 100644 (file)
@@ -13,22 +13,18 @@ import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
 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.LspDbVersionTlv;
 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.OfListTlv;
 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.PredundancyGroupIdTlv;
 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.StatefulCapabilityTlv;
 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.lsp.db.version.tlv.LspDbVersion;
+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.message.open.message.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.LspDbVersionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.OfListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.PredundancyGroupIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
+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.stateful.capability.tlv.Stateful;
 
 import com.google.common.primitives.UnsignedBytes;
 
@@ -36,7 +32,7 @@ import com.google.common.primitives.UnsignedBytes;
  * Parser for {@link OpenObject}
  */
 
-public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<OpenBuilder> {
+public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<TlvsBuilder> {
 
        public static final int CLASS = 1;
 
@@ -45,33 +41,29 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<OpenBuild
        /*
         * lengths of fields in bytes
         */
-       public static final int VER_FLAGS_MF_LENGTH = 1; // multi-field
-       public static final int KEEPALIVE_F_LENGTH = 1;
-       public static final int DEAD_TIMER_LENGTH = 1;
-       public static final int SID_F_LENGTH = 1;
+       private static final int VER_FLAGS_MF_LENGTH = 1;
+       private static final int KEEPALIVE_F_LENGTH = 1;
+       private static final int DEAD_TIMER_LENGTH = 1;
+       private static final int SID_F_LENGTH = 1;
 
        /*
         * lengths of subfields inside multi-field in bits
         */
-       public static final int VERSION_SF_LENGTH = 3;
-       public static final int FLAGS_SF_LENGTH = 5;
+       private static final int VERSION_SF_LENGTH = 3;
 
        /*
         * offsets of field in bytes
         */
-
-       public static final int VER_FLAGS_MF_OFFSET = 0;
-       public static final int KEEPALIVE_F_OFFSET = VER_FLAGS_MF_OFFSET + VER_FLAGS_MF_LENGTH;
-       public static final int DEAD_TIMER_OFFSET = KEEPALIVE_F_OFFSET + KEEPALIVE_F_LENGTH;
-       public static final int SID_F_OFFSET = DEAD_TIMER_OFFSET + DEAD_TIMER_LENGTH;
-       public static final int TLVS_OFFSET = SID_F_OFFSET + SID_F_LENGTH;
+       private static final int VER_FLAGS_MF_OFFSET = 0;
+       private static final int KEEPALIVE_F_OFFSET = VER_FLAGS_MF_OFFSET + VER_FLAGS_MF_LENGTH;
+       private static final int DEAD_TIMER_OFFSET = KEEPALIVE_F_OFFSET + KEEPALIVE_F_LENGTH;
+       private static final int SID_F_OFFSET = DEAD_TIMER_OFFSET + DEAD_TIMER_LENGTH;
+       private static final int TLVS_OFFSET = SID_F_OFFSET + SID_F_LENGTH;
 
        /*
         * offsets of subfields inside multi-field in bits
         */
-
-       public static final int VERSION_SF_OFFSET = 0;
-       public static final int FLAGS_SF_OFFSET = VERSION_SF_LENGTH + VERSION_SF_OFFSET;
+       private static final int VERSION_SF_OFFSET = 0;
 
        private static final int PCEP_VERSION = 1;
 
@@ -84,39 +76,36 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<OpenBuild
                if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
                }
-
                final int versionValue = ByteArray.copyBitsRange(bytes[VER_FLAGS_MF_OFFSET], VERSION_SF_OFFSET, VERSION_SF_LENGTH);
 
                if (versionValue != PCEP_VERSION) {
                        throw new PCEPDocumentedException("Unsupported PCEP version " + versionValue, PCEPErrors.PCEP_VERSION_NOT_SUPPORTED);
                }
-
                final OpenBuilder builder = new OpenBuilder();
-
-               parseTlvs(builder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
-
                builder.setVersion(new ProtocolVersion((short) versionValue));
                builder.setProcessingRule(header.isProcessingRule());
                builder.setIgnore(header.isIgnore());
                builder.setDeadTimer((short) UnsignedBytes.toInt(bytes[DEAD_TIMER_OFFSET]));
                builder.setKeepalive((short) UnsignedBytes.toInt(bytes[KEEPALIVE_F_OFFSET]));
                builder.setSessionId((short) UnsignedBytes.toInt(bytes[SID_F_OFFSET]));
+
+               final TlvsBuilder tbuilder = new TlvsBuilder();
+               parseTlvs(tbuilder, ByteArray.cutBytes(bytes, TLVS_OFFSET));
+               builder.setTlvs(tbuilder.build());
                return builder.build();
        }
 
        @Override
-       public void addTlv(final OpenBuilder builder, final Tlv tlv) {
-               final TlvsBuilder tbuilder = new TlvsBuilder();
-               if (tlv instanceof OfListTlv) {
-                       tbuilder.setOfList(new OfListBuilder().setCodes(((OfListTlv) tlv).getCodes()).build());
-               } else if (tlv instanceof StatefulCapabilityTlv) {
-                       tbuilder.setStateful(new StatefulBuilder().setFlags(((StatefulCapabilityTlv) tlv).getFlags()).build());
-               } else if (tlv instanceof PredundancyGroupIdTlv) {
-                       tbuilder.setPredundancyGroupId(new PredundancyGroupIdBuilder().setIdentifier(((PredundancyGroupIdTlv) tlv).getIdentifier()).build());
-               } else if (tlv instanceof LspDbVersionTlv) {
-                       tbuilder.setLspDbVersion(new LspDbVersionBuilder().build());
+       public void addTlv(final TlvsBuilder tbuilder, final Tlv tlv) {
+               if (tlv instanceof OfList) {
+                       tbuilder.setOfList((OfList) tlv);
+               } else if (tlv instanceof Stateful) {
+                       tbuilder.setStateful((Stateful) tlv);
+               } else if (tlv instanceof PredundancyGroupId) {
+                       tbuilder.setPredundancyGroupId((PredundancyGroupId) tlv);
+               } else if (tlv instanceof LspDbVersion) {
+                       tbuilder.setLspDbVersion((LspDbVersion) tlv);
                }
-               builder.setTlvs(tbuilder.build());
        }
 
        @Override
@@ -133,31 +122,59 @@ public class PCEPOpenObjectParser extends AbstractObjectWithTlvsParser<OpenBuild
                final byte[] bytes = new byte[TLVS_OFFSET + tlvs.length + getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
 
                bytes[VER_FLAGS_MF_OFFSET] = versionFlagMF;
-               bytes[KEEPALIVE_F_OFFSET] = ByteArray.shortToBytes(open.getKeepalive())[1];
-               bytes[DEAD_TIMER_OFFSET] = ByteArray.shortToBytes(open.getDeadTimer())[1];
-               bytes[SID_F_OFFSET] = ByteArray.shortToBytes(open.getSessionId())[1];
-               ByteArray.copyWhole(tlvs, bytes, TLVS_OFFSET);
-
+               bytes[KEEPALIVE_F_OFFSET] = UnsignedBytes.checkedCast(open.getKeepalive());
+               bytes[DEAD_TIMER_OFFSET] = UnsignedBytes.checkedCast(open.getDeadTimer());
+               bytes[SID_F_OFFSET] = UnsignedBytes.checkedCast(open.getSessionId());
+               if (tlvs.length != 0) {
+                       ByteArray.copyWhole(tlvs, bytes, TLVS_OFFSET);
+               }
                return bytes;
        }
 
        public byte[] serializeTlvs(final Tlvs tlvs) {
+               if (tlvs == null) {
+                       return new byte[0];
+               }
                int finalLength = 0;
+               byte[] ofListBytes = null;
+               byte[] statefulBytes = null;
+               byte[] predundancyBytes = null;
+               byte[] lspDbBytes = null;
+               if (tlvs.getOfList() != null) {
+                       ofListBytes = serializeTlv(tlvs.getOfList());
+                       finalLength += ofListBytes.length;
+               }
+               if (tlvs.getStateful() != null) {
+                       statefulBytes = serializeTlv(tlvs.getStateful());
+                       finalLength += statefulBytes.length;
+               }
+               if (tlvs.getPredundancyGroupId() != null) {
+                       predundancyBytes = serializeTlv(tlvs.getPredundancyGroupId());
+                       finalLength += predundancyBytes.length;
+               }
                if (tlvs.getLspDbVersion() != null) {
-                       final byte[] lspDbBytes = serializeTlv(new LspDbVersionBuilder().setVersion(tlvs.getLspDbVersion().getVersion()).build());
-                       finalLength = lspDbBytes.length;
+                       lspDbBytes = serializeTlv(tlvs.getLspDbVersion());
+                       finalLength += lspDbBytes.length;
                }
-               if (tlvs.getOfList() != null) {
-                       final byte[] ofListBytes = serializeTlv(new OfListBuilder().setCodes(tlvs.getOfList().getCodes()).build());
-                       finalLength = ofListBytes.length;
+               int offset = 0;
+               final byte[] result = new byte[finalLength];
+               if (ofListBytes != null) {
+                       ByteArray.copyWhole(ofListBytes, result, offset);
+                       offset += ofListBytes.length;
                }
-
-               // FIXME: finish
-
-               final byte[] bytes = new byte[finalLength];
-
-               // FIXME copy result bytes
-               return bytes;
+               if (statefulBytes != null) {
+                       ByteArray.copyWhole(statefulBytes, result, offset);
+                       offset += statefulBytes.length;
+               }
+               if (lspDbBytes != null) {
+                       ByteArray.copyWhole(lspDbBytes, result, offset);
+                       offset += lspDbBytes.length;
+               }
+               if (predundancyBytes != null) {
+                       ByteArray.copyWhole(predundancyBytes, result, offset);
+                       offset += predundancyBytes.length;
+               }
+               return result;
        }
 
        @Override
index 2930bcac890b2091a50df5ac483297c5a07c773c..50eaab96b8ab8c587e78f9af5020fdae62f991e8 100644 (file)
@@ -8,17 +8,18 @@
 package org.opendaylight.protocol.pcep.impl.tlv;
 
 import java.math.BigInteger;
+import java.util.Arrays;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
 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.open.object.tlvs.LspDbVersionBuilder;
+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;
 
 /**
- * Parser for {@link LspDbVersionTlv}
+ * Parser for {@link LspDbVersion}
  */
 public class LspDbVersionTlvParser implements TlvParser, TlvSerializer {
 
@@ -27,7 +28,7 @@ public class LspDbVersionTlvParser implements TlvParser, TlvSerializer {
        private static final int DBV_F_LENGTH = 8;
 
        @Override
-       public LspDbVersionTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+       public LspDbVersion parseTlv(final byte[] buffer) throws PCEPDeserializerException {
                return new LspDbVersionBuilder().setVersion(BigInteger.valueOf(ByteArray.bytesToLong(ByteArray.subByte(buffer, 0, DBV_F_LENGTH)))).build();
        }
 
@@ -36,8 +37,19 @@ public class LspDbVersionTlvParser implements TlvParser, TlvSerializer {
                if (tlv == null) {
                        throw new IllegalArgumentException("LspDbVersionTlv is mandatory.");
                }
-               final LspDbVersionTlv lsp = (LspDbVersionTlv) tlv;
-               return ByteArray.subByte(lsp.getVersion().toByteArray(), 0, DBV_F_LENGTH);
+               final LspDbVersion lsp = (LspDbVersion) tlv;
+               final byte[] array = lsp.getVersion().toByteArray();
+               if (array.length > DBV_F_LENGTH) {
+                       throw new IllegalArgumentException("LspDBVersion too big.");
+               }
+               final byte[] result = new byte[DBV_F_LENGTH];
+               Arrays.fill(result, (byte) 0);
+               int j = 7;
+               for (int i = array.length - 1; i >= 0; i--) {
+                       result[j] |= array[i];
+                       j--;
+               }
+               return result;
        }
 
        @Override
index f0cb131590aa2aaee0813f87dbf109014d3dfcc9..86f79d40134bc2b63eea38617dcc91c43c3ddbea 100644 (file)
@@ -16,14 +16,14 @@ import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.util.ByteArray;
 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.OfListTlv;
 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.open.object.tlvs.OfListBuilder;
+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.of.list.tlv.OfListBuilder;
 
 import com.google.common.collect.Lists;
 
 /**
- * Parser for {@link OfListTlv}
+ * Parser for {@link OfList}
  */
 public class OFListTlvParser implements TlvParser, TlvSerializer {
 
@@ -32,7 +32,7 @@ public class OFListTlvParser implements TlvParser, TlvSerializer {
        private static final int OF_CODE_ELEMENT_LENGTH = 2;
 
        @Override
-       public OfListTlv parseTlv(final byte[] valueBytes) throws PCEPDeserializerException {
+       public OfList parseTlv(final byte[] valueBytes) throws PCEPDeserializerException {
                if (valueBytes == null || valueBytes.length == 0) {
                        throw new IllegalArgumentException("Value bytes array is mandatory. Can't be null or empty.");
                }
@@ -55,7 +55,7 @@ public class OFListTlvParser implements TlvParser, TlvSerializer {
                if (tlv == null) {
                        throw new IllegalArgumentException("OFListTlv is mandatory.");
                }
-               final OfListTlv oft = (OfListTlv) tlv;
+               final OfList oft = (OfList) tlv;
 
                final List<OfId> ofCodes = oft.getCodes();
                final byte[] retBytes = new byte[ofCodes.size() * OF_CODE_ELEMENT_LENGTH];
index aa8f7978a351e90132f41c9f5da1d6952d08f4ea..cb88adcfc2b5e8a2a10ddc85043fb34b21e3e64a 100644 (file)
@@ -13,13 +13,13 @@ import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
 import org.opendaylight.protocol.util.ByteArray;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv.Flags;
 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.open.object.tlvs.StatefulBuilder;
+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;
 
 /**
- * Parser for {@link StatefulCapabilityTlv}
+ * Parser for {@link Stateful}
  */
 public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSerializer {
 
@@ -32,7 +32,7 @@ public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSeria
        private static final int U_FLAG_OFFSET = 31;
 
        @Override
-       public StatefulCapabilityTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+       public Stateful parseTlv(final byte[] buffer) throws PCEPDeserializerException {
                if (buffer == null || buffer.length == 0) {
                        throw new IllegalArgumentException("Value bytes array is mandatory. Can't be null or empty.");
                }
@@ -50,7 +50,7 @@ public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSeria
                if (tlv == null) {
                        throw new IllegalArgumentException("StatefulCapabilityTlv is mandatory.");
                }
-               final StatefulCapabilityTlv sct = (StatefulCapabilityTlv) tlv;
+               final Stateful sct = (Stateful) tlv;
 
                final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
                flags.set(I_FLAG_OFFSET, sct.getFlags().isInitiation());
index 4f7ff939cfc2cda3bd60ffbf7d0bbec437effc63..fee3fdaa3bdbb11fc3ea0558c9776b82613295cf 100644 (file)
@@ -10,27 +10,28 @@ package org.opendaylight.protocol.pcep.impl.tlv;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.TlvParser;
 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
 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.open.object.tlvs.PredundancyGroupIdBuilder;
+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;
 
 /**
- * Parser for {@link PredundancyGroupIdTlv}
+ * Parser for {@link PredundancyGroupId}
  */
 public class PredundancyGroupTlvParser implements TlvParser, TlvSerializer {
 
        public static final int TYPE = 24;
 
        @Override
-       public PredundancyGroupIdTlv parseTlv(final byte[] buffer) throws PCEPDeserializerException {
+       public PredundancyGroupId parseTlv(final byte[] buffer) throws PCEPDeserializerException {
                return new PredundancyGroupIdBuilder().setIdentifier(buffer).build();
        }
 
        @Override
        public byte[] serializeTlv(final Tlv tlv) {
-               if (tlv == null)
+               if (tlv == null) {
                        throw new IllegalArgumentException("PredundancyGroupIdTlv is mandatory.");
-               final PredundancyGroupIdTlv pgt = (PredundancyGroupIdTlv) tlv;
+               }
+               final PredundancyGroupId pgt = (PredundancyGroupId) tlv;
                return pgt.getIdentifier();
        }
 
index 684be5731c762dd6c74aaf2b695cf5b30ed4002b..1d8890f4aa62d6f57177b3c91d9874b37dfe5d09 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
+import java.math.BigInteger;
 import java.util.List;
 
 import org.junit.Before;
@@ -32,6 +33,7 @@ import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
@@ -44,6 +46,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.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.close.message.c.close.message.CCloseBuilder;
@@ -52,8 +55,11 @@ 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.attributes.ClassTypeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.LspaBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.OfBuilder;
+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.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.open.message.open.message.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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.TlvsBuilder;
@@ -70,7 +76,12 @@ 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.pcreq.message.pcreq.message.requests.segment.computation.p2p.reported.route.BandwidthBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.GcBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.svec.MetricBuilder;
+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.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.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathNameBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AttributeFilter;
@@ -87,12 +98,31 @@ public class PCEPObjectParserTest {
                this.tlvRegistry = PCEPExtensionProviderContextImpl.create().getTlvHandlerRegistry();
        }
 
-       // @Test
-       // @Ignore
-       // // FIXME: temporary
-       // public void testObjectDeserialization() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
-       // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
-       // }
+       @Test
+       public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+               final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry);
+               final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin");
+
+               final OpenBuilder builder = new OpenBuilder();
+               builder.setProcessingRule(false);
+               builder.setIgnore(false);
+               builder.setVersion(new ProtocolVersion((short) 1));
+               builder.setKeepalive((short) 30);
+               builder.setDeadTimer((short) 120);
+               builder.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();
+               final byte[] predundancyBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a, (byte) 0xbc, (byte) 0xde,
+                               (byte) 0xf0 };
+               final PredundancyGroupId tlv3 = new PredundancyGroupIdBuilder().setIdentifier(predundancyBytes).build();
+
+               builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder().setStateful(
+                               tlv1).setPredundancyGroupId(tlv3).setLspDbVersion(tlv2).build());
+
+               assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result));
+               assertArrayEquals(result, parser.serializeObject(builder.build()));
+       }
 
        @Test
        public void testCloseObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
@@ -422,51 +452,6 @@ public class PCEPObjectParserTest {
                assertArrayEquals(result, parser.serializeObject(builder.build()));
        }
 
-       //
-       // /**
-       // * Standard ser deser test<br/>
-       // * used resources:<br/>
-       // * - PCEPOpenObject1.bin
-       // *
-       // * @throws PCEPDeserializerException
-       // * @throws IOException
-       // * @throws PCEPDocumentedException
-       // */
-       // @Test
-       // @Ignore
-       // // FIXME: temporary
-       // public void testOpenObjectSerDeser() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
-       // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
-       // // tlvs.add(new PCEStatefulCapabilityTlv(false, true, true));
-       // // tlvs.add(new LSPStateDBVersionTlv(0x80));
-       // // final byte[] valueBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC,
-       // (byte) 0xDE, (byte) 0xF0 };
-       // // tlvs.add(new NodeIdentifierTlv(valueBytes));
-       // // final PCEPOpenObject specObject = new PCEPOpenObject(30, 120, 1, tlvs);
-       // //
-       // // serDeserTest("src/test/resources/PCEPOpenObject1.bin", specObject);
-       // }
-       //
-       // /**
-       // * Specific test for upper bounds and without tlvs<br/>
-       // * Used resources:<br/>
-       // * - PCEPOpenObject2UpperBoundsNoTlv.bin
-       // *
-       // * @throws PCEPDeserializerException
-       // * @throws IOException
-       // * @throws PCEPDocumentedException
-       // */
-       // @Test
-       // public void testOpenObjectBoundsWithoutTlvs() throws IOException, PCEPDeserializerException,
-       // PCEPDocumentedException {
-       // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
-       // // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
-       // tlvs));
-       // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
-       // null));
-       // }
-       //
-
        @Test
        public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
                final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry);
@@ -627,55 +612,4 @@ public class PCEPObjectParserTest {
                assertArrayEquals(result, parser.serializeObject(builder.build()));
        }
 
-       // // FIXME: add at least one test with true value
-       // @Test
-       // public void openObjectWithTlv() throws PCEPDeserializerException, PCEPDocumentedException {
-       // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, false, false));
-       // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, false, true));
-       // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, false));
-       // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, true));
-       // }
-       //
-       // // private void testOpenObjectWithSpecTlv(final PCEPTlv tlv) throws PCEPDeserializerException,
-       // PCEPDocumentedException {
-       // // final List<PCEPObject> objs = new ArrayList<PCEPObject>();
-       // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
-       // // tlvs.add(tlv);
-       // // final PCEPOpenObject oo = new PCEPOpenObject(30, 120, 0, tlvs);
-       // // objs.add(oo);
-       // // final byte[] bytes = PCEPObjectFactory.put(objs);
-       // // final PCEPObject obj = PCEPObjectFactory.parseObjects(bytes).get(0);
-       // // assertEquals(oo, obj);
-       // // }
-       //
-       // @Test
-       // public void testErrorsMapping() {
-       // final PCEPErrorObjectParser.PCEPErrorsMaping mapper = PCEPErrorObjectParser.PCEPErrorsMaping.getInstance();
-       //
-       // for (final PCEPErrors error : PCEPErrors.values()) {
-       // final PCEPErrorIdentifier errorId = mapper.getFromErrorsEnum(error);
-       // assertEquals(error, mapper.getFromErrorIdentifier(errorId));
-       // }
-       // }
-       //
-       // @Test
-       // public void testSERObjects() throws PCEPDocumentedException, PCEPDeserializerException {
-       // final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>();
-       // eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192,
-       // (byte) 168, 1, 8 }), 16), false));
-       // eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] { (byte) 192,
-       // (byte) 168, 2, 1,
-       // (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 }), 64), false));
-       //
-       // serDeserTestWithoutBin(new PCEPSecondaryExplicitRouteObject(eroSubobjects, true, false));
-       // }
-       //
-       // @Test
-       // public void testSRRObject() throws PCEPDocumentedException, PCEPDeserializerException {
-       // final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>();
-       // rroSubobjects.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(this.ipv4addr, 16), true, false));
-       // rroSubobjects.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(this.ipv6addr, 64), false, true));
-       //
-       // serDeserTestWithoutBin(new PCEPSecondaryRecordRouteObject(rroSubobjects, true, false));
-       // }
 }
index 3809333c3e245440b292c2dd74483c8bcd6a1f07..d5032921d2130c689aafcd39e7ef6478578eb55b 100644 (file)
@@ -31,29 +31,26 @@ import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
 import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv;
 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.OfListTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
 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.StatefulCapabilityTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv.Flags;
+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.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.lsp.identifiers.tlv.LspIdentifiers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.LspIdentifiersBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.identifiers.tlv.lsp.identifiers.address.family.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.LspDbVersionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.OfListBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.PredundancyGroupIdBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
+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.of.list.tlv.OfListBuilder;
 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.order.tlv.OrderBuilder;
 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.overload.duration.tlv.OverloadDurationBuilder;
 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.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.ReqMissing;
 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.rsvp.error.spec.tlv.RsvpErrorSpec;
@@ -62,6 +59,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.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp.RsvpErrorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user.UserErrorBuilder;
+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.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.symbolic.path.name.tlv.SymbolicPathNameBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.Ipv4ExtendedTunnelId;
@@ -107,7 +107,7 @@ public class PCEPTlvParserTest {
        @Test
        public void testStatefulTlv() throws PCEPDeserializerException {
                final PCEStatefulCapabilityTlvParser parser = new PCEStatefulCapabilityTlvParser();
-               final StatefulCapabilityTlv tlv = new StatefulBuilder().setFlags(new Flags(true, false, false)).build();
+               final Stateful tlv = new StatefulBuilder().setFlags(new Flags(true, false, false)).build();
                assertEquals(tlv, parser.parseTlv(statefulBytes));
                assertArrayEquals(statefulBytes, parser.serializeTlv(tlv));
        }
@@ -115,7 +115,7 @@ public class PCEPTlvParserTest {
        @Test
        public void testStateDbVersionTlv() throws PCEPDeserializerException {
                final LspDbVersionTlvParser parser = new LspDbVersionTlvParser();
-               final LspDbVersionTlv tlv = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0xFF00FFAAB2F5F2CFL)).build();
+               final LspDbVersion tlv = new LspDbVersionBuilder().setVersion(BigInteger.valueOf(0xFF00FFAAB2F5F2CFL)).build();
                assertEquals(tlv, parser.parseTlv(DbVersionBytes));
                assertArrayEquals(DbVersionBytes, parser.serializeTlv(tlv));
        }
@@ -246,7 +246,7 @@ public class PCEPTlvParserTest {
                final List<OfId> ids = Lists.newArrayList();
                ids.add(new OfId(0x1234));
                ids.add(new OfId(0x5678));
-               final OfListTlv tlv = new OfListBuilder().setCodes(ids).build();
+               final OfList tlv = new OfListBuilder().setCodes(ids).build();
                assertEquals(tlv, parser.parseTlv(ofListBytes));
                assertArrayEquals(ofListBytes, parser.serializeTlv(tlv));
        }
@@ -254,7 +254,7 @@ public class PCEPTlvParserTest {
        @Test
        public void testPredundancyTlv() throws PCEPDeserializerException {
                final PredundancyGroupTlvParser parser = new PredundancyGroupTlvParser();
-               final PredundancyGroupIdTlv tlv = new PredundancyGroupIdBuilder().setIdentifier(predundancyBytes).build();
+               final PredundancyGroupId tlv = new PredundancyGroupIdBuilder().setIdentifier(predundancyBytes).build();
                assertEquals(tlv, parser.parseTlv(predundancyBytes));
                assertArrayEquals(predundancyBytes, parser.serializeTlv(tlv));
        }
index 58f380f21160f45b20aee319978e68d0f9935076..669df5b4cc6010148fe222a3a95708cc92709513 100644 (file)
Binary files a/pcep/impl/src/test/resources/PCEPOpenObject1.bin and b/pcep/impl/src/test/resources/PCEPOpenObject1.bin differ
diff --git a/pcep/impl/src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin b/pcep/impl/src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin
deleted file mode 100644 (file)
index 533fbb1..0000000
Binary files a/pcep/impl/src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin and /dev/null differ
diff --git a/pcep/impl/src/test/resources/PCEPOpenObject3.bin b/pcep/impl/src/test/resources/PCEPOpenObject3.bin
deleted file mode 100644 (file)
index 82aedb8..0000000
Binary files a/pcep/impl/src/test/resources/PCEPOpenObject3.bin and /dev/null differ
index 6934e98d3171869d9d23422ae2120899e0894e77..d250f0a3830a4faedff269ccc70a7a9e71dca203 100644 (file)
@@ -32,7 +32,7 @@ import org.opendaylight.protocol.pcep.spi.pojo.PCEPExtensionProviderContextImpl;
 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.open.message.open.message.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.PredundancyGroupIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.predundancy.group.id.tlv.PredundancyGroupIdBuilder;
 
 import com.google.common.base.Preconditions;
 
@@ -66,17 +66,15 @@ public class PCCMock<M, S extends ProtocolSession<M>, L extends SessionListener<
                final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new OpenBuilder().setKeepalive(
                                (short) 30).setDeadTimer((short) 120).setSessionId((short) 0).setTlvs(builder.build()).build(), 0);
 
-               final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf,
-                               new PCEPHandlerFactory(PCEPExtensionProviderContextImpl.getSingletonInstance().getMessageHandlerRegistry()),
-                               new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
+               final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(PCEPExtensionProviderContextImpl.getSingletonInstance().getMessageHandlerRegistry()), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
 
                pcc.createClient(new InetSocketAddress("127.0.0.3", 12345), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000),
                                new SessionListenerFactory<PCEPSessionListener>() {
 
-                       @Override
-                       public PCEPSessionListener getSessionListener() {
-                               return new SimpleSessionListener();
-                       }
-               }).get();
+                                       @Override
+                                       public PCEPSessionListener getSessionListener() {
+                                               return new SimpleSessionListener();
+                                       }
+                               }).get();
        }
 }
index d8d26c3757cf49b76752f9673af9db412e3c2c1a..3a0f5090828bed9d505a9403239afd939d6bf9f6 100644 (file)
@@ -31,10 +31,10 @@ 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.PlspId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.Stateful;
 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.pcrpt.message.pcrpt.message.Reports;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrpt.message.pcrpt.message.reports.Lsp;
+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;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PccBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.pcc.Lsps;
@@ -160,7 +160,7 @@ final class ServerSessionManager implements SessionListenerFactory<PCEPSessionLi
                        final Stateful stateful = tlvs.getStateful();
                        if (stateful != null) {
                                // FIXME: rework once groupings can be used in builders
-                               ServerSessionManager.this.pccBuilder.setStatefulTlv(new StatefulTlvBuilder().setFlags(tlvs.getStateful().getFlags()).build());
+                               ServerSessionManager.this.pccBuilder.setStatefulTlv(new StatefulTlvBuilder().setStateful(stateful).build());
                                ServerSessionManager.this.pccBuilder.setStateSync(PccSyncState.InitialResync);
                        }