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.Lists;
18 import io.netty.buffer.ByteBuf;
19 import io.netty.buffer.Unpooled;
20 import java.io.IOException;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.Collections;
24 import java.util.List;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
28 import org.opendaylight.protocol.pcep.parser.BaseParserExtensionActivator;
29 import org.opendaylight.protocol.pcep.parser.object.PCEPBandwidthObjectParser;
30 import org.opendaylight.protocol.pcep.parser.object.PCEPClassTypeObjectParser;
31 import org.opendaylight.protocol.pcep.parser.object.PCEPCloseObjectParser;
32 import org.opendaylight.protocol.pcep.parser.object.PCEPErrorObjectParser;
33 import org.opendaylight.protocol.pcep.parser.object.PCEPExcludeRouteObjectParser;
34 import org.opendaylight.protocol.pcep.parser.object.PCEPExistingBandwidthObjectParser;
35 import org.opendaylight.protocol.pcep.parser.object.PCEPExplicitRouteObjectParser;
36 import org.opendaylight.protocol.pcep.parser.object.PCEPGlobalConstraintsObjectParser;
37 import org.opendaylight.protocol.pcep.parser.object.PCEPIncludeRouteObjectParser;
38 import org.opendaylight.protocol.pcep.parser.object.PCEPLoadBalancingObjectParser;
39 import org.opendaylight.protocol.pcep.parser.object.PCEPLspaObjectParser;
40 import org.opendaylight.protocol.pcep.parser.object.PCEPMetricObjectParser;
41 import org.opendaylight.protocol.pcep.parser.object.PCEPMonitoringObjectParser;
42 import org.opendaylight.protocol.pcep.parser.object.PCEPNoPathObjectParser;
43 import org.opendaylight.protocol.pcep.parser.object.PCEPNotificationObjectParser;
44 import org.opendaylight.protocol.pcep.parser.object.PCEPObjectiveFunctionObjectParser;
45 import org.opendaylight.protocol.pcep.parser.object.PCEPOpenObjectParser;
46 import org.opendaylight.protocol.pcep.parser.object.PCEPOverloadObjectParser;
47 import org.opendaylight.protocol.pcep.parser.object.PCEPPathKeyObjectParser;
48 import org.opendaylight.protocol.pcep.parser.object.PCEPPccIdReqIPv4ObjectParser;
49 import org.opendaylight.protocol.pcep.parser.object.PCEPPccIdReqIPv6ObjectParser;
50 import org.opendaylight.protocol.pcep.parser.object.PCEPPceIdIPv4ObjectParser;
51 import org.opendaylight.protocol.pcep.parser.object.PCEPPceIdIPv6ObjectParser;
52 import org.opendaylight.protocol.pcep.parser.object.PCEPProcTimeObjectParser;
53 import org.opendaylight.protocol.pcep.parser.object.PCEPReportedRouteObjectParser;
54 import org.opendaylight.protocol.pcep.parser.object.PCEPRequestParameterObjectParser;
55 import org.opendaylight.protocol.pcep.parser.object.PCEPSvecObjectParser;
56 import org.opendaylight.protocol.pcep.parser.object.bnc.BNCUtil;
57 import org.opendaylight.protocol.pcep.parser.object.bnc.BranchNodeListObjectParser;
58 import org.opendaylight.protocol.pcep.parser.object.bnc.NonBranchNodeListObjectParser;
59 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv4ObjectParser;
60 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsIpv6ObjectParser;
61 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPEndPointsObjectSerializer;
62 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPP2MPEndPointsIpv4ObjectParser;
63 import org.opendaylight.protocol.pcep.parser.object.end.points.PCEPP2MPEndPointsIpv6ObjectParser;
64 import org.opendaylight.protocol.pcep.parser.object.unreach.PCEPIpv4UnreachDestinationParser;
65 import org.opendaylight.protocol.pcep.parser.object.unreach.PCEPIpv6UnreachDestinationParser;
66 import org.opendaylight.protocol.pcep.parser.object.unreach.PCEPUnreachDestinationSerializer;
67 import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
68 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
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 this.ctx = new SimplePCEPExtensionProviderContext();
178 this.act = new BaseParserExtensionActivator();
179 this.viAct = new TestVendorInformationActivator();
180 this.act.start(this.ctx);
181 this.viAct.start(this.ctx);
182 this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
183 this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
187 public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
188 final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.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(this.tlvRegistry, this.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(this.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(this.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(this.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()).setProtectionAvailable(false)
419 .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.subobjects
423 .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 builder.setProcessingRule(true);
536 builder.setIgnore(false);
537 builder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(
538 new Ipv4Builder().setSourceIpv4Address(Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
539 .setDestinationIpv4Address(
540 Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(destIPBytes))).build()).build());
542 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
543 result.slice(4, result.readableBytes() - 4)));
544 final ByteBuf buf = Unpooled.buffer();
545 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
546 serializer.serializeObject(builder.build(), buf);
547 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
550 parser.parseObject(new ObjectHeaderImpl(true, true), null);
552 } catch (final IllegalArgumentException e) {
553 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
556 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
558 } catch (final IllegalArgumentException e) {
559 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
565 public void testEndPointsObjectP2MPIPv4() throws PCEPDeserializerException {
566 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
567 final byte[] destIPBytes = {
568 (byte) 0x04, (byte) 0x32, (byte) 0x00, (byte) 0x14,
569 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
570 (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E,
571 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
572 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFC};
574 final PCEPP2MPEndPointsIpv4ObjectParser parser = new PCEPP2MPEndPointsIpv4ObjectParser();
575 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
577 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
578 builder.setProcessingRule(true);
579 builder.setIgnore(false);
580 builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(new P2mpIpv4Builder()
581 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
582 .setSourceIpv4Address(Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
583 .setDestinationIpv4Address(Arrays.asList(new Ipv4AddressNoZone("255.255.255.255"),
584 new Ipv4AddressNoZone("255.255.255.252"))).build()).build());
586 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
587 result.slice(4, result.readableBytes() - 4)));
588 final ByteBuf buf = Unpooled.buffer();
589 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
590 serializer.serializeObject(builder.build(), buf);
591 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
594 parser.parseObject(new ObjectHeaderImpl(true, true), null);
596 } catch (final IllegalArgumentException e) {
597 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
600 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
602 } catch (final IllegalArgumentException e) {
603 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
608 public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException {
609 final byte[] destIPBytes = {
610 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
611 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
613 final byte[] srcIPBytes = {
614 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
615 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF
618 final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser();
619 final ByteBuf result =
620 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject2IPv6.bin"));
622 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
623 builder.setProcessingRule(true);
624 builder.setIgnore(false);
625 builder.setAddressFamily(new Ipv6CaseBuilder().setIpv6(
626 new Ipv6Builder().setSourceIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
627 .setDestinationIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(destIPBytes)))
630 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
631 result.slice(4, result.readableBytes() - 4)));
632 final ByteBuf buf = Unpooled.buffer();
633 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
634 serializer.serializeObject(builder.build(), buf);
635 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
638 parser.parseObject(new ObjectHeaderImpl(true, true), null);
640 } catch (final IllegalArgumentException e) {
641 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
644 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
646 } catch (final IllegalArgumentException e) {
647 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
652 public void testEndPointsObjectP2MPIPv6() throws IOException, PCEPDeserializerException {
653 final byte[] destIPBytes = {
654 (byte) 0x04, (byte) 0x42, (byte) 0x00, (byte) 0x38,
655 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
656 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
657 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
658 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2,
659 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
660 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
661 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
662 (byte) 0x00, (byte) 0x03, (byte) 0x5D, (byte) 0xD2,
663 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
664 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
665 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
667 final byte[] srcIPBytes = {
668 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
669 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF
672 final PCEPP2MPEndPointsIpv6ObjectParser parser = new PCEPP2MPEndPointsIpv6ObjectParser();
673 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
675 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
676 builder.setProcessingRule(true);
677 builder.setIgnore(false);
678 builder.setAddressFamily(new P2mpIpv6CaseBuilder().setP2mpIpv6(new P2mpIpv6Builder()
679 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
680 .setSourceIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
681 .setDestinationIpv6Address(Arrays.asList(
682 new Ipv6AddressNoZone("2:5dd2:ffec:a1b6:581e:9f50::"),
683 new Ipv6AddressNoZone("3:5dd2:ffec:a1b6:581e:9f50::")
684 )).build()).build());
686 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
687 result.slice(4, result.readableBytes() - 4)));
688 final ByteBuf buf = Unpooled.buffer();
689 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
690 serializer.serializeObject(builder.build(), buf);
691 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
694 parser.parseObject(new ObjectHeaderImpl(true, true), null);
696 } catch (final IllegalArgumentException e) {
697 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
700 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
702 } catch (final IllegalArgumentException e) {
703 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
708 public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
709 final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
711 final ErrorObjectBuilder builder = new ErrorObjectBuilder()
712 .setProcessingRule(true)
715 .setValue(Uint8.ONE);
717 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
718 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
719 result.slice(4, result.readableBytes() - 4)));
720 ByteBuf buf = Unpooled.buffer();
721 parser.serializeObject(builder.build(), buf);
722 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
724 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
726 builder.setType(Uint8.valueOf(7))
727 .setValue(Uint8.ZERO)
728 .setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder()
729 .setRequestId(new RequestId(Uint32.valueOf(0x00001155L)))
733 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
734 result.slice(4, result.readableBytes() - 4)));
735 buf = Unpooled.buffer();
736 parser.serializeObject(builder.build(), buf);
737 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
740 parser.parseObject(new ObjectHeaderImpl(true, true), null);
742 } catch (final IllegalArgumentException e) {
743 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
746 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
748 } catch (final IllegalArgumentException e) {
749 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
754 public void testLspaObject() throws IOException, PCEPDeserializerException {
755 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
757 final LspaBuilder builder = new LspaBuilder()
758 .setProcessingRule(true)
760 .setExcludeAny(new AttributeFilter(Uint32.ZERO))
761 .setIncludeAny(new AttributeFilter(Uint32.ZERO))
762 .setIncludeAll(new AttributeFilter(Uint32.ZERO))
763 .setHoldPriority(Uint8.ZERO)
764 .setSetupPriority(Uint8.ZERO)
765 .setLocalProtectionDesired(false)
766 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa
767 .object.lspa.TlvsBuilder().build());
770 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
771 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
772 result.slice(4, result.readableBytes() - 4)));
773 ByteBuf buf = Unpooled.buffer();
774 parser.serializeObject(builder.build(), buf);
775 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
777 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject2UpperBounds.bin"));
779 builder.setExcludeAny(new AttributeFilter(Uint32.MAX_VALUE))
780 .setIncludeAny(new AttributeFilter(Uint32.MAX_VALUE))
781 .setIncludeAll(new AttributeFilter(Uint32.MAX_VALUE))
782 .setHoldPriority(Uint8.MAX_VALUE)
783 .setSetupPriority(Uint8.MAX_VALUE)
784 .setLocalProtectionDesired(true);
786 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
787 result.slice(4, result.readableBytes() - 4)));
788 buf = Unpooled.buffer();
789 parser.serializeObject(builder.build(), buf);
790 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
793 parser.parseObject(new ObjectHeaderImpl(true, true), null);
795 } catch (final IllegalArgumentException e) {
796 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
799 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
801 } catch (final IllegalArgumentException e) {
802 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
807 public void testMetricObject() throws IOException, PCEPDeserializerException {
808 final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
810 final MetricBuilder builder = new MetricBuilder()
811 .setProcessingRule(true)
815 .setMetricType(Uint8.ONE)
816 .setValue(new Float32(new byte[] { 0, 0, 0, 0 }));
819 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));
820 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
821 result.slice(4, result.readableBytes() - 4)));
822 ByteBuf buf = Unpooled.buffer();
823 parser.serializeObject(builder.build(), buf);
824 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
826 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));
828 builder.setComputed(true)
830 .setMetricType(Uint8.TWO)
831 .setValue(new Float32(new byte[] { (byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00 }));
833 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
834 result.slice(4, result.readableBytes() - 4)));
835 buf = Unpooled.buffer();
836 parser.serializeObject(builder.build(), buf);
837 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
840 parser.parseObject(new ObjectHeaderImpl(true, true), null);
842 } catch (final IllegalArgumentException e) {
843 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
846 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
848 } catch (final IllegalArgumentException e) {
849 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
854 public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
855 final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
857 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
859 final NoPathBuilder builder = new NoPathBuilder()
860 .setProcessingRule(true)
862 .setNatureOfIssue(Uint8.ONE)
863 .setUnsatisfiedConstraints(true)
864 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep
865 .message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
867 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
868 result.slice(4, result.readableBytes() - 4)));
869 ByteBuf buf = Unpooled.buffer();
870 parser.serializeObject(builder.build(), buf);
871 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
873 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject2WithTLV.bin"));
875 builder.setNatureOfIssue(Uint8.ZERO);
876 builder.setUnsatisfiedConstraints(false);
878 final NoPathVectorBuilder b = new NoPathVectorBuilder();
879 b.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
880 .NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true));
881 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
882 .pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().setNoPathVector(
885 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
886 result.slice(4, result.readableBytes() - 4)));
887 buf = Unpooled.buffer();
888 parser.serializeObject(builder.build(), buf);
889 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
892 parser.parseObject(new ObjectHeaderImpl(true, true), null);
894 } catch (final IllegalArgumentException e) {
895 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
898 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
900 } catch (final IllegalArgumentException e) {
901 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
906 public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
907 final PCEPNotificationObjectParser parser =
908 new PCEPNotificationObjectParser(this.tlvRegistry, this.viTlvRegistry);
910 final CNotificationBuilder builder = new CNotificationBuilder()
911 .setProcessingRule(true)
913 .setType(Uint8.MAX_VALUE)
914 .setValue(Uint8.MAX_VALUE);
917 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));
918 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
919 result.slice(4, result.readableBytes() - 4)));
920 ByteBuf buf = Unpooled.buffer();
921 parser.serializeObject(builder.build(), buf);
922 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
924 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject1WithTlv.bin"));
926 builder.setType(Uint8.TWO)
928 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
929 .notification.object.c.notification.TlvsBuilder().setOverloadDuration(
930 new OverloadDurationBuilder().setDuration(Uint32.valueOf(0xff0000a2L)).build()).build());
932 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
933 result.slice(4, result.readableBytes() - 4)));
934 buf = Unpooled.buffer();
935 parser.serializeObject(builder.build(), buf);
936 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
939 parser.parseObject(new ObjectHeaderImpl(true, true), null);
941 } catch (final IllegalArgumentException e) {
942 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
945 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
947 } catch (final IllegalArgumentException e) {
948 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
953 public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
954 final PCEPRequestParameterObjectParser parser =
955 new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
957 final RpBuilder builder = new RpBuilder()
958 .setProcessingRule(true)
960 .setReoptimization(true)
961 .setBiDirectional(false)
963 .setMakeBeforeBreak(true)
967 .setFragmentation(false)
969 .setEroCompression(false)
970 .setPriority(Uint8.valueOf(5))
971 .setRequestId(new RequestId(Uint32.valueOf(0xdeadbeefL)))
972 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
973 .object.rp.TlvsBuilder().build());
975 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
976 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
977 result.slice(4, result.readableBytes() - 4)));
978 ByteBuf buf = Unpooled.buffer();
979 parser.serializeObject(builder.build(), buf);
980 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
982 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
984 builder.setReoptimization(false);
985 builder.setFragmentation(true);
986 builder.setEroCompression(true);
988 final OrderBuilder b = new OrderBuilder()
989 .setDelete(Uint32.valueOf(0xffffffffL))
990 .setSetup(Uint32.ONE);
992 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
993 .object.rp.TlvsBuilder().setOrder(b.build()).build());
995 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
996 result.slice(4, result.readableBytes() - 4)));
997 buf = Unpooled.buffer();
998 parser.serializeObject(builder.build(), buf);
999 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1002 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1004 } catch (final IllegalArgumentException e) {
1005 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1008 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1010 } catch (final IllegalArgumentException e) {
1011 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1016 public void testSvecObject() throws IOException, PCEPDeserializerException {
1017 final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
1019 final SvecBuilder builder = new SvecBuilder()
1020 .setProcessingRule(false)
1022 .setLinkDiverse(false)
1023 .setNodeDiverse(false)
1024 .setSrlgDiverse(false)
1025 .setPartialPathDiverse(false)
1026 .setLinkDirectionDiverse(false)
1027 .setRequestsIds(Lists.newArrayList(new RequestId(Uint32.valueOf(0xFF))));
1029 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
1030 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1031 result.slice(4, result.readableBytes() - 4)));
1032 ByteBuf buf = Unpooled.buffer();
1033 parser.serializeObject(builder.build(), buf);
1034 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1036 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
1038 builder.setProcessingRule(true);
1039 builder.setLinkDiverse(true);
1040 builder.setSrlgDiverse(true);
1042 final List<RequestId> requestIDs = new ArrayList<>();
1043 requestIDs.add(new RequestId(Uint32.valueOf(0xFFFFFFFFL)));
1044 requestIDs.add(new RequestId(Uint32.valueOf(0x00000001L)));
1045 requestIDs.add(new RequestId(Uint32.valueOf(0x01234567L)));
1046 requestIDs.add(new RequestId(Uint32.valueOf(0x89ABCDEFL)));
1047 requestIDs.add(new RequestId(Uint32.valueOf(0xFEDCBA98L)));
1048 requestIDs.add(new RequestId(Uint32.valueOf(0x76543210L)));
1049 requestIDs.add(new RequestId(Uint32.valueOf(0x15825266L)));
1050 requestIDs.add(new RequestId(Uint32.valueOf(0x48120BBEL)));
1051 requestIDs.add(new RequestId(Uint32.valueOf(0x25FB7E52L)));
1052 requestIDs.add(new RequestId(Uint32.valueOf(0xB2F2546BL)));
1054 builder.setRequestsIds(requestIDs);
1056 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1057 result.slice(4, result.readableBytes() - 4)));
1058 buf = Unpooled.buffer();
1059 parser.serializeObject(builder.build(), buf);
1060 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1063 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1065 } catch (final IllegalArgumentException e) {
1066 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1069 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1071 } catch (final IllegalArgumentException e) {
1072 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1077 public void testClassTypeObject() throws PCEPDeserializerException {
1078 final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
1079 final ByteBuf result = Unpooled.wrappedBuffer(new byte[] {
1080 (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });
1082 final ClassTypeBuilder builder = new ClassTypeBuilder()
1083 .setProcessingRule(true)
1085 .setClassType(new ClassType(Uint8.valueOf(4)));
1087 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1088 result.slice(4, result.readableBytes() - 4)));
1089 final ByteBuf buf = Unpooled.buffer();
1090 parser.serializeObject(builder.build(), buf);
1091 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1094 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1096 } catch (final IllegalArgumentException e) {
1097 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1100 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1102 } catch (final IllegalArgumentException e) {
1103 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1108 public void testExcludeRouteObject() throws Exception {
1109 final PCEPExcludeRouteObjectParser parser =
1110 new PCEPExcludeRouteObjectParser(this.ctx.getXROSubobjectHandlerRegistry());
1111 final ByteBuf result =
1112 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPExcludeRouteObject.1.bin"));
1114 final XroBuilder builder = new XroBuilder();
1115 builder.setProcessingRule(false);
1116 builder.setIgnore(false);
1117 builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
1118 .exclude.route.object.Xro.Flags(true));
1119 final List<Subobject> subs = new ArrayList<>();
1120 subs.add(new SubobjectBuilder()
1122 .setSubobjectType(new IpPrefixCaseBuilder()
1123 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("192.168.0.0/16"))).build())
1125 .setAttribute(Attribute.Node).build());
1126 subs.add(new SubobjectBuilder()
1127 .setMandatory(false)
1128 .setSubobjectType(new AsNumberCaseBuilder()
1129 .setAsNumber(new AsNumberBuilder()
1130 .setAsNumber(new AsNumber(Uint32.valueOf(0x1234L)))
1134 builder.setSubobject(subs);
1136 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1137 result.slice(4, result.readableBytes() - 4)));
1138 final ByteBuf buf = Unpooled.buffer();
1139 parser.serializeObject(builder.build(), buf);
1140 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1143 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1145 } catch (final IllegalArgumentException e) {
1146 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1149 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1151 } catch (final IllegalArgumentException e) {
1152 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1157 public void testPathKeyObject() throws Exception {
1158 final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1159 final ByteBuf result =
1160 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPPathKeyObject.bin"));
1162 final PathKeyBuilder builder = new PathKeyBuilder();
1163 builder.setProcessingRule(true);
1164 builder.setIgnore(false);
1165 final List<PathKeys> list = new ArrayList<>();
1166 list.add(new PathKeysBuilder().setLoose(true).setPathKey(new PathKey(Uint16.valueOf(0x1234)))
1167 .setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })).build());
1168 builder.setPathKeys(list);
1170 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1171 result.slice(4, result.readableBytes() - 4)));
1172 final ByteBuf buf = Unpooled.buffer();
1173 parser.serializeObject(builder.build(), buf);
1174 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1177 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1179 } catch (final IllegalArgumentException e) {
1180 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1183 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1185 } catch (final IllegalArgumentException e) {
1186 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1191 public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
1192 final PCEPObjectiveFunctionObjectParser parser =
1193 new PCEPObjectiveFunctionObjectParser(this.tlvRegistry, this.viTlvRegistry);
1194 final ByteBuf result =
1195 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin"));
1197 final OfBuilder builder = new OfBuilder()
1198 .setProcessingRule(true)
1200 .setCode(new OfId(Uint16.valueOf(4)))
1201 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of
1202 .object.of.TlvsBuilder().build());
1204 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1205 result.slice(4, result.readableBytes() - 4)));
1206 final ByteBuf buf = Unpooled.buffer();
1207 parser.serializeObject(builder.build(), buf);
1208 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1211 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1213 } catch (final IllegalArgumentException e) {
1214 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1217 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1219 } catch (final IllegalArgumentException e) {
1220 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1225 public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
1226 final PCEPGlobalConstraintsObjectParser parser =
1227 new PCEPGlobalConstraintsObjectParser(this.tlvRegistry, this.viTlvRegistry);
1228 final ByteBuf result =
1229 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin"));
1231 final GcBuilder builder = new GcBuilder()
1232 .setProcessingRule(true)
1234 .setMaxHop(Uint8.ONE)
1235 .setMaxUtilization(Uint8.ZERO)
1236 .setMinUtilization(Uint8.valueOf(100))
1237 .setOverBookingFactor(Uint8.valueOf(99))
1238 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc
1239 .object.gc.TlvsBuilder().build());
1241 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1242 result.slice(4, result.readableBytes() - 4)));
1243 final ByteBuf buf = Unpooled.buffer();
1244 parser.serializeObject(builder.build(), buf);
1245 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1248 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1250 } catch (final IllegalArgumentException e) {
1251 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1254 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1256 } catch (final IllegalArgumentException e) {
1257 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1262 public void testIgnoreUknownObject() throws PCEPDeserializerException {
1263 final Object object =
1264 this.ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
1269 public void testUnrecognizedObjectType() throws PCEPDeserializerException {
1270 final Object object =
1271 this.ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
1272 assertNotNull(object);
1273 assertTrue(object instanceof UnknownObject);
1274 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_TYPE, ((UnknownObject) object).getError());
1278 public void testUnrecognizedObjectClass() throws PCEPDeserializerException {
1279 final Object object = this.ctx.getObjectHandlerRegistry()
1280 .parseObject(35, 1, new ObjectHeaderImpl(true, true), null);
1281 assertNotNull(object);
1282 assertTrue(object instanceof UnknownObject);
1283 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_CLASS, ((UnknownObject) object).getError());
1287 public void testLspaObjectSerializerDefence() throws IOException {
1288 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
1289 final ByteBuf result =
1290 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
1292 final LspaBuilder builder = new LspaBuilder();
1293 builder.setProcessingRule(true);
1294 builder.setIgnore(true);
1295 builder.setLocalProtectionDesired(false);
1297 final ByteBuf buf = Unpooled.buffer(result.readableBytes());
1298 parser.serializeObject(builder.build(), buf);
1299 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1303 public void testEmptyEroObject() throws PCEPDeserializerException {
1304 final Object object = this.ctx.getObjectHandlerRegistry().parseObject(7, 1,
1305 new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1306 assertNotNull(object);
1307 assertTrue(object instanceof Ero);
1308 final Ero eroObject = (Ero) object;
1309 assertTrue(eroObject.getSubobject().isEmpty());
1311 final ByteBuf buffer = Unpooled.buffer();
1312 this.ctx.getObjectHandlerRegistry().serializeObject(eroObject, buffer);
1313 final byte[] expected = {0x07, 0x13, 0x00, 0x04};
1314 assertArrayEquals(expected, ByteArray.getAllBytes(buffer));
1318 public void testCloseObjectWithVendorInformationTlv() throws PCEPDeserializerException {
1319 final byte[] closeBytes = {
1320 0x0f, 0x10, 0x00, 0x14,
1321 0x00, 0x00, 0x00, 0x05,
1322 /* vendor-information TLV */
1323 0x00, 0x07, 0x00, 0x08,
1324 /* enterprise number */
1325 0x00, 0x00, 0x00, 0x00,
1326 /* enterprise specific information */
1327 0x00, 0x00, 0x00, 0x05
1329 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
1330 final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
1332 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1333 final VendorInformationTlv viTlv = new VendorInformationTlvBuilder()
1334 .setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO))
1335 .setEnterpriseSpecificInformation(esInfo).build();
1336 final CCloseBuilder builder = new CCloseBuilder()
1337 .setProcessingRule(false)
1339 .setReason(Uint8.valueOf(5))
1340 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close
1341 .object.c.close.TlvsBuilder().setVendorInformationTlv(Lists.newArrayList(viTlv)).build());
1343 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1344 result.slice(4, result.readableBytes() - 4)));
1346 final ByteBuf buf = Unpooled.buffer();
1347 parser.serializeObject(builder.build(), buf);
1348 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1352 public void testVendorInformationObject() throws PCEPDeserializerException {
1353 final byte[] viObjBytes = {
1354 /* vendor-information object */
1355 0x22, 0x10, 0x00, 0x0C,
1356 /* enterprise number */
1357 0x00, 0x00, 0x00, 0x00,
1358 /* enterprise specific information */
1359 0x00, 0x00, 0x00, 0x05
1361 final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
1362 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1363 final VendorInformationObject viObj = new VendorInformationObjectBuilder()
1364 .setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO))
1365 .setEnterpriseSpecificInformation(esInfo).build();
1366 final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
1367 result.readerIndex(8);
1368 final VendorInformationObject o = (VendorInformationObject) parser.parseObject(
1369 new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
1370 assertEquals(viObj, o);
1372 final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
1373 parser.serializeObject(viObj, buf);
1374 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1378 public void testMonitoringObject() throws PCEPDeserializerException {
1379 final byte[] monitoringBytes = {
1381 0x13, 0x10, 0x00, 0x0C,
1383 0x00, 0x00, 0x00, 0x01,
1384 /* monitoring-id=16 */
1385 0x00, 0x00, 0x00, 0x10
1387 final PCEPMonitoringObjectParser parser = new PCEPMonitoringObjectParser(this.tlvRegistry, this.viTlvRegistry);
1388 final Monitoring monitoring = new MonitoringBuilder()
1389 .setMonitoringId(Uint32.valueOf(16L))
1390 .setFlags(new Flags(false, false, true, false, false))
1391 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
1392 .monitoring.object.monitoring.TlvsBuilder().build()).build();
1393 final ByteBuf result = Unpooled.wrappedBuffer(monitoringBytes);
1394 assertEquals(monitoring, parser.parseObject(new ObjectHeaderImpl(false, false),
1395 result.slice(4, result.readableBytes() - 4)));
1397 final ByteBuf buf = Unpooled.buffer(monitoringBytes.length);
1398 parser.serializeObject(monitoring, buf);
1399 assertArrayEquals(monitoringBytes, buf.array());
1403 public void testPccIdReqIPv4Object() throws PCEPDeserializerException {
1404 final byte[] pccIdReqBytes = {
1406 0x14, 0x10, 0x00, 0x08,
1408 0x7f, 0x00, 0x00, 0x01
1410 final PCEPPccIdReqIPv4ObjectParser parser = new PCEPPccIdReqIPv4ObjectParser();
1411 final PccIdReq pccIdReq =
1412 new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).build();
1413 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1414 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1415 result.slice(4, result.readableBytes() - 4)));
1417 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1418 parser.serializeObject(pccIdReq, buf);
1419 assertArrayEquals(pccIdReqBytes, buf.array());
1423 public void testPccIdReqIPv6Object() throws PCEPDeserializerException {
1424 final byte[] pccIdReqBytes = {
1426 0x14, 0x20, 0x00, 0x14,
1428 0x00, 0x00, 0x00, 0x00,
1429 0x00, 0x00, 0x00, 0x00,
1430 0x00, 0x00, 0x00, 0x00,
1431 0x00, 0x00, 0x00, 0x01
1433 final PCEPPccIdReqIPv6ObjectParser parser = new PCEPPccIdReqIPv6ObjectParser();
1434 final PccIdReq pccIdReq =
1435 new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("::1"))).build();
1436 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1437 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1438 result.slice(4, result.readableBytes() - 4)));
1440 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1441 parser.serializeObject(pccIdReq, buf);
1442 assertArrayEquals(pccIdReqBytes, buf.array());
1446 public void testPceIdIPv4Object() throws PCEPDeserializerException {
1447 final byte[] pccIdReqBytes = {
1449 0x19, 0x10, 0x00, 0x08,
1451 0x7f, 0x00, 0x00, 0x01
1453 final PCEPPceIdIPv4ObjectParser parser = new PCEPPceIdIPv4ObjectParser();
1454 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1455 .PceId pceId = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1456 new Ipv4AddressNoZone("127.0.0.1"))).build();
1457 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1458 assertEquals(pceId, parser.parseObject(new ObjectHeaderImpl(false, false),
1459 result.slice(4, result.readableBytes() - 4)));
1461 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1462 parser.serializeObject(pceId, buf);
1463 assertArrayEquals(pccIdReqBytes, buf.array());
1467 public void testPceIdIPv6Object() throws PCEPDeserializerException {
1468 final byte[] pccIdReqBytes = {
1470 0x19, 0x20, 0x00, 0x14,
1472 0x00, 0x00, 0x00, 0x00,
1473 0x00, 0x00, 0x00, 0x00,
1474 0x00, 0x00, 0x00, 0x00,
1475 0x00, 0x00, 0x00, 0x01
1477 final PCEPPceIdIPv6ObjectParser parser = new PCEPPceIdIPv6ObjectParser();
1478 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1479 .PceId pccIdReq = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1480 new Ipv6AddressNoZone("::1"))).build();
1481 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1482 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1483 result.slice(4, result.readableBytes() - 4)));
1485 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1486 parser.serializeObject(pccIdReq, buf);
1487 assertArrayEquals(pccIdReqBytes, buf.array());
1491 public void testProcTimeObject() throws PCEPDeserializerException {
1492 final byte[] proctimeBytes = {
1494 0x1A, 0x10, 0x00, 0x1C,
1496 0x00, 0x00, 0x00, 0x01,
1497 /* current proc. time */
1498 0x00, 0x00, 0x00, 0x01,
1499 /* min proc. time */
1500 0x00, 0x00, 0x00, 0x02,
1502 0x00, 0x00, 0x00, 0x03,
1503 /* average proc time */
1504 0x00, 0x00, 0x00, 0x04,
1505 /* variance proc time */
1506 0x00, 0x00, 0x00, 0x05,
1508 final PCEPProcTimeObjectParser parser = new PCEPProcTimeObjectParser();
1509 final ProcTime procTime = new ProcTimeBuilder()
1511 .setAverageProcTime(Uint32.valueOf(4))
1512 .setCurrentProcTime(Uint32.ONE)
1513 .setMaxProcTime(Uint32.valueOf(3))
1514 .setMinProcTime(Uint32.TWO)
1515 .setVarianceProcTime(Uint32.valueOf(5))
1517 final ByteBuf result = Unpooled.wrappedBuffer(proctimeBytes);
1518 assertEquals(procTime, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4,
1519 result.readableBytes() - 4)));
1521 final ByteBuf buf = Unpooled.buffer(proctimeBytes.length);
1522 parser.serializeObject(procTime, buf);
1523 assertArrayEquals(proctimeBytes, buf.array());
1527 public void testOverloadObject() throws PCEPDeserializerException {
1528 final byte[] overloadBytes = {
1530 0x1B, 0x10, 0x00, 0x08,
1531 /* overload duration */
1532 0x00, 0x00, 0x00, 0x78
1534 final PCEPOverloadObjectParser parser = new PCEPOverloadObjectParser();
1535 final Overload overload = new OverloadBuilder().setDuration(Uint16.valueOf(120)).build();
1536 final ByteBuf result = Unpooled.wrappedBuffer(overloadBytes);
1537 assertEquals(overload, parser.parseObject(new ObjectHeaderImpl(false, false),
1538 result.slice(4, result.readableBytes() - 4)));
1540 final ByteBuf buf = Unpooled.buffer(overloadBytes.length);
1541 parser.serializeObject(overload, buf);
1542 assertArrayEquals(overloadBytes, buf.array());
1546 public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
1548 final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde,
1549 (byte) 0xad, (byte) 0xbe, (byte) 0xef,
1551 0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
1553 final PCEPRequestParameterObjectParser parser
1554 = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
1555 final RpBuilder builder = new RpBuilder()
1556 .setProcessingRule(false)
1558 .setReoptimization(true)
1559 .setBiDirectional(false)
1561 .setMakeBeforeBreak(true)
1565 .setFragmentation(false)
1567 .setEroCompression(false)
1568 .setPriority(Uint8.valueOf(5))
1569 .setRequestId(new RequestId(Uint32.valueOf(0xdeadbeefL)))
1570 .setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
1571 .object.rp.TlvsBuilder()
1572 .setPathSetupType(new PathSetupTypeBuilder().setPst(Uint8.ZERO)
1576 final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
1577 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1578 result.slice(4, result.readableBytes() - 4)));
1579 final ByteBuf buf = Unpooled.buffer();
1580 parser.serializeObject(builder.build(), buf);
1581 assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
1585 public void testBranchNodeListObject() throws Exception {
1586 final byte[] expected = {
1587 0x1f, 0x10, 0x0, 0xc,
1589 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1592 final BranchNodeListObjectParser parser
1593 = new BranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1594 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1596 final BranchNodeListBuilder builder = new BranchNodeListBuilder();
1597 builder.setProcessingRule(false);
1598 builder.setIgnore(false);
1599 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1600 .route.object.ero.Subobject> subs = new ArrayList<>();
1601 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1602 .route.object.ero.SubobjectBuilder()
1604 .setSubobjectType(new IpPrefixCaseBuilder()
1605 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1606 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1607 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1609 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1610 result.slice(4, result.readableBytes() - 4)));
1611 final ByteBuf buf = Unpooled.buffer();
1612 parser.serializeObject(builder.build(), buf);
1613 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1616 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1618 } catch (final IllegalArgumentException e) {
1619 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1624 public void testNonBranchNodeListObject() throws Exception {
1625 final byte[] expected = {
1626 0x1f, 0x20, 0x0, 0xc,
1628 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1631 final NonBranchNodeListObjectParser parser
1632 = new NonBranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1633 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1635 final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
1636 builder.setProcessingRule(false);
1637 builder.setIgnore(false);
1638 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1639 .route.object.ero.Subobject> subs = new ArrayList<>();
1640 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1641 .route.object.ero.SubobjectBuilder()
1643 .setSubobjectType(new IpPrefixCaseBuilder()
1644 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1645 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1646 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1648 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1649 result.slice(4, result.readableBytes() - 4)));
1650 final ByteBuf buf = Unpooled.buffer();
1651 parser.serializeObject(builder.build(), buf);
1652 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1655 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1657 } catch (final IllegalArgumentException e) {
1658 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1663 public void testPCEPIpv4UnreachDestinationObject() throws Exception {
1664 final byte[] expected = {
1665 0x1c, 0x10, 0x0, 0x8,
1666 (byte) 0x7F, (byte) 0x0, (byte) 0x0, (byte) 0x1
1669 final PCEPIpv4UnreachDestinationParser parser = new PCEPIpv4UnreachDestinationParser();
1670 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1671 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1673 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1674 builder.setProcessingRule(false);
1675 builder.setIgnore(false);
1676 final Ipv4DestinationCase dest = new Ipv4DestinationCaseBuilder()
1677 .setDestinationIpv4Address(Collections.singletonList(new Ipv4AddressNoZone("127.0.0.1")))
1679 builder.setDestination(dest);
1681 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1682 result.slice(4, result.readableBytes() - 4)));
1683 final ByteBuf buf = Unpooled.buffer();
1684 serializer.serializeObject(builder.build(), buf);
1685 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1688 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1690 } catch (final IllegalArgumentException e) {
1691 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1696 public void testPCEPIpv6UnreachDestinationObject() throws Exception {
1697 final byte[] expected = {
1698 0x1c, 0x20, 0x0, 0x14,
1699 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
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) 0x1
1705 final PCEPIpv6UnreachDestinationParser parser = new PCEPIpv6UnreachDestinationParser();
1706 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1707 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1709 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1710 builder.setProcessingRule(false);
1711 builder.setIgnore(false);
1712 final Ipv6DestinationCase dest = new Ipv6DestinationCaseBuilder()
1713 .setDestinationIpv6Address(Collections.singletonList(new Ipv6AddressNoZone("::1")))
1715 builder.setDestination(dest);
1717 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1718 result.slice(4, result.readableBytes() - 4)));
1719 final ByteBuf buf = Unpooled.buffer();
1720 serializer.serializeObject(builder.build(), buf);
1721 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1724 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1726 } catch (final IllegalArgumentException e) {
1727 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());