Search in sources :

Example 1 with XROAsNumberSubobjectParser

use of org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROAsNumberSubobjectParser in project bgpcep by opendaylight.

the class XROSubobjectParserTest method testXROAsNumberSubobject.

@Test
public void testXROAsNumberSubobject() throws RSVPParsingException {
    final XROAsNumberSubobjectParser parser = new XROAsNumberSubobjectParser();
    final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
    subs.setMandatory(true);
    subs.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
    assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(AS_NUMBER_BYTES, 2)), true));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeSubobject(subs.build(), buff);
    Assert.assertArrayEquals(AS_NUMBER_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 : XROAsNumberSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROAsNumberSubobjectParser) AsNumberBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.exclude.route.object.exclude.route.object.SubobjectContainerBuilder) AsNumberCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder) ByteBuf(io.netty.buffer.ByteBuf) AsNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber) Test(org.junit.Test)

Example 2 with XROAsNumberSubobjectParser

use of org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROAsNumberSubobjectParser in project bgpcep by opendaylight.

the class RSVPActivator method registerXROParsers.

private static void registerXROParsers(final List<AutoCloseable> regs, final RSVPExtensionProviderContext context) {
    final XROIpv4PrefixSubobjectParser ipv4prefixParser = new XROIpv4PrefixSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROIpv4PrefixSubobjectParser.TYPE, ipv4prefixParser));
    regs.add(context.registerXROSubobjectSerializer(IpPrefixCase.class, ipv4prefixParser));
    regs.add(context.registerXROSubobjectParser(XROIpv6PrefixSubobjectParser.TYPE, new XROIpv6PrefixSubobjectParser()));
    final XROAsNumberSubobjectParser asNumberParser = new XROAsNumberSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROAsNumberSubobjectParser.TYPE, asNumberParser));
    regs.add(context.registerXROSubobjectSerializer(AsNumberCase.class, asNumberParser));
    final XROSrlgSubobjectParser srlgParser = new XROSrlgSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROSrlgSubobjectParser.TYPE, srlgParser));
    regs.add(context.registerXROSubobjectSerializer(SrlgCase.class, srlgParser));
    final XROUnnumberedInterfaceSubobjectParser unnumberedParser = new XROUnnumberedInterfaceSubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROUnnumberedInterfaceSubobjectParser.TYPE, unnumberedParser));
    regs.add(context.registerXROSubobjectSerializer(UnnumberedCase.class, unnumberedParser));
    final XROPathKey32SubobjectParser pathKeyParser = new XROPathKey32SubobjectParser();
    regs.add(context.registerXROSubobjectParser(XROPathKey32SubobjectParser.TYPE, pathKeyParser));
    regs.add(context.registerXROSubobjectParser(XROPathKey128SubobjectParser.TYPE, new XROPathKey128SubobjectParser()));
    regs.add(context.registerXROSubobjectSerializer(PathKeyCase.class, pathKeyParser));
}
Also used : XROAsNumberSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROAsNumberSubobjectParser) XROPathKey128SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROPathKey128SubobjectParser) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) SrlgCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCase) PathKeyCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) XROPathKey32SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROPathKey32SubobjectParser) XROIpv6PrefixSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROIpv6PrefixSubobjectParser) AsNumberCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase) XROUnnumberedInterfaceSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROUnnumberedInterfaceSubobjectParser) UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase) XROSrlgSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROSrlgSubobjectParser) XROIpv4PrefixSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROIpv4PrefixSubobjectParser)

Aggregations

XROAsNumberSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROAsNumberSubobjectParser)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 XROIpv4PrefixSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROIpv4PrefixSubobjectParser)1 XROIpv6PrefixSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROIpv6PrefixSubobjectParser)1 XROPathKey128SubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROPathKey128SubobjectParser)1 XROPathKey32SubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROPathKey32SubobjectParser)1 XROSrlgSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROSrlgSubobjectParser)1 XROUnnumberedInterfaceSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.xro.XROUnnumberedInterfaceSubobjectParser)1 AsNumber (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber)1 AsNumberCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase)1 AsNumberCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder)1 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)1 SrlgCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.SrlgCase)1 UnnumberedCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase)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.exclude.route.object.exclude.route.object.SubobjectContainerBuilder)1 PathKeyCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase)1