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.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;
162 public class PCEPObjectParserTest {
164 private TlvRegistry tlvRegistry;
166 private VendorInformationTlvRegistry viTlvRegistry;
168 private SimplePCEPExtensionProviderContext ctx;
169 private BaseParserExtensionActivator act;
170 private TestVendorInformationActivator viAct;
173 public void setUp() {
174 this.ctx = new SimplePCEPExtensionProviderContext();
175 this.act = new BaseParserExtensionActivator();
176 this.viAct = new TestVendorInformationActivator();
177 this.act.start(this.ctx);
178 this.viAct.start(this.ctx);
179 this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
180 this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
184 public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
185 final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
186 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
188 final OpenBuilder builder = new OpenBuilder();
189 builder.setProcessingRule(false);
190 builder.setIgnore(false);
191 builder.setVersion(new ProtocolVersion((short) 1));
192 builder.setKeepalive((short) 30);
193 builder.setDeadTimer((short) 120);
194 builder.setSessionId((short) 1);
196 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open
197 .object.open.TlvsBuilder().build());
199 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
200 result.slice(4, result.readableBytes() - 4)));
201 final ByteBuf buf = Unpooled.buffer();
202 parser.serializeObject(builder.build(), buf);
203 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
206 parser.parseObject(new ObjectHeaderImpl(true, true), null);
208 } catch (final IllegalArgumentException e) {
209 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
212 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
214 } catch (final IllegalArgumentException e) {
215 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
220 public void testCloseObject() throws IOException, PCEPDeserializerException {
221 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
222 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseObject1.bin"));
224 final CCloseBuilder builder = new CCloseBuilder();
225 builder.setProcessingRule(false);
226 builder.setIgnore(false);
227 builder.setReason((short) 5);
228 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close
229 .object.c.close.TlvsBuilder().build());
231 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
232 result.slice(4, result.readableBytes() - 4)));
233 final ByteBuf buf = Unpooled.buffer();
234 parser.serializeObject(builder.build(), buf);
235 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
238 parser.parseObject(new ObjectHeaderImpl(true, true), null);
240 } catch (final IllegalArgumentException e) {
241 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
244 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
246 } catch (final IllegalArgumentException e) {
247 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
252 public void testLoadBalancingObject() throws IOException, PCEPDeserializerException {
253 final PCEPLoadBalancingObjectParser parser = new PCEPLoadBalancingObjectParser();
254 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLoadBalancingObject1.bin"));
256 final LoadBalancingBuilder builder = new LoadBalancingBuilder();
257 builder.setProcessingRule(true);
258 builder.setIgnore(false);
259 builder.setMaxLsp((short) UnsignedBytes.toInt((byte) 0xf1));
260 builder.setMinBandwidth(new Bandwidth(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }));
262 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
263 final ByteBuf buf = Unpooled.buffer();
264 parser.serializeObject(builder.build(), buf);
265 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
268 parser.parseObject(new ObjectHeaderImpl(true, true), null);
270 } catch (final IllegalArgumentException e) {
271 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
274 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
276 } catch (final IllegalArgumentException e) {
277 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
282 public void testERObject() throws Exception {
283 final PCEPExplicitRouteObjectParser parser = new PCEPExplicitRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
284 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin"));
286 final EroBuilder builder = new EroBuilder();
287 builder.setProcessingRule(false);
288 builder.setIgnore(false);
289 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject> subs = Lists.newArrayList();
290 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(
291 true).setSubobjectType(
292 new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0xffffL)).build()).build()).build());
293 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(
294 true).setSubobjectType(
295 new IpPrefixCaseBuilder().setIpPrefix(
296 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
297 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.SubobjectBuilder().setLoose(
298 true).setSubobjectType(
299 new UnnumberedCaseBuilder().setUnnumbered(
300 new UnnumberedBuilder().setRouterId(0xffffffffL).setInterfaceId(0xffffffffL).build()).build()).build());
301 builder.setSubobject(subs);
303 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
304 final ByteBuf buf = Unpooled.buffer();
305 parser.serializeObject(builder.build(), buf);
306 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
309 parser.parseObject(new ObjectHeaderImpl(true, true), null);
311 } catch (final IllegalArgumentException e) {
312 assertEquals("Array of bytes is mandatory. Can't be null.", e.getMessage());
317 public void testIRObject() throws Exception {
318 final PCEPIncludeRouteObjectParser parser = new PCEPIncludeRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
319 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin"));
320 final byte[] ip6PrefixBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
321 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
323 final IroBuilder builder = new IroBuilder();
324 builder.setProcessingRule(false);
325 builder.setIgnore(false);
326 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.Subobject> subs = Lists.newArrayList();
327 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder().setSubobjectType(
328 new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x10L)).build()).build()).setLoose(true).build());
329 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder().setSubobjectType(
330 new IpPrefixCaseBuilder().setIpPrefix(
331 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("18.52.80.0/21"))).build()).build()).setLoose(true).build());
332 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder().setSubobjectType(
333 new IpPrefixCaseBuilder().setIpPrefix(
334 new IpPrefixBuilder().setIpPrefix(new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22))).build()).build()).setLoose(true).build());
335 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.include.route.object.iro.SubobjectBuilder().setSubobjectType(
336 new UnnumberedCaseBuilder().setUnnumbered(
337 new UnnumberedBuilder().setRouterId(0x1245678L).setInterfaceId(0x9abcdef0L).build()).build()).setLoose(true).build());
338 builder.setSubobject(subs);
340 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
341 final ByteBuf buf = Unpooled.buffer();
342 parser.serializeObject(builder.build(), buf);
343 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
346 parser.parseObject(new ObjectHeaderImpl(true, true), null);
348 } catch (final IllegalArgumentException e) {
349 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
352 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
354 } catch (final IllegalArgumentException e) {
355 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
360 public void testRRObject() throws Exception {
361 final PCEPReportedRouteObjectParser parser = new PCEPReportedRouteObjectParser(this.ctx.getRROSubobjectHandlerRegistry());
362 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin"));
363 final byte[] ip6PrefixBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
364 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
366 final RroBuilder builder = new RroBuilder();
367 builder.setProcessingRule(false);
368 builder.setIgnore(false);
369 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.Subobject> subs = Lists.newArrayList();
370 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(
371 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder().setIpPrefix(
372 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder().setIpPrefix(
373 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).setProtectionAvailable(false).setProtectionInUse(
375 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(
376 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.IpPrefixCaseBuilder().setIpPrefix(
377 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.ip.prefix._case.IpPrefixBuilder().setIpPrefix(
378 new IpPrefix(Ipv6Util.prefixForBytes(ip6PrefixBytes, 22))).build()).build()).setProtectionAvailable(false).setProtectionInUse(
380 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder().setSubobjectType(
381 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.UnnumberedCaseBuilder().setUnnumbered(
382 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.record.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder().setRouterId(
383 0x1245678L).setInterfaceId(0x9abcdef0L).build()).build()).setProtectionAvailable(false).setProtectionInUse(
385 builder.setSubobject(subs);
387 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
388 final ByteBuf buf = Unpooled.buffer();
389 parser.serializeObject(builder.build(), buf);
390 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
393 parser.parseObject(new ObjectHeaderImpl(true, true), null);
395 } catch (final IllegalArgumentException e) {
396 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
399 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
401 } catch (final IllegalArgumentException e) {
402 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
407 public void testBandwidthObject() throws IOException, PCEPDeserializerException {
408 final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser();
409 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin"));
411 final BandwidthBuilder builder = new BandwidthBuilder();
412 builder.setProcessingRule(true);
413 builder.setIgnore(true);
414 builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 }));
416 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
417 final ByteBuf buf = Unpooled.buffer();
418 parser.serializeObject(builder.build(), buf);
419 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
422 parser.parseObject(new ObjectHeaderImpl(true, true), null);
424 } catch (final IllegalArgumentException e) {
425 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
428 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
430 } catch (final IllegalArgumentException e) {
431 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
436 public void testExistingBandwidthObject() throws IOException, PCEPDeserializerException {
437 final PCEPExistingBandwidthObjectParser parser = new PCEPExistingBandwidthObjectParser();
438 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject2UpperBounds.bin"));
440 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reoptimization
441 .bandwidth.object.ReoptimizationBandwidthBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml
442 .ns.yang.pcep.types.rev181109.reoptimization.bandwidth.object.ReoptimizationBandwidthBuilder();
443 builder.setProcessingRule(true);
444 builder.setIgnore(true);
445 builder.setBandwidth(new Bandwidth(new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }));
447 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
448 final ByteBuf buf = Unpooled.buffer();
449 parser.serializeObject(builder.build(), buf);
450 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
453 parser.parseObject(new ObjectHeaderImpl(true, true), null);
455 } catch (final IllegalArgumentException e) {
456 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
459 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
461 } catch (final IllegalArgumentException e) {
462 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
467 public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException {
468 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
469 final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
471 final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser();
473 = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject1IPv4.bin"));
475 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
476 builder.setProcessingRule(true);
477 builder.setIgnore(false);
478 builder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(
479 new Ipv4Builder().setSourceIpv4Address(Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
480 .setDestinationIpv4Address(
481 Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(destIPBytes))).build()).build());
483 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
484 result.slice(4, result.readableBytes() - 4)));
485 final ByteBuf buf = Unpooled.buffer();
486 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
487 serializer.serializeObject(builder.build(), buf);
488 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
491 parser.parseObject(new ObjectHeaderImpl(true, true), null);
493 } catch (final IllegalArgumentException e) {
494 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
497 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
499 } catch (final IllegalArgumentException e) {
500 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
506 public void testEndPointsObjectP2MPIPv4() throws PCEPDeserializerException {
507 final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
508 final byte[] destIPBytes = {
509 (byte) 0x04, (byte) 0x32, (byte) 0x00, (byte) 0x14,
510 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
511 (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E,
512 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
513 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFC};
515 final PCEPP2MPEndPointsIpv4ObjectParser parser = new PCEPP2MPEndPointsIpv4ObjectParser();
516 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
518 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
519 builder.setProcessingRule(true);
520 builder.setIgnore(false);
521 builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(new P2mpIpv4Builder()
522 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
523 .setSourceIpv4Address(Ipv4Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
524 .setDestinationIpv4Address(Arrays.asList(new Ipv4AddressNoZone("255.255.255.255"),
525 new Ipv4AddressNoZone("255.255.255.252"))).build()).build());
527 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
528 result.slice(4, result.readableBytes() - 4)));
529 final ByteBuf buf = Unpooled.buffer();
530 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
531 serializer.serializeObject(builder.build(), buf);
532 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
535 parser.parseObject(new ObjectHeaderImpl(true, true), null);
537 } catch (final IllegalArgumentException e) {
538 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
541 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
543 } catch (final IllegalArgumentException e) {
544 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
549 public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException {
550 final byte[] destIPBytes = { (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte) 0xA1,
551 (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, };
552 final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
553 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
555 final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser();
556 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject2IPv6.bin"));
558 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
559 builder.setProcessingRule(true);
560 builder.setIgnore(false);
561 builder.setAddressFamily(new Ipv6CaseBuilder().setIpv6(
562 new Ipv6Builder().setSourceIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes))).setDestinationIpv6Address(
563 Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(destIPBytes))).build()).build());
565 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
566 final ByteBuf buf = Unpooled.buffer();
567 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
568 serializer.serializeObject(builder.build(), buf);
569 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
572 parser.parseObject(new ObjectHeaderImpl(true, true), null);
574 } catch (final IllegalArgumentException e) {
575 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
578 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
580 } catch (final IllegalArgumentException e) {
581 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
586 public void testEndPointsObjectP2MPIPv6() throws IOException, PCEPDeserializerException {
587 final byte[] destIPBytes = {
588 (byte) 0x04, (byte) 0x42, (byte) 0x00, (byte) 0x38,
589 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01,
590 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
591 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
592 (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2,
593 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
594 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
595 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
596 (byte) 0x00, (byte) 0x03, (byte) 0x5D, (byte) 0xD2,
597 (byte) 0xFF, (byte) 0xEC, (byte) 0xA1, (byte) 0xB6,
598 (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50,
599 (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
601 final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
602 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
604 final PCEPP2MPEndPointsIpv6ObjectParser parser = new PCEPP2MPEndPointsIpv6ObjectParser();
605 final ByteBuf result = Unpooled.wrappedBuffer(destIPBytes);
607 final EndpointsObjBuilder builder = new EndpointsObjBuilder();
608 builder.setProcessingRule(true);
609 builder.setIgnore(false);
610 builder.setAddressFamily(new P2mpIpv6CaseBuilder().setP2mpIpv6(new P2mpIpv6Builder()
611 .setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
612 .setSourceIpv6Address(Ipv6Util.noZoneAddressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
613 .setDestinationIpv6Address(Arrays.asList(
614 new Ipv6AddressNoZone("2:5dd2:ffec:a1b6:581e:9f50::"),
615 new Ipv6AddressNoZone("3:5dd2:ffec:a1b6:581e:9f50::")
616 )).build()).build());
618 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
619 result.slice(4, result.readableBytes() - 4)));
620 final ByteBuf buf = Unpooled.buffer();
621 final PCEPEndPointsObjectSerializer serializer = new PCEPEndPointsObjectSerializer();
622 serializer.serializeObject(builder.build(), buf);
623 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
626 parser.parseObject(new ObjectHeaderImpl(true, true), null);
628 } catch (final IllegalArgumentException e) {
629 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
632 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
634 } catch (final IllegalArgumentException e) {
635 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
640 public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
641 final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
642 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));
644 final ErrorObjectBuilder builder = new ErrorObjectBuilder();
645 builder.setProcessingRule(true);
646 builder.setIgnore(true);
647 builder.setType((short) 1);
648 builder.setValue((short) 1);
650 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
651 ByteBuf buf = Unpooled.buffer();
652 parser.serializeObject(builder.build(), buf);
653 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
655 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));
657 builder.setType((short) 7);
658 builder.setValue((short) 0);
659 builder.setTlvs(new TlvsBuilder().setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(0x00001155L)).build()).build());
661 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
662 buf = Unpooled.buffer();
663 parser.serializeObject(builder.build(), buf);
664 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
667 parser.parseObject(new ObjectHeaderImpl(true, true), null);
669 } catch (final IllegalArgumentException e) {
670 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
673 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
675 } catch (final IllegalArgumentException e) {
676 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
681 public void testLspaObject() throws IOException, PCEPDeserializerException {
682 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
683 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
685 final LspaBuilder builder = new LspaBuilder();
686 builder.setProcessingRule(true);
687 builder.setIgnore(true);
688 builder.setExcludeAny(new AttributeFilter(0L));
689 builder.setIncludeAny(new AttributeFilter(0L));
690 builder.setIncludeAll(new AttributeFilter(0L));
691 builder.setHoldPriority((short) 0);
692 builder.setSetupPriority((short) 0);
693 builder.setLocalProtectionDesired(false);
694 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lspa.object.lspa.TlvsBuilder().build());
696 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
697 ByteBuf buf = Unpooled.buffer();
698 parser.serializeObject(builder.build(), buf);
699 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
701 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject2UpperBounds.bin"));
703 builder.setExcludeAny(new AttributeFilter(0xFFFFFFFFL));
704 builder.setIncludeAny(new AttributeFilter(0xFFFFFFFFL));
705 builder.setIncludeAll(new AttributeFilter(0xFFFFFFFFL));
706 builder.setHoldPriority((short) 0xFF);
707 builder.setSetupPriority((short) 0xFF);
708 builder.setLocalProtectionDesired(true);
710 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
711 buf = Unpooled.buffer();
712 parser.serializeObject(builder.build(), buf);
713 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
716 parser.parseObject(new ObjectHeaderImpl(true, true), null);
718 } catch (final IllegalArgumentException e) {
719 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
722 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
724 } catch (final IllegalArgumentException e) {
725 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
730 public void testMetricObject() throws IOException, PCEPDeserializerException {
731 final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
732 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));
734 final MetricBuilder builder = new MetricBuilder();
735 builder.setProcessingRule(true);
736 builder.setIgnore(true);
737 builder.setComputed(false);
738 builder.setBound(false);
739 builder.setMetricType((short) 1);
740 builder.setValue(new Float32(new byte[] { 0, 0, 0, 0 }));
742 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
743 ByteBuf buf = Unpooled.buffer();
744 parser.serializeObject(builder.build(), buf);
745 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
747 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));
749 builder.setComputed(true);
750 builder.setBound(false);
751 builder.setMetricType((short) 2);
752 builder.setValue(new Float32(new byte[] { (byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00 }));
754 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
755 buf = Unpooled.buffer();
756 parser.serializeObject(builder.build(), buf);
757 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
760 parser.parseObject(new ObjectHeaderImpl(true, true), null);
762 } catch (final IllegalArgumentException e) {
763 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
766 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
768 } catch (final IllegalArgumentException e) {
769 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
774 public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
775 final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
776 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
778 final NoPathBuilder builder = new NoPathBuilder();
779 builder.setProcessingRule(true);
780 builder.setIgnore(true);
781 builder.setNatureOfIssue((short) 1);
782 builder.setUnsatisfiedConstraints(true);
783 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
785 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
786 ByteBuf buf = Unpooled.buffer();
787 parser.serializeObject(builder.build(), buf);
788 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
790 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject2WithTLV.bin"));
792 builder.setNatureOfIssue((short) 0);
793 builder.setUnsatisfiedConstraints(false);
795 final NoPathVectorBuilder b = new NoPathVectorBuilder();
796 b.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.NoPathVectorTlv.Flags(false, true, false, true, false, true, true, true));
797 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().setNoPathVector(
800 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
801 buf = Unpooled.buffer();
802 parser.serializeObject(builder.build(), buf);
803 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
806 parser.parseObject(new ObjectHeaderImpl(true, true), null);
808 } catch (final IllegalArgumentException e) {
809 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
812 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
814 } catch (final IllegalArgumentException e) {
815 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
820 public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
821 final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry, this.viTlvRegistry);
822 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));
824 final CNotificationBuilder builder = new CNotificationBuilder();
825 builder.setProcessingRule(true);
826 builder.setIgnore(true);
827 builder.setType((short) 0xff);
828 builder.setValue((short) 0xff);
830 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
831 ByteBuf buf = Unpooled.buffer();
832 parser.serializeObject(builder.build(), buf);
833 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
835 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject1WithTlv.bin"));
837 builder.setType((short) 2);
838 builder.setValue((short) 1);
839 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.notification.object.c.notification.TlvsBuilder().setOverloadDuration(
840 new OverloadDurationBuilder().setDuration(0xff0000a2L).build()).build());
842 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
843 buf = Unpooled.buffer();
844 parser.serializeObject(builder.build(), buf);
845 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
848 parser.parseObject(new ObjectHeaderImpl(true, true), null);
850 } catch (final IllegalArgumentException e) {
851 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
854 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
856 } catch (final IllegalArgumentException e) {
857 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
862 public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
863 final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
864 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));
866 final RpBuilder builder = new RpBuilder();
867 builder.setProcessingRule(true);
868 builder.setIgnore(true);
869 builder.setReoptimization(true);
870 builder.setBiDirectional(false);
871 builder.setLoose(true);
872 builder.setMakeBeforeBreak(true);
873 builder.setOrder(false);
874 builder.setPathKey(false);
875 builder.setSupplyOf(false);
876 builder.setFragmentation(false);
877 builder.setP2mp(false);
878 builder.setEroCompression(false);
879 builder.setPriority((short) 5);
880 builder.setRequestId(new RequestId(0xdeadbeefL));
881 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().build());
883 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
884 ByteBuf buf = Unpooled.buffer();
885 parser.serializeObject(builder.build(), buf);
886 assertArrayEquals(result.array(),ByteArray.getAllBytes(buf));
888 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));
890 builder.setReoptimization(false);
891 builder.setFragmentation(true);
892 builder.setEroCompression(true);
894 final OrderBuilder b = new OrderBuilder();
895 b.setDelete(0xffffffffL);
898 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp.object.rp.TlvsBuilder().setOrder(
901 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
902 buf = Unpooled.buffer();
903 parser.serializeObject(builder.build(), buf);
904 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
907 parser.parseObject(new ObjectHeaderImpl(true, true), null);
909 } catch (final IllegalArgumentException e) {
910 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
913 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
915 } catch (final IllegalArgumentException e) {
916 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
921 public void testSvecObject() throws IOException, PCEPDeserializerException {
922 final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
923 ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
925 final SvecBuilder builder = new SvecBuilder();
926 builder.setProcessingRule(false);
927 builder.setIgnore(false);
928 builder.setLinkDiverse(false);
929 builder.setNodeDiverse(false);
930 builder.setSrlgDiverse(false);
931 builder.setPartialPathDiverse(false);
932 builder.setLinkDirectionDiverse(false);
933 builder.setRequestsIds(Lists.newArrayList(new RequestId(0xFFL)));
935 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
936 result.slice(4, result.readableBytes() - 4)));
937 ByteBuf buf = Unpooled.buffer();
938 parser.serializeObject(builder.build(), buf);
939 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
941 result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));
943 builder.setProcessingRule(true);
944 builder.setLinkDiverse(true);
945 builder.setSrlgDiverse(true);
947 final List<RequestId> requestIDs = Lists.newArrayList();
948 requestIDs.add(new RequestId(0xFFFFFFFFL));
949 requestIDs.add(new RequestId(0x00000001L));
950 requestIDs.add(new RequestId(0x01234567L));
951 requestIDs.add(new RequestId(0x89ABCDEFL));
952 requestIDs.add(new RequestId(0xFEDCBA98L));
953 requestIDs.add(new RequestId(0x76543210L));
954 requestIDs.add(new RequestId(0x15825266L));
955 requestIDs.add(new RequestId(0x48120BBEL));
956 requestIDs.add(new RequestId(0x25FB7E52L));
957 requestIDs.add(new RequestId(0xB2F2546BL));
959 builder.setRequestsIds(requestIDs);
961 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
962 result.slice(4, result.readableBytes() - 4)));
963 buf = Unpooled.buffer();
964 parser.serializeObject(builder.build(), buf);
965 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
968 parser.parseObject(new ObjectHeaderImpl(true, true), null);
970 } catch (final IllegalArgumentException e) {
971 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
974 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
976 } catch (final IllegalArgumentException e) {
977 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
982 public void testClassTypeObject() throws PCEPDeserializerException {
983 final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
984 final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });
986 final ClassTypeBuilder builder = new ClassTypeBuilder();
987 builder.setProcessingRule(true);
988 builder.setIgnore(false);
989 builder.setClassType(new ClassType((short) 4));
991 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
992 final ByteBuf buf = Unpooled.buffer();
993 parser.serializeObject(builder.build(), buf);
994 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
997 parser.parseObject(new ObjectHeaderImpl(true, true), null);
999 } catch (final IllegalArgumentException e) {
1000 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1003 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1005 } catch (final IllegalArgumentException e) {
1006 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1011 public void testExcludeRouteObject() throws Exception {
1012 final PCEPExcludeRouteObjectParser parser = new PCEPExcludeRouteObjectParser(this.ctx.getXROSubobjectHandlerRegistry());
1013 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPExcludeRouteObject.1.bin"));
1015 final XroBuilder builder = new XroBuilder();
1016 builder.setProcessingRule(false);
1017 builder.setIgnore(false);
1018 builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.exclude.route.object.Xro.Flags(true));
1019 final List<Subobject> subs = Lists.newArrayList();
1020 subs.add(new SubobjectBuilder().setMandatory(true).setSubobjectType(
1021 new IpPrefixCaseBuilder().setIpPrefix(
1022 new IpPrefixBuilder().setIpPrefix(new IpPrefix(new Ipv4Prefix("192.168.0.0/16"))).build()).build()).setAttribute(
1023 Attribute.Node).build());
1024 subs.add(new SubobjectBuilder().setMandatory(false).setSubobjectType(
1025 new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x1234L)).build()).build()).build());
1026 builder.setSubobject(subs);
1028 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
1029 final ByteBuf buf = Unpooled.buffer();
1030 parser.serializeObject(builder.build(), buf);
1031 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1034 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1036 } catch (final IllegalArgumentException e) {
1037 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1040 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1042 } catch (final IllegalArgumentException e) {
1043 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1048 public void testPathKeyObject() throws Exception {
1049 final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1050 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPPathKeyObject.bin"));
1052 final PathKeyBuilder builder = new PathKeyBuilder();
1053 builder.setProcessingRule(true);
1054 builder.setIgnore(false);
1055 final List<PathKeys> list = Lists.newArrayList();
1056 list.add(new PathKeysBuilder().setLoose(true).setPathKey(new PathKey(0x1234)).setPceId(
1057 new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })).build());
1058 builder.setPathKeys(list);
1060 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
1061 final ByteBuf buf = Unpooled.buffer();
1062 parser.serializeObject(builder.build(), buf);
1063 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1066 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1068 } catch (final IllegalArgumentException e) {
1069 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1072 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1074 } catch (final IllegalArgumentException e) {
1075 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1080 public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
1081 final PCEPObjectiveFunctionObjectParser parser = new PCEPObjectiveFunctionObjectParser(this.tlvRegistry, this.viTlvRegistry);
1082 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin"));
1084 final OfBuilder builder = new OfBuilder();
1085 builder.setProcessingRule(true);
1086 builder.setIgnore(false);
1087 builder.setCode(new OfId(4));
1088 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.of.object.of.TlvsBuilder().build());
1090 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
1091 final ByteBuf buf = Unpooled.buffer();
1092 parser.serializeObject(builder.build(), buf);
1093 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1096 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1098 } catch (final IllegalArgumentException e) {
1099 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1102 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1104 } catch (final IllegalArgumentException e) {
1105 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1110 public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
1111 final PCEPGlobalConstraintsObjectParser parser = new PCEPGlobalConstraintsObjectParser(this.tlvRegistry, this.viTlvRegistry);
1112 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin"));
1114 final GcBuilder builder = new GcBuilder();
1115 builder.setProcessingRule(true);
1116 builder.setIgnore(false);
1117 builder.setMaxHop((short) 1);
1118 builder.setMaxUtilization((short) 0);
1119 builder.setMinUtilization((short) 100);
1120 builder.setOverBookingFactor((short) 99);
1121 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.gc.object.gc.TlvsBuilder().build());
1123 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
1124 final ByteBuf buf = Unpooled.buffer();
1125 parser.serializeObject(builder.build(), buf);
1126 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1129 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1131 } catch (final IllegalArgumentException e) {
1132 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1135 parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1137 } catch (final IllegalArgumentException e) {
1138 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1143 public void testIgnoreUknownObject() throws PCEPDeserializerException {
1144 final Object object = this.ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
1149 public void testUnrecognizedObjectType() throws PCEPDeserializerException {
1150 final Object object = this.ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
1151 assertNotNull(object);
1152 assertTrue(object instanceof UnknownObject);
1153 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_TYPE, ((UnknownObject) object).getError());
1157 public void testUnrecognizedObjectClass() throws PCEPDeserializerException {
1158 final Object object = this.ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(true, true), null);
1159 assertNotNull(object);
1160 assertTrue(object instanceof UnknownObject);
1161 assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_CLASS, ((UnknownObject) object).getError());
1165 public void testLspaObjectSerializerDefence() throws IOException {
1166 final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
1167 final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
1169 final LspaBuilder builder = new LspaBuilder();
1170 builder.setProcessingRule(true);
1171 builder.setIgnore(true);
1172 builder.setLocalProtectionDesired(false);
1174 final ByteBuf buf = Unpooled.buffer(result.readableBytes());
1175 parser.serializeObject(builder.build(), buf);
1176 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1180 public void testEmptyEroObject() throws PCEPDeserializerException {
1181 final Object object = this.ctx.getObjectHandlerRegistry().parseObject(7, 1,
1182 new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
1183 assertNotNull(object);
1184 assertTrue(object instanceof Ero);
1185 final Ero eroObject = (Ero) object;
1186 assertTrue(eroObject.getSubobject().isEmpty());
1188 final ByteBuf buffer = Unpooled.buffer();
1189 this.ctx.getObjectHandlerRegistry().serializeObject(eroObject, buffer);
1190 final byte[] expected = {0x07, 0x13, 0x00, 0x04};
1191 assertArrayEquals(expected, ByteArray.getAllBytes(buffer));
1195 public void testCloseObjectWithVendorInformationTlv() throws PCEPDeserializerException {
1196 final byte[] closeBytes = {
1197 0x0f, 0x10, 0x00, 0x14,
1198 0x00, 0x00, 0x00, 0x05,
1199 /* vendor-information TLV */
1200 0x00, 0x07, 0x00, 0x08,
1201 /* enterprise number */
1202 0x00, 0x00, 0x00, 0x00,
1203 /* enterprise specific information */
1204 0x00, 0x00, 0x00, 0x05
1206 final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
1207 final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
1209 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1210 final VendorInformationTlv viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(new EnterpriseNumber(0L))
1211 .setEnterpriseSpecificInformation(esInfo).build();
1212 final CCloseBuilder builder = new CCloseBuilder();
1213 builder.setProcessingRule(false);
1214 builder.setIgnore(false);
1215 builder.setReason((short) 5);
1216 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.c.close.TlvsBuilder()
1217 .setVendorInformationTlv(Lists.newArrayList(viTlv)).build());
1219 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
1221 final ByteBuf buf = Unpooled.buffer();
1222 parser.serializeObject(builder.build(), buf);
1223 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1227 public void testVendorInformationObject() throws PCEPDeserializerException {
1228 final byte[] viObjBytes = {
1229 /* vendor-information object */
1230 0x22, 0x10, 0x00, 0x0C,
1231 /* enterprise number */
1232 0x00, 0x00, 0x00, 0x00,
1233 /* enterprise specific information */
1234 0x00, 0x00, 0x00, 0x05
1236 final TestVendorInformationObjectParser parser = new TestVendorInformationObjectParser();
1237 final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
1238 final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L))
1239 .setEnterpriseSpecificInformation(esInfo).build();
1240 final ByteBuf result = Unpooled.wrappedBuffer(viObjBytes);
1241 result.readerIndex(8);
1242 final VendorInformationObject o = (VendorInformationObject) parser.parseObject(new ObjectHeaderImpl(false, false), result.readSlice(result.readableBytes()));
1243 assertEquals(viObj, o);
1245 final ByteBuf buf = Unpooled.buffer(viObjBytes.length);
1246 parser.serializeObject(viObj, buf);
1247 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1251 public void testMonitoringObject() throws PCEPDeserializerException {
1252 final byte[] monitoringBytes = {
1254 0x13, 0x10, 0x00, 0x0C,
1256 0x00, 0x00, 0x00, 0x01,
1257 /* monitoring-id=16 */
1258 0x00, 0x00, 0x00, 0x10
1260 final PCEPMonitoringObjectParser parser = new PCEPMonitoringObjectParser(this.tlvRegistry, this.viTlvRegistry);
1261 final Monitoring monitoring = new MonitoringBuilder().setMonitoringId(16L).setFlags(new Flags(false, false, true, false, false)).setTlvs(
1262 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.monitoring.object.monitoring.TlvsBuilder().build()).build();
1263 final ByteBuf result = Unpooled.wrappedBuffer(monitoringBytes);
1264 assertEquals(monitoring, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
1266 final ByteBuf buf = Unpooled.buffer(monitoringBytes.length);
1267 parser.serializeObject(monitoring, buf);
1268 assertArrayEquals(monitoringBytes, buf.array());
1272 public void testPccIdReqIPv4Object() throws PCEPDeserializerException {
1273 final byte[] pccIdReqBytes = {
1275 0x14, 0x10, 0x00, 0x08,
1277 0x7f, 0x00, 0x00, 0x01
1279 final PCEPPccIdReqIPv4ObjectParser parser = new PCEPPccIdReqIPv4ObjectParser();
1280 final PccIdReq pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1"))).build();
1281 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1282 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
1284 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1285 parser.serializeObject(pccIdReq, buf);
1286 assertArrayEquals(pccIdReqBytes, buf.array());
1290 public void testPccIdReqIPv6Object() throws PCEPDeserializerException {
1291 final byte[] pccIdReqBytes = {
1293 0x14, 0x20, 0x00, 0x14,
1295 0x00, 0x00, 0x00, 0x00,
1296 0x00, 0x00, 0x00, 0x00,
1297 0x00, 0x00, 0x00, 0x00,
1298 0x00, 0x00, 0x00, 0x01
1300 final PCEPPccIdReqIPv6ObjectParser parser = new PCEPPccIdReqIPv6ObjectParser();
1301 final PccIdReq pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(new Ipv6AddressNoZone("::1"))).build();
1302 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1303 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
1305 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1306 parser.serializeObject(pccIdReq, buf);
1307 assertArrayEquals(pccIdReqBytes, buf.array());
1311 public void testPceIdIPv4Object() throws PCEPDeserializerException {
1312 final byte[] pccIdReqBytes = {
1314 0x19, 0x10, 0x00, 0x08,
1316 0x7f, 0x00, 0x00, 0x01
1318 final PCEPPceIdIPv4ObjectParser parser = new PCEPPceIdIPv4ObjectParser();
1319 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1320 .PceId pceId = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1321 new Ipv4AddressNoZone("127.0.0.1"))).build();
1322 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1323 assertEquals(pceId, parser.parseObject(new ObjectHeaderImpl(false, false),
1324 result.slice(4, result.readableBytes() - 4)));
1326 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1327 parser.serializeObject(pceId, buf);
1328 assertArrayEquals(pccIdReqBytes, buf.array());
1332 public void testPceIdIPv6Object() throws PCEPDeserializerException {
1333 final byte[] pccIdReqBytes = {
1335 0x19, 0x20, 0x00, 0x14,
1337 0x00, 0x00, 0x00, 0x00,
1338 0x00, 0x00, 0x00, 0x00,
1339 0x00, 0x00, 0x00, 0x00,
1340 0x00, 0x00, 0x00, 0x01
1342 final PCEPPceIdIPv6ObjectParser parser = new PCEPPceIdIPv6ObjectParser();
1343 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pce.id.object
1344 .PceId pccIdReq = new PceIdBuilder().setIpAddress(new IpAddressNoZone(
1345 new Ipv6AddressNoZone("::1"))).build();
1346 final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
1347 assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false),
1348 result.slice(4, result.readableBytes() - 4)));
1350 final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
1351 parser.serializeObject(pccIdReq, buf);
1352 assertArrayEquals(pccIdReqBytes, buf.array());
1356 public void testProcTimeObject() throws PCEPDeserializerException {
1357 final byte[] proctimeBytes = {
1359 0x1A, 0x10, 0x00, 0x1C,
1361 0x00, 0x00, 0x00, 0x01,
1362 /* current proc. time */
1363 0x00, 0x00, 0x00, 0x01,
1364 /* min proc. time */
1365 0x00, 0x00, 0x00, 0x02,
1367 0x00, 0x00, 0x00, 0x03,
1368 /* average proc time */
1369 0x00, 0x00, 0x00, 0x04,
1370 /* variance proc time */
1371 0x00, 0x00, 0x00, 0x05,
1373 final PCEPProcTimeObjectParser parser = new PCEPProcTimeObjectParser();
1374 final ProcTime procTime = new ProcTimeBuilder()
1376 .setAverageProcTime(4L)
1377 .setCurrentProcTime(1L)
1380 .setVarianceProcTime(5L).build();
1381 final ByteBuf result = Unpooled.wrappedBuffer(proctimeBytes);
1382 assertEquals(procTime, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
1384 final ByteBuf buf = Unpooled.buffer(proctimeBytes.length);
1385 parser.serializeObject(procTime, buf);
1386 assertArrayEquals(proctimeBytes, buf.array());
1390 public void testOverloadObject() throws PCEPDeserializerException {
1391 final byte[] overloadBytes = {
1393 0x1B, 0x10, 0x00, 0x08,
1394 /* overload duration */
1395 0x00, 0x00, 0x00, 0x78
1397 final PCEPOverloadObjectParser parser = new PCEPOverloadObjectParser();
1398 final Overload overload = new OverloadBuilder().setDuration(120).build();
1399 final ByteBuf result = Unpooled.wrappedBuffer(overloadBytes);
1400 assertEquals(overload, parser.parseObject(new ObjectHeaderImpl(false, false),
1401 result.slice(4, result.readableBytes() - 4)));
1403 final ByteBuf buf = Unpooled.buffer(overloadBytes.length);
1404 parser.serializeObject(overload, buf);
1405 assertArrayEquals(overloadBytes, buf.array());
1409 public void testRpObjectWithPstTlvParser() throws PCEPDeserializerException {
1411 final byte[] rpObjectWithPstTlvBytes = { 0x2, 0x10, 0x0, 0x14, 0x0, 0x0, 0x4, 0x2d, (byte) 0xde,
1412 (byte) 0xad, (byte) 0xbe, (byte) 0xef,
1414 0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
1416 final PCEPRequestParameterObjectParser parser
1417 = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
1418 final RpBuilder builder = new RpBuilder();
1419 builder.setProcessingRule(false);
1420 builder.setIgnore(false);
1421 builder.setReoptimization(true);
1422 builder.setBiDirectional(false);
1423 builder.setLoose(true);
1424 builder.setMakeBeforeBreak(true);
1425 builder.setOrder(false);
1426 builder.setPathKey(false);
1427 builder.setSupplyOf(false);
1428 builder.setFragmentation(false);
1429 builder.setP2mp(false);
1430 builder.setEroCompression(false);
1431 builder.setPriority((short) 5);
1432 builder.setRequestId(new RequestId(0xdeadbeefL));
1433 builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
1434 .object.rp.TlvsBuilder().setPathSetupType(new PathSetupTypeBuilder().setPst((short) 0).build()).build());
1436 final ByteBuf result = Unpooled.wrappedBuffer(rpObjectWithPstTlvBytes);
1437 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1438 result.slice(4, result.readableBytes() - 4)));
1439 final ByteBuf buf = Unpooled.buffer();
1440 parser.serializeObject(builder.build(), buf);
1441 assertArrayEquals(rpObjectWithPstTlvBytes, ByteArray.getAllBytes(buf));
1445 public void testBranchNodeListObject() throws Exception {
1446 final byte[] expected = {
1447 0x1f, 0x10, 0x0, 0xc,
1449 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1452 final BranchNodeListObjectParser parser
1453 = new BranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1454 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1456 final BranchNodeListBuilder builder = new BranchNodeListBuilder();
1457 builder.setProcessingRule(false);
1458 builder.setIgnore(false);
1459 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1460 .route.object.ero.Subobject> subs = Lists.newArrayList();
1461 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1462 .route.object.ero.SubobjectBuilder()
1464 .setSubobjectType(new IpPrefixCaseBuilder()
1465 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1466 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1467 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1469 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1470 result.slice(4, result.readableBytes() - 4)));
1471 final ByteBuf buf = Unpooled.buffer();
1472 parser.serializeObject(builder.build(), buf);
1473 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1476 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1478 } catch (final IllegalArgumentException e) {
1479 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1484 public void testNonBranchNodeListObject() throws Exception {
1485 final byte[] expected = {
1486 0x1f, 0x20, 0x0, 0xc,
1488 (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 0x20, 0x0,
1491 final NonBranchNodeListObjectParser parser
1492 = new NonBranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
1493 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1495 final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
1496 builder.setProcessingRule(false);
1497 builder.setIgnore(false);
1498 final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1499 .route.object.ero.Subobject> subs = Lists.newArrayList();
1500 subs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
1501 .route.object.ero.SubobjectBuilder()
1503 .setSubobjectType(new IpPrefixCaseBuilder()
1504 .setIpPrefix(new IpPrefixBuilder().setIpPrefix(
1505 new IpPrefix(new Ipv4Prefix("255.255.255.255/32"))).build()).build()).build());
1506 builder.setSubobject(BNCUtil.toBncSubobject(subs));
1508 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1509 result.slice(4, result.readableBytes() - 4)));
1510 final ByteBuf buf = Unpooled.buffer();
1511 parser.serializeObject(builder.build(), buf);
1512 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1515 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1517 } catch (final IllegalArgumentException e) {
1518 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1523 public void testPCEPIpv4UnreachDestinationObject() throws Exception {
1524 final byte[] expected = {
1525 0x1c, 0x10, 0x0, 0x8,
1526 (byte) 0x7F, (byte) 0x0, (byte) 0x0, (byte) 0x1
1529 final PCEPIpv4UnreachDestinationParser parser = new PCEPIpv4UnreachDestinationParser();
1530 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1531 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1533 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1534 builder.setProcessingRule(false);
1535 builder.setIgnore(false);
1536 final Ipv4DestinationCase dest = new Ipv4DestinationCaseBuilder()
1537 .setDestinationIpv4Address(Collections.singletonList(new Ipv4AddressNoZone("127.0.0.1")))
1539 builder.setDestination(dest);
1541 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1542 result.slice(4, result.readableBytes() - 4)));
1543 final ByteBuf buf = Unpooled.buffer();
1544 serializer.serializeObject(builder.build(), buf);
1545 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1548 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1550 } catch (final IllegalArgumentException e) {
1551 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
1556 public void testPCEPIpv6UnreachDestinationObject() throws Exception {
1557 final byte[] expected = {
1558 0x1c, 0x20, 0x0, 0x14,
1559 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1560 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1561 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x0,
1562 (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1
1565 final PCEPIpv6UnreachDestinationParser parser = new PCEPIpv6UnreachDestinationParser();
1566 final PCEPUnreachDestinationSerializer serializer = new PCEPUnreachDestinationSerializer();
1567 final ByteBuf result = Unpooled.wrappedBuffer(expected);
1569 final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
1570 builder.setProcessingRule(false);
1571 builder.setIgnore(false);
1572 final Ipv6DestinationCase dest = new Ipv6DestinationCaseBuilder()
1573 .setDestinationIpv6Address(Collections.singletonList(new Ipv6AddressNoZone("::1")))
1575 builder.setDestination(dest);
1577 assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
1578 result.slice(4, result.readableBytes() - 4)));
1579 final ByteBuf buf = Unpooled.buffer();
1580 serializer.serializeObject(builder.build(), buf);
1581 assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
1584 parser.parseObject(new ObjectHeaderImpl(true, true), null);
1586 } catch (final IllegalArgumentException e) {
1587 assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());