Search in sources :

Example 1 with EROPathKey32SubobjectParser

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

the class EROSubobjectParserTest method testEROPathKey128Subobject.

@Test
public void testEROPathKey128Subobject() throws RSVPParsingException {
    final EROPathKey128SubobjectParser parser128 = new EROPathKey128SubobjectParser();
    final EROPathKey32SubobjectParser parser = new EROPathKey32SubobjectParser();
    final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
    subs.setLoose(true);
    final PathKeyBuilder pBuilder = new PathKeyBuilder();
    pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
    pBuilder.setPathKey(new PathKey(4660));
    subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
    assertEquals(subs.build(), parser128.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(PATH_KEY_128_BYTES, 2)), true));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeSubobject(subs.build(), buff);
    Assert.assertArrayEquals(PATH_KEY_128_BYTES, ByteArray.getAllBytes(buff));
    try {
        parser128.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 {
        parser128.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 : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey) PathKeyCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder) EROPathKey128SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey128SubobjectParser) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder) ByteBuf(io.netty.buffer.ByteBuf) EROPathKey32SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey32SubobjectParser) Test(org.junit.Test)

Example 2 with EROPathKey32SubobjectParser

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

the class EROSubobjectParserTest method testEROPathKey32Subobject.

@Test
public void testEROPathKey32Subobject() throws RSVPParsingException {
    final EROPathKey32SubobjectParser parser = new EROPathKey32SubobjectParser();
    final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
    subs.setLoose(true);
    final PathKeyBuilder pBuilder = new PathKeyBuilder();
    pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 }));
    pBuilder.setPathKey(new PathKey(4660));
    subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build());
    assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(PATH_KEY_32_BYTES, 2)), true));
    final ByteBuf buff = Unpooled.buffer();
    parser.serializeSubobject(subs.build(), buff);
    Assert.assertArrayEquals(PATH_KEY_32_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 : PathKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey) PathKeyCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder) SubobjectContainerBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder) PceId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId) PathKeyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder) ByteBuf(io.netty.buffer.ByteBuf) EROPathKey32SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey32SubobjectParser) Test(org.junit.Test)

Example 3 with EROPathKey32SubobjectParser

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

the class RSVPActivator method registerEROParsers.

private static void registerEROParsers(final List<AutoCloseable> regs, final RSVPExtensionProviderContext context, final LabelRegistry labelReg) {
    final EROIpv4PrefixSubobjectParser ipv4prefixParser = new EROIpv4PrefixSubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROIpv4PrefixSubobjectParser.TYPE, ipv4prefixParser));
    regs.add(context.registerEROSubobjectSerializer(IpPrefixCase.class, ipv4prefixParser));
    regs.add(context.registerEROSubobjectParser(EROIpv6PrefixSubobjectParser.TYPE, new EROIpv6PrefixSubobjectParser()));
    final EROAsNumberSubobjectParser asNumberParser = new EROAsNumberSubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROAsNumberSubobjectParser.TYPE, asNumberParser));
    regs.add(context.registerEROSubobjectSerializer(AsNumberCase.class, asNumberParser));
    final EROUnnumberedInterfaceSubobjectParser unnumberedParser = new EROUnnumberedInterfaceSubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROUnnumberedInterfaceSubobjectParser.TYPE, unnumberedParser));
    regs.add(context.registerEROSubobjectSerializer(UnnumberedCase.class, unnumberedParser));
    final EROPathKey32SubobjectParser pathKeyParser = new EROPathKey32SubobjectParser();
    regs.add(context.registerEROSubobjectParser(EROPathKey32SubobjectParser.TYPE, pathKeyParser));
    regs.add(context.registerEROSubobjectParser(EROPathKey128SubobjectParser.TYPE, new EROPathKey128SubobjectParser()));
    regs.add(context.registerEROSubobjectSerializer(PathKeyCase.class, pathKeyParser));
    final EROLabelSubobjectParser labelParser = new EROLabelSubobjectParser(labelReg);
    regs.add(context.registerEROSubobjectParser(EROLabelSubobjectParser.TYPE, labelParser));
    regs.add(context.registerEROSubobjectSerializer(LabelCase.class, labelParser));
    final SERODynamicProtectionSubobjectParser seroDynamicParser = new SERODynamicProtectionSubobjectParser();
    final SEROBasicProtectionSubobjectParser seroBasicParser = new SEROBasicProtectionSubobjectParser();
    regs.add(context.registerEROSubobjectParser(SERODynamicProtectionSubobjectParser.TYPE, seroBasicParser));
    regs.add(context.registerEROSubobjectSerializer(DynamicControlProtectionCase.class, seroDynamicParser));
    regs.add(context.registerEROSubobjectSerializer(BasicProtectionCase.class, seroBasicParser));
}
Also used : DynamicControlProtectionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.DynamicControlProtectionCase) SEROBasicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.SEROBasicProtectionSubobjectParser) EROUnnumberedInterfaceSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROUnnumberedInterfaceSubobjectParser) EROIpv6PrefixSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv6PrefixSubobjectParser) SERODynamicProtectionSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.SERODynamicProtectionSubobjectParser) BasicProtectionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.secondary.explicit.route.object.secondary.explicit.route.object.subobject.container.subobject.type.BasicProtectionCase) EROLabelSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROLabelSubobjectParser) AsNumberCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase) UnnumberedCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase) EROPathKey32SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey32SubobjectParser) IpPrefixCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase) EROPathKey128SubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey128SubobjectParser) PathKeyCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCase) GeneralizedLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.GeneralizedLabelCase) Type1LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.Type1LabelCase) LabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase) WavebandSwitchingLabelCase(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.label.subobject.label.type.WavebandSwitchingLabelCase) EROIpv4PrefixSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv4PrefixSubobjectParser) EROAsNumberSubobjectParser(org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROAsNumberSubobjectParser)

Aggregations

EROPathKey32SubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey32SubobjectParser)3 ByteBuf (io.netty.buffer.ByteBuf)2 Test (org.junit.Test)2 EROPathKey128SubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROPathKey128SubobjectParser)2 PathKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey)2 PceId (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId)2 SubobjectContainerBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.list.SubobjectContainerBuilder)2 PathKeyCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.PathKeyCaseBuilder)2 PathKeyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.path.key._case.PathKeyBuilder)2 EROAsNumberSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROAsNumberSubobjectParser)1 EROIpv4PrefixSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv4PrefixSubobjectParser)1 EROIpv6PrefixSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROIpv6PrefixSubobjectParser)1 EROLabelSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROLabelSubobjectParser)1 EROUnnumberedInterfaceSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.EROUnnumberedInterfaceSubobjectParser)1 SEROBasicProtectionSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.SEROBasicProtectionSubobjectParser)1 SERODynamicProtectionSubobjectParser (org.opendaylight.protocol.rsvp.parser.impl.subobject.ero.SERODynamicProtectionSubobjectParser)1 AsNumberCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCase)1 IpPrefixCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCase)1 LabelCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.LabelCase)1 UnnumberedCase (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase)1