Search in sources :

Example 1 with Type1LabelBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1LabelBuilder in project bgpcep by opendaylight.

the class LabelSubobjectParserTest method testTypeOneLabel.

@Test
public void testTypeOneLabel() throws RSVPParsingException {
    final Type1LabelParser parser = new Type1LabelParser();
    final Type1LabelBuilder iBuilder = new Type1LabelBuilder();
    iBuilder.setType1Label(0x120025ffL);
    final Type1LabelCaseBuilder builder = new Type1LabelCaseBuilder().setType1Label(iBuilder.build());
    assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(TYPE_ONE_LABEL_BYTES, 2))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeLabel(true, true, builder.build(), buff);
    assertArrayEquals(TYPE_ONE_LABEL_BYTES, ByteArray.getAllBytes(buff));
    try {
        parser.parseLabel(null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseLabel(Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : Type1LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1LabelBuilder) Type1LabelParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.label.Type1LabelParser) Type1LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with Type1LabelBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1LabelBuilder in project bgpcep by opendaylight.

the class LabelSubobjectParserTest method testTypeOneLabel.

@Test
public void testTypeOneLabel() throws PCEPDeserializerException {
    final Type1LabelParser parser = new Type1LabelParser();
    final Type1LabelBuilder iBuilder = new Type1LabelBuilder();
    iBuilder.setType1Label(0x120025ffL);
    final Type1LabelCaseBuilder builder = new Type1LabelCaseBuilder().setType1Label(iBuilder.build());
    assertEquals(builder.build(), parser.parseLabel(Unpooled.wrappedBuffer(ByteArray.cutBytes(typeOneLabelBytes, 2))));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeLabel(true, true, builder.build(), buff);
    assertArrayEquals(typeOneLabelBytes, ByteArray.getAllBytes(buff));
    try {
        parser.parseLabel(null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseLabel(Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : Type1LabelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1LabelBuilder) Type1LabelParser(org.opendaylight.protocol.pcep.parser.subobject.Type1LabelParser) Type1LabelCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 Type1LabelCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCaseBuilder)2 Type1LabelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.type1.label._case.Type1LabelBuilder)2 Type1LabelParser (org.opendaylight.protocol.pcep.parser.subobject.Type1LabelParser)1 Type1LabelParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.label.Type1LabelParser)1