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 com.google.common.primitives.UnsignedBytes;
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.Arrays;
24 import java.util.Collections;
25 import java.util.List;
26 import org.junit.Before;
27 import org.junit.Test;
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.PCEPDeserializerException;
70 import org.opendaylight.protocol.pcep.spi.PCEPErrors;
71 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
72 import org.opendaylight.protocol.pcep.spi.UnknownObject;
73 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
74 import org.opendaylight.protocol.pcep.spi.pojo.SimplePCEPExtensionProviderContext;
75 import org.opendaylight.protocol.util.ByteArray;
76 import org.opendaylight.protocol.util.Ipv4Util;
77 import org.opendaylight.protocol.util.Ipv6Util;
78 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
79 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
80 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
81 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
82 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
83 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.Bandwidth;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ClassType;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OfId;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.P2mpLeaves;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ProtocolVersion;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.RequestId;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.bandwidth.object.BandwidthBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.branch.node.object.BranchNodeListBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.classtype.object.ClassTypeBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv4CaseBuilder;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.Ipv6CaseBuilder;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv4CaseBuilder;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.P2mpIpv6CaseBuilder;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv4._case.Ipv4Builder;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.ipv6._case.Ipv6Builder;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv4._case.P2mpIpv4Builder;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.address.family.p2mp.ipv6._case.P2mpIpv6Builder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.endpoints.object.EndpointsObjBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.XroBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.Subobject;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.xro.SubobjectBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc.object.GcBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.IroBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.load.balancing.object.LoadBalancingBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.LspaBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.metric.object.MetricBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.Monitoring.Flags;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.MonitoringBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.non.branch.node.object.NonBranchNodeListBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.CNotificationBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.OfBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.order.tlv.OrderBuilder;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.duration.tlv.OverloadDurationBuilder;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.Overload;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.overload.object.OverloadBuilder;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.PathKeyBuilder;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.path.key.PathKeys;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.key.object.path.key.PathKeysBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.path.setup.type.tlv.PathSetupTypeBuilder;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReqBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object.PceIdBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.error.object.TlvsBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.NoPathBuilder;
136 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;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTime;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.proc.time.object.ProcTimeBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.RroBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.req.missing.tlv.ReqMissingBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.RpBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.svec.object.SvecBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.UnreachDestinationObjBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCase;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv4DestinationCaseBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCase;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.unreach.destination.object.unreach.destination.obj.destination.Ipv6DestinationCaseBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObject;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.objects.VendorInformationObjectBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlv;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.vendor.information.tlvs.VendorInformationTlvBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AttributeFilter;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.ExcludeRouteSubobjects.Attribute;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PathKey;
155 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.PceId;
156 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder;
157 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.IpPrefixCaseBuilder;
158 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder;
159 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.as.number._case.AsNumberBuilder;
160 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder;
161 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
163 public class PCEPObjectParserTest {
165 private TlvRegistry tlvRegistry;
167 private VendorInformationTlvRegistry viTlvRegistry;
169 private SimplePCEPExtensionProviderContext ctx;
170 private BaseParserExtensionActivator act;
171 private TestVendorInformationActivator viAct;
174 public void setUp() {
175 this.ctx = new SimplePCEPExtensionProviderContext();
176 this.act = new BaseParserExtensionActivator();
177 this.viAct = new TestVendorInformationActivator();
178 this.act.start(this.ctx);
179 this.viAct.start(this.ctx);
180 this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
181 this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
185 public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
186 final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
187 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
189 final OpenBuilder builder = new OpenBuilder();
190 builder.setProcessingRule(false);
191 builder.setIgnore(false);
192 builder.setVersion(new ProtocolVersion((short) 1));
193 builder.setKeepalive((short) 30);
194 builder.setDeadTimer((short) 120);
195 builder.setSessionId((short) 1);
197 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open
198 .object.open.TlvsBuilder().build());
200 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
201 result.slice(4, result.readableBytes() - 4)));
202 final ByteBuf buf = Unpooled.buffer();
203 parser.serializeObject(builder.build(), buf);
204 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
207 parser.parseObject(new ObjectHeaderImpl(true, true), null);
209 } catch (final IllegalArgumentException e) {
210 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
213 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
215 } catch (final IllegalArgumentException e) {
216 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
221 public void testCloseObject() throws IOException, PCEPDeserializerException {
222 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
223 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseObject1.bin"));
225 final CCloseBuilder builder = new CCloseBuilder();
226 builder.setProcessingRule(false);
227 builder.setIgnore(false);
228 builder.setReason((short) 5);
229 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close
230 .object.c.close.TlvsBuilder().build());
232 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
233 result.slice(4, result.readableBytes() - 4)));
234 final ByteBuf buf = Unpooled.buffer();
235 parser.serializeObject(builder.build(), buf);
236 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
239 parser.parseObject(new ObjectHeaderImpl(true, true), null);
241 } catch (final IllegalArgumentException e) {
242 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
245 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
247 } catch (final IllegalArgumentException e) {
248 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
253 public void testLoadBalancingObject() throws IOException, PCEPDeserializerException {
254 final PCEPLoadBalancingObjectParser parser = new PCEPLoadBalancingObjectParser();
255 final ByteBuf result =
256 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLoadBalancingObject1.bin"));
258 final LoadBalancingBuilder builder = new LoadBalancingBuilder();
259 builder.setProcessingRule(true);
260 builder.setIgnore(false);
261 builder.setMaxLsp((short) UnsignedBytes.toInt((byte) 0xf1));
262 builder.setMinBandwidth(new Bandwidth(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }));
264 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
265 result.slice(4, result.readableBytes() - 4)));
266 final ByteBuf buf = Unpooled.buffer();
267 parser.serializeObject(builder.build(), buf);
268 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
271 parser.parseObject(new ObjectHeaderImpl(true, true), null);
273 } catch (final IllegalArgumentException e) {
274 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
277 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
279 } catch (final IllegalArgumentException e) {
280 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
285 public void testERObject() throws Exception {
286 final PCEPExplicitRouteObjectParser parser =
287 new PCEPExplicitRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
288 final ByteBuf result =
289 Unpooled.wrappedBuffer(
290 ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin"));
292 final EroBuilder builder = new EroBuilder();
293 builder.setProcessingRule(false);
294 builder.setIgnore(false);
295 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
296 .route.object.ero.Subobject> subs = new ArrayList<>();
297 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
298 .route.object.ero.SubobjectBuilder().setLoose(
299 true).setSubobjectType(
300 new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0xffffL))
301 .build()).build()).build());
302 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
303 .route.object.ero.SubobjectBuilder().setLoose(true).setSubobjectType(new IpPrefixCaseBuilder()
305 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build())
307 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
308 .route.object.ero.SubobjectBuilder().setLoose(true).setSubobjectType(new UnnumberedCaseBuilder()
309 .setUnnumbered(new UnnumberedBuilder().setRouterId(0xffffffffL).setInterfaceId(0xffffffffL).build())
311 builder.setSubobject(subs);
313 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
314 result.slice(4, result.readableBytes() - 4)));
315 final ByteBuf buf = Unpooled.buffer();
316 parser.serializeObject(builder.build(), buf);
317 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
320 parser.parseObject(new ObjectHeaderImpl(true, true), null);
322 } catch (final IllegalArgumentException e) {
323 assertEquals("Array of bytes is mandatory. Can't be null.", e.getMessage());
328 public void testIRObject() throws Exception {
329 final PCEPIncludeRouteObjectParser parser =
330 new PCEPIncludeRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
331 final ByteBuf result =
332 Unpooled.wrappedBuffer(
333 ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin"));
334 final byte[] ip6PrefixBytes = {
335 (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
336 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
339 final IroBuilder builder = new IroBuilder();
340 builder.setProcessingRule(false);
341 builder.setIgnore(false);
342 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
343 .route.object.iro.Subobject> subs = new ArrayList<>();
344 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
345 .route.object.iro.SubobjectBuilder().setSubobjectType(
346 new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder()
347 .setAsNumber(new AsNumber(0x10L)).build()).build()).setLoose(true).build());
348 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
349 .route.object.iro.SubobjectBuilder().setSubobjectType(
350 new IpPrefixCaseBuilder().setIpPrefix(
351 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("18.52.80.0/21"))).build()).build())
352 .setLoose(true).build());
353 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include
354 .route.object.iro.SubobjectBuilder().setSubobjectType(
355 new IpPrefixCaseBuilder().setIpPrefix(
356 new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22)))
357 .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 UnnumberedCaseBuilder().setUnnumbered(
361 new UnnumberedBuilder().setRouterId(0x1245678L).setInterfaceId(0x9abcdef0L)
362 .build()).build()).setLoose(true).build());
363 builder.setSubobject(subs);
365 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
366 result.slice(4, result.readableBytes() - 4)));
367 final ByteBuf buf = Unpooled.buffer();
368 parser.serializeObject(builder.build(), buf);
369 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
372 parser.parseObject(new ObjectHeaderImpl(true, true), null);
374 } catch (final IllegalArgumentException e) {
375 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
378 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
380 } catch (final IllegalArgumentException e) {
381 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
386 public void testRRObject() throws Exception {
387 final PCEPReportedRouteObjectParser parser =
388 new PCEPReportedRouteObjectParser(this.ctx.getRROSubobjectHandlerRegistry());
389 final ByteBuf result =
390 Unpooled.wrappedBuffer(
391 ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin"));
392 final byte[] ip6PrefixBytes = {
393 (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
394 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00
397 final RroBuilder builder = new RroBuilder();
398 builder.setProcessingRule(false);
399 builder.setIgnore(false);
400 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
401 .route.object.rro.Subobject> subs = new ArrayList<>();
402 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
403 .route.object.rro.SubobjectBuilder().setSubobjectType(
404 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record
405 .route.subobjects.subobject.type.IpPrefixCaseBuilder().setIpPrefix(
406 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record
407 .route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder().setIpPrefix(
408 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).setProtectionAvailable(false)
409 .setProtectionInUse(false).build());
410 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
411 .route.object.rro.SubobjectBuilder().setSubobjectType(
412 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects
413 .subobject.type.IpPrefixCaseBuilder().setIpPrefix(
414 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record
415 .route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder().setIpPrefix(
416 new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22))).build()).build())
417 .setProtectionAvailable(false).setProtectionInUse(false).build());
418 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported
419 .route.object.rro.SubobjectBuilder().setSubobjectType(
420 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record
421 .route.subobjects.subobject.type.UnnumberedCaseBuilder().setUnnumbered(
422 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record
423 .route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder()
424 .setRouterId(0x1245678L).setInterfaceId(0x9abcdef0L).build())
426 .setProtectionAvailable(false).setProtectionInUse(false).build());
427 builder.setSubobject(subs);
429 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
430 result.slice(4, result.readableBytes() - 4)));
431 final ByteBuf buf = Unpooled.buffer();
432 parser.serializeObject(builder.build(), buf);
433 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
436 parser.parseObject(new ObjectHeaderImpl(true, true), null);
438 } catch (final IllegalArgumentException e) {
439 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
442 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
444 } catch (final IllegalArgumentException e) {
445 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
450 public void testBandwidthObject() throws IOException, PCEPDeserializerException {
451 final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser();
452 final ByteBuf result =
453 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin"));
455 final BandwidthBuilder builder = new BandwidthBuilder();
456 builder.setProcessingRule(true);
457 builder.setIgnore(true);
458 builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
460 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
461 result.slice(4, result.readableBytes() - 4)));
462 final ByteBuf buf = Unpooled.buffer();
463 parser.serializeObject(builder.build(), buf);
464 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
467 parser.parseObject(new ObjectHeaderImpl(true, true), null);
469 } catch (final IllegalArgumentException e) {
470 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
473 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
475 } catch (final IllegalArgumentException e) {
476 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
481 public void testExistingBandwidthObject() throws IOException, PCEPDeserializerException {
482 final PCEPExistingBandwidthObjectParser parser = new PCEPExistingBandwidthObjectParser();
483 final ByteBuf result =
484 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject2UpperBounds.bin"));
486 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization
487 .bandwidth.object.ReoptimizationBandwidthBuilder builder = new org.opendaylight.yang.gen.v1
488 .urn.opendaylight.params.xml
489 .ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidthBuilder();
490 builder.setProcessingRule(true);
491 builder.setIgnore(true);
492 builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }));
494 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
495 result.slice(4, result.readableBytes() - 4)));
496 final ByteBuf buf = Unpooled.buffer();
497 parser.serializeObject(builder.build(), buf);
498 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
501 parser.parseObject(new ObjectHeaderImpl(true, true), null);
503 } catch (final IllegalArgumentException e) {
504 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
507 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
509 } catch (final IllegalArgumentException e) {
510 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
515 public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException {
516 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
517 final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
519 final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser();
521 = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject1IPv4.bin"));
523 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
524 builder.setProcessingRule(true);
525 builder.setIgnore(false);
526 builder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(
527 new Ipv4Builder().setSourceIpv4Address(Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
528 .setDestinationIpv4Address(
529 Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(destIPBytes))).build()).build());
531 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
532 result.slice(4, result.readableBytes() - 4)));
533 final ByteBuf buf = Unpooled.buffer();
534 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
535 serializer.serializeObject(builder.build(), buf);
536 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
539 parser.parseObject(new ObjectHeaderImpl(true, true), null);
541 } catch (final IllegalArgumentException e) {
542 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
545 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
547 } catch (final IllegalArgumentException e) {
548 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
554 public void testEndPointsObjectP2MPIPv4() throws PCEPDeserializerException {
555 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
556 final byte[] destIPBytes = {
557 (byte) 0x04, (byte) 0x32, (byte) 0x00, (byte) 0x14,
558 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
559 (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E,
560 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
561 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFC};
563 final PCEPP2MPEndPointsIpv4ObjectParser parser = new PCEPP2MPEndPointsIpv4ObjectParser();
564 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
566 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
567 builder.setProcessingRule(true);
568 builder.setIgnore(false);
569 builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(new P2mpIpv4Builder()
570 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
571 .setSourceIpv4Address(Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
572 .setDestinationIpv4Address(Arrays.asList(new Ipv4AddressNoZone("255.255.255.255"),
573 new Ipv4AddressNoZone("255.255.255.252"))).build()).build());
575 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
576 result.slice(4, result.readableBytes() - 4)));
577 final ByteBuf buf = Unpooled.buffer();
578 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
579 serializer.serializeObject(builder.build(), buf);
580 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
583 parser.parseObject(new ObjectHeaderImpl(true, true), null);
585 } catch (final IllegalArgumentException e) {
586 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
589 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
591 } catch (final IllegalArgumentException e) {
592 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
597 public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException {
598 final byte[] destIPBytes = {
599 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
600 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
602 final byte[] srcIPBytes = {
603 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
604 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF
607 final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser();
608 final ByteBuf result =
609 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject2IPv6.bin"));
611 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
612 builder.setProcessingRule(true);
613 builder.setIgnore(false);
614 builder.setAddressFamily(new Ipv6CaseBuilder().setIpv6(
615 new Ipv6Builder().setSourceIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
616 .setDestinationIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(destIPBytes)))
619 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
620 result.slice(4, result.readableBytes() - 4)));
621 final ByteBuf buf = Unpooled.buffer();
622 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
623 serializer.serializeObject(builder.build(), buf);
624 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
627 parser.parseObject(new ObjectHeaderImpl(true, true), null);
629 } catch (final IllegalArgumentException e) {
630 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
633 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
635 } catch (final IllegalArgumentException e) {
636 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
641 public void testEndPointsObjectP2MPIPv6() throws IOException, PCEPDeserializerException {
642 final byte[] destIPBytes = {
643 (byte) 0x04, (byte) 0x42, (byte) 0x00, (byte) 0x38,
644 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
645 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
646 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
647 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2,
648 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
649 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
650 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
651 (byte) 0x00, (byte) 0x03, (byte) 0x5D, (byte) 0xD2,
652 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
653 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
654 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
656 final byte[] srcIPBytes = {
657 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
658 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF
661 final PCEPP2MPEndPointsIpv6ObjectParser parser = new PCEPP2MPEndPointsIpv6ObjectParser();
662 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
664 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
665 builder.setProcessingRule(true);
666 builder.setIgnore(false);
667 builder.setAddressFamily(new P2mpIpv6CaseBuilder().setP2mpIpv6(new P2mpIpv6Builder()
668 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
669 .setSourceIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
670 .setDestinationIpv6Address(Arrays.asList(
671 new Ipv6AddressNoZone("2:5dd2:ffec:a1b6:581e:9f50::"),
672 new Ipv6AddressNoZone("3:5dd2:ffec:a1b6:581e:9f50::")
673 )).build()).build());
675 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
676 result.slice(4, result.readableBytes() - 4)));
677 final ByteBuf buf = Unpooled.buffer();
678 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
679 serializer.serializeObject(builder.build(), buf);
680 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
683 parser.parseObject(new ObjectHeaderImpl(true, true), null);
685 } catch (final IllegalArgumentException e) {
686 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
689 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
691 } catch (final IllegalArgumentException e) {
692 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
697 public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
698 final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
700 final ErrorObjectBuilder builder = new ErrorObjectBuilder();
701 builder.setProcessingRule(true);
702 builder.setIgnore(true);
703 builder.setType((short) 1);
704 builder.setValue((short) 1);
706 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
707 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
708 result.slice(4, result.readableBytes() - 4)));
709 ByteBuf buf = Unpooled.buffer();
710 parser.serializeObject(builder.build(), buf);
711 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
713 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
715 builder.setType((short) 7);
716 builder.setValue((short) 0);
717 builder.setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(0x00001155L))
720 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
721 result.slice(4, result.readableBytes() - 4)));
722 buf = Unpooled.buffer();
723 parser.serializeObject(builder.build(), buf);
724 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
727 parser.parseObject(new ObjectHeaderImpl(true, true), null);
729 } catch (final IllegalArgumentException e) {
730 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
733 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
735 } catch (final IllegalArgumentException e) {
736 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
741 public void testLspaObject() throws IOException, PCEPDeserializerException {
742 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
744 final LspaBuilder builder = new LspaBuilder();
745 builder.setProcessingRule(true);
746 builder.setIgnore(true);
747 builder.setExcludeAny(new AttributeFilter(0L));
748 builder.setIncludeAny(new AttributeFilter(0L));
749 builder.setIncludeAll(new AttributeFilter(0L));
750 builder.setHoldPriority((short) 0);
751 builder.setSetupPriority((short) 0);
752 builder.setLocalProtectionDesired(false);
753 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa
754 .object.lspa.TlvsBuilder().build());
757 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
758 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
759 result.slice(4, result.readableBytes() - 4)));
760 ByteBuf buf = Unpooled.buffer();
761 parser.serializeObject(builder.build(), buf);
762 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
764 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject2UpperBounds.bin"));
766 builder.setExcludeAny(new AttributeFilter(0xFFFFFFFFL));
767 builder.setIncludeAny(new AttributeFilter(0xFFFFFFFFL));
768 builder.setIncludeAll(new AttributeFilter(0xFFFFFFFFL));
769 builder.setHoldPriority((short) 0xFF);
770 builder.setSetupPriority((short) 0xFF);
771 builder.setLocalProtectionDesired(true);
773 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
774 result.slice(4, result.readableBytes() - 4)));
775 buf = Unpooled.buffer();
776 parser.serializeObject(builder.build(), buf);
777 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
780 parser.parseObject(new ObjectHeaderImpl(true, true), null);
782 } catch (final IllegalArgumentException e) {
783 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
786 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
788 } catch (final IllegalArgumentException e) {
789 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
794 public void testMetricObject() throws IOException, PCEPDeserializerException {
795 final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
797 final MetricBuilder builder = new MetricBuilder();
798 builder.setProcessingRule(true);
799 builder.setIgnore(true);
800 builder.setComputed(false);
801 builder.setBound(false);
802 builder.setMetricType((short) 1);
803 builder.setValue(new Float32(new byte[] { 0, 0, 0, 0 }));
806 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));
807 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
808 result.slice(4, result.readableBytes() - 4)));
809 ByteBuf buf = Unpooled.buffer();
810 parser.serializeObject(builder.build(), buf);
811 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
813 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));
815 builder.setComputed(true);
816 builder.setBound(false);
817 builder.setMetricType((short) 2);
818 builder.setValue(new Float32(new byte[] { (byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00 }));
820 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
821 result.slice(4, result.readableBytes() - 4)));
822 buf = Unpooled.buffer();
823 parser.serializeObject(builder.build(), buf);
824 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
827 parser.parseObject(new ObjectHeaderImpl(true, true), null);
829 } catch (final IllegalArgumentException e) {
830 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
833 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
835 } catch (final IllegalArgumentException e) {
836 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
841 public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
842 final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
844 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
846 final NoPathBuilder builder = new NoPathBuilder();
847 builder.setProcessingRule(true);
848 builder.setIgnore(true);
849 builder.setNatureOfIssue((short) 1);
850 builder.setUnsatisfiedConstraints(true);
851 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep
852 .message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
854 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
855 result.slice(4, result.readableBytes() - 4)));
856 ByteBuf buf = Unpooled.buffer();
857 parser.serializeObject(builder.build(), buf);
858 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
860 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject2WithTLV.bin"));
862 builder.setNatureOfIssue((short) 0);
863 builder.setUnsatisfiedConstraints(false);
865 final NoPathVectorBuilder b = new NoPathVectorBuilder();
866 b.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
867 .NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true));
868 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
869 .pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().setNoPathVector(
872 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
873 result.slice(4, result.readableBytes() - 4)));
874 buf = Unpooled.buffer();
875 parser.serializeObject(builder.build(), buf);
876 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
879 parser.parseObject(new ObjectHeaderImpl(true, true), null);
881 } catch (final IllegalArgumentException e) {
882 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
885 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
887 } catch (final IllegalArgumentException e) {
888 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
893 public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
894 final PCEPNotificationObjectParser parser =
895 new PCEPNotificationObjectParser(this.tlvRegistry, this.viTlvRegistry);
897 final CNotificationBuilder builder = new CNotificationBuilder();
898 builder.setProcessingRule(true);
899 builder.setIgnore(true);
900 builder.setType((short) 0xff);
901 builder.setValue((short) 0xff);
904 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));
905 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
906 result.slice(4, result.readableBytes() - 4)));
907 ByteBuf buf = Unpooled.buffer();
908 parser.serializeObject(builder.build(), buf);
909 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
911 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject1WithTlv.bin"));
913 builder.setType((short) 2);
914 builder.setValue((short) 1);
915 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
916 .notification.object.c.notification.TlvsBuilder().setOverloadDuration(
917 new OverloadDurationBuilder().setDuration(0xff0000a2L).build()).build());
919 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
920 result.slice(4, result.readableBytes() - 4)));
921 buf = Unpooled.buffer();
922 parser.serializeObject(builder.build(), buf);
923 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
926 parser.parseObject(new ObjectHeaderImpl(true, true), null);
928 } catch (final IllegalArgumentException e) {
929 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
932 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
934 } catch (final IllegalArgumentException e) {
935 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
940 public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
941 final PCEPRequestParameterObjectParser parser =
942 new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
944 final RpBuilder builder = new RpBuilder();
945 builder.setProcessingRule(true);
946 builder.setIgnore(true);
947 builder.setReoptimization(true);
948 builder.setBiDirectional(false);
949 builder.setLoose(true);
950 builder.setMakeBeforeBreak(true);
951 builder.setOrder(false);
952 builder.setPathKey(false);
953 builder.setSupplyOf(false);
954 builder.setFragmentation(false);
955 builder.setP2mp(false);
956 builder.setEroCompression(false);
957 builder.setPriority((short) 5);
958 builder.setRequestId(new RequestId(0xdeadbeefL));
959 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
960 .object.rp.TlvsBuilder().build());
962 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
963 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
964 result.slice(4, result.readableBytes() - 4)));
965 ByteBuf buf = Unpooled.buffer();
966 parser.serializeObject(builder.build(), buf);
967 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
969 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
971 builder.setReoptimization(false);
972 builder.setFragmentation(true);
973 builder.setEroCompression(true);
975 final OrderBuilder b = new OrderBuilder();
976 b.setDelete(0xffffffffL);
979 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
980 .object.rp.TlvsBuilder().setOrder(b.build()).build());
982 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true),
983 result.slice(4, result.readableBytes() - 4)));
984 buf = Unpooled.buffer();
985 parser.serializeObject(builder.build(), buf);
986 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
989 parser.parseObject(new ObjectHeaderImpl(true, true), null);
991 } catch (final IllegalArgumentException e) {
992 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
995 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
997 } catch (final IllegalArgumentException e) {
998 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1003 public void testSvecObject() throws IOException, PCEPDeserializerException {
1004 final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
1006 final SvecBuilder builder = new SvecBuilder();
1007 builder.setProcessingRule(false);
1008 builder.setIgnore(false);
1009 builder.setLinkDiverse(false);
1010 builder.setNodeDiverse(false);
1011 builder.setSrlgDiverse(false);
1012 builder.setPartialPathDiverse(false);
1013 builder.setLinkDirectionDiverse(false);
1014 builder.setRequestsIds(Lists.newArrayList(new RequestId(0xFFL)));
1016 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
1017 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1018 result.slice(4, result.readableBytes() - 4)));
1019 ByteBuf buf = Unpooled.buffer();
1020 parser.serializeObject(builder.build(), buf);
1021 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1023 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
1025 builder.setProcessingRule(true);
1026 builder.setLinkDiverse(true);
1027 builder.setSrlgDiverse(true);
1029 final List<RequestId> requestIDs = new ArrayList<>();
1030 requestIDs.add(new RequestId(0xFFFFFFFFL));
1031 requestIDs.add(new RequestId(0x00000001L));
1032 requestIDs.add(new RequestId(0x01234567L));
1033 requestIDs.add(new RequestId(0x89ABCDEFL));
1034 requestIDs.add(new RequestId(0xFEDCBA98L));
1035 requestIDs.add(new RequestId(0x76543210L));
1036 requestIDs.add(new RequestId(0x15825266L));
1037 requestIDs.add(new RequestId(0x48120BBEL));
1038 requestIDs.add(new RequestId(0x25FB7E52L));
1039 requestIDs.add(new RequestId(0xB2F2546BL));
1041 builder.setRequestsIds(requestIDs);
1043 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1044 result.slice(4, result.readableBytes() - 4)));
1045 buf = Unpooled.buffer();
1046 parser.serializeObject(builder.build(), buf);
1047 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1050 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1052 } catch (final IllegalArgumentException e) {
1053 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1056 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1058 } catch (final IllegalArgumentException e) {
1059 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1064 public void testClassTypeObject() throws PCEPDeserializerException {
1065 final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
1066 final ByteBuf result = Unpooled.wrappedBuffer(new byte[] {
1067 (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });
1069 final ClassTypeBuilder builder = new ClassTypeBuilder();
1070 builder.setProcessingRule(true);
1071 builder.setIgnore(false);
1072 builder.setClassType(new ClassType((short) 4));
1074 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1075 result.slice(4, result.readableBytes() - 4)));
1076 final ByteBuf buf = Unpooled.buffer();
1077 parser.serializeObject(builder.build(), buf);
1078 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1081 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1083 } catch (final IllegalArgumentException e) {
1084 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1087 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1089 } catch (final IllegalArgumentException e) {
1090 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1095 public void testExcludeRouteObject() throws Exception {
1096 final PCEPExcludeRouteObjectParser parser =
1097 new PCEPExcludeRouteObjectParser(this.ctx.getXROSubobjectHandlerRegistry());
1098 final ByteBuf result =
1099 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPExcludeRouteObject.1.bin"));
1101 final XroBuilder builder = new XroBuilder();
1102 builder.setProcessingRule(false);
1103 builder.setIgnore(false);
1104 builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
1105 .exclude.route.object.Xro.Flags(true));
1106 final List<Subobject> subs = new ArrayList<>();
1107 subs.add(new SubobjectBuilder().setMandatory(true).setSubobjectType(
1108 new IpPrefixCaseBuilder().setIpPrefix(
1109 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("192.168.0.0/16"))).build()).build())
1110 .setAttribute(Attribute.Node).build());
1111 subs.add(new SubobjectBuilder().setMandatory(false).setSubobjectType(
1112 new AsNumberCaseBuilder()
1113 .setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x1234L)).build()).build()).build());
1114 builder.setSubobject(subs);
1116 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1117 result.slice(4, result.readableBytes() - 4)));
1118 final ByteBuf buf = Unpooled.buffer();
1119 parser.serializeObject(builder.build(), buf);
1120 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1123 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1125 } catch (final IllegalArgumentException e) {
1126 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1129 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1131 } catch (final IllegalArgumentException e) {
1132 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1137 public void testPathKeyObject() throws Exception {
1138 final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1139 final ByteBuf result =
1140 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPPathKeyObject.bin"));
1142 final PathKeyBuilder builder = new PathKeyBuilder();
1143 builder.setProcessingRule(true);
1144 builder.setIgnore(false);
1145 final List<PathKeys> list = new ArrayList<>();
1146 list.add(new PathKeysBuilder().setLoose(true).setPathKey(new PathKey(0x1234)).setPceId(
1147 new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })).build());
1148 builder.setPathKeys(list);
1150 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1151 result.slice(4, result.readableBytes() - 4)));
1152 final ByteBuf buf = Unpooled.buffer();
1153 parser.serializeObject(builder.build(), buf);
1154 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1157 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1159 } catch (final IllegalArgumentException e) {
1160 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1163 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1165 } catch (final IllegalArgumentException e) {
1166 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1171 public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
1172 final PCEPObjectiveFunctionObjectParser parser =
1173 new PCEPObjectiveFunctionObjectParser(this.tlvRegistry, this.viTlvRegistry);
1174 final ByteBuf result =
1175 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin"));
1177 final OfBuilder builder = new OfBuilder();
1178 builder.setProcessingRule(true);
1179 builder.setIgnore(false);
1180 builder.setCode(new OfId(4));
1181 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of
1182 .object.of.TlvsBuilder().build());
1184 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1185 result.slice(4, result.readableBytes() - 4)));
1186 final ByteBuf buf = Unpooled.buffer();
1187 parser.serializeObject(builder.build(), buf);
1188 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1191 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1193 } catch (final IllegalArgumentException e) {
1194 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1197 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1199 } catch (final IllegalArgumentException e) {
1200 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1205 public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
1206 final PCEPGlobalConstraintsObjectParser parser =
1207 new PCEPGlobalConstraintsObjectParser(this.tlvRegistry, this.viTlvRegistry);
1208 final ByteBuf result =
1209 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin"));
1211 final GcBuilder builder = new GcBuilder();
1212 builder.setProcessingRule(true);
1213 builder.setIgnore(false);
1214 builder.setMaxHop((short) 1);
1215 builder.setMaxUtilization((short) 0);
1216 builder.setMinUtilization((short) 100);
1217 builder.setOverBookingFactor((short) 99);
1218 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc
1219 .object.gc.TlvsBuilder().build());
1221 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
1222 result.slice(4, result.readableBytes() - 4)));
1223 final ByteBuf buf = Unpooled.buffer();
1224 parser.serializeObject(builder.build(), buf);
1225 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1228 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1230 } catch (final IllegalArgumentException e) {
1231 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1234 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1236 } catch (final IllegalArgumentException e) {
1237 assertEquals("Array of bytes is mandatory. Cannot be null or empty.", e.getMessage());
1242 public void testIgnoreUknownObject() throws PCEPDeserializerException {
1243 final Object object =
1244 this.ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
1249 public void testUnrecognizedObjectType() throws PCEPDeserializerException {
1250 final Object object =
1251 this.ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
1252 assertNotNull(object);
1253 assertTrue(object instanceof UnknownObject);
1254 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_TYPE, ((UnknownObject) object).getError());
1258 public void testUnrecognizedObjectClass() throws PCEPDeserializerException {
1259 final Object object = this.ctx.getObjectHandlerRegistry()
1260 .parseObject(35, 1, new ObjectHeaderImpl(true, true), null);
1261 assertNotNull(object);
1262 assertTrue(object instanceof UnknownObject);
1263 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_CLASS, ((UnknownObject) object).getError());
1267 public void testLspaObjectSerializerDefence() throws IOException {
1268 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
1269 final ByteBuf result =
1270 Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
1272 final LspaBuilder builder = new LspaBuilder();
1273 builder.setProcessingRule(true);
1274 builder.setIgnore(true);
1275 builder.setLocalProtectionDesired(false);
1277 final ByteBuf buf = Unpooled.buffer(result.readableBytes());
1278 parser.serializeObject(builder.build(), buf);
1279 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1283 public void testEmptyEroObject() throws PCEPDeserializerException {
1284 final Object object = this.ctx.getObjectHandlerRegistry().parseObject(7, 1,
1285 new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1286 assertNotNull(object);
1287 assertTrue(object instanceof Ero);
1288 final Ero eroObject = (Ero) object;
1289 assertTrue(eroObject.getSubobject().isEmpty());
1291 final ByteBuf buffer = Unpooled.buffer();
1292 this.ctx.getObjectHandlerRegistry().serializeObject(eroObject, buffer);
1293 final byte[] expected = {0x07, 0x13, 0x00, 0x04};
1294 assertArrayEquals(expected, ByteArray.getAllBytes(buffer));
1298 public void testCloseObjectWithVendorInformationTlv() throws PCEPDeserializerException {
1299 final byte[] closeBytes = {
1300 0x0f, 0x10, 0x00, 0x14,
1301 0x00, 0x00, 0x00, 0x05,
1302 /* vendor-information TLV */
1303 0x00, 0x07, 0x00, 0x08,
1304 /* enterprise number */
1305 0x00, 0x00, 0x00, 0x00,
1306 /* enterprise specific information */
1307 0x00, 0x00, 0x00, 0x05
1309 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
1310 final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
1312 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1313 final VendorInformationTlv viTlv = new VendorInformationTlvBuilder()
1314 .setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
1315 final CCloseBuilder builder = new CCloseBuilder();
1316 builder.setProcessingRule(false);
1317 builder.setIgnore(false);
1318 builder.setReason((short) 5);
1319 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close
1320 .object.c.close.TlvsBuilder().setVendorInformationTlv(Lists.newArrayList(viTlv)).build());
1322 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1323 result.slice(4, result.readableBytes() - 4)));
1325 final ByteBuf buf = Unpooled.buffer();
1326 parser.serializeObject(builder.build(), buf);
1327 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1331 public void testVendorInformationObject() throws PCEPDeserializerException {
1332 final byte[] viObjBytes = {
1333 /* vendor-information object */
1334 0x22, 0x10, 0x00, 0x0C,
1335 /* enterprise number */
1336 0x00, 0x00, 0x00, 0x00,
1337 /* enterprise specific information */
1338 0x00, 0x00, 0x00, 0x05
1340 final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
1341 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1342 final VendorInformationObject viObj = new VendorInformationObjectBuilder()
1343 .setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
1344 final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
1345 result.readerIndex(8);
1346 final VendorInformationObject o = (VendorInformationObject) parser.parseObject(
1347 new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
1348 assertEquals(viObj, o);
1350 final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
1351 parser.serializeObject(viObj, buf);
1352 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1356 public void testMonitoringObject() throws PCEPDeserializerException {
1357 final byte[] monitoringBytes = {
1359 0x13, 0x10, 0x00, 0x0C,
1361 0x00, 0x00, 0x00, 0x01,
1362 /* monitoring-id=16 */
1363 0x00, 0x00, 0x00, 0x10
1365 final PCEPMonitoringObjectParser parser = new PCEPMonitoringObjectParser(this.tlvRegistry, this.viTlvRegistry);
1366 final Monitoring monitoring =
1367 new MonitoringBuilder().setMonitoringId(16L).setFlags(new Flags(false, false, true, false, false)).setTlvs(
1368 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring
1369 .object.monitoring.TlvsBuilder().build()).build();
1370 final ByteBuf result = Unpooled.wrappedBuffer(monitoringBytes);
1371 assertEquals(monitoring, parser.parseObject(new ObjectHeaderImpl(false, false),
1372 result.slice(4, result.readableBytes() - 4)));
1374 final ByteBuf buf = Unpooled.buffer(monitoringBytes.length);
1375 parser.serializeObject(monitoring, buf);
1376 assertArrayEquals(monitoringBytes, buf.array());
1380 public void testPccIdReqIPv4Object() throws PCEPDeserializerException {
1381 final byte[] pccIdReqBytes = {
1383 0x14, 0x10, 0x00, 0x08,
1385 0x7f, 0x00, 0x00, 0x01
1387 final PCEPPccIdReqIPv4ObjectParser parser = new PCEPPccIdReqIPv4ObjectParser();
1388 final PccIdReq pccIdReq =
1389 new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).build();
1390 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1391 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1392 result.slice(4, result.readableBytes() - 4)));
1394 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1395 parser.serializeObject(pccIdReq, buf);
1396 assertArrayEquals(pccIdReqBytes, buf.array());
1400 public void testPccIdReqIPv6Object() throws PCEPDeserializerException {
1401 final byte[] pccIdReqBytes = {
1403 0x14, 0x20, 0x00, 0x14,
1405 0x00, 0x00, 0x00, 0x00,
1406 0x00, 0x00, 0x00, 0x00,
1407 0x00, 0x00, 0x00, 0x00,
1408 0x00, 0x00, 0x00, 0x01
1410 final PCEPPccIdReqIPv6ObjectParser parser = new PCEPPccIdReqIPv6ObjectParser();
1411 final PccIdReq pccIdReq =
1412 new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("::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 testPceIdIPv4Object() throws PCEPDeserializerException {
1424 final byte[] pccIdReqBytes = {
1426 0x19, 0x10, 0x00, 0x08,
1428 0x7f, 0x00, 0x00, 0x01
1430 final PCEPPceIdIPv4ObjectParser parser = new PCEPPceIdIPv4ObjectParser();
1431 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1432 .PceId pceId = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1433 new Ipv4AddressNoZone("127.0.0.1"))).build();
1434 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1435 assertEquals(pceId, parser.parseObject(new ObjectHeaderImpl(false, false),
1436 result.slice(4, result.readableBytes() - 4)));
1438 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1439 parser.serializeObject(pceId, buf);
1440 assertArrayEquals(pccIdReqBytes, buf.array());
1444 public void testPceIdIPv6Object() throws PCEPDeserializerException {
1445 final byte[] pccIdReqBytes = {
1447 0x19, 0x20, 0x00, 0x14,
1449 0x00, 0x00, 0x00, 0x00,
1450 0x00, 0x00, 0x00, 0x00,
1451 0x00, 0x00, 0x00, 0x00,
1452 0x00, 0x00, 0x00, 0x01
1454 final PCEPPceIdIPv6ObjectParser parser = new PCEPPceIdIPv6ObjectParser();
1455 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1456 .PceId pccIdReq = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1457 new Ipv6AddressNoZone("::1"))).build();
1458 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1459 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1460 result.slice(4, result.readableBytes() - 4)));
1462 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1463 parser.serializeObject(pccIdReq, buf);
1464 assertArrayEquals(pccIdReqBytes, buf.array());
1468 public void testProcTimeObject() throws PCEPDeserializerException {
1469 final byte[] proctimeBytes = {
1471 0x1A, 0x10, 0x00, 0x1C,
1473 0x00, 0x00, 0x00, 0x01,
1474 /* current proc. time */
1475 0x00, 0x00, 0x00, 0x01,
1476 /* min proc. time */
1477 0x00, 0x00, 0x00, 0x02,
1479 0x00, 0x00, 0x00, 0x03,
1480 /* average proc time */
1481 0x00, 0x00, 0x00, 0x04,
1482 /* variance proc time */
1483 0x00, 0x00, 0x00, 0x05,
1485 final PCEPProcTimeObjectParser parser = new PCEPProcTimeObjectParser();
1486 final ProcTime procTime = new ProcTimeBuilder()
1488 .setAverageProcTime(4L)
1489 .setCurrentProcTime(1L)
1492 .setVarianceProcTime(5L).build();
1493 final ByteBuf result = Unpooled.wrappedBuffer(proctimeBytes);
1494 assertEquals(procTime, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4,
1495 result.readableBytes() - 4)));
1497 final ByteBuf buf = Unpooled.buffer(proctimeBytes.length);
1498 parser.serializeObject(procTime, buf);
1499 assertArrayEquals(proctimeBytes, buf.array());
1503 public void testOverloadObject() throws PCEPDeserializerException {
1504 final byte[] overloadBytes = {
1506 0x1B, 0x10, 0x00, 0x08,
1507 /* overload duration */
1508 0x00, 0x00, 0x00, 0x78
1510 final PCEPOverloadObjectParser parser = new PCEPOverloadObjectParser();
1511 final Overload overload = new OverloadBuilder().setDuration(120).build();
1512 final ByteBuf result = Unpooled.wrappedBuffer(overloadBytes);
1513 assertEquals(overload, parser.parseObject(new ObjectHeaderImpl(false, false),
1514 result.slice(4, result.readableBytes() - 4)));
1516 final ByteBuf buf = Unpooled.buffer(overloadBytes.length);
1517 parser.serializeObject(overload, buf);
1518 assertArrayEquals(overloadBytes, buf.array());
1522 public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
1524 final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde,
1525 (byte) 0xad, (byte) 0xbe, (byte) 0xef,
1527 0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
1529 final PCEPRequestParameterObjectParser parser
1530 = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
1531 final RpBuilder builder = new RpBuilder();
1532 builder.setProcessingRule(false);
1533 builder.setIgnore(false);
1534 builder.setReoptimization(true);
1535 builder.setBiDirectional(false);
1536 builder.setLoose(true);
1537 builder.setMakeBeforeBreak(true);
1538 builder.setOrder(false);
1539 builder.setPathKey(false);
1540 builder.setSupplyOf(false);
1541 builder.setFragmentation(false);
1542 builder.setP2mp(false);
1543 builder.setEroCompression(false);
1544 builder.setPriority((short) 5);
1545 builder.setRequestId(new RequestId(0xdeadbeefL));
1546 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
1547 .object.rp.TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst((short) 0).build()).build());
1549 final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
1550 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1551 result.slice(4, result.readableBytes() - 4)));
1552 final ByteBuf buf = Unpooled.buffer();
1553 parser.serializeObject(builder.build(), buf);
1554 assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
1558 public void testBranchNodeListObject() throws Exception {
1559 final byte[] expected = {
1560 0x1f, 0x10, 0x0, 0xc,
1562 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1565 final BranchNodeListObjectParser parser
1566 = new BranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1567 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1569 final BranchNodeListBuilder builder = new BranchNodeListBuilder();
1570 builder.setProcessingRule(false);
1571 builder.setIgnore(false);
1572 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1573 .route.object.ero.Subobject> subs = new ArrayList<>();
1574 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1575 .route.object.ero.SubobjectBuilder()
1577 .setSubobjectType(new IpPrefixCaseBuilder()
1578 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1579 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1580 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1582 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1583 result.slice(4, result.readableBytes() - 4)));
1584 final ByteBuf buf = Unpooled.buffer();
1585 parser.serializeObject(builder.build(), buf);
1586 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1589 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1591 } catch (final IllegalArgumentException e) {
1592 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1597 public void testNonBranchNodeListObject() throws Exception {
1598 final byte[] expected = {
1599 0x1f, 0x20, 0x0, 0xc,
1601 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1604 final NonBranchNodeListObjectParser parser
1605 = new NonBranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1606 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1608 final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
1609 builder.setProcessingRule(false);
1610 builder.setIgnore(false);
1611 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1612 .route.object.ero.Subobject> subs = new ArrayList<>();
1613 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1614 .route.object.ero.SubobjectBuilder()
1616 .setSubobjectType(new IpPrefixCaseBuilder()
1617 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1618 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1619 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1621 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1622 result.slice(4, result.readableBytes() - 4)));
1623 final ByteBuf buf = Unpooled.buffer();
1624 parser.serializeObject(builder.build(), buf);
1625 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1628 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1630 } catch (final IllegalArgumentException e) {
1631 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1636 public void testPCEPIpv4UnreachDestinationObject() throws Exception {
1637 final byte[] expected = {
1638 0x1c, 0x10, 0x0, 0x8,
1639 (byte) 0x7F, (byte) 0x0, (byte) 0x0, (byte) 0x1
1642 final PCEPIpv4UnreachDestinationParser parser = new PCEPIpv4UnreachDestinationParser();
1643 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1644 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1646 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1647 builder.setProcessingRule(false);
1648 builder.setIgnore(false);
1649 final Ipv4DestinationCase dest = new Ipv4DestinationCaseBuilder()
1650 .setDestinationIpv4Address(Collections.singletonList(new Ipv4AddressNoZone("127.0.0.1")))
1652 builder.setDestination(dest);
1654 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1655 result.slice(4, result.readableBytes() - 4)));
1656 final ByteBuf buf = Unpooled.buffer();
1657 serializer.serializeObject(builder.build(), buf);
1658 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1661 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1663 } catch (final IllegalArgumentException e) {
1664 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1669 public void testPCEPIpv6UnreachDestinationObject() throws Exception {
1670 final byte[] expected = {
1671 0x1c, 0x20, 0x0, 0x14,
1672 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1673 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1674 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1675 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1
1678 final PCEPIpv6UnreachDestinationParser parser = new PCEPIpv6UnreachDestinationParser();
1679 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1680 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1682 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1683 builder.setProcessingRule(false);
1684 builder.setIgnore(false);
1685 final Ipv6DestinationCase dest = new Ipv6DestinationCaseBuilder()
1686 .setDestinationIpv6Address(Collections.singletonList(new Ipv6AddressNoZone("::1")))
1688 builder.setDestination(dest);
1690 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1691 result.slice(4, result.readableBytes() - 4)));
1692 final ByteBuf buf = Unpooled.buffer();
1693 serializer.serializeObject(builder.build(), buf);
1694 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1697 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1699 } catch (final IllegalArgumentException e) {
1700 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());