BUG-130 : introduced XROSubobjectUtil. 47/3647/1
authorDana Kutenicsova <dkutenic@cisco.com>
Wed, 11 Dec 2013 15:40:31 +0000 (16:40 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Wed, 11 Dec 2013 15:42:18 +0000 (16:42 +0100)
Change-Id: I4379bad92913ca164637f44856edda11a9e7bbe8
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/AbstractXROWithSubobjectsParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/XROSubobjectUtil.java [new file with mode: 0644]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/EROExplicitExclusionRouteSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROAsNumberSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIpv4PrefixSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROIpv6PrefixSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKey128SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROPathKey32SubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROSRLGSubobjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/subobject/XROUnnumberedInterfaceSubobjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPXROSubobjectParserTest.java

index f6aa9059ac46b0a83a9b8e7d572bedbb4b390f86..dd250211de24b3e1b9c9a274f9e7c515e17f5172 100644 (file)
@@ -90,18 +90,7 @@ public abstract class AbstractXROWithSubobjectsParser implements ObjectParser, O
 
                        final XROSubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject.getSubobjectType());
 
-                       final byte typeBytes = (byte) (UnsignedBytes.checkedCast(serializer.getType()) | (subobject.isMandatory() ? 1 << 7 : 0));
-
-                       final byte[] valueBytes = serializer.serializeSubobject(subobject);
-
-                       final byte lengthBytes = UnsignedBytes.checkedCast(valueBytes.length + SUB_HEADER_LENGTH);
-
-                       final byte[] bytes = new byte[valueBytes.length + SUB_HEADER_LENGTH];
-
-                       bytes[0] = typeBytes;
-                       bytes[1] = lengthBytes;
-                       ByteArray.copyWhole(valueBytes, bytes, SUB_HEADER_LENGTH);
-
+                       final byte[] bytes = serializer.serializeSubobject(subobject);
                        finalLength += bytes.length;
                        result.add(bytes);
                }
diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/XROSubobjectUtil.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/XROSubobjectUtil.java
new file mode 100644 (file)
index 0000000..c5bc357
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.impl.object;
+
+import com.google.common.primitives.UnsignedBytes;
+
+public class XROSubobjectUtil {
+
+       private static final int HEADER_SIZE = 2;
+
+       private XROSubobjectUtil() {
+       }
+
+       public static byte[] formatSubobject(final int type, final boolean mandatory, final byte[] value) {
+               final byte[] bytes = new byte[HEADER_SIZE + value.length];
+               bytes[0] = (byte) (UnsignedBytes.checkedCast(type) | (mandatory ? 1 << 7 : 0));
+               bytes[1] = UnsignedBytes.checkedCast(value.length + HEADER_SIZE);
+               System.arraycopy(value, 0, bytes, HEADER_SIZE, value.length);
+               return bytes;
+       }
+}
index 894c21d463b0298c146342bb8756055e18b45eb6..56148546b6dbbded30ab2b1835dfa11040dbd353 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.explicit.route.subobjects.subobject.type.exrs._case.ExrsBuilder;
 
 import com.google.common.collect.Lists;
-import com.google.common.primitives.UnsignedBytes;
 
 public class EROExplicitExclusionRouteSubobjectParser implements EROSubobjectParser, EROSubobjectSerializer {
 
@@ -33,7 +32,6 @@ public class EROExplicitExclusionRouteSubobjectParser implements EROSubobjectPar
 
        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;
 
        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;
@@ -131,18 +129,7 @@ public class EROExplicitExclusionRouteSubobjectParser implements EROSubobjectPar
 
                        final XROSubobjectSerializer serializer = this.registry.getSubobjectSerializer(subobject.getSubobjectType());
 
-                       final byte[] valueBytes = serializer.serializeSubobject(subobject);
-
-                       final byte[] bytes = new byte[SUB_HEADER_LENGTH + valueBytes.length];
-
-                       final byte typeBytes = (byte) (UnsignedBytes.checkedCast(serializer.getType()) | (subobject.isMandatory() ? 1 << 7 : 0));
-
-                       final byte lengthBytes = UnsignedBytes.checkedCast(valueBytes.length + SUB_HEADER_LENGTH);
-
-                       bytes[0] = typeBytes;
-                       bytes[1] = lengthBytes;
-                       System.arraycopy(valueBytes, 0, bytes, SUB_HEADER_LENGTH, valueBytes.length);
-
+                       final byte[] bytes = serializer.serializeSubobject(subobject);
                        finalLength += bytes.length;
                        result.add(bytes);
                }
index 74840c19e859083cacc794f039a56081304783b7..24da8a080d0a72f0134345556b5b17966bdb9fc2 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.pcep.impl.subobject;
 
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -56,7 +57,7 @@ public class XROAsNumberSubobjectParser implements XROSubobjectParser, XROSubobj
                final AsNumberSubobject obj = ((AsNumberCase) subobject.getSubobjectType()).getAsNumber();
                System.arraycopy(ByteArray.longToBytes(obj.getAsNumber().getValue(), AS_NUMBER_LENGTH), 0, retBytes, AS_NUMBER_OFFSET,
                                AS_NUMBER_LENGTH);
-               return retBytes;
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index 46e44b56162c6fab017bde72a7ed50964adeebd7..b0ab8474c0cd2d94d2241f1e4086632bd3fc96d7 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.concepts.Ipv4Util;
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -72,15 +73,14 @@ public class XROIpv4PrefixSubobjectParser implements XROSubobjectParser, XROSubo
                        throw new IllegalArgumentException("Unknown AbstractPrefix instance. Passed " + prefix.getClass() + ".");
                }
 
-               if (prefix.getIpv4Prefix() != null) {
-                       final byte[] retBytes = new byte[CONTENT4_LENGTH];
-                       ByteArray.copyWhole(Ipv4Util.bytesForPrefix(prefix.getIpv4Prefix()), retBytes, IP_F_OFFSET);
-                       retBytes[PREFIX4_F_OFFSET] = UnsignedBytes.checkedCast(Ipv4Util.getPrefixLength(prefix));
-                       retBytes[ATTRIBUTE4_OFFSET] = UnsignedBytes.checkedCast(subobject.getAttribute().getIntValue());
-                       return retBytes;
-               } else {
+               if (prefix.getIpv4Prefix() == null) {
                        return new XROIpv6PrefixSubobjectParser().serializeSubobject(subobject);
                }
+               final byte[] retBytes = new byte[CONTENT4_LENGTH];
+               ByteArray.copyWhole(Ipv4Util.bytesForPrefix(prefix.getIpv4Prefix()), retBytes, IP_F_OFFSET);
+               retBytes[PREFIX4_F_OFFSET] = UnsignedBytes.checkedCast(Ipv4Util.getPrefixLength(prefix));
+               retBytes[ATTRIBUTE4_OFFSET] = UnsignedBytes.checkedCast(subobject.getAttribute().getIntValue());
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index 174b34531ea16ebaa2722366dde36e2a91690ed9..05a2dfd1d2ff268f53e86d8ec612b0347db7d7b9 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.pcep.impl.subobject;
 
 import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.Ipv6Util;
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -76,7 +77,7 @@ public class XROIpv6PrefixSubobjectParser implements XROSubobjectParser, XROSubo
                ByteArray.copyWhole(Ipv6Util.bytesForPrefix(prefix.getIpv6Prefix()), retBytes, IP_F_OFFSET);
                retBytes[PREFIX6_F_OFFSET] = UnsignedBytes.checkedCast(Ipv4Util.getPrefixLength(prefix));
                retBytes[ATTRIBUTE6_OFFSET] = UnsignedBytes.checkedCast(subobject.getAttribute().getIntValue());
-               return retBytes;
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index 48a5feaa4fd139bf798a11206ffe985a9a1ad7bb..d49002e69da9ef30cc03a23ccf1375bfcd01dce6 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.pcep.impl.subobject;
 
 import java.util.Arrays;
 
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -65,7 +66,7 @@ public class XROPathKey128SubobjectParser implements XROSubobjectParser, XROSubo
                final byte[] retBytes = new byte[PK_F_LENGTH + pceId.length];
                System.arraycopy(ByteArray.shortToBytes((short) pathKey), 0, retBytes, PK_F_OFFSET, PK_F_LENGTH);
                System.arraycopy(pceId, 0, retBytes, PCE_ID_F_OFFSET, pceId.length);
-               return retBytes;
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index eb371829534710ee5a55dd96420090fc81737938..721a281fde81a4bae980403fbe8cd49b89906ae6 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.pcep.impl.subobject;
 
 import java.util.Arrays;
 
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -64,7 +65,7 @@ public class XROPathKey32SubobjectParser implements XROSubobjectParser, XROSubob
                final byte[] retBytes = new byte[PK_F_LENGTH + pceId.length];
                System.arraycopy(ByteArray.shortToBytes((short) pathKey), 0, retBytes, PK_F_OFFSET, PK_F_LENGTH);
                System.arraycopy(pceId, 0, retBytes, PCE_ID_F_OFFSET, pceId.length);
-               return retBytes;
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index 998afb6983254e7d113875be6f4e9746dccf3bb4..ee5f9b6a8399d877e338c558ef1961de7acf0fcf 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.pcep.impl.subobject;
 
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -70,7 +71,7 @@ public class XROSRLGSubobjectParser implements XROSubobjectParser, XROSubobjectS
                ByteArray.copyWhole(ByteArray.longToBytes(specObj.getSrlgId().getValue(), SRLG_ID_NUMBER_LENGTH), retBytes, SRLG_ID_NUMBER_OFFSET);
                retBytes[ATTRIBUTE_OFFSET] = UnsignedBytes.checkedCast(subobject.getAttribute().getIntValue());
 
-               return retBytes;
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index ce18eceda686cd007635bc410082f526cccd66d2..0e34dd322bc8b3803a5d64999a55baebe243630c 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.protocol.pcep.impl.subobject;
 
+import org.opendaylight.protocol.pcep.impl.object.XROSubobjectUtil;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.XROSubobjectSerializer;
@@ -74,7 +75,7 @@ public class XROUnnumberedInterfaceSubobjectParser implements XROSubobjectParser
                ByteArray.copyWhole(ByteArray.longToBytes(specObj.getRouterId(), ROUTER_ID_NUMBER_LENGTH), retBytes, ROUTER_ID_NUMBER_OFFSET);
                System.arraycopy(ByteArray.longToBytes(specObj.getInterfaceId(), INTERFACE_ID_NUMBER_LENGTH), 0, retBytes,
                                INTERFACE_ID_NUMBER_OFFSET, INTERFACE_ID_NUMBER_LENGTH);
-               return retBytes;
+               return XROSubobjectUtil.formatSubobject(TYPE, subobject.isMandatory(), retBytes);
        }
 
        @Override
index 05a2f9ef84cba9d377fcf6ee0cc3d8e34ffd9fb3..8959742399c4e5dfb874ade9c1a1cf45f8ae5cf3 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.protocol.pcep.impl.subobject.XROPathKey32SubobjectParser
 import org.opendaylight.protocol.pcep.impl.subobject.XROSRLGSubobjectParser;
 import org.opendaylight.protocol.pcep.impl.subobject.XROUnnumberedInterfaceSubobjectParser;
 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+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;
@@ -41,18 +42,20 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev
 
 public class PCEPXROSubobjectParserTest {
 
-       private static final byte[] ip4PrefixBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x00 };
-       private static final byte[] ip6PrefixBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+       private static final byte[] ip4PrefixBytes = { (byte) 0x01, (byte) 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
+                       (byte) 0x16, (byte) 0x00 };
+       private static final byte[] ip6PrefixBytes = { (byte) 0x82, (byte) 0x14, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
                        (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
-                       (byte) 0xFF, (byte) 0x16, (byte) 0x01 };
-       private static final byte[] srlgBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x02 };
-       private static final byte[] unnumberedBytes = { (byte) 0x00, (byte) 0x01, (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00,
-                       (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
-       private static final byte[] asNumberBytes = { (byte) 0x00, (byte) 0x64 };
-       private static final byte[] pathKey32Bytes = { (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 };
-       private static final byte[] pathKey128Bytes = { (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
-                       (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00,
-                       (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+                       (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x01 };
+       private static final byte[] srlgBytes = { (byte) 0xa2, (byte) 0x07, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x02 };
+       private static final byte[] unnumberedBytes = { (byte) 0x84, (byte) 0x0c, (byte) 0x00, (byte) 0x01, (byte) 0x12, (byte) 0x34,
+                       (byte) 0x50, (byte) 0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+       private static final byte[] asNumberBytes = { (byte) 0xa0, (byte) 0x04, (byte) 0x00, (byte) 0x64 };
+       private static final byte[] pathKey32Bytes = { (byte) 0xc0, (byte) 0x08, (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34,
+                       (byte) 0x50, (byte) 0x00 };
+       private static final byte[] pathKey128Bytes = { (byte) 0xc1, (byte) 0x14, (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34,
+                       (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00,
+                       (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
 
        @Test
        public void testXROIp4PrefixSubobject() throws PCEPDeserializerException {
@@ -62,7 +65,7 @@ public class PCEPXROSubobjectParserTest {
                subs.setAttribute(Attribute.Interface);
                subs.setSubobjectType(new IpPrefixCaseBuilder().setIpPrefix(
                                new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/22"))).build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(ip4PrefixBytes, false));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(ip4PrefixBytes, 2), false));
                assertArrayEquals(ip4PrefixBytes, parser.serializeSubobject(subs.build()));
        }
 
@@ -77,7 +80,7 @@ public class PCEPXROSubobjectParserTest {
                                                new IpPrefix(Ipv6Util.prefixForBytes(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
                                                                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
                                                                (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }, 22))).build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(ip6PrefixBytes, true));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(ip6PrefixBytes, 2), true));
                assertArrayEquals(ip6PrefixBytes, parser.serializeSubobject(subs.build()));
        }
 
@@ -88,7 +91,7 @@ public class PCEPXROSubobjectParserTest {
                subs.setMandatory(true);
                subs.setAttribute(Attribute.Srlg);
                subs.setSubobjectType(new SrlgCaseBuilder().setSrlg(new SrlgBuilder().setSrlgId(new SrlgId(0x12345678L)).build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(srlgBytes, true));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(srlgBytes, 2), true));
                assertArrayEquals(srlgBytes, parser.serializeSubobject(subs.build()));
        }
 
@@ -100,7 +103,7 @@ public class PCEPXROSubobjectParserTest {
                subs.setAttribute(Attribute.Node);
                subs.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(
                                new UnnumberedBuilder().setRouterId(0x12345000L).setInterfaceId(0xffffffffL).build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(unnumberedBytes, true));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(unnumberedBytes, 2), true));
                assertArrayEquals(unnumberedBytes, parser.serializeSubobject(subs.build()));
        }
 
@@ -110,7 +113,7 @@ public class PCEPXROSubobjectParserTest {
                final SubobjectsBuilder subs = new SubobjectsBuilder();
                subs.setMandatory(true);
                subs.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(asNumberBytes, true));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(asNumberBytes, 2), true));
                assertArrayEquals(asNumberBytes, parser.serializeSubobject(subs.build()));
        }
 
@@ -123,7 +126,7 @@ public class PCEPXROSubobjectParserTest {
                pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 }));
                pBuilder.setPathKey(new PathKey(4660));
                subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(pathKey32Bytes, true));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(pathKey32Bytes, 2), true));
                assertArrayEquals(pathKey32Bytes, parser.serializeSubobject(subs.build()));
        }
 
@@ -137,7 +140,7 @@ public class PCEPXROSubobjectParserTest {
                                (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
                pBuilder.setPathKey(new PathKey(4660));
                subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
-               assertEquals(subs.build(), parser.parseSubobject(pathKey128Bytes, true));
+               assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(pathKey128Bytes, 2), true));
                assertArrayEquals(pathKey128Bytes, parser.serializeSubobject(subs.build()));
        }
 }