Search in sources :

Example 6 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testRPObjectWithTlv.

@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
    final RpBuilder builder = new RpBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setReoptimization(true);
    builder.setBiDirectional(false);
    builder.setLoose(true);
    builder.setMakeBeforeBreak(true);
    builder.setOrder(false);
    builder.setPathKey(false);
    builder.setSupplyOf(false);
    builder.setFragmentation(false);
    builder.setP2mp(false);
    builder.setEroCompression(false);
    builder.setPriority((short) 5);
    builder.setRequestId(new RequestId(0xdeadbeefL));
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
    builder.setReoptimization(false);
    builder.setFragmentation(true);
    builder.setEroCompression(true);
    final OrderBuilder b = new OrderBuilder();
    b.setDelete(0xffffffffL);
    b.setSetup(1L);
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setOrder(b.build()).build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) OrderBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.order.tlv.OrderBuilder) TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder) Subobject(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.exclude.route.object.xro.Subobject) Test(org.junit.Test)

Example 7 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testErrorObjectWithTlv.

@Test
public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
    final ErrorObjectBuilder builder = new ErrorObjectBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setType((short) 1);
    builder.setValue((short) 1);
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
    builder.setType((short) 7);
    builder.setValue((short) 0);
    builder.setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(0x00001155L)).build()).build());
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : TlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.error.object.TlvsBuilder) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) PCEPErrorObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser) ReqMissingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder) ByteBuf(io.netty.buffer.ByteBuf) ErrorObjectBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder) Test(org.junit.Test)

Example 8 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class PCEPObjectParserTest method testRpObjectWithPstTlvParser.

@Test
public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
    final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef, /* pst-tlv */
    0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
    final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
    final RpBuilder builder = new RpBuilder();
    builder.setProcessingRule(false);
    builder.setIgnore(false);
    builder.setReoptimization(true);
    builder.setBiDirectional(false);
    builder.setLoose(true);
    builder.setMakeBeforeBreak(true);
    builder.setOrder(false);
    builder.setPathKey(false);
    builder.setSupplyOf(false);
    builder.setFragmentation(false);
    builder.setP2mp(false);
    builder.setEroCompression(false);
    builder.setPriority((short) 5);
    builder.setRequestId(new RequestId(0xdeadbeefL));
    builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst((short) 0).build()).build());
    final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) ObjectHeaderImpl(org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl) ByteBuf(io.netty.buffer.ByteBuf) PCEPRequestParameterObjectParser(org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser) PathSetupTypeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.path.setup.type.tlv.PathSetupTypeBuilder) RpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder) Test(org.junit.Test)

Example 9 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class PCEPTlvParserTest method testReqMissingTlv.

@Test
public void testReqMissingTlv() throws PCEPDeserializerException {
    final ReqMissingTlvParser parser = new ReqMissingTlvParser();
    final ReqMissing tlv = new ReqMissingBuilder().setRequestId(new RequestId(0xF7823517L)).build();
    assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(reqMissingBytes, 4))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeTlv(tlv, buff);
    assertArrayEquals(reqMissingBytes, ByteArray.getAllBytes(buff));
    assertNull(parser.parseTlv(null));
}
Also used : RequestId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId) ReqMissing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing) ReqMissingBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder) ReqMissingTlvParser(org.opendaylight.protocol.pcep.parser.tlv.ReqMissingTlvParser) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 10 with RequestId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId in project bgpcep by opendaylight.

the class ReqMissingTlvParser method serializeTlv.

@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
    Preconditions.checkArgument(tlv instanceof ReqMissing, "ReqMissingTlv is mandatory.");
    final ReqMissing req = (ReqMissing) tlv;
    final ByteBuf body = Unpooled.buffer();
    Preconditions.checkArgument(req.getRequestId() != null, "RequestId is mandatory.");
    writeUnsignedInt(req.getRequestId().getValue(), body);
    TlvUtil.formatTlv(TYPE, body, buffer);
}
Also used : ReqMissing(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

RequestId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RequestId)10 ByteBuf (io.netty.buffer.ByteBuf)9 Test (org.junit.Test)6 RpBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.RpBuilder)5 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)4 BitArray (org.opendaylight.protocol.util.BitArray)4 SvecBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.svec.object.SvecBuilder)3 Collections (java.util.Collections)2 PCEPRequestParameterObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser)2 ProtocolVersion (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion)2 Subobject (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.iro.Subobject)2 ReqMissing (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissing)2 ReqMissingBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.req.missing.tlv.ReqMissingBuilder)2 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 Stateful07ErrorMessageParser (org.opendaylight.protocol.pcep.ietf.stateful07.Stateful07ErrorMessageParser)1 StatefulActivator (org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator)1 TestEnterpriseSpecificInformation (org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation)1 BaseParserExtensionActivator (org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator)1 PCEPErrorObjectParser (org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser)1