List of usage examples for io.netty.buffer ByteBuf array
public abstract byte[] array();
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.FSExtendedCommunitiesTest.java
License:Open Source License
@Test public void testredirect2bSerializer() throws BGPDocumentedException, BGPParsingException { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder() .setRedirectExtendedCommunity( new RedirectExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(35L)) .setLocalAdministrator(new byte[] { 4, 2, 8, 7 }).build()) .build();//from www .j a v a2s. com final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect) .setTransitive(true).build(); final ByteBuf output = Unpooled.buffer(REDIRECT_AS_2BYTES.length); registry.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(REDIRECT_AS_2BYTES, output.array()); }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.FSExtendedCommunitiesTest.java
License:Open Source License
@Test public void testRedirectIpv6Serializer() { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCaseBuilder() .setRedirectIpv6(new RedirectIpv6Builder() .setGlobalAdministrator(new Ipv6Address("102:304:506:708:90a:b0c:d0e:f10")) .setLocalAdministrator(258).build()) .build();/*from w w w .j a v a 2 s .c om*/ final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect) .setTransitive(true).build(); final ByteBuf output = Unpooled.buffer(REDIRECT_IPV6.length); this.registry.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(REDIRECT_IPV6, output.array()); }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.FSExtendedCommunitiesTest.java
License:Open Source License
@Test public void testredirect4bSerializer() throws BGPDocumentedException, BGPParsingException { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCaseBuilder() .setRedirectAs4(new RedirectAs4Builder().setGlobalAdministrator(new AsNumber(6548L)) .setLocalAdministrator(126).build()) .build();/* w w w. j a v a2 s .com*/ final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect) .setTransitive(true).build(); final ByteBuf output = Unpooled.buffer(REDIRECT_AS_4BYTES.length); registry.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(REDIRECT_AS_4BYTES, output.array()); }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.FSExtendedCommunitiesTest.java
License:Open Source License
@Test public void testredirectIpv4Serializer() throws BGPDocumentedException, BGPParsingException { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCaseBuilder() .setRedirectIpv4(new RedirectIpv4Builder().setGlobalAdministrator(new Ipv4Address("127.0.0.1")) .setLocalAdministrator(126).build()) .build();//ww w.j a va2 s. co m final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect) .setTransitive(true).build(); final ByteBuf output = Unpooled.buffer(REDIRECT_IPV4.length); registry.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(REDIRECT_IPV4, output.array()); }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.FSExtendedCommunitiesTest.java
License:Open Source License
@Test public void testredirectIpv4NhSerializer() throws BGPDocumentedException, BGPParsingException { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder() .setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder() .setNextHopAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).setCopy(true).build()) .build();/*from w w w. j a v a 2 s.c o m*/ final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect) .setTransitive(true).build(); final ByteBuf output = Unpooled.buffer(REDIRECT_NH_IPV4.length); registry.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(REDIRECT_NH_IPV4, output.array()); }
From source file:org.opendaylight.protocol.bgp.flowspec.extended.communities.FSExtendedCommunitiesTest.java
License:Open Source License
@Test public void testredirectIpv6NhSerializer() throws BGPDocumentedException, BGPParsingException { final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev150807.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder() .setRedirectIpNhExtendedCommunity(new RedirectIpNhExtendedCommunityBuilder() .setNextHopAddress(new IpAddress(new Ipv6Address("2001::1"))).build()) .build();//from w w w. j a v a2 s . c o m final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect) .setTransitive(true).build(); final ByteBuf output = Unpooled.buffer(REDIRECT_NH_IPV6.length); registry.serializeExtendedCommunity(expected, output); Assert.assertArrayEquals(REDIRECT_NH_IPV6, output.array()); }
From source file:org.opendaylight.protocol.bgp.inet.codec.Ipv4NlriParserTest.java
License:Open Source License
@Test public void parseReachNlriMultiPathTest() { final MpReachNlri mpReachNlri = new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder() .setDestinationType(new DestinationIpv4CaseBuilder() .setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(PREFIXES).build()).build()) .build()).build();/*from w ww . j a v a 2 s . com*/ final MpReachNlriBuilder mpReachNlriBuilder = new MpReachNlriBuilder(); mpReachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class); this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpReachNlriBuilder, this.constraint); mpReachNlriBuilder.setAfi(null).setSafi(null); Assert.assertEquals(mpReachNlri, mpReachNlriBuilder.build()); final Ipv4NlriParser serializer = new Ipv4NlriParser(); final ByteBuf output = Unpooled.buffer(MP_NLRI_BYTES.length); final Attributes attributes = new AttributesBuilder() .addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachNlri).build()) .build(); serializer.serializeAttribute(attributes, output); Assert.assertArrayEquals(MP_NLRI_BYTES, output.array()); }
From source file:org.opendaylight.protocol.bgp.inet.codec.Ipv4NlriParserTest.java
License:Open Source License
@Test public void parseUnreachNlriMultiPathTest() { final MpUnreachNlri mpUnreachNlri = new MpUnreachNlriBuilder() .setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType( new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder() .setDestinationIpv4(new DestinationIpv4Builder().setIpv4Prefixes(PREFIXES).build()) .build())// w w w .ja va 2s . c om .build()) .build(); final MpUnreachNlriBuilder mpUnreachNlriBuilder = new MpUnreachNlriBuilder(); mpUnreachNlriBuilder.setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class); this.parser.parseNlri(Unpooled.wrappedBuffer(MP_NLRI_BYTES), mpUnreachNlriBuilder, this.constraint); mpUnreachNlriBuilder.setAfi(null).setSafi(null); Assert.assertEquals(mpUnreachNlri, mpUnreachNlriBuilder.build()); final Ipv4NlriParser serializer = new Ipv4NlriParser(); final ByteBuf output = Unpooled.buffer(MP_NLRI_BYTES.length); final Attributes attributes = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mpUnreachNlri).build()).build(); serializer.serializeAttribute(attributes, output); Assert.assertArrayEquals(MP_NLRI_BYTES, output.array()); }
From source file:org.opendaylight.protocol.bgp.inet.Ipv6BgpPrefixSidParserTest.java
License:Open Source License
@Test public void testHandling() { final Ipv6SidTlvBuilder tlv = new Ipv6SidTlvBuilder(); tlv.setProcessIpv6HeadAbility(Boolean.TRUE); final ByteBuf serialized = Unpooled.buffer(3); this.handler.serializeBgpPrefixSidTlv(tlv.build(), serialized); assertArrayEquals(this.expected, serialized.array()); assertTrue(this.handler.parseBgpPrefixSidTlv(serialized).isProcessIpv6HeadAbility()); }
From source file:org.opendaylight.protocol.bgp.labeled.unicast.BgpPrefixSidTlvsTest.java
License:Open Source License
@Test public void testLabelIndexParser() { final LabelIndexTlvParser parser = new LabelIndexTlvParser(); final LuLabelIndexTlv tlv = new LuLabelIndexTlvBuilder().setLabelIndexTlv(333L).build(); final ByteBuf serialized = Unpooled.buffer(7); final byte[] expected = new byte[] { 0, 0, 0, 0, 0, 1, (byte) 0x4d }; parser.serializeBgpPrefixSidTlv(tlv, serialized); assertArrayEquals(expected, serialized.array()); assertEquals(tlv.getLabelIndexTlv(), parser.parseBgpPrefixSidTlv(serialized).getLabelIndexTlv()); assertEquals(1, parser.getType());/*from w w w. j av a2 s . c o m*/ }