2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.bgp.flowspec.extended.communities;
11 import io.netty.buffer.ByteBuf;
12 import io.netty.buffer.Unpooled;
13 import org.junit.After;
14 import org.junit.Assert;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.protocol.bgp.flowspec.BGPActivator;
18 import org.opendaylight.protocol.bgp.flowspec.FlowspecActivator;
19 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
20 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
21 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
22 import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
23 import org.opendaylight.protocol.bgp.parser.spi.extended.community.ExtendedCommunityRegistry;
24 import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
25 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
26 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
28 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.Dscp;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.as4.extended.community.RedirectAs4Builder;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.extended.community.RedirectExtendedCommunityBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.ip.nh.extended.community.RedirectIpNhExtendedCommunityBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.ipv4.extended.community.RedirectIpv4Builder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.redirect.ipv6.extended.community.RedirectIpv6Builder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.traffic.action.extended.community.TrafficActionExtendedCommunityBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.traffic.marking.extended.community.TrafficMarkingExtendedCommunityBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.traffic.rate.extended.community.TrafficRateExtendedCommunityBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCase;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCaseBuilder;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCase;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder;
42 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCase;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCaseBuilder;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCase;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCaseBuilder;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCaseBuilder;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.TrafficMarkingExtendedCommunityCase;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.TrafficMarkingExtendedCommunityCaseBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCase;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.update.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCaseBuilder;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunities;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.ExtendedCommunitiesBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.ShortAsNumber;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
59 public class FSExtendedCommunitiesTest {
61 private static final byte[] TRAFFIC_RATE = {(byte)128, 6, 0, 72, 0, 1, 2, 3};
63 private static final byte[] TRAFFIC_ACTION = {(byte)128, 7, 0, 0, 0, 0, 0, 3};
65 private static final byte[] REDIRECT_AS_2BYTES = {(byte)128, 8, 0, 35, 4, 2, 8, 7};
67 private static final byte[] TRAFFIC_MARKING = {(byte)128, 9, 0, 0, 0, 0, 0, 63};
69 private static final byte[] REDIRECT_IPV6 = {(byte)128, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1, 2};
71 private static final byte[] REDIRECT_AS_4BYTES = {(byte)130, 8, 0, 0, 0x19, (byte) 0x94, 0, 126};
73 private static final byte[] REDIRECT_IPV4 = {(byte)129, 8, 127, 0, 0, 1, 0, 126};
75 private static final byte[] REDIRECT_NH_IPV4 = {8, 0, 127, 0, 0, 1, 0, 1};
77 private static final byte[] REDIRECT_NH_IPV6 = {8, 0, 0x20, (byte) 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0, 0};
80 private ExtendedCommunityRegistry registry;
81 private BGPActivator act;
84 public void setUp() throws Exception {
85 final SimpleFlowspecExtensionProviderContext fsContext = new SimpleFlowspecExtensionProviderContext();
86 final FlowspecActivator activator = new FlowspecActivator(fsContext);
88 this.act= new BGPActivator(activator);
89 final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
90 this.act.start(context);
91 this.registry = context.getExtendedCommunityRegistry();
95 public void tearDown() {
100 public void testTrafficRateParser() throws BGPDocumentedException, BGPParsingException {
101 final TrafficRateExtendedCommunityCase trafficRate = new TrafficRateExtendedCommunityCaseBuilder().setTrafficRateExtendedCommunity(
102 new TrafficRateExtendedCommunityBuilder().setInformativeAs(new ShortAsNumber(72L))
103 .setLocalAdministrator(new Bandwidth(new byte[] { 0, 1, 2, 3 })).build()).build();
104 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficRate).setTransitive(true).build();
106 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_RATE));
107 Assert.assertEquals(expected, parsed);
111 public void testTrafficRateSerializer() throws BGPDocumentedException, BGPParsingException {
112 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCase trafficRate = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.TrafficRateExtendedCommunityCaseBuilder().setTrafficRateExtendedCommunity(
113 new TrafficRateExtendedCommunityBuilder().setInformativeAs(new ShortAsNumber(72L))
114 .setLocalAdministrator(new Bandwidth(new byte[] { 0, 1, 2, 3 })).build()).build();
115 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficRate).setTransitive(true).build();
117 final ByteBuf output = Unpooled.buffer(TRAFFIC_RATE.length);
118 this.registry.serializeExtendedCommunity(expected, output);
119 Assert.assertArrayEquals(TRAFFIC_RATE, output.array());
123 public void testTrafficActionParser() throws BGPDocumentedException, BGPParsingException {
124 final TrafficActionExtendedCommunityCase trafficAction = new TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(
125 new TrafficActionExtendedCommunityBuilder().setSample(true).setTerminalAction(true).build()).build();
126 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficAction).setTransitive(true).build();
128 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_ACTION));
129 Assert.assertEquals(expected, parsed);
133 public void testTrafficActionSerializer() throws BGPDocumentedException, BGPParsingException {
134 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCase trafficAction = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.TrafficActionExtendedCommunityCaseBuilder().setTrafficActionExtendedCommunity(
135 new TrafficActionExtendedCommunityBuilder().setSample(true).setTerminalAction(true).build()).build();
136 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficAction).setTransitive(true).build();
138 final ByteBuf output = Unpooled.buffer(TRAFFIC_ACTION.length);
139 this.registry.serializeExtendedCommunity(expected, output);
140 Assert.assertArrayEquals(TRAFFIC_ACTION, output.array());
144 public void testTrafficMarkingParser() throws BGPDocumentedException, BGPParsingException {
145 final TrafficMarkingExtendedCommunityCase trafficMarking = new TrafficMarkingExtendedCommunityCaseBuilder().setTrafficMarkingExtendedCommunity(
146 new TrafficMarkingExtendedCommunityBuilder().setGlobalAdministrator(new Dscp((short) 63)).build()).build();
147 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficMarking).setTransitive(true).build();
149 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(TRAFFIC_MARKING));
150 Assert.assertEquals(expected, parsed);
154 public void testTrafficMarkingSerializer() throws BGPDocumentedException, BGPParsingException {
155 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.TrafficMarkingExtendedCommunityCase trafficMarking = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.TrafficMarkingExtendedCommunityCaseBuilder().setTrafficMarkingExtendedCommunity(
156 new TrafficMarkingExtendedCommunityBuilder().setGlobalAdministrator(new Dscp((short) 63)).build()).build();
157 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(trafficMarking).setTransitive(true).build();
159 final ByteBuf output = Unpooled.buffer(TRAFFIC_MARKING.length);
160 this.registry.serializeExtendedCommunity(expected, output);
161 Assert.assertArrayEquals(TRAFFIC_MARKING, output.array());
165 public void testRedirect2bParser() throws BGPDocumentedException, BGPParsingException {
166 final RedirectExtendedCommunityCase redirect = new RedirectExtendedCommunityCaseBuilder().setRedirectExtendedCommunity(
167 new RedirectExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(35L)).setLocalAdministrator(
168 new byte[] { 4, 2, 8, 7 }).build()).build();
169 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
171 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_AS_2BYTES));
172 Assert.assertEquals(expected, parsed);
176 public void testredirect2bSerializer() throws BGPDocumentedException, BGPParsingException {
177 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectExtendedCommunityCaseBuilder().setRedirectExtendedCommunity(
178 new RedirectExtendedCommunityBuilder().setGlobalAdministrator(new ShortAsNumber(35L)).setLocalAdministrator(
179 new byte[] { 4, 2, 8, 7 }).build()).build();
180 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
182 final ByteBuf output = Unpooled.buffer(REDIRECT_AS_2BYTES.length);
183 this.registry.serializeExtendedCommunity(expected, output);
184 Assert.assertArrayEquals(REDIRECT_AS_2BYTES, output.array());
188 public void testRedirectIpv6Parser() throws BGPDocumentedException, BGPParsingException {
189 final RedirectIpv6ExtendedCommunityCase redirect = new RedirectIpv6ExtendedCommunityCaseBuilder()
190 .setRedirectIpv6(new RedirectIpv6Builder()
191 .setGlobalAdministrator(new Ipv6Address("102:304:506:708:90a:b0c:d0e:f10"))
192 .setLocalAdministrator(258).build()).build();
193 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
195 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_IPV6));
196 Assert.assertEquals(expected, parsed);
200 public void testRedirectIpv6Serializer() {
201 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv6ExtendedCommunityCaseBuilder()
202 .setRedirectIpv6(new RedirectIpv6Builder()
203 .setGlobalAdministrator(new Ipv6Address("102:304:506:708:90a:b0c:d0e:f10"))
204 .setLocalAdministrator(258).build()).build();
205 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
207 final ByteBuf output = Unpooled.buffer(REDIRECT_IPV6.length);
208 this.registry.serializeExtendedCommunity(expected, output);
209 Assert.assertArrayEquals(REDIRECT_IPV6, output.array());
213 public void testRedirect4bParser() throws BGPDocumentedException, BGPParsingException {
214 final RedirectAs4ExtendedCommunityCase redirect = new RedirectAs4ExtendedCommunityCaseBuilder().setRedirectAs4(
215 new RedirectAs4Builder().setGlobalAdministrator(new AsNumber(6548L)).setLocalAdministrator(126).build()).build();
217 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
219 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_AS_4BYTES));
220 Assert.assertEquals(expected, parsed);
224 public void testredirect4bSerializer() throws BGPDocumentedException, BGPParsingException {
225 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectAs4ExtendedCommunityCaseBuilder().setRedirectAs4(
226 new RedirectAs4Builder().setGlobalAdministrator(new AsNumber(6548L)).setLocalAdministrator(126).build()).build();
228 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
230 final ByteBuf output = Unpooled.buffer(REDIRECT_AS_4BYTES.length);
231 this.registry.serializeExtendedCommunity(expected, output);
232 Assert.assertArrayEquals(REDIRECT_AS_4BYTES, output.array());
236 public void testRedirectIpv4Parser() throws BGPDocumentedException, BGPParsingException {
237 final RedirectIpv4ExtendedCommunityCase redirect = new RedirectIpv4ExtendedCommunityCaseBuilder().setRedirectIpv4(
238 new RedirectIpv4Builder().setGlobalAdministrator(new Ipv4Address("127.0.0.1")).setLocalAdministrator(126).build()).build();
240 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
242 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_IPV4));
243 Assert.assertEquals(expected, parsed);
247 public void testredirectIpv4Serializer() throws BGPDocumentedException, BGPParsingException {
248 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpv4ExtendedCommunityCaseBuilder().setRedirectIpv4(
249 new RedirectIpv4Builder().setGlobalAdministrator(new Ipv4Address("127.0.0.1")).setLocalAdministrator(126).build()).build();
251 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
253 final ByteBuf output = Unpooled.buffer(REDIRECT_IPV4.length);
254 this.registry.serializeExtendedCommunity(expected, output);
255 Assert.assertArrayEquals(REDIRECT_IPV4, output.array());
259 public void testRedirectIpv4NhParser() throws BGPDocumentedException, BGPParsingException {
260 final RedirectIpNhExtendedCommunityCase redirect = new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(
261 new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).setCopy(true).build()).build();
263 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
265 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV4));
266 Assert.assertEquals(expected, parsed);
270 public void testredirectIpv4NhSerializer() throws BGPDocumentedException, BGPParsingException {
271 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(
272 new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).setCopy(true).build()).build();
274 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
276 final ByteBuf output = Unpooled.buffer(REDIRECT_NH_IPV4.length);
277 this.registry.serializeExtendedCommunity(expected, output);
278 Assert.assertArrayEquals(REDIRECT_NH_IPV4, output.array());
282 public void testRedirectIpv6NhParser() throws BGPDocumentedException, BGPParsingException {
283 final RedirectIpNhExtendedCommunityCase redirect = new RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(
284 new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv6Address("2001::1"))).setCopy(false).build()).build();
286 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
288 final ExtendedCommunities parsed = this.registry.parseExtendedCommunity(Unpooled.copiedBuffer(REDIRECT_NH_IPV6));
289 Assert.assertEquals(expected, parsed);
293 public void testredirectIpv6NhSerializer() throws BGPDocumentedException, BGPParsingException {
294 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCase redirect = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.route.attributes.extended.communities.extended.community.RedirectIpNhExtendedCommunityCaseBuilder().setRedirectIpNhExtendedCommunity(
295 new RedirectIpNhExtendedCommunityBuilder().setNextHopAddress(new IpAddress(new Ipv6Address("2001::1"))).build()).build();
297 final ExtendedCommunities expected = new ExtendedCommunitiesBuilder().setExtendedCommunity(redirect).setTransitive(true).build();
299 final ByteBuf output = Unpooled.buffer(REDIRECT_NH_IPV6.length);
300 this.registry.serializeExtendedCommunity(expected, output);
301 Assert.assertArrayEquals(REDIRECT_NH_IPV6, output.array());