BUG-50 : added test for XRO object. 33/2333/1
authorDana Kutenicsova <dkutenic@cisco.com>
Sun, 3 Nov 2013 11:36:00 +0000 (12:36 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Sun, 3 Nov 2013 11:36:00 +0000 (12:36 +0100)
Change-Id: I0e54b24b5ebb1a24aa5905a26ce9a445fd4da570
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
12 files changed:
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Activator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractXROWithSubobjectsParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPExcludeRouteObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPLspaObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROExplicitExclusionRouteSubobjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/resources/PCEPExcludeRouteObject.1.bin
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPExtensionProviderContext.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/XROSubobjectHandlerRegistry.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/osgi/OSGiPCEPExtensionProviderContext.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/pojo/PCEPExtensionProviderContextImpl.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/pojo/SimpleXROSubobjectHandlerRegistry.java

index 8a251138ddda20f51e7088aa5d4c7f9082721b3f..8fffe1f53611f33bb50f7d9e39f37652e2b17781 100644 (file)
@@ -112,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.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.explicit.route.object.subobjects.subobject.type.PathKey;
 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;
@@ -127,8 +128,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.rsvp.rev130820.AsNumberSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.IpPrefixSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.LabelSubobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.SrlgSubobject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.UnnumberedSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.Srlg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.Unnumbered;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.GeneralizedLabel;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.Type1Label;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.label.type.WavebandSwitchingLabel;
@@ -192,11 +196,11 @@ public final class Activator implements PCEPExtensionProviderActivator {
                context.registerXROSubobjectParser(XROPathKeySubobjectParser.TYPE, new XROPathKeySubobjectParser());
                context.registerXROSubobjectParser(XROPathKeySubobjectParser.TYPE128, new XROPathKeySubobjectParser());
 
-               context.registerXROSubobjectSerializer(IpPrefixSubobject.class, new XROIpPrefixSubobjectParser());
-               context.registerXROSubobjectSerializer(AsNumberSubobject.class, new XROAsNumberSubobjectParser());
-               context.registerXROSubobjectSerializer(SrlgSubobject.class, new XROSRLGSubobjectParser());
-               context.registerXROSubobjectSerializer(UnnumberedSubobject.class, new XROUnnumberedInterfaceSubobjectParser());
-               context.registerXROSubobjectSerializer(PathKeySubobject.class, new XROPathKeySubobjectParser());
+               context.registerXROSubobjectSerializer(IpPrefix.class, new XROIpPrefixSubobjectParser());
+               context.registerXROSubobjectSerializer(AsNumber.class, new XROAsNumberSubobjectParser());
+               context.registerXROSubobjectSerializer(Srlg.class, new XROSRLGSubobjectParser());
+               context.registerXROSubobjectSerializer(Unnumbered.class, new XROUnnumberedInterfaceSubobjectParser());
+               context.registerXROSubobjectSerializer(PathKey.class, new XROPathKeySubobjectParser());
 
                final TlvHandlerRegistry tlvReg = context.getTlvHandlerRegistry();
                context.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
index bc63d3f62067bebcac4beddf5e946ebf53385c12..208d47426fda4d095f11223ac496c58707c1e3f8 100644 (file)
@@ -21,20 +21,19 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
+import com.google.common.primitives.UnsignedBytes;
 
 public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, ObjectSerializer {
 
-       private static final Logger logger = LoggerFactory.getLogger(AbstractXROWithSubobjectsParser.class);
+       private static final Logger LOG = LoggerFactory.getLogger(AbstractXROWithSubobjectsParser.class);
 
        private static final int SUB_TYPE_FLAG_F_LENGTH = 1;
        private static final int SUB_LENGTH_F_LENGTH = 1;
        private static final int SUB_HEADER_LENGTH = SUB_TYPE_FLAG_F_LENGTH + SUB_LENGTH_F_LENGTH;
 
-       public static final int TYPE_FLAG_F_OFFSET = 0;
-       public static final int LENGTH_F_OFFSET = TYPE_FLAG_F_OFFSET + SUB_TYPE_FLAG_F_LENGTH;
-       public static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + SUB_LENGTH_F_LENGTH;
-
-       protected static final int PADDED_TO = 4;
+       private static final int TYPE_FLAG_F_OFFSET = 0;
+       private static final int LENGTH_F_OFFSET = TYPE_FLAG_F_OFFSET + SUB_TYPE_FLAG_F_LENGTH;
+       private static final int SO_CONTENTS_OFFSET = LENGTH_F_OFFSET + SUB_LENGTH_F_LENGTH;
 
        private final XROSubobjectHandlerRegistry subobjReg;
 
@@ -46,9 +45,7 @@ public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, O
                if (bytes == null) {
                        throw new IllegalArgumentException("Byte array is mandatory.");
                }
-
                int type;
-
                byte[] soContentsBytes;
                int length;
                int offset = 0;
@@ -57,26 +54,28 @@ public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, O
 
                while (offset < bytes.length) {
 
-                       length = ByteArray.bytesToInt(ByteArray.subByte(bytes, offset + LENGTH_F_OFFSET, SUB_LENGTH_F_LENGTH));
+                       final boolean mandatory = ((bytes[offset] & (1 << 7)) != 0) ? true : false;
+                       type = UnsignedBytes.checkedCast((bytes[offset] & 0xff) & ~(1 << 7));
 
-                       final boolean mandatory = ((bytes[offset + TYPE_FLAG_F_OFFSET] & (1 << 7)) != 0) ? true : false;
-                       type = (bytes[offset + TYPE_FLAG_F_OFFSET] & 0xff) & ~(1 << 7);
+                       offset += SUB_TYPE_FLAG_F_LENGTH;
 
-                       if (length > bytes.length - offset) {
+                       length = UnsignedBytes.toInt(bytes[offset]);
+
+                       offset += SUB_LENGTH_F_LENGTH;
+
+                       if (length - SUB_HEADER_LENGTH > bytes.length - offset) {
                                throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
                                                + (bytes.length - offset));
                        }
+                       soContentsBytes = ByteArray.subByte(bytes, offset, length - SO_CONTENTS_OFFSET);
 
-                       soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
-                       System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
-
-                       logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
+                       LOG.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
                        final Subobjects sub = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes, mandatory);
-                       logger.debug("Subobject was parsed. {}", sub);
+                       LOG.debug("Subobject was parsed. {}", sub);
 
                        subs.add(sub);
 
-                       offset += length;
+                       offset += soContentsBytes.length;
                }
                return subs;
        }
@@ -89,19 +88,20 @@ public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, O
 
                for (final Subobjects subobject : subobjects) {
 
-                       final XROSubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
+                       final XROSubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject.getSubobjectType());
+
+                       final byte typeBytes = (byte) (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - 1)[0] | (subobject.isMandatory() ? 1 << 7
+                                       : 0));
 
                        final byte[] valueBytes = serializer.serializeSubobject(subobject);
 
-                       final byte[] bytes = new byte[SUB_HEADER_LENGTH + valueBytes.length];
+                       final byte lengthBytes = UnsignedBytes.checkedCast(valueBytes.length + SUB_HEADER_LENGTH);
 
-                       final byte typeBytes = (byte) (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - 1)[0] | (subobject.isMandatory() ? 1 << 7
-                                       : 0));
-                       final byte lengthBytes = ByteArray.cutBytes(ByteArray.intToBytes(valueBytes.length), (Integer.SIZE / 8) - 1)[0];
+                       final byte[] bytes = new byte[valueBytes.length + SUB_HEADER_LENGTH];
 
                        bytes[0] = typeBytes;
                        bytes[1] = lengthBytes;
-                       System.arraycopy(valueBytes, 0, bytes, SUB_HEADER_LENGTH, valueBytes.length);
+                       ByteArray.copyWhole(valueBytes, bytes, SUB_HEADER_LENGTH);
 
                        finalLength += bytes.length;
                        result.add(bytes);
index b911a880437be7bc02268cc60340cb5e02530780..f357a9e90a8233a5a61966298d00676c0b99236f 100644 (file)
@@ -10,20 +10,26 @@ package org.opendaylight.protocol.pcep.impl.object;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
+import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject.Flags;
 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.pcreq.message.pcreq.message.svec.XroBuilder;
 
+import com.google.common.primitives.UnsignedBytes;
+
 /**
  * Parser for {@link ExcludeRouteObject}
  */
 public final class PCEPExcludeRouteObjectParser extends AbstractXROWithSubobjectsParser {
 
-       public static final int CLASS = 7; // FIXME: to actual value
+       public static final int CLASS = 7;
 
        public static final int TYPE = 1;
 
+       private static final int FLAGS_OFFSET = 3;
+
        public PCEPExcludeRouteObjectParser(final XROSubobjectHandlerRegistry registry) {
                super(registry);
        }
@@ -31,24 +37,31 @@ public final class PCEPExcludeRouteObjectParser extends AbstractXROWithSubobject
        @Override
        public ExcludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
                        PCEPDocumentedException {
-               if (bytes == null || bytes.length == 0)
+               if (bytes == null || bytes.length == 0) {
                        throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
-
+               }
                final XroBuilder builder = new XroBuilder();
-
                builder.setIgnore(header.isIgnore());
                builder.setProcessingRule(header.isProcessingRule());
-               builder.setSubobjects(parseSubobjects(bytes));
+               builder.setFlags(new Flags(UnsignedBytes.toInt(bytes[FLAGS_OFFSET]) != 0));
+               builder.setSubobjects(parseSubobjects(ByteArray.cutBytes(bytes, FLAGS_OFFSET + 1)));
                return builder.build();
        }
 
        @Override
        public byte[] serializeObject(final Object object) {
-               if (!(object instanceof ExcludeRouteObject))
+               if (!(object instanceof ExcludeRouteObject)) {
                        throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed ExcludeRouteObject.");
+               }
                final ExcludeRouteObject obj = (ExcludeRouteObject) object;
                assert !(obj.getSubobjects().isEmpty()) : "Empty Excluded Route Object.";
-               return serializeSubobject(obj.getSubobjects());
+               final byte[] bytes = serializeSubobject(obj.getSubobjects());
+               final byte[] result = new byte[FLAGS_OFFSET + 1 + bytes.length];
+               if (obj.getFlags().isFail()) {
+                       result[FLAGS_OFFSET] = 1;
+               }
+               ByteArray.copyWhole(bytes, result, FLAGS_OFFSET + 1);
+               return result;
        }
 
        @Override
index f2e96c03c413e607a012adbe58a6a69ea7962f68..881d5fc19d08a81835dd37b88c93d99bf798770b 100644 (file)
@@ -44,7 +44,6 @@ public class PCEPLspaObjectParser extends AbstractObjectWithTlvsParser<LspaBuild
        /*
         * offsets of flags inside flags field in bits
         */
-       private static final int S_FLAG_OFFSET = 6;
        private static final int L_FLAG_OFFSET = 7;
 
        /*
index 406de8620a6fc3d19b7c6b04c0b9dbe0d04255a2..30b3b832cf7828766a920845fb32c096ddc1d6b7 100644 (file)
@@ -128,7 +128,7 @@ public class EROExplicitExclusionRouteSubobjectParser implements EROSubobjectPar
 
                for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects subobject : subobjects) {
 
-                       final XROSubobjectSerializer serializer = this.registry.getSubobjectSerializer(subobject);
+                       final XROSubobjectSerializer serializer = this.registry.getSubobjectSerializer(subobject.getSubobjectType());
 
                        System.out.println(serializer);
 
index 1d8890f4aa62d6f57177b3c91d9874b37dfe5d09..9d096d834c3d98db4f8b94f6db12c5e3687a56e5 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPExcludeRouteObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPLspObjectParser;
@@ -41,6 +42,9 @@ import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.pojo.PCEPExtensionProviderContextImpl;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfId;
@@ -52,6 +56,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.close.message.c.close.message.CCloseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.address.family.Ipv4Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.address.family.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.SubobjectsBuilder;
 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;
@@ -76,6 +82,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.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.pcreq.message.pcreq.message.svec.XroBuilder;
 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;
@@ -85,6 +92,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.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;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ExcludeRouteSubobjects.Attribute;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.AsNumberBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.subobject.type.IpPrefixBuilder;
 
 import com.google.common.collect.Lists;
 import com.google.common.primitives.UnsignedBytes;
@@ -546,26 +556,25 @@ public class PCEPObjectParserTest {
                assertArrayEquals(result, parser.serializeObject(builder.build()));
        }
 
-       //
-       // /**
-       // * Test PCEPExcludeRouteObjectObject (Serialization/Deserialization)<br/>
-       // * Used resources:<br/>
-       // * - PCEPExcludeRouteObject.1.bin<br/>
-       // *
-       // * @throws IOException
-       // * @throws PCEPDeserializerException
-       // * @throws PCEPDocumentedException
-       // */
-       // @Test
-       // public void testExcludeRouteObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
-       // final List<ExcludeRouteSubobject> xroSubobjects = new ArrayList<ExcludeRouteSubobject>();
-       // xroSubobjects.add(new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192,
-       // (byte) 168,
-       // (byte) 100, (byte) 100 }), 16), true, XROSubobjectAttribute.NODE));
-       // xroSubobjects.add(new XROAsNumberSubobject(new AsNumber(0x1234L), false));
-       //
-       // }
-       //
+       @Test
+       public void testExcludeRouteObject() throws Exception {
+               final PCEPExcludeRouteObjectParser parser = new PCEPExcludeRouteObjectParser(PCEPExtensionProviderContextImpl.create().getXROSubobjectHandlerRegistry());
+               final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPExcludeRouteObject.1.bin");
+
+               final XroBuilder builder = new XroBuilder();
+               builder.setProcessingRule(false);
+               builder.setIgnore(false);
+               builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExcludeRouteObject.Flags(true));
+               final List<Subobjects> subs = Lists.newArrayList();
+               subs.add(new SubobjectsBuilder().setMandatory(true).setSubobjectType(
+                               new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("192.168.0.0/16"))).build()).setAttribute(Attribute.Node).build());
+               subs.add(new SubobjectsBuilder().setMandatory(false).setSubobjectType(
+                               new AsNumberBuilder().setAsNumber(new AsNumber(0x1234L)).build()).build());
+               builder.setSubobjects(subs);
+
+               assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result));
+               assertArrayEquals(result, parser.serializeObject(builder.build()));
+       }
 
        @Test
        public void testSrpObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
index a2c2bc9aa08c282a2b19191f3ede47d72ce8d4b2..994e2b6ad981e69abc5e058e49fac747dd2d1a26 100644 (file)
Binary files a/pcep/impl/src/test/resources/PCEPExcludeRouteObject.1.bin and b/pcep/impl/src/test/resources/PCEPExcludeRouteObject.1.bin differ
index f2b538853580ddfbaca71fbc69e1369d25c67d34..84e219d3ad8b96d6bab1c1ca192874abe6c2b33a 100644 (file)
@@ -11,6 +11,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.Object;
 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.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 
 public interface PCEPExtensionProviderContext extends PCEPExtensionConsumerContext {
@@ -38,7 +39,7 @@ public interface PCEPExtensionProviderContext extends PCEPExtensionConsumerConte
 
        public AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
 
-       public AutoCloseable registerXROSubobjectSerializer(Class<? extends CSubobject> subobjectClass, XROSubobjectSerializer serializer);
+       public AutoCloseable registerXROSubobjectSerializer(Class<? extends SubobjectType> subobjectClass, XROSubobjectSerializer serializer);
 
        public AutoCloseable registerXROSubobjectParser(int subobjectType, XROSubobjectParser parser);
 }
index 2e4637077476c95bf7c7ae6707dbab702a6818cd..3ad96724dea46555fddb976e5c22716239e82978 100644 (file)
@@ -7,9 +7,10 @@
  */
 package org.opendaylight.protocol.pcep.spi;
 
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
 
 public interface XROSubobjectHandlerRegistry {
        public XROSubobjectParser getSubobjectParser(int subobjectType);
-       public XROSubobjectSerializer getSubobjectSerializer(Subobjects subobject);
+
+       public XROSubobjectSerializer getSubobjectSerializer(SubobjectType subobject);
 }
index 682c7117a84ea02a5d435530ea7e2d845a4ab61e..dff12f9a3fd789f4831ee04da920dd97963edc56 100644 (file)
@@ -26,6 +26,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.Object;
 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.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 import org.osgi.framework.BundleContext;
 
@@ -109,7 +110,7 @@ class OSGiPCEPExtensionProviderContext extends OSGiPCEPExtensionConsumerContext
        }
 
        @Override
-       public AutoCloseable registerXROSubobjectSerializer(final Class<? extends CSubobject> subobjectClass,
+       public AutoCloseable registerXROSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
                        final XROSubobjectSerializer serializer) {
                // TODO Auto-generated method stub
                return null;
index ab2910d686de1aaebfbe33004df44fa0c18c370b..b697116975e6ffacdb591b5b566662b07bbe0265 100644 (file)
@@ -38,6 +38,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.Object;
 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.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.label.subobject.LabelType;
 
 /**
@@ -188,7 +189,7 @@ public final class PCEPExtensionProviderContextImpl implements PCEPExtensionProv
        }
 
        @Override
-       public AutoCloseable registerXROSubobjectSerializer(final Class<? extends CSubobject> subobjectClass,
+       public AutoCloseable registerXROSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
                        final XROSubobjectSerializer serializer) {
                return this.xroSubReg.registerSubobjectSerializer(subobjectClass, serializer);
        }
index 030adfcb64d1c8607d40060ffcaa3f3b94209af5..7f6781dd17d2ee893b3f00049076f408eeb54712 100644 (file)
@@ -12,8 +12,7 @@ import org.opendaylight.protocol.pcep.spi.XROSubobjectHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
 import org.opendaylight.protocol.util.Util;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.Subobjects;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.basic.explicit.route.subobjects.SubobjectType;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 import com.google.common.base.Preconditions;
@@ -26,7 +25,7 @@ public final class SimpleXROSubobjectHandlerRegistry implements XROSubobjectHand
                return this.handlers.registerParser(subobjectType, parser);
        }
 
-       public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass,
+       public AutoCloseable registerSubobjectSerializer(final Class<? extends SubobjectType> subobjectClass,
                        final XROSubobjectSerializer serializer) {
                return this.handlers.registerSerializer(subobjectClass, serializer);
        }
@@ -38,7 +37,7 @@ public final class SimpleXROSubobjectHandlerRegistry implements XROSubobjectHand
        }
 
        @Override
-       public XROSubobjectSerializer getSubobjectSerializer(final Subobjects subobject) {
+       public XROSubobjectSerializer getSubobjectSerializer(final SubobjectType subobject) {
                return this.handlers.getSerializer(subobject.getImplementedInterface());
        }
 }