2 * Copyright (c) 2013 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
8 package org.opendaylight.protocol.pcep.impl;
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.assertTrue;
15 import static org.junit.Assert.fail;
17 import com.google.common.collect.ImmutableSet;
18 import com.google.common.collect.Lists;
19 import io.netty.buffer.ByteBuf;
20 import io.netty.buffer.Unpooled;
21 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
28 import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
29 import org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator;
30 import org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser;
31 import org.opendaylight.protocol.pcep.parser.object.PCEPClassTypeObjectParser;
32 import org.opendaylight.protocol.pcep.parser.object.PCEPCloseObjectParser;
33 import org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser;
34 import org.opendaylight.protocol.pcep.parser.object.PCEPExcludeRouteObjectParser;
35 import org.opendaylight.protocol.pcep.parser.object.PCEPExistingBandwidthObjectParser;
36 import org.opendaylight.protocol.pcep.parser.object.PCEPExplicitRouteObjectParser;
37 import org.opendaylight.protocol.pcep.parser.object.PCEPGlobalConstraintsObjectParser;
38 import org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser;
39 import org.opendaylight.protocol.pcep.parser.object.PCEPLoadBalancingObjectParser;
40 import org.opendaylight.protocol.pcep.parser.object.PCEPLspaObjectParser;
41 import org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser;
42 import org.opendaylight.protocol.pcep.parser.object.PCEPMonitoringObjectParser;
43 import org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser;
44 import org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser;
45 import org.opendaylight.protocol.pcep.parser.object.PCEPObjectiveFunctionObjectParser;
46 import org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser;
47 import org.opendaylight.protocol.pcep.parser.object.PCEPOverloadObjectParser;
48 import org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser;
49 import org.opendaylight.protocol.pcep.parser.object.PCEPPccIdReqIPv4ObjectParser;
50 import org.opendaylight.protocol.pcep.parser.object.PCEPPccIdReqIPv6ObjectParser;
51 import org.opendaylight.protocol.pcep.parser.object.PCEPPceIdIPv4ObjectParser;
52 import org.opendaylight.protocol.pcep.parser.object.PCEPPceIdIPv6ObjectParser;
53 import org.opendaylight.protocol.pcep.parser.object.PCEPProcTimeObjectParser;
54 import org.opendaylight.protocol.pcep.parser.object.PCEPReportedRouteObjectParser;
55 import org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser;
56 import org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser;
57 import org.opendaylight.protocol.pcep.parser.object.bnc.BNCUtil;
58 import org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser;
59 import org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser;
60 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser;
61 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv6ObjectParser;
62 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer;
63 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPP2MPEndPointsIpv4ObjectParser;
64 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPP2MPEndPointsIpv6ObjectParser;
65 import org.opendaylight.protocol.pcep.parser.object.unreach.PCEPIpv4UnreachDestinationParser;
66 import org.opendaylight.protocol.pcep.parser.object.unreach.PCEPIpv6UnreachDestinationParser;
67 import org.opendaylight.protocol.pcep.parser.object.unreach.PCEPUnreachDestinationSerializer;
68 import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
69 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
70 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
71 import org.opendaylight.protocol.pcep.spi.UnknownObject;
72 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
73 import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
74 import org.opendaylight.protocol.util.ByteArray;
75 import org.opendaylight.protocol.util.Ipv4Util;
76 import org.opendaylight.protocol.util.Ipv6Util;
77 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
78 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
79 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
80 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
81 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
82 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.P2mpLeaves;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeListBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassTypeBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6CaseBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv6CaseBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6Builder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv6._case.P2mpIpv6Builder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.XroBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc.object.GcBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.IroBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancingBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.LspaBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.MonitoringBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeListBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotificationBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.OfBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.OrderBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDurationBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.Overload;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.OverloadBuilder;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.path.key.PathKeys;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.path.key.PathKeysBuilder;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReqBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceIdBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.error.object.TlvsBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.no.path.tlvs.NoPathVectorBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTime;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTimeBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.RroBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.req.missing.tlv.ReqMissingBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObjBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCase;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCaseBuilder;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCase;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCaseBuilder;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
161 import org.opendaylight.yangtools.yang.common.Uint16;
162 import org.opendaylight.yangtools.yang.common.Uint32;
163 import org.opendaylight.yangtools.yang.common.Uint8;
165 public class PCEPObjectParserTest {
167 private TlvRegistry tlvRegistry;
169 private VendorInformationTlvRegistry viTlvRegistry;
171 private SimplePCEPExtensionProviderContext ctx;
172 private BaseParserExtensionActivator act;
173 private TestVendorInformationActivator viAct;
176 public void setUp() {
177 ctx = new SimplePCEPExtensionProviderContext();
178 act = new BaseParserExtensionActivator();
179 viAct = new TestVendorInformationActivator();
182 tlvRegistry = ctx.getTlvHandlerRegistry();
183 viTlvRegistry = ctx.getVendorInformationTlvRegistry();
187 public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
188 final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(tlvRegistry, viTlvRegistry);
189 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
191 final OpenBuilder builder = new OpenBuilder()
192 .setProcessingRule(false)
194 .setVersion(new ProtocolVersion(Uint8.ONE))
195 .setKeepalive(Uint8.valueOf(30))
196 .setDeadTimer(Uint8.valueOf(120))
197 .setSessionId(Uint8.ONE);
199 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open
200 .object.open.TlvsBuilder().build());
202 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
203 result.slice(4, result.readableBytes() - 4)));
204 final ByteBuf buf = Unpooled.buffer();
205 parser.serializeObject(builder.build(), buf);
206 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
209 parser.parseObject(new ObjectHeaderImpl(true, true), null);
211 } catch (final IllegalArgumentException e) {
212 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
215 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
217 } catch (final IllegalArgumentException e) {
218 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
223 public void testCloseObject() throws IOException, PCEPDeserializerException {
224 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(tlvRegistry, viTlvRegistry);
225 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseObject1.bin"));
227 final CCloseBuilder builder = new CCloseBuilder()
228 .setProcessingRule(false)
230 .setReason(Uint8.valueOf(5))
231 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close
232 .object.c.close.TlvsBuilder().build());
234 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
235 result.slice(4, result.readableBytes() - 4)));
236 final ByteBuf buf = Unpooled.buffer();
237 parser.serializeObject(builder.build(), buf);
238 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
241 parser.parseObject(new ObjectHeaderImpl(true, true), null);
243 } catch (final IllegalArgumentException e) {
244 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
247 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
249 } catch (final IllegalArgumentException e) {
250 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
255 public void testLoadBalancingObject() throws IOException, PCEPDeserializerException {
256 final PCEPLoadBalancingObjectParser parser = new PCEPLoadBalancingObjectParser();
257 final ByteBuf result =
258 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLoadBalancingObject1.bin"));
260 final LoadBalancingBuilder builder = new LoadBalancingBuilder()
261 .setProcessingRule(true)
263 .setMaxLsp(Uint8.valueOf(0xf1))
264 .setMinBandwidth(new Bandwidth(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }));
266 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
267 result.slice(4, result.readableBytes() - 4)));
268 final ByteBuf buf = Unpooled.buffer();
269 parser.serializeObject(builder.build(), buf);
270 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
273 parser.parseObject(new ObjectHeaderImpl(true, true), null);
275 } catch (final IllegalArgumentException e) {
276 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
279 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
281 } catch (final IllegalArgumentException e) {
282 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
287 public void testERObject() throws Exception {
288 final PCEPExplicitRouteObjectParser parser =
289 new PCEPExplicitRouteObjectParser(ctx.getEROSubobjectHandlerRegistry());
290 final ByteBuf result =
291 Unpooled.wrappedBuffer(
292 ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin"));
294 final EroBuilder builder = new EroBuilder();
295 builder.setProcessingRule(false);
296 builder.setIgnore(false);
297 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
298 .route.object.ero.Subobject> subs = new ArrayList<>();
299 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
300 .route.object.ero.SubobjectBuilder()
302 .setSubobjectType(new AsNumberCaseBuilder()
303 .setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(Uint32.valueOf(0xffff))).build())
306 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
307 .route.object.ero.SubobjectBuilder().setLoose(true).setSubobjectType(new IpPrefixCaseBuilder()
309 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build())
311 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
312 .route.object.ero.SubobjectBuilder()
314 .setSubobjectType(new UnnumberedCaseBuilder()
315 .setUnnumbered(new UnnumberedBuilder()
316 .setRouterId(Uint32.valueOf(0xffffffffL))
317 .setInterfaceId(Uint32.valueOf(0xffffffffL))
321 builder.setSubobject(subs);
323 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
324 result.slice(4, result.readableBytes() - 4)));
325 final ByteBuf buf = Unpooled.buffer();
326 parser.serializeObject(builder.build(), buf);
327 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
330 parser.parseObject(new ObjectHeaderImpl(true, true), null);
332 } catch (final IllegalArgumentException e) {
333 assertEquals("Array of bytes is mandatory. Can't be null.", e.getMessage());
338 public void testIRObject() throws Exception {
339 final PCEPIncludeRouteObjectParser parser =
340 new PCEPIncludeRouteObjectParser(ctx.getEROSubobjectHandlerRegistry());
341 final ByteBuf result =
342 Unpooled.wrappedBuffer(
343 ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin"));
344 final byte[] ip6PrefixBytes = {
345 (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
346 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
349 final IroBuilder builder = new IroBuilder();
350 builder.setProcessingRule(false);
351 builder.setIgnore(false);
352 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
353 .route.object.iro.Subobject> subs = new ArrayList<>();
354 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
355 .route.object.iro.SubobjectBuilder().setSubobjectType(
356 new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder()
357 .setAsNumber(new AsNumber(Uint32.valueOf(0x10))).build()).build()).setLoose(true).build());
358 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
359 .route.object.iro.SubobjectBuilder().setSubobjectType(
360 new IpPrefixCaseBuilder().setIpPrefix(
361 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("18.52.80.0/21"))).build()).build())
362 .setLoose(true).build());
363 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
364 .route.object.iro.SubobjectBuilder().setSubobjectType(
365 new IpPrefixCaseBuilder().setIpPrefix(
366 new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22)))
367 .build()).build()).setLoose(true).build());
368 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
369 .route.object.iro.SubobjectBuilder().setSubobjectType(new UnnumberedCaseBuilder()
370 .setUnnumbered(new UnnumberedBuilder()
371 .setRouterId(Uint32.valueOf(0x1245678L)).setInterfaceId(Uint32.valueOf(0x9abcdef0L))
372 .build()).build()).setLoose(true).build());
373 builder.setSubobject(subs);
375 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
376 result.slice(4, result.readableBytes() - 4)));
377 final ByteBuf buf = Unpooled.buffer();
378 parser.serializeObject(builder.build(), buf);
379 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
382 parser.parseObject(new ObjectHeaderImpl(true, true), null);
384 } catch (final IllegalArgumentException e) {
385 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
388 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
390 } catch (final IllegalArgumentException e) {
391 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
396 public void testRRObject() throws Exception {
397 final PCEPReportedRouteObjectParser parser =
398 new PCEPReportedRouteObjectParser(ctx.getRROSubobjectHandlerRegistry());
399 final ByteBuf result =
400 Unpooled.wrappedBuffer(
401 ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin"));
402 final byte[] ip6PrefixBytes = {
403 (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
404 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
407 final RroBuilder builder = new RroBuilder();
408 builder.setProcessingRule(false);
409 builder.setIgnore(false);
410 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
411 .route.object.rro.Subobject> subs = new ArrayList<>();
412 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
413 .route.object.rro.SubobjectBuilder().setSubobjectType(
414 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record
415 .route.subobjects.subobject.type.IpPrefixCaseBuilder().setIpPrefix(
416 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record
417 .route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder().setIpPrefix(
418 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build())
419 .setProtectionAvailable(false).setProtectionInUse(false).build());
420 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
421 .route.object.rro.SubobjectBuilder().setSubobjectType(
422 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record.route
423 .subobjects.subobject.type.IpPrefixCaseBuilder().setIpPrefix(
424 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record
425 .route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder().setIpPrefix(
426 new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22))).build()).build())
427 .setProtectionAvailable(false).setProtectionInUse(false).build());
428 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
429 .route.object.rro.SubobjectBuilder().setSubobjectType(
430 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record
431 .route.subobjects.subobject.type.UnnumberedCaseBuilder().setUnnumbered(
432 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820._record
433 .route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder()
434 .setRouterId(Uint32.valueOf(0x1245678L)).setInterfaceId(Uint32.valueOf(0x9abcdef0L))
437 .setProtectionAvailable(false).setProtectionInUse(false).build());
438 builder.setSubobject(subs);
440 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
441 result.slice(4, result.readableBytes() - 4)));
442 final ByteBuf buf = Unpooled.buffer();
443 parser.serializeObject(builder.build(), buf);
444 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
447 parser.parseObject(new ObjectHeaderImpl(true, true), null);
449 } catch (final IllegalArgumentException e) {
450 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
453 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
455 } catch (final IllegalArgumentException e) {
456 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
461 public void testBandwidthObject() throws IOException, PCEPDeserializerException {
462 final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser();
463 final ByteBuf result =
464 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin"));
466 final BandwidthBuilder builder = new BandwidthBuilder();
467 builder.setProcessingRule(true);
468 builder.setIgnore(true);
469 builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
471 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
472 result.slice(4, result.readableBytes() - 4)));
473 final ByteBuf buf = Unpooled.buffer();
474 parser.serializeObject(builder.build(), buf);
475 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
478 parser.parseObject(new ObjectHeaderImpl(true, true), null);
480 } catch (final IllegalArgumentException e) {
481 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
484 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
486 } catch (final IllegalArgumentException e) {
487 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
492 public void testExistingBandwidthObject() throws IOException, PCEPDeserializerException {
493 final PCEPExistingBandwidthObjectParser parser = new PCEPExistingBandwidthObjectParser();
494 final ByteBuf result =
495 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject2UpperBounds.bin"));
497 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization
498 .bandwidth.object.ReoptimizationBandwidthBuilder builder = new org.opendaylight.yang.gen.v1
499 .urn.opendaylight.params.xml
500 .ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidthBuilder();
501 builder.setProcessingRule(true);
502 builder.setIgnore(true);
503 builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }));
505 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
506 result.slice(4, result.readableBytes() - 4)));
507 final ByteBuf buf = Unpooled.buffer();
508 parser.serializeObject(builder.build(), buf);
509 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
512 parser.parseObject(new ObjectHeaderImpl(true, true), null);
514 } catch (final IllegalArgumentException e) {
515 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
518 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
520 } catch (final IllegalArgumentException e) {
521 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
526 public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException {
527 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
528 final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
530 final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser();
532 = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject1IPv4.bin"));
534 final EndpointsObjBuilder builder = new EndpointsObjBuilder()
535 .setProcessingRule(true)
537 .setAddressFamily(new Ipv4CaseBuilder()
538 .setIpv4(new Ipv4Builder()
539 .setSourceIpv4Address(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
540 .setDestinationIpv4Address(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(destIPBytes)))
544 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
545 result.slice(4, result.readableBytes() - 4)));
546 final ByteBuf buf = Unpooled.buffer();
547 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
548 serializer.serializeObject(builder.build(), buf);
549 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
552 parser.parseObject(new ObjectHeaderImpl(true, true), null);
554 } catch (final IllegalArgumentException e) {
555 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
558 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
560 } catch (final IllegalArgumentException e) {
561 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
567 public void testEndPointsObjectP2MPIPv4() throws PCEPDeserializerException {
568 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
569 final byte[] destIPBytes = {
570 (byte) 0x04, (byte) 0x32, (byte) 0x00, (byte) 0x14,
571 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
572 (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E,
573 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
574 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFC};
576 final PCEPP2MPEndPointsIpv4ObjectParser parser = new PCEPP2MPEndPointsIpv4ObjectParser();
577 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
579 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
580 builder.setProcessingRule(true);
581 builder.setIgnore(false);
582 builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(new P2mpIpv4Builder()
583 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
584 .setSourceIpv4Address(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
585 .setDestinationIpv4Address(ImmutableSet.of(new Ipv4AddressNoZone("255.255.255.255"),
586 new Ipv4AddressNoZone("255.255.255.252"))).build()).build());
588 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
589 result.slice(4, result.readableBytes() - 4)));
590 final ByteBuf buf = Unpooled.buffer();
591 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
592 serializer.serializeObject(builder.build(), buf);
593 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
596 parser.parseObject(new ObjectHeaderImpl(true, true), null);
598 } catch (final IllegalArgumentException e) {
599 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
602 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
604 } catch (final IllegalArgumentException e) {
605 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
610 public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException {
611 final byte[] destIPBytes = {
612 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
613 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
615 final byte[] srcIPBytes = {
616 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
617 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF
620 final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser();
621 final ByteBuf result =
622 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject2IPv6.bin"));
624 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
625 builder.setProcessingRule(true);
626 builder.setIgnore(false);
627 builder.setAddressFamily(new Ipv6CaseBuilder().setIpv6(
628 new Ipv6Builder().setSourceIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
629 .setDestinationIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(destIPBytes)))
632 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
633 result.slice(4, result.readableBytes() - 4)));
634 final ByteBuf buf = Unpooled.buffer();
635 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
636 serializer.serializeObject(builder.build(), buf);
637 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
640 parser.parseObject(new ObjectHeaderImpl(true, true), null);
642 } catch (final IllegalArgumentException e) {
643 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
646 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
648 } catch (final IllegalArgumentException e) {
649 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
654 public void testEndPointsObjectP2MPIPv6() throws IOException, PCEPDeserializerException {
655 final byte[] destIPBytes = {
656 (byte) 0x04, (byte) 0x42, (byte) 0x00, (byte) 0x38,
657 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
658 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
659 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
660 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2,
661 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
662 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
663 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
664 (byte) 0x00, (byte) 0x03, (byte) 0x5D, (byte) 0xD2,
665 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
666 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
667 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
669 final byte[] srcIPBytes = {
670 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
671 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF
674 final PCEPP2MPEndPointsIpv6ObjectParser parser = new PCEPP2MPEndPointsIpv6ObjectParser();
675 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
677 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
678 builder.setProcessingRule(true);
679 builder.setIgnore(false);
680 builder.setAddressFamily(new P2mpIpv6CaseBuilder().setP2mpIpv6(new P2mpIpv6Builder()
681 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
682 .setSourceIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
683 .setDestinationIpv6Address(ImmutableSet.of(
684 new Ipv6AddressNoZone("2:5dd2:ffec:a1b6:581e:9f50::"),
685 new Ipv6AddressNoZone("3:5dd2:ffec:a1b6:581e:9f50::")
686 )).build()).build());
688 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
689 result.slice(4, result.readableBytes() - 4)));
690 final ByteBuf buf = Unpooled.buffer();
691 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
692 serializer.serializeObject(builder.build(), buf);
693 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
696 parser.parseObject(new ObjectHeaderImpl(true, true), null);
698 } catch (final IllegalArgumentException e) {
699 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
702 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
704 } catch (final IllegalArgumentException e) {
705 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
710 public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
711 final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(tlvRegistry, viTlvRegistry);
713 final ErrorObjectBuilder builder = new ErrorObjectBuilder()
714 .setProcessingRule(true)
717 .setValue(Uint8.ONE);
719 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
720 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
721 result.slice(4, result.readableBytes() - 4)));
722 ByteBuf buf = Unpooled.buffer();
723 parser.serializeObject(builder.build(), buf);
724 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
726 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
728 builder.setType(Uint8.valueOf(7))
729 .setValue(Uint8.ZERO)
730 .setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder()
731 .setRequestId(new RequestId(Uint32.valueOf(0x00001155L)))
735 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
736 result.slice(4, result.readableBytes() - 4)));
737 buf = Unpooled.buffer();
738 parser.serializeObject(builder.build(), buf);
739 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
742 parser.parseObject(new ObjectHeaderImpl(true, true), null);
744 } catch (final IllegalArgumentException e) {
745 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
748 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
750 } catch (final IllegalArgumentException e) {
751 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
756 public void testLspaObject() throws IOException, PCEPDeserializerException {
757 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(tlvRegistry, viTlvRegistry);
759 final LspaBuilder builder = new LspaBuilder()
760 .setProcessingRule(true)
762 .setExcludeAny(new AttributeFilter(Uint32.ZERO))
763 .setIncludeAny(new AttributeFilter(Uint32.ZERO))
764 .setIncludeAll(new AttributeFilter(Uint32.ZERO))
765 .setHoldPriority(Uint8.ZERO)
766 .setSetupPriority(Uint8.ZERO)
767 .setLocalProtectionDesired(false)
768 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa
769 .object.lspa.TlvsBuilder().build());
772 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
773 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
774 result.slice(4, result.readableBytes() - 4)));
775 ByteBuf buf = Unpooled.buffer();
776 parser.serializeObject(builder.build(), buf);
777 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
779 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject2UpperBounds.bin"));
781 builder.setExcludeAny(new AttributeFilter(Uint32.MAX_VALUE))
782 .setIncludeAny(new AttributeFilter(Uint32.MAX_VALUE))
783 .setIncludeAll(new AttributeFilter(Uint32.MAX_VALUE))
784 .setHoldPriority(Uint8.MAX_VALUE)
785 .setSetupPriority(Uint8.MAX_VALUE)
786 .setLocalProtectionDesired(true);
788 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
789 result.slice(4, result.readableBytes() - 4)));
790 buf = Unpooled.buffer();
791 parser.serializeObject(builder.build(), buf);
792 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
795 parser.parseObject(new ObjectHeaderImpl(true, true), null);
797 } catch (final IllegalArgumentException e) {
798 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
801 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
803 } catch (final IllegalArgumentException e) {
804 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
809 public void testMetricObject() throws IOException, PCEPDeserializerException {
810 final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
812 final MetricBuilder builder = new MetricBuilder()
813 .setProcessingRule(true)
817 .setMetricType(Uint8.ONE)
818 .setValue(new Float32(new byte[] { 0, 0, 0, 0 }));
821 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));
822 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
823 result.slice(4, result.readableBytes() - 4)));
824 ByteBuf buf = Unpooled.buffer();
825 parser.serializeObject(builder.build(), buf);
826 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
828 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));
830 builder.setComputed(true)
832 .setMetricType(Uint8.TWO)
833 .setValue(new Float32(new byte[] { (byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00 }));
835 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
836 result.slice(4, result.readableBytes() - 4)));
837 buf = Unpooled.buffer();
838 parser.serializeObject(builder.build(), buf);
839 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
842 parser.parseObject(new ObjectHeaderImpl(true, true), null);
844 } catch (final IllegalArgumentException e) {
845 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
848 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
850 } catch (final IllegalArgumentException e) {
851 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
856 public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
857 final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(tlvRegistry, viTlvRegistry);
859 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
861 final NoPathBuilder builder = new NoPathBuilder()
862 .setProcessingRule(true)
864 .setNatureOfIssue(Uint8.ONE)
865 .setUnsatisfiedConstraints(true)
866 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep
867 .message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
869 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
870 result.slice(4, result.readableBytes() - 4)));
871 ByteBuf buf = Unpooled.buffer();
872 parser.serializeObject(builder.build(), buf);
873 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
875 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject2WithTLV.bin"));
877 builder.setNatureOfIssue(Uint8.ZERO);
878 builder.setUnsatisfiedConstraints(false);
880 final NoPathVectorBuilder b = new NoPathVectorBuilder();
881 b.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
882 .NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true));
883 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
884 .pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().setNoPathVector(
887 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
888 result.slice(4, result.readableBytes() - 4)));
889 buf = Unpooled.buffer();
890 parser.serializeObject(builder.build(), buf);
891 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
894 parser.parseObject(new ObjectHeaderImpl(true, true), null);
896 } catch (final IllegalArgumentException e) {
897 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
900 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
902 } catch (final IllegalArgumentException e) {
903 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
908 public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
909 final PCEPNotificationObjectParser parser =
910 new PCEPNotificationObjectParser(tlvRegistry, viTlvRegistry);
912 final CNotificationBuilder builder = new CNotificationBuilder()
913 .setProcessingRule(true)
915 .setType(Uint8.MAX_VALUE)
916 .setValue(Uint8.MAX_VALUE);
919 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));
920 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
921 result.slice(4, result.readableBytes() - 4)));
922 ByteBuf buf = Unpooled.buffer();
923 parser.serializeObject(builder.build(), buf);
924 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
926 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject1WithTlv.bin"));
928 builder.setType(Uint8.TWO)
930 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
931 .notification.object.c.notification.TlvsBuilder().setOverloadDuration(
932 new OverloadDurationBuilder().setDuration(Uint32.valueOf(0xff0000a2L)).build()).build());
934 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
935 result.slice(4, result.readableBytes() - 4)));
936 buf = Unpooled.buffer();
937 parser.serializeObject(builder.build(), buf);
938 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
941 parser.parseObject(new ObjectHeaderImpl(true, true), null);
943 } catch (final IllegalArgumentException e) {
944 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
947 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
949 } catch (final IllegalArgumentException e) {
950 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
955 public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
956 final PCEPRequestParameterObjectParser parser =
957 new PCEPRequestParameterObjectParser(tlvRegistry, viTlvRegistry);
959 final RpBuilder builder = new RpBuilder()
960 .setProcessingRule(true)
962 .setReoptimization(true)
963 .setBiDirectional(false)
965 .setMakeBeforeBreak(true)
969 .setFragmentation(false)
971 .setEroCompression(false)
972 .setPriority(Uint8.valueOf(5))
973 .setRequestId(new RequestId(Uint32.valueOf(0xdeadbeefL)))
974 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
975 .object.rp.TlvsBuilder().build());
977 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
978 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
979 result.slice(4, result.readableBytes() - 4)));
980 ByteBuf buf = Unpooled.buffer();
981 parser.serializeObject(builder.build(), buf);
982 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
984 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
986 builder.setReoptimization(false);
987 builder.setFragmentation(true);
988 builder.setEroCompression(true);
990 final OrderBuilder b = new OrderBuilder()
991 .setDelete(Uint32.valueOf(0xffffffffL))
992 .setSetup(Uint32.ONE);
994 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
995 .object.rp.TlvsBuilder().setOrder(b.build()).build());
997 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
998 result.slice(4, result.readableBytes() - 4)));
999 buf = Unpooled.buffer();
1000 parser.serializeObject(builder.build(), buf);
1001 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1004 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1006 } catch (final IllegalArgumentException e) {
1007 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1010 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1012 } catch (final IllegalArgumentException e) {
1013 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1018 public void testSvecObject() throws IOException, PCEPDeserializerException {
1019 final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
1021 final SvecBuilder builder = new SvecBuilder()
1022 .setProcessingRule(false)
1024 .setLinkDiverse(false)
1025 .setNodeDiverse(false)
1026 .setSrlgDiverse(false)
1027 .setPartialPathDiverse(false)
1028 .setLinkDirectionDiverse(false)
1029 .setRequestsIds(Set.of(new RequestId(Uint32.valueOf(0xFF))));
1031 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
1032 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1033 result.slice(4, result.readableBytes() - 4)));
1034 ByteBuf buf = Unpooled.buffer();
1035 parser.serializeObject(builder.build(), buf);
1036 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1038 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
1040 builder.setProcessingRule(true);
1041 builder.setLinkDiverse(true);
1042 builder.setSrlgDiverse(true);
1044 builder.setRequestsIds(ImmutableSet.of(
1045 // Order is important for assertion
1046 new RequestId(Uint32.valueOf(0xFFFFFFFFL)),
1047 new RequestId(Uint32.valueOf(0x00000001L)),
1048 new RequestId(Uint32.valueOf(0x01234567L)),
1049 new RequestId(Uint32.valueOf(0x89ABCDEFL)),
1050 new RequestId(Uint32.valueOf(0xFEDCBA98L)),
1051 new RequestId(Uint32.valueOf(0x76543210L)),
1052 new RequestId(Uint32.valueOf(0x15825266L)),
1053 new RequestId(Uint32.valueOf(0x48120BBEL)),
1054 new RequestId(Uint32.valueOf(0x25FB7E52L)),
1055 new RequestId(Uint32.valueOf(0xB2F2546BL))));
1057 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1058 result.slice(4, result.readableBytes() - 4)));
1059 buf = Unpooled.buffer();
1060 parser.serializeObject(builder.build(), buf);
1061 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1064 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1066 } catch (final IllegalArgumentException e) {
1067 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1070 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1072 } catch (final IllegalArgumentException e) {
1073 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1078 public void testClassTypeObject() throws PCEPDeserializerException {
1079 final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
1080 final ByteBuf result = Unpooled.wrappedBuffer(new byte[] {
1081 (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });
1083 final ClassTypeBuilder builder = new ClassTypeBuilder()
1084 .setProcessingRule(true)
1086 .setClassType(new ClassType(Uint8.valueOf(4)));
1088 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1089 result.slice(4, result.readableBytes() - 4)));
1090 final ByteBuf buf = Unpooled.buffer();
1091 parser.serializeObject(builder.build(), buf);
1092 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1095 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1097 } catch (final IllegalArgumentException e) {
1098 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1101 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1103 } catch (final IllegalArgumentException e) {
1104 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1109 public void testExcludeRouteObject() throws Exception {
1110 final PCEPExcludeRouteObjectParser parser =
1111 new PCEPExcludeRouteObjectParser(ctx.getXROSubobjectHandlerRegistry());
1112 final ByteBuf result =
1113 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPExcludeRouteObject.1.bin"));
1115 final XroBuilder builder = new XroBuilder();
1116 builder.setProcessingRule(false);
1117 builder.setIgnore(false);
1118 builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
1119 .exclude.route.object.Xro.Flags(true));
1120 final List<Subobject> subs = new ArrayList<>();
1121 subs.add(new SubobjectBuilder()
1123 .setSubobjectType(new IpPrefixCaseBuilder()
1124 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("192.168.0.0/16"))).build())
1126 .setAttribute(Attribute.Node).build());
1127 subs.add(new SubobjectBuilder()
1128 .setMandatory(false)
1129 .setSubobjectType(new AsNumberCaseBuilder()
1130 .setAsNumber(new AsNumberBuilder()
1131 .setAsNumber(new AsNumber(Uint32.valueOf(0x1234L)))
1135 builder.setSubobject(subs);
1137 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1138 result.slice(4, result.readableBytes() - 4)));
1139 final ByteBuf buf = Unpooled.buffer();
1140 parser.serializeObject(builder.build(), buf);
1141 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1144 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1146 } catch (final IllegalArgumentException e) {
1147 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1150 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1152 } catch (final IllegalArgumentException e) {
1153 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1158 public void testPathKeyObject() throws Exception {
1159 final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(ctx.getEROSubobjectHandlerRegistry());
1160 final ByteBuf result =
1161 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPPathKeyObject.bin"));
1163 final PathKeyBuilder builder = new PathKeyBuilder();
1164 builder.setProcessingRule(true);
1165 builder.setIgnore(false);
1166 final List<PathKeys> list = new ArrayList<>();
1167 list.add(new PathKeysBuilder().setLoose(true).setPathKey(new PathKey(Uint16.valueOf(0x1234)))
1168 .setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })).build());
1169 builder.setPathKeys(list);
1171 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1172 result.slice(4, result.readableBytes() - 4)));
1173 final ByteBuf buf = Unpooled.buffer();
1174 parser.serializeObject(builder.build(), buf);
1175 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1178 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1180 } catch (final IllegalArgumentException e) {
1181 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1184 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1186 } catch (final IllegalArgumentException e) {
1187 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1192 public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
1193 final PCEPObjectiveFunctionObjectParser parser =
1194 new PCEPObjectiveFunctionObjectParser(tlvRegistry, viTlvRegistry);
1195 final ByteBuf result =
1196 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin"));
1198 final OfBuilder builder = new OfBuilder()
1199 .setProcessingRule(true)
1201 .setCode(new OfId(Uint16.valueOf(4)))
1202 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of
1203 .object.of.TlvsBuilder().build());
1205 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1206 result.slice(4, result.readableBytes() - 4)));
1207 final ByteBuf buf = Unpooled.buffer();
1208 parser.serializeObject(builder.build(), buf);
1209 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1212 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1214 } catch (final IllegalArgumentException e) {
1215 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1218 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1220 } catch (final IllegalArgumentException e) {
1221 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1226 public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
1227 final PCEPGlobalConstraintsObjectParser parser =
1228 new PCEPGlobalConstraintsObjectParser(tlvRegistry, viTlvRegistry);
1229 final ByteBuf result =
1230 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin"));
1232 final GcBuilder builder = new GcBuilder()
1233 .setProcessingRule(true)
1235 .setMaxHop(Uint8.ONE)
1236 .setMaxUtilization(Uint8.ZERO)
1237 .setMinUtilization(Uint8.valueOf(100))
1238 .setOverBookingFactor(Uint8.valueOf(99))
1239 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc
1240 .object.gc.TlvsBuilder().build());
1242 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1243 result.slice(4, result.readableBytes() - 4)));
1244 final ByteBuf buf = Unpooled.buffer();
1245 parser.serializeObject(builder.build(), buf);
1246 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1249 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1251 } catch (final IllegalArgumentException e) {
1252 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1255 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1257 } catch (final IllegalArgumentException e) {
1258 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1263 public void testIgnoreUknownObject() throws PCEPDeserializerException {
1264 final Object object =
1265 ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
1270 public void testUnrecognizedObjectType() throws PCEPDeserializerException {
1271 final Object object =
1272 ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
1273 assertNotNull(object);
1274 assertTrue(object instanceof UnknownObject);
1275 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_TYPE, ((UnknownObject) object).getError());
1279 public void testUnrecognizedObjectClass() throws PCEPDeserializerException {
1280 final Object object = ctx.getObjectHandlerRegistry()
1281 .parseObject(35, 1, new ObjectHeaderImpl(true, true), null);
1282 assertNotNull(object);
1283 assertTrue(object instanceof UnknownObject);
1284 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_CLASS, ((UnknownObject) object).getError());
1288 public void testLspaObjectSerializerDefence() throws IOException {
1289 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(tlvRegistry, viTlvRegistry);
1290 final ByteBuf result =
1291 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
1293 final LspaBuilder builder = new LspaBuilder();
1294 builder.setProcessingRule(true);
1295 builder.setIgnore(true);
1296 builder.setLocalProtectionDesired(false);
1298 final ByteBuf buf = Unpooled.buffer(result.readableBytes());
1299 parser.serializeObject(builder.build(), buf);
1300 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1304 public void testEmptyEroObject() throws PCEPDeserializerException {
1305 final Object object = ctx.getObjectHandlerRegistry().parseObject(7, 1,
1306 new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1307 assertNotNull(object);
1308 assertTrue(object instanceof Ero);
1309 final Ero eroObject = (Ero) object;
1310 assertNull(eroObject.getSubobject());
1312 final ByteBuf buffer = Unpooled.buffer();
1313 ctx.getObjectHandlerRegistry().serializeObject(eroObject, buffer);
1314 final byte[] expected = {0x07, 0x13, 0x00, 0x04};
1315 assertArrayEquals(expected, ByteArray.getAllBytes(buffer));
1319 public void testCloseObjectWithVendorInformationTlv() throws PCEPDeserializerException {
1320 final byte[] closeBytes = {
1321 0x0f, 0x10, 0x00, 0x14,
1322 0x00, 0x00, 0x00, 0x05,
1323 /* vendor-information TLV */
1324 0x00, 0x07, 0x00, 0x08,
1325 /* enterprise number */
1326 0x00, 0x00, 0x00, 0x00,
1327 /* enterprise specific information */
1328 0x00, 0x00, 0x00, 0x05
1330 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(tlvRegistry, viTlvRegistry);
1331 final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
1333 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1334 final VendorInformationTlv viTlv = new VendorInformationTlvBuilder()
1335 .setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO))
1336 .setEnterpriseSpecificInformation(esInfo).build();
1337 final CCloseBuilder builder = new CCloseBuilder()
1338 .setProcessingRule(false)
1340 .setReason(Uint8.valueOf(5))
1341 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close
1342 .object.c.close.TlvsBuilder().setVendorInformationTlv(Lists.newArrayList(viTlv)).build());
1344 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1345 result.slice(4, result.readableBytes() - 4)));
1347 final ByteBuf buf = Unpooled.buffer();
1348 parser.serializeObject(builder.build(), buf);
1349 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1353 public void testVendorInformationObject() throws PCEPDeserializerException {
1354 final byte[] viObjBytes = {
1355 /* vendor-information object */
1356 0x22, 0x10, 0x00, 0x0C,
1357 /* enterprise number */
1358 0x00, 0x00, 0x00, 0x00,
1359 /* enterprise specific information */
1360 0x00, 0x00, 0x00, 0x05
1362 final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
1363 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1364 final VendorInformationObject viObj = new VendorInformationObjectBuilder()
1365 .setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO))
1366 .setEnterpriseSpecificInformation(esInfo).build();
1367 final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
1368 result.readerIndex(8);
1369 final VendorInformationObject o = (VendorInformationObject) parser.parseObject(
1370 new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
1371 assertEquals(viObj, o);
1373 final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
1374 parser.serializeObject(viObj, buf);
1375 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1379 public void testMonitoringObject() throws PCEPDeserializerException {
1380 final byte[] monitoringBytes = {
1382 0x13, 0x10, 0x00, 0x0C,
1384 0x00, 0x00, 0x00, 0x01,
1385 /* monitoring-id=16 */
1386 0x00, 0x00, 0x00, 0x10
1388 final PCEPMonitoringObjectParser parser = new PCEPMonitoringObjectParser(tlvRegistry, viTlvRegistry);
1389 final Monitoring monitoring = new MonitoringBuilder()
1390 .setMonitoringId(Uint32.valueOf(16L))
1391 .setFlags(new Flags(false, false, true, false, false))
1392 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
1393 .monitoring.object.monitoring.TlvsBuilder().build()).build();
1394 final ByteBuf result = Unpooled.wrappedBuffer(monitoringBytes);
1395 assertEquals(monitoring, parser.parseObject(new ObjectHeaderImpl(false, false),
1396 result.slice(4, result.readableBytes() - 4)));
1398 final ByteBuf buf = Unpooled.buffer(monitoringBytes.length);
1399 parser.serializeObject(monitoring, buf);
1400 assertArrayEquals(monitoringBytes, buf.array());
1404 public void testPccIdReqIPv4Object() throws PCEPDeserializerException {
1405 final byte[] pccIdReqBytes = {
1407 0x14, 0x10, 0x00, 0x08,
1409 0x7f, 0x00, 0x00, 0x01
1411 final PCEPPccIdReqIPv4ObjectParser parser = new PCEPPccIdReqIPv4ObjectParser();
1412 final PccIdReq pccIdReq =
1413 new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).build();
1414 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1415 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1416 result.slice(4, result.readableBytes() - 4)));
1418 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1419 parser.serializeObject(pccIdReq, buf);
1420 assertArrayEquals(pccIdReqBytes, buf.array());
1424 public void testPccIdReqIPv6Object() throws PCEPDeserializerException {
1425 final byte[] pccIdReqBytes = {
1427 0x14, 0x20, 0x00, 0x14,
1429 0x00, 0x00, 0x00, 0x00,
1430 0x00, 0x00, 0x00, 0x00,
1431 0x00, 0x00, 0x00, 0x00,
1432 0x00, 0x00, 0x00, 0x01
1434 final PCEPPccIdReqIPv6ObjectParser parser = new PCEPPccIdReqIPv6ObjectParser();
1435 final PccIdReq pccIdReq =
1436 new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("::1"))).build();
1437 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1438 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1439 result.slice(4, result.readableBytes() - 4)));
1441 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1442 parser.serializeObject(pccIdReq, buf);
1443 assertArrayEquals(pccIdReqBytes, buf.array());
1447 public void testPceIdIPv4Object() throws PCEPDeserializerException {
1448 final byte[] pccIdReqBytes = {
1450 0x19, 0x10, 0x00, 0x08,
1452 0x7f, 0x00, 0x00, 0x01
1454 final PCEPPceIdIPv4ObjectParser parser = new PCEPPceIdIPv4ObjectParser();
1455 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1456 .PceId pceId = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1457 new Ipv4AddressNoZone("127.0.0.1"))).build();
1458 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1459 assertEquals(pceId, parser.parseObject(new ObjectHeaderImpl(false, false),
1460 result.slice(4, result.readableBytes() - 4)));
1462 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1463 parser.serializeObject(pceId, buf);
1464 assertArrayEquals(pccIdReqBytes, buf.array());
1468 public void testPceIdIPv6Object() throws PCEPDeserializerException {
1469 final byte[] pccIdReqBytes = {
1471 0x19, 0x20, 0x00, 0x14,
1473 0x00, 0x00, 0x00, 0x00,
1474 0x00, 0x00, 0x00, 0x00,
1475 0x00, 0x00, 0x00, 0x00,
1476 0x00, 0x00, 0x00, 0x01
1478 final PCEPPceIdIPv6ObjectParser parser = new PCEPPceIdIPv6ObjectParser();
1479 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1480 .PceId pccIdReq = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1481 new Ipv6AddressNoZone("::1"))).build();
1482 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1483 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1484 result.slice(4, result.readableBytes() - 4)));
1486 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1487 parser.serializeObject(pccIdReq, buf);
1488 assertArrayEquals(pccIdReqBytes, buf.array());
1492 public void testProcTimeObject() throws PCEPDeserializerException {
1493 final byte[] proctimeBytes = {
1495 0x1A, 0x10, 0x00, 0x1C,
1497 0x00, 0x00, 0x00, 0x01,
1498 /* current proc. time */
1499 0x00, 0x00, 0x00, 0x01,
1500 /* min proc. time */
1501 0x00, 0x00, 0x00, 0x02,
1503 0x00, 0x00, 0x00, 0x03,
1504 /* average proc time */
1505 0x00, 0x00, 0x00, 0x04,
1506 /* variance proc time */
1507 0x00, 0x00, 0x00, 0x05,
1509 final PCEPProcTimeObjectParser parser = new PCEPProcTimeObjectParser();
1510 final ProcTime procTime = new ProcTimeBuilder()
1512 .setAverageProcTime(Uint32.valueOf(4))
1513 .setCurrentProcTime(Uint32.ONE)
1514 .setMaxProcTime(Uint32.valueOf(3))
1515 .setMinProcTime(Uint32.TWO)
1516 .setVarianceProcTime(Uint32.valueOf(5))
1518 final ByteBuf result = Unpooled.wrappedBuffer(proctimeBytes);
1519 assertEquals(procTime, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4,
1520 result.readableBytes() - 4)));
1522 final ByteBuf buf = Unpooled.buffer(proctimeBytes.length);
1523 parser.serializeObject(procTime, buf);
1524 assertArrayEquals(proctimeBytes, buf.array());
1528 public void testOverloadObject() throws PCEPDeserializerException {
1529 final byte[] overloadBytes = {
1531 0x1B, 0x10, 0x00, 0x08,
1532 /* overload duration */
1533 0x00, 0x00, 0x00, 0x78
1535 final PCEPOverloadObjectParser parser = new PCEPOverloadObjectParser();
1536 final Overload overload = new OverloadBuilder().setDuration(Uint16.valueOf(120)).build();
1537 final ByteBuf result = Unpooled.wrappedBuffer(overloadBytes);
1538 assertEquals(overload, parser.parseObject(new ObjectHeaderImpl(false, false),
1539 result.slice(4, result.readableBytes() - 4)));
1541 final ByteBuf buf = Unpooled.buffer(overloadBytes.length);
1542 parser.serializeObject(overload, buf);
1543 assertArrayEquals(overloadBytes, buf.array());
1547 public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
1549 final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde,
1550 (byte) 0xad, (byte) 0xbe, (byte) 0xef,
1552 0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
1554 final PCEPRequestParameterObjectParser parser
1555 = new PCEPRequestParameterObjectParser(tlvRegistry, viTlvRegistry);
1556 final RpBuilder builder = new RpBuilder()
1557 .setProcessingRule(false)
1559 .setReoptimization(true)
1560 .setBiDirectional(false)
1562 .setMakeBeforeBreak(true)
1566 .setFragmentation(false)
1568 .setEroCompression(false)
1569 .setPriority(Uint8.valueOf(5))
1570 .setRequestId(new RequestId(Uint32.valueOf(0xdeadbeefL)))
1571 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
1572 .object.rp.TlvsBuilder()
1573 .setPathSetupType(new PathSetupTypeBuilder().setPst(Uint8.ZERO)
1577 final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
1578 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1579 result.slice(4, result.readableBytes() - 4)));
1580 final ByteBuf buf = Unpooled.buffer();
1581 parser.serializeObject(builder.build(), buf);
1582 assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
1586 public void testBranchNodeListObject() throws Exception {
1587 final byte[] expected = {
1588 0x1f, 0x10, 0x0, 0xc,
1590 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1593 final BranchNodeListObjectParser parser
1594 = new BranchNodeListObjectParser(ctx.getEROSubobjectHandlerRegistry());
1595 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1597 final BranchNodeListBuilder builder = new BranchNodeListBuilder();
1598 builder.setProcessingRule(false);
1599 builder.setIgnore(false);
1600 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1601 .route.object.ero.Subobject> subs = new ArrayList<>();
1602 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1603 .route.object.ero.SubobjectBuilder()
1605 .setSubobjectType(new IpPrefixCaseBuilder()
1606 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1607 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1608 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1610 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1611 result.slice(4, result.readableBytes() - 4)));
1612 final ByteBuf buf = Unpooled.buffer();
1613 parser.serializeObject(builder.build(), buf);
1614 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1617 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1619 } catch (final IllegalArgumentException e) {
1620 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1625 public void testNonBranchNodeListObject() throws Exception {
1626 final byte[] expected = {
1627 0x1f, 0x20, 0x0, 0xc,
1629 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1632 final NonBranchNodeListObjectParser parser
1633 = new NonBranchNodeListObjectParser(ctx.getEROSubobjectHandlerRegistry());
1634 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1636 final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
1637 builder.setProcessingRule(false);
1638 builder.setIgnore(false);
1639 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1640 .route.object.ero.Subobject> subs = new ArrayList<>();
1641 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1642 .route.object.ero.SubobjectBuilder()
1644 .setSubobjectType(new IpPrefixCaseBuilder()
1645 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1646 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1647 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1649 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1650 result.slice(4, result.readableBytes() - 4)));
1651 final ByteBuf buf = Unpooled.buffer();
1652 parser.serializeObject(builder.build(), buf);
1653 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1656 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1658 } catch (final IllegalArgumentException e) {
1659 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1664 public void testPCEPIpv4UnreachDestinationObject() throws Exception {
1665 final byte[] expected = {
1666 0x1c, 0x10, 0x0, 0x8,
1667 (byte) 0x7F, (byte) 0x0, (byte) 0x0, (byte) 0x1
1670 final PCEPIpv4UnreachDestinationParser parser = new PCEPIpv4UnreachDestinationParser();
1671 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1672 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1674 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1675 builder.setProcessingRule(false);
1676 builder.setIgnore(false);
1677 final Ipv4DestinationCase dest = new Ipv4DestinationCaseBuilder()
1678 .setDestinationIpv4Address(Set.of(new Ipv4AddressNoZone("127.0.0.1")))
1680 builder.setDestination(dest);
1682 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1683 result.slice(4, result.readableBytes() - 4)));
1684 final ByteBuf buf = Unpooled.buffer();
1685 serializer.serializeObject(builder.build(), buf);
1686 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1689 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1691 } catch (final IllegalArgumentException e) {
1692 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1697 public void testPCEPIpv6UnreachDestinationObject() throws Exception {
1698 final byte[] expected = {
1699 0x1c, 0x20, 0x0, 0x14,
1700 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1701 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1702 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1703 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1
1706 final PCEPIpv6UnreachDestinationParser parser = new PCEPIpv6UnreachDestinationParser();
1707 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1708 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1710 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1711 builder.setProcessingRule(false);
1712 builder.setIgnore(false);
1713 final Ipv6DestinationCase dest = new Ipv6DestinationCaseBuilder()
1714 .setDestinationIpv6Address(Set.of(new Ipv6AddressNoZone("::1")))
1716 builder.setDestination(dest);
1718 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1719 result.slice(4, result.readableBytes() - 4)));
1720 final ByteBuf buf = Unpooled.buffer();
1721 serializer.serializeObject(builder.build(), buf);
1722 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1725 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1727 } catch (final IllegalArgumentException e) {
1728 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());