Search in sources :

Example 1 with EROExplicitExclusionRouteSubobjectParser

use of org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROExplicitExclusionRouteSubobjectParser in project bgpcep by opendaylight.

the class EROSubobjectParserTest method testEROExrsSubobject.

@Test
public void testEROExrsSubobject() throws Exception {
    final EROExplicitExclusionRouteSubobjectParser parser = new EROExplicitExclusionRouteSubobjectParser(this.ctx.getXROSubobjectHandlerRegistry());
    final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
    subs.setLoose(true);
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.Exrs> list = Lists.newArrayList();
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder();
    builder.setMandatory(true);
    builder.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
    list.add(builder.build());
    subs.setSubobjectType(new ExrsCaseBuilder().setExrs(new ExrsBuilder().setExrs(list).build()).build());
    assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(EXRS_BYTES, 2)), true));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeSubobject(subs.build(), buff);
    Assert.assertArrayEquals(EXRS_BYTES, ByteArray.getAllBytes(buff));
    try {
        parser.parseSubobject(null, true);
        Assert.fail();
    } catch (final IllegalArgumentException e) {
        Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
        Assert.fail();
    } catch (final IllegalArgumentException e) {
        Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}
Also used : AsNumberCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder) ExrsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.ExrsBuilder) ByteBuf(io.netty.buffer.ByteBuf) AsNumberBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder) EROExplicitExclusionRouteSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROExplicitExclusionRouteSubobjectParser) ExrsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.ExrsCaseBuilder) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder) Test(org.junit.Test)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 EROExplicitExclusionRouteSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROExplicitExclusionRouteSubobjectParser)1 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)1 AsNumberCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder)1 AsNumberBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder)1 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder)1 ExrsCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.ExrsCaseBuilder)1 ExrsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.ExrsBuilder)1