Search in sources :

Example 21 with ObjectHeaderImpl

use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.

the class PCCEndPointIpv4ObjectParserTest method testNullBytes.

@Test(expected = IllegalArgumentException.class)
public void testNullBytes() throws PCEPDeserializerException {
    final ObjectHeader header = new ObjectHeaderImpl(false, false);
    final ByteBuf bytes = null;
    new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
}
Also used : ObjectHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 22 with ObjectHeaderImpl

use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.

the class PCCEndPointIpv4ObjectParserTest method testEmptyBytes.

@Test(expected = IllegalArgumentException.class)
public void testEmptyBytes() throws PCEPDeserializerException {
    final ObjectHeader header = new ObjectHeaderImpl(false, false);
    final ByteBuf bytes = Unpooled.buffer();
    new PCCEndPointIpv4ObjectParser().parseObject(header, bytes);
}
Also used : ObjectHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 23 with ObjectHeaderImpl

use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testIgnoreUknownObject.

@Test
public void testIgnoreUknownObject() throws PCEPDeserializerException {
    final Object object = this.ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
    assertNull(object);
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject) Test(org.junit.Test)

Example 24 with ObjectHeaderImpl

use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testUnrecognizedObjectType.

@Test
public void testUnrecognizedObjectType() throws PCEPDeserializerException {
    final Object object = this.ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
    assertNotNull(object);
    assertTrue(object instanceof UnknownObject);
    assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_TYPE, ((UnknownObject) object).getError());
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) VendorInformationObject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject) UnknownObject(org.opendaylight.protocol.pcep.spi.UnknownObject) Test(org.junit.Test)

Example 25 with ObjectHeaderImpl

use of org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testPccIdReqIPv4Object.

@Test
public void testPccIdReqIPv4Object() throws PCEPDeserializerException {
    final byte[] pccIdReqBytes = { /* object header */
    0x14, 0x10, 0x00, 0x08, /* ipv4 address */
    0x7f, 0x00, 0x00, 0x01 };
    final PCEPPccIdReqIPv4ObjectParser parser = new PCEPPccIdReqIPv4ObjectParser();
    final PccIdReq pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
    final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
    assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
    parser.serializeObject(pccIdReq, buf);
    assertArrayEquals(pccIdReqBytes, buf.array());
}
Also used : ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) PccIdReq(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ByteBuf(io.netty.buffer.ByteBuf) PCEPPccIdReqIPv4ObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPPccIdReqIPv4ObjectParser) PccIdReqBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReqBuilder) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)49 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)49 ByteBuf (io.netty.buffer.ByteBuf)46 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject)14 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder)8 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)6 UnknownObject (org.opendaylight.protocol.pcep.spi.UnknownObject)4 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)4 Ipv4Prefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix)4 ObjectHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader)4 RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)4 VendorInformationObject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vendor.information.objects.VendorInformationObject)4 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)3 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)3 Bandwidth (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth)3 TlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.srp.object.srp.TlvsBuilder)3 SymbolicPathName (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathName)3 SymbolicPathNameBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.symbolic.path.name.tlv.SymbolicPathNameBuilder)3 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)3 SubobjectBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.SubobjectBuilder)3