use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder in project bgpcep by opendaylight.
the class RouteRefreshCapabilityHandlerTest method testRRCapHandler.
@Test
public void testRRCapHandler() throws BGPDocumentedException, BGPParsingException {
final CParameters expectedParams = new CParametersBuilder().addAugmentation(new CParameters1Builder().setRouteRefreshCapability(new RouteRefreshCapabilityBuilder().build()).build()).build();
assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(OK_BYTES)));
assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(WRONG_BYTES)));
final ByteBuf byteAggregator = Unpooled.buffer(2);
HANDLER.serializeCapability(expectedParams, byteAggregator);
assertEquals(Unpooled.copiedBuffer(CAP_BYTES), byteAggregator);
final CParameters missingCap = new CParametersBuilder().addAugmentation(new CParameters1Builder().setRouteRefreshCapability(null).build()).build();
final ByteBuf byteAggregator2 = Unpooled.buffer(0);
HANDLER.serializeCapability(missingCap, byteAggregator2);
assertEquals(Unpooled.copiedBuffer(new byte[] {}), byteAggregator2);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method noSerializationTest.
@Test
public void noSerializationTest() {
final CParameters capabilityNoAugmentation = new CParametersBuilder().removeAugmentation(CParameters1.class).build();
final CParameters capabilityNoMP = new CParametersBuilder().addAugmentation(new CParameters1Builder().build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safirException);
handler.serializeCapability(capabilityNoAugmentation, bytes);
assertEquals(0, bytes.readableBytes());
handler.serializeCapability(capabilityNoMP, bytes);
assertEquals(0, bytes.readableBytes());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testUnhandledAfi.
@Test(expected = IllegalArgumentException.class)
public void testUnhandledAfi() {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(2)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afirExpection, this.safiRegistry);
handler.serializeCapability(capabilityToSerialize, bytes);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testSendReceiveIgnored.
@Test
public void testSendReceiveIgnored() throws BGPDocumentedException, BGPParsingException {
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(new ArrayList<>()).build()).build()).build();
final ByteBuf bytes = this.parseWrongBytes.copy();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safiRegistry);
final CParameters newCaps = handler.parseCapability(bytes);
assertEquals(capabilityToSerialize.hashCode(), newCaps.hashCode());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParametersBuilder in project bgpcep by opendaylight.
the class AddPathCapabilityHandlerTest method testUnhandledSafi.
@Test(expected = IllegalArgumentException.class)
public void testUnhandledSafi() {
final List<AddressFamilies> family = new ArrayList<>();
family.add(new AddressFamiliesBuilder().setAfi(AddPathCapabilityHandlerTest.AFI).setSafi(AddPathCapabilityHandlerTest.SAFI).setSendReceive(SendReceive.forValue(3)).build());
final CParameters capabilityToSerialize = new CParametersBuilder().addAugmentation(new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(family).build()).build()).build();
final ByteBuf bytes = Unpooled.buffer();
final AddPathCapabilityHandler handler = new AddPathCapabilityHandler(this.afiRegistry, this.safirException);
handler.serializeCapability(capabilityToSerialize, bytes);
}
Aggregations