use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCaseBuilder in project bgpcep by opendaylight.
the class NextHopUtilTest method testSerializeNextHop.
@Test
public void testSerializeNextHop() {
CNextHop hop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(IPV4).build()).build();
final ByteBuf buffer = Unpooled.buffer();
NextHopUtil.serializeNextHop(hop, buffer);
assertArrayEquals(IPV4B, ByteArray.readAllBytes(buffer));
hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IPV6).build()).build();
buffer.clear();
NextHopUtil.serializeNextHop(hop, buffer);
assertArrayEquals(IPV6B, ByteArray.readAllBytes(buffer));
hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IPV6).setLinkLocal(IPV6L).build()).build();
buffer.clear();
NextHopUtil.serializeNextHop(hop, buffer);
assertArrayEquals(IPV6LB, ByteArray.readAllBytes(buffer));
buffer.clear();
hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setLinkLocal(IPV6L).build()).build();
buffer.clear();
try {
NextHopUtil.serializeNextHop(hop, buffer);
fail("Exception should happen");
} catch (final IllegalArgumentException e) {
assertEquals("Ipv6 Next Hop is missing Global address.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.c.next.hop.Ipv6NextHopCaseBuilder in project bgpcep by opendaylight.
the class NextHopParserSerializerTest method testSerializeIpv6LinkNextHopCase.
@Test
public void testSerializeIpv6LinkNextHopCase() throws BGPParsingException {
this.hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IPV6).setLinkLocal(IPV6L).build()).build();
this.buffer.clear();
this.ipv6NextHopParserSerializer.serializeNextHop(this.hop, this.buffer);
assertArrayEquals(IPV6LB, ByteArray.readAllBytes(this.buffer));
final CNextHop parsedHop = this.ipv6NextHopParserSerializer.parseNextHop(Unpooled.wrappedBuffer(IPV6LB));
assertTrue(parsedHop instanceof Ipv6NextHopCase);
assertEquals(this.hop, parsedHop);
}
Aggregations