Search in sources :

Example 16 with TablesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder in project bgpcep by opendaylight.

the class GracefulCapabilityHandlerTest method testRestartTimeMinValue.

@Test(expected = IllegalArgumentException.class)
public void testRestartTimeMinValue() {
    final GracefulCapabilityHandler handler = new GracefulCapabilityHandler(this.ctx.getAddressFamilyRegistry(), this.ctx.getSubsequentAddressFamilyRegistry());
    final GracefulRestartCapabilityBuilder capaBuilder = new GracefulRestartCapabilityBuilder().setRestartFlags(new RestartFlags(true)).setRestartTime(Uint16.MAX_VALUE).setTables(BindingMap.of(new TablesBuilder().setAfiFlags(new AfiFlags(true)).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()));
    final ByteBuf buffer = Unpooled.buffer();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability.RestartFlags) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) ByteBuf(io.netty.buffer.ByteBuf) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapabilityBuilder) UnicastSubsequentAddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesBuilder) Test(org.junit.Test)

Example 17 with TablesBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder in project bgpcep by opendaylight.

the class GracefulCapabilityHandlerTest method testGracefulCapabilityHandler.

@Test
public void testGracefulCapabilityHandler() throws BGPDocumentedException, BGPParsingException {
    final GracefulCapabilityHandler handler = new GracefulCapabilityHandler(this.ctx.getAddressFamilyRegistry(), this.ctx.getSubsequentAddressFamilyRegistry());
    final byte[] capaBytes = { (byte) 0x40, (byte) 0x06, (byte) 0x81, (byte) 0xf4, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x80 };
    final GracefulRestartCapabilityBuilder capaBuilder = new GracefulRestartCapabilityBuilder().setRestartFlags(new RestartFlags(true)).setRestartTime(Uint16.valueOf(500));
    final TablesBuilder tablesBuilder = new TablesBuilder().setAfiFlags(new AfiFlags(true)).setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class);
    capaBuilder.setTables(BindingMap.of(tablesBuilder.build()));
    final ByteBuf buffer = Unpooled.buffer(capaBytes.length);
    handler.serializeCapability(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
    assertArrayEquals(capaBytes, buffer.array());
    assertEquals(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), handler.parseCapability(Unpooled.wrappedBuffer(capaBytes).slice(2, capaBytes.length - 2)));
    final byte[] capaBytes2 = { (byte) 0x40, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x01, (byte) 0x00 };
    capaBuilder.setRestartFlags(new RestartFlags(false));
    capaBuilder.setRestartTime(Uint16.ZERO);
    tablesBuilder.setAfiFlags(new AfiFlags(false));
    capaBuilder.setTables(BindingMap.of(tablesBuilder.build()));
    buffer.clear();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
    assertArrayEquals(capaBytes2, buffer.array());
    assertEquals(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), handler.parseCapability(Unpooled.wrappedBuffer(capaBytes2).slice(2, capaBytes2.length - 2)));
    capaBuilder.setRestartFlags(null);
    tablesBuilder.setAfiFlags(null);
    capaBuilder.setRestartTime((Uint16) null);
    capaBuilder.setTables(BindingMap.of(tablesBuilder.build()));
    buffer.clear();
    handler.serializeCapability(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), buffer);
    assertArrayEquals(capaBytes2, buffer.array());
    final byte[] capaBytes3 = { (byte) 0x40, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
    capaBuilder.setRestartFlags(new RestartFlags(false));
    capaBuilder.setRestartTime(Uint16.ZERO);
    capaBuilder.setTables(Map.of());
    assertEquals(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), handler.parseCapability(Unpooled.wrappedBuffer(capaBytes3).slice(2, capaBytes3.length - 2)));
    final byte[] capaBytes4 = { (byte) 0x40, (byte) 0x06, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00 };
    assertEquals(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(capaBuilder.build()).build()).build(), handler.parseCapability(Unpooled.wrappedBuffer(capaBytes4).slice(2, capaBytes4.length - 2)));
    final byte[] capaBytes5 = { (byte) 0x40, (byte) 0x02, (byte) 0x00, (byte) 0x00 };
    final ByteBuf b = Unpooled.buffer(capaBytes5.length);
    handler.serializeCapability(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().build()).build()).build(), b);
    assertArrayEquals(capaBytes5, b.array());
    assertEquals(new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().setRestartFlags(new RestartFlags(Boolean.FALSE)).setRestartTime(Uint16.ZERO).build()).build()).build(), handler.parseCapability(Unpooled.wrappedBuffer(capaBytes5).slice(2, capaBytes5.length - 2)));
}
Also used : RestartFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability.RestartFlags) CParametersBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder) AfiFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables.AfiFlags) CParameters1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder) GracefulCapabilityHandler(org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler) Ipv4AddressFamily(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily) ByteBuf(io.netty.buffer.ByteBuf) GracefulRestartCapabilityBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapabilityBuilder) TablesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)13 CParametersBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder)13 CParameters1Builder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.CParameters1Builder)13 ByteBuf (io.netty.buffer.ByteBuf)9 RestartFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapability.RestartFlags)7 GracefulRestartCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.GracefulRestartCapabilityBuilder)7 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.TablesBuilder)7 Ipv4AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily)7 CParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters)6 LlGracefulRestartCapabilityBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapabilityBuilder)6 AfiFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.graceful.restart.capability.Tables.AfiFlags)6 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.ll.graceful.restart.capability.TablesBuilder)6 GracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.GracefulCapabilityHandler)5 LlGracefulRestartCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.mp.capabilities.LlGracefulRestartCapability)5 Ipv6AddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily)5 Uint24 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.types.rev171204.Uint24)4 UnicastSubsequentAddressFamily (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily)4 NextTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.NextTableBuilder)3 TablesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.next.table.TablesBuilder)3 LlGracefulCapabilityHandler (org.opendaylight.protocol.bgp.parser.impl.message.open.LlGracefulCapabilityHandler)2