import org.opendaylight.protocol.pcep.impl.subobject.RROUnnumberedInterfaceSubobjectParser;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
+import org.opendaylight.protocol.util.ByteArray;
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.pcep.types.rev131005.PathKey;
public class PCEPRROSubobjectParserTest {
- private static final byte[] ip4PrefixBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x01 };
- 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) 0x01 };
+ private static final byte[] ip6PrefixBytes = { (byte) 0x02, (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) 0x02 };
- private static final byte[] unnumberedBytes = { (byte) 0x02, (byte) 0x00, (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00,
- (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
- 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 };
- private static final byte[] labelBytes = { (byte) 0x81, (byte) 0x02, (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF };
+ (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x02 };
+ private static final byte[] unnumberedBytes = { (byte) 0x04, (byte) 0x0c, (byte) 0x02, (byte) 0x00, (byte) 0x12, (byte) 0x34,
+ (byte) 0x50, (byte) 0x00, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
+ private static final byte[] pathKey32Bytes = { (byte) 0x40, (byte) 0x08, (byte) 0x12, (byte) 0x34, (byte) 0x12, (byte) 0x34,
+ (byte) 0x50, (byte) 0x00 };
+ private static final byte[] pathKey128Bytes = { (byte) 0x41, (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 };
+ private static final byte[] labelBytes = { (byte) 0x03, (byte) 0x08, (byte) 0x81, (byte) 0x02, (byte) 0x12, (byte) 0x00, (byte) 0x25,
+ (byte) 0xFF };
@Test
public void testRROIp4PrefixSubobject() throws PCEPDeserializerException {
subs.setProtectionInUse(false);
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));
+ assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(ip4PrefixBytes, 2)));
assertArrayEquals(ip4PrefixBytes, parser.serializeSubobject(subs.build()));
}
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));
+ assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(ip6PrefixBytes, 2)));
assertArrayEquals(ip6PrefixBytes, parser.serializeSubobject(subs.build()));
}
subs.setProtectionInUse(true);
subs.setSubobjectType(new UnnumberedCaseBuilder().setUnnumbered(
new UnnumberedBuilder().setRouterId(0x12345000L).setInterfaceId(0xffffffffL).build()).build());
- assertEquals(subs.build(), parser.parseSubobject(unnumberedBytes));
+ assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(unnumberedBytes, 2)));
assertArrayEquals(unnumberedBytes, parser.serializeSubobject(subs.build()));
}
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));
+ assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(pathKey32Bytes, 2)));
assertArrayEquals(pathKey32Bytes, parser.serializeSubobject(subs.build()));
}
(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));
+ assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(pathKey128Bytes, 2)));
assertArrayEquals(pathKey128Bytes, parser.serializeSubobject(subs.build()));
}
new GeneralizedLabelCaseBuilder().setGeneralizedLabel(
new GeneralizedLabelBuilder().setGeneralizedLabel(
new byte[] { (byte) 0x12, (byte) 0x00, (byte) 0x25, (byte) 0xFF }).build()).build()).build()).build());
- assertEquals(subs.build(), parser.parseSubobject(labelBytes));
+ assertEquals(subs.build(), parser.parseSubobject(ByteArray.cutBytes(labelBytes, 2)));
assertArrayEquals(labelBytes, parser.serializeSubobject(subs.build()));
}
}