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;
11 public class PCEPValidatorTest {
13 // private static final LspaObject lspa = new PCEPLspaObject(0L, 0L, 0L, (short) 0, (short) 0, false, false, false,
16 // private final List<ExplicitRouteSubobject> eroSubobjects = asList(
17 // new EROAsNumberSubobject(new AsNumber(0xFFFFL), false),
18 // new EROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte)
19 // 0x33 }), new UnnumberedInterfaceIdentifier(0x00FF00FF), false));
21 // private final List<ReportedRouteSubobject> rroSubobjects = asList((ReportedRouteSubobject) new
22 // RROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] {
23 // (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33 }), new UnnumberedInterfaceIdentifier(0x00FF00FF)));
25 // private final List<Long> requestIds = asList(0x000001L);
27 // private final IPv4Address ip4addr = new IPv4Address(new byte[] { (byte) 0xFF, 0x00, 0x00, 0x01 });
29 // private final PCEPSvecObject svecObj = new PCEPSvecObject(true, true, true, false, false,
30 // PCEPValidatorTest.this.requestIds, true);
32 // private final PCEPRequestParameterObject requestParameter = new PCEPRequestParameterObject(true, false, false,
33 // false, false, false, false, false, (short) 3, 1, true, false);
35 // // private final PCEPEndPointsObject<IPv4Address> endPoints = new
36 // // PCEPEndPointsObject<IPv4Address>(this.ip4addr, this.ip4addr);
38 // private final PCEPEndPointsObject<IPv4Address> endPoints = new PCEPEndPointsObject<IPv4Address>(this.ip4addr,
41 // private static final RawPCEPMessageFactory msgFactory = new RawPCEPMessageFactory();
43 // // private final PCEPClassTypeObject classType = new
44 // // PCEPClassTypeObject((short) 7);
45 // // private final PCEPClassTypeObjectProvider classTypeProvider = new
46 // // PCEPClassTypeObjectProvider((short) 7, true);
48 // private static List<Message> deserMsg(final String srcFile) throws IOException, DeserializerException,
49 // DocumentedException,
50 // PCEPDeserializerException {
51 // final byte[] bytesFromFile = ByteArray.fileToBytes(srcFile);
52 // final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytesFromFile).get(0);
54 // return PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects());
58 // public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
59 // PCEPDeserializerException {
61 // deserMsg("src/test/resources/PCEPOpenMessage1.bin").toString(),
63 // new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
64 // new LSPStateDBVersionTlv(0x80))))).toString());
66 // assertEquals(deserMsg("src/test/resources/Open.1.bin").toString(),
67 // asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1))).toString());
70 // deserMsg("src/test/resources/Open.3.bin").toString(),
72 // new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
73 // new LSPStateDBVersionTlv(53))))).toString());
77 // public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException,
78 // PCEPDocumentedException,
79 // DeserializerException, DocumentedException {
80 // assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin").toString(),
81 // asList(new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build()).toString());
82 // assertEquals(deserMsg("src/test/resources/Keepalive.1.bin").toString(),
83 // asList(new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build()).toString());
88 // // FIXME: should be fixed when we remove PCEPObject
89 // public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException,
90 // DeserializerException,
91 // DocumentedException {
93 // deserMsg("src/test/resources/PCEPCloseMessage1.bin"),
94 // asList(new CloseBuilder().setCCloseMessage(
95 // new CCloseMessageBuilder().setCClose(
96 // new CCloseBuilder().setReason(TerminationReason.TooManyUnknownMsg.getShortValue()).build()).build()).build()));
98 // deserMsg("src/test/resources/Close.1.bin").toString(),
99 // asList(new CloseBuilder().setCCloseMessage(
100 // new CCloseMessageBuilder().setCClose(
101 // new CCloseBuilder().setReason(TerminationReason.Unknown.getShortValue()).build()).build()).build()));
105 // public void testRequestMessageValidationFromBin() throws IOException, PCEPDeserializerException,
106 // PCEPDocumentedException,
107 // DeserializerException, DocumentedException {
108 // List<CompositeRequestObject> requests = new ArrayList<CompositeRequestObject>();
109 // final byte[] ipAdress = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
110 // requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false,
111 // false, false, (short) 5, 0xDEADBEEFL, true, false), new PCEPEndPointsObject<IPv4Address>(new
112 // IPv4Address(ipAdress), new IPv4Address(ipAdress))));
113 // PCEPRequestMessage specMessage = new PCEPRequestMessage(requests);
114 // List<Message> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
115 // final List<Message> specMessages = Lists.newArrayList();
116 // specMessages.add(specMessage);
118 // assertEquals(deserMsgs.toString(), specMessages.toString());
120 // requests = new ArrayList<CompositeRequestObject>();
121 // final byte[] ipAdress2 = { (byte) 0x7F, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
122 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
123 // IPv4Address(ipAdress2), new IPv4Address(ipAdress2))));
124 // specMessage = new PCEPRequestMessage(requests);
125 // deserMsgs = deserMsg("src/test/resources/PCReq.1.bin");
126 // specMessages.clear();
127 // specMessages.add(specMessage);
128 // assertEquals(deserMsgs.toString(), specMessages.toString());
130 // requests = new ArrayList<CompositeRequestObject>();
131 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
132 // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, new
133 // PCEPLoadBalancingObject(3, new Bandwidth(ByteArray.floatToBytes((float) 1024.75)), false)));
134 // specMessage = new PCEPRequestMessage(requests);
135 // deserMsgs = deserMsg("src/test/resources/PCReq.2.bin");
136 // specMessages.clear();
137 // specMessages.add(specMessage);
138 // assertEquals(deserMsgs.toString(), specMessages.toString());
140 // requests = new ArrayList<CompositeRequestObject>();
141 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
142 // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, new PCEPLspObject(1, false, false, true, false),
143 // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false,
144 // false), new ArrayList<PCEPMetricObject>() {
145 // private static final long serialVersionUID = 1L;
148 // this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
150 // }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new
151 // Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false,
152 // false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3)), false)));
154 // List<CompositeRequestSvecObject> svecList = new ArrayList<CompositeRequestSvecObject>();
155 // svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(true, false, false, false, false, this.requestIds,
158 // specMessage = new PCEPRequestMessage(svecList, requests);
159 // deserMsgs = deserMsg("src/test/resources/PCReq.3.bin");
160 // specMessages.clear();
161 // specMessages.add(specMessage);
163 // // assertEquals(deserMsgs, specMessages);
165 // specMessages.clear();
166 // requests = new ArrayList<CompositeRequestObject>();
167 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
168 // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, null));
169 // specMessages.add(new PCEPRequestMessage(requests));
171 // final byte[] ipAdress3 = { (byte) 0x7F, (byte) 0x00, (byte) 0x30, (byte) 0x01 };
172 // requests = new ArrayList<CompositeRequestObject>();
173 // requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(false, false, false, false, false, false,
174 // false, false, (short) 4, 1, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress3), new
175 // IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, null));
176 // specMessages.add(new PCEPRequestMessage(requests));
178 // final byte[] ipAdress4 = { (byte) 0x7F, (byte) 0x30, (byte) 0x00, (byte) 0x01 };
179 // requests = new ArrayList<CompositeRequestObject>();
180 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
181 // IPv4Address(ipAdress2), new IPv4Address(ipAdress4)), null, null, null, null, null, null, null, null, null));
182 // specMessages.add(new PCEPRequestMessage(requests));
184 // final byte[] ipAdress5 = { (byte) 0x7F, (byte) 0xd0, (byte) 0x00, (byte) 0x01 };
185 // requests = new ArrayList<CompositeRequestObject>();
186 // requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false,
187 // false, false, (short) 1, 1, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress5), new
188 // IPv4Address(ipAdress5)), null, null, null, null, null, null, null, null, null));
190 // specMessages.add(new PCEPRequestMessage(requests));
191 // deserMsgs = deserMsg("src/test/resources/PCReq.4.bin");
192 // assertEquals(deserMsgs.toString(), specMessages.toString());
194 // specMessages.clear();
195 // svecList = new ArrayList<CompositeRequestSvecObject>();
196 // svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(true, false, false, false, false, this.requestIds,
198 // svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(false, true, true, false, false, this.requestIds,
199 // false), new PCEPObjectiveFunctionObject(PCEPOFCodes.MCC, true, false), new PCEPGlobalConstraintsObject((short)
200 // 0x55, (short) 1, (short) 100, (short) 0x26, true, false), new PCEPExcludeRouteObject(new
201 // ArrayList<ExcludeRouteSubobject>() {
202 // private static final long serialVersionUID = 1L;
205 // this.add(new XROAsNumberSubobject(new AsNumber((long) 0x12), true));
207 // }, true, true, false), new ArrayList<PCEPMetricObject>() {
208 // private static final long serialVersionUID = 1L;
211 // this.add(new PCEPMetricObject(true, true, new TEMetric(123456L), true, false));
215 // requests = new ArrayList<CompositeRequestObject>();
216 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
217 // IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, PCEPValidatorTest.lspa, new
218 // PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new
219 // ArrayList<PCEPMetricObject>() {
220 // private static final long serialVersionUID = 1L;
223 // this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
224 // this.add(new PCEPMetricObject(true, true, new IGPMetric(5335L), false, false));
225 // this.add(new PCEPMetricObject(true, true, new IGPMetric(128256), false, false));
227 // }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new
228 // Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false,
229 // false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3)), false)));
231 // final byte[] ipAdress6 = { (byte) 0x7F, (byte) 0xF0, (byte) 0x00, (byte) 0x01 };
232 // specMessages.add(new PCEPRequestMessage(svecList, requests));
234 // requests = new ArrayList<CompositeRequestObject>();
235 // requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new
236 // IPv4Address(ipAdress6), new IPv4Address(ipAdress6)), null, null, PCEPValidatorTest.lspa, new
237 // PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new
238 // ArrayList<PCEPMetricObject>() {
239 // private static final long serialVersionUID = 1L;
242 // this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
244 // }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new
245 // Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false,
246 // false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3f)), false)));
247 // deserMsgs = deserMsg("src/test/resources/PCReq.5.bin");
248 // specMessages.add(new PCEPRequestMessage(svecList, requests));
250 // // assertEquals(deserMsgs, specMessages);
252 // // FIXME: need construct with invalid processed parameter
253 // // assertEquals(deserMsg("src/test/resources/PCReq.6.invalid.bin"),
255 // // new PCEPErrorMessage(new CompositeErrorObject(new
256 // // PCEPRequestParameterObject(true, false, false, false, false, false,
257 // // false, false, (short) 3,
258 // // 1L, false, false), new PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))),
259 // // new PCEPRequestMessage(asList(new
260 // // CompositeRequestObject(this.requestParameter, new
261 // // PCEPEndPointsObject<IPv4Address>(IPv4Address
262 // // .getNetworkAddressFactory().getNetworkAddressForBytes(new byte[] {
263 // // 127, 0, 0, 1 }), IPv4Address.getNetworkAddressFactory()
264 // // .getNetworkAddressForBytes(new byte[] { 127, 0, 0, 1 })), null, null,
265 // // null, null, null, null, null, null, new PCEPLoadBalancingObject(
266 // // 3, new Bandwidth(1024.75), false))))));
271 // public void testRequestMessageValidationFromRawMsg() throws PCEPDeserializerException {
272 // List<PCEPObject> objs = new ArrayList<PCEPObject>();
273 // List<Message> msgs;
274 // PCEPRequestParameterObject tmpRP;
276 // // test unrecognized object in svec list
277 // objs.add(this.svecObj);
278 // objs.add(new UnknownObject(true, false, PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
279 // objs.add(new PCEPSvecObject(true, true, true, false, false, PCEPValidatorTest.this.requestIds, true));
281 // msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
283 // assertEquals(msgs.get(0).toString(), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
284 // private static final long serialVersionUID = 1L;
287 // this.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
291 // // test with request p flag not set and ignoracion of more than one
292 // // end-points objects
293 // objs = new ArrayList<PCEPObject>();
294 // objs.add(this.svecObj);
295 // objs.add(this.svecObj);
296 // tmpRP = new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1,
299 // objs.add(this.endPoints);
301 // objs.add(this.requestParameter);
302 // objs.add(this.endPoints);
303 // objs.add(this.endPoints);
304 // // FIXME:mv use object constructor with set processed flag
305 // // objs.add(this.classTypeProvider);
306 // // objs.add(this.requestParameter);
307 // // objs.add(this.endPointsProvider);
308 // // objs.add(new PCEPClassTypeObjectProvider((short) 7, false));
310 // msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
311 // // FIXME:mv use object constructor with set processed flag
312 // // assertEquals(msgs.get(0), new PCEPErrorMessage(new
313 // // CompositeErrorObject(tmpRP, new
314 // // PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))));
317 // // new PCEPRequestMessage(asList(new
318 // // CompositeRequestSvecObject(this.svecObj), new
319 // // CompositeRequestSvecObject(this.svecObj)), Util
320 // // .asList(new CompositeRequestObject(this.requestParameter,
321 // // this.endPoints, this.classType, null, null, null, null, null, null,
324 // // assertEquals(msgs.get(2), new PCEPErrorMessage(new
325 // // CompositeErrorObject(tmpRP, new
326 // // PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))));
330 // public void testReplyMessageValidatorFromBin() throws IOException, PCEPDeserializerException,
331 // PCEPDocumentedException,
332 // DeserializerException, DocumentedException {
334 // List<PCEPReplyMessage> specMessages = new ArrayList<PCEPReplyMessage>();
335 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
336 // false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, true)))));
337 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
338 // true, true, false, false, false, false, false, (short) 7, 0x12345678L, false, false)))));
339 // assertEquals(deserMsg("src/test/resources/PCEPReplyMessage1.bin").toString(), specMessages.toString());
341 // specMessages = new ArrayList<PCEPReplyMessage>();
342 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
343 // false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
344 // assertEquals(deserMsg("src/test/resources/PCRep.1.bin").toString(), specMessages.toString());
346 // specMessages = new ArrayList<PCEPReplyMessage>();
347 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
348 // false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
349 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false,
350 // false, false, false, false, false, false, false, (short) 5, 2, false, false), new PCEPNoPathObject((short) 0,
351 // false, false), null, null, null, null, null, null))));
352 // assertEquals(deserMsg("src/test/resources/PCRep.2.bin").toString(), specMessages.toString());
354 // specMessages = new ArrayList<PCEPReplyMessage>();
355 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
356 // false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1,
357 // true, false), new PCEPLspObject(1, true, true, false, true), PCEPValidatorTest.lspa, new
358 // PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new
359 // ArrayList<PCEPMetricObject>() {
360 // private static final long serialVersionUID = 1L;
363 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234), false, false));
365 // }, new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new ArrayList<CompositePathObject>() {
366 // private static final long serialVersionUID = 1L;
369 // this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa,
370 // new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new
371 // ArrayList<PCEPMetricObject>() {
372 // private static final long serialVersionUID = 1L;
375 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
377 // }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
381 // // assertEquals(deserMsg("src/test/resources/PCRep.3.bin"), specMessages);
383 // specMessages = new ArrayList<PCEPReplyMessage>();
384 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
385 // false, false, false, false, false, false, false, (short) 7, 1, false, false)))));
386 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
387 // false, false, false, false, false, false, false, (short) 1, 2, false, false)))));
388 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
389 // false, false, false, false, false, false, false, (short) 2, 4, false, false)))));
390 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false,
391 // false, false, false, false, false, false, false, (short) 3, 4, false, false)))));
392 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false,
393 // false, false, false, false, false, false, false, (short) 6, 5, false, false)))));
394 // assertEquals(deserMsg("src/test/resources/PCRep.4.bin").toString(), specMessages.toString());
396 // specMessages = new ArrayList<PCEPReplyMessage>();
397 // final List<Long> requestIDs = new ArrayList<Long>();
398 // requestIDs.add(0x25069045L);
400 // final List<PCEPMetricObject> metrics = new ArrayList<PCEPMetricObject>();
401 // metrics.add(new PCEPMetricObject(true, true, new IGPMetric(234L), true, false));
403 // final List<CompositeReplySvecObject> svecList = new ArrayList<CompositeReplySvecObject>();
404 // svecList.add(new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIDs, true),
405 // new PCEPObjectiveFunctionObject(PCEPOFCodes.MCC, true, false), metrics));
407 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
408 // false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1,
409 // true, false), null, PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new
410 // Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
411 // private static final long serialVersionUID = 1L;
414 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234), false, false));
416 // }, new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new ArrayList<CompositePathObject>() {
417 // private static final long serialVersionUID = 1L;
420 // this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa,
421 // new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new
422 // ArrayList<PCEPMetricObject>() {
423 // private static final long serialVersionUID = 1L;
426 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
427 // this.add(new PCEPMetricObject(true, true, new IGPMetric(5355L), false, false));
428 // this.add(new PCEPMetricObject(true, true, new IGPMetric(5353L), false, false));
430 // }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
433 // specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true,
434 // false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1,
435 // true, false), null, PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new
436 // Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
437 // private static final long serialVersionUID = 1L;
440 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234), false, false));
442 // }, new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new ArrayList<CompositePathObject>() {
443 // private static final long serialVersionUID = 1L;
446 // this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa,
447 // new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new
448 // ArrayList<PCEPMetricObject>() {
449 // private static final long serialVersionUID = 1L;
452 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
454 // }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
455 // this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa,
456 // new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new
457 // ArrayList<PCEPMetricObject>() {
458 // private static final long serialVersionUID = 1L;
461 // this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
463 // }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
466 // assertEquals(deserMsg("src/test/resources/PCRep.5.bin").toString(), specMessages.toString());
470 // public void testUpdMessageValidatorFromBin() throws IOException, PCEPDeserializerException,
471 // PCEPDocumentedException,
472 // DeserializerException, DocumentedException {
473 // List<Message> specMessages = Lists.newArrayList();
475 // List<CompositeUpdateRequestObject> requests = new ArrayList<CompositeUpdateRequestObject>();
476 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
478 // specMessages.add(new PCEPUpdateRequestMessage(requests));
479 // assertEquals(deserMsg("src/test/resources/PCUpd.1.bin").toString(), specMessages.toString());
481 // specMessages = Lists.newArrayList();
482 // List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>();
483 // paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
484 // PCEPValidatorTest.lspa, null, null));
485 // requests = new ArrayList<CompositeUpdateRequestObject>();
486 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
487 // specMessages.add(new PCEPUpdateRequestMessage(requests));
488 // assertEquals(deserMsg("src/test/resources/PCUpd.2.bin").toString(), specMessages.toString());
490 // specMessages = Lists.newArrayList();
491 // paths = new ArrayList<CompositeUpdPathObject>();
492 // paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
493 // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
494 // false), new ArrayList<PCEPMetricObject>() {
495 // private static final long serialVersionUID = 1L;
498 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
501 // requests = new ArrayList<CompositeUpdateRequestObject>();
502 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
503 // specMessages.add(new PCEPUpdateRequestMessage(requests));
504 // assertEquals(deserMsg("src/test/resources/PCUpd.3.bin").toString(), specMessages.toString());
506 // specMessages = Lists.newArrayList();
507 // requests = new ArrayList<CompositeUpdateRequestObject>();
508 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
509 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
510 // specMessages.add(new PCEPUpdateRequestMessage(requests));
511 // assertEquals(deserMsg("src/test/resources/PCUpd.4.bin").toString(), specMessages.toString());
513 // specMessages = Lists.newArrayList();
514 // requests = new ArrayList<CompositeUpdateRequestObject>();
515 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
516 // paths = new ArrayList<CompositeUpdPathObject>();
517 // paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
518 // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
519 // false), new ArrayList<PCEPMetricObject>() {
520 // private static final long serialVersionUID = 1L;
523 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
526 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
527 // paths = new ArrayList<CompositeUpdPathObject>();
528 // paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
529 // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
530 // false), new ArrayList<PCEPMetricObject>() {
531 // private static final long serialVersionUID = 1L;
534 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
537 // paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
538 // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
539 // false), new ArrayList<PCEPMetricObject>() {
540 // private static final long serialVersionUID = 1L;
543 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
546 // paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
547 // PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
548 // false), new ArrayList<PCEPMetricObject>() {
549 // private static final long serialVersionUID = 1L;
552 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
553 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
556 // requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
557 // specMessages.add(new PCEPUpdateRequestMessage(requests));
558 // assertEquals(deserMsg("src/test/resources/PCUpd.5.bin").toString(), specMessages.toString());
562 // public void testRptMessageValidatorFromBin() throws IOException, PCEPDeserializerException,
563 // PCEPDocumentedException,
564 // DeserializerException, DocumentedException {
565 // List<Message> specMessages = Lists.newArrayList();
566 // List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>();
567 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
568 // specMessages.add(new PCEPReportMessage(reports));
569 // assertEquals(deserMsg("src/test/resources/PCRpt.1.bin").toString(), specMessages.toString());
571 // specMessages = Lists.newArrayList();
572 // List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>();
573 // paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
574 // PCEPValidatorTest.lspa, null, null, null));
575 // reports = new ArrayList<CompositeStateReportObject>();
576 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
577 // specMessages.add(new PCEPReportMessage(reports));
578 // assertEquals(deserMsg("src/test/resources/PCRpt.2.bin").toString(), specMessages.toString());
580 // specMessages = Lists.newArrayList();
581 // paths = new ArrayList<CompositeRptPathObject>();
582 // paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
583 // PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
584 // false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
585 // private static final long serialVersionUID = 1L;
588 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
592 // reports = new ArrayList<CompositeStateReportObject>();
593 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
594 // specMessages.add(new PCEPReportMessage(reports));
597 // // assertEquals(deserMsg("src/test/resources/PCRpt.3.bin"), specMessages);
599 // specMessages = Lists.newArrayList();
600 // reports = new ArrayList<CompositeStateReportObject>();
601 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
602 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
603 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
604 // specMessages.add(new PCEPReportMessage(reports));
605 // assertEquals(deserMsg("src/test/resources/PCRpt.4.bin").toString(), specMessages.toString());
607 // specMessages = Lists.newArrayList();
608 // reports = new ArrayList<CompositeStateReportObject>();
609 // paths = new ArrayList<CompositeRptPathObject>();
610 // paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
611 // PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
612 // false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
613 // private static final long serialVersionUID = 1L;
616 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
619 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
620 // paths = new ArrayList<CompositeRptPathObject>();
621 // paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
622 // PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
623 // false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
624 // private static final long serialVersionUID = 1L;
627 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
628 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
629 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
632 // paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false),
633 // PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false,
634 // false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
635 // private static final long serialVersionUID = 1L;
638 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
641 // reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
642 // specMessages.add(new PCEPReportMessage(reports));
644 // // assertEquals(deserMsg("src/test/resources/PCRpt.5.bin").toString(), specMessages.toString());
648 // public void testPCCreateMessage() throws DeserializerException, DocumentedException, PCEPDeserializerException {
649 // final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
650 // final List<ExplicitRouteSubobject> subs = new ArrayList<ExplicitRouteSubobject>();
651 // subs.add(new EROAsNumberSubobject(new AsNumber((long) 10), false));
652 // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
653 // final LSPSymbolicNameTlv tlv = new LSPSymbolicNameTlv(new LSPSymbolicName(new byte[] { 5, 4 }));
655 // insts.add(new CompositeInstantiationObject(new
656 // PCEPEndPointsObject<IPv4Address>(IPv4.FAMILY.addressForString("127.0.0.2"),
657 // IPv4.FAMILY.addressForString("127.0.0.1")), PCEPValidatorTest.lspa, new PCEPExplicitRouteObject(subs, true),
658 // null, new ArrayList<PCEPMetricObject>() {
659 // private static final long serialVersionUID = 1L;
662 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
663 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
664 // this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
667 // final PCCreateMessage msg = new PCCreateMessage(insts);
669 // final byte[] bytes = msgFactory.put(msg);
671 // // FIXME: need construct with invalid processed parameter
672 // final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytes).get(0);
674 // assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()).toString(),
675 // asList((Message) msg).toString());
679 // public void testNotificationValidatorFromBin() throws IOException, PCEPDeserializerException,
680 // PCEPDocumentedException,
681 // DeserializerException, DocumentedException {
682 // List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>();
683 // List<PCEPNotificationObject> notificationsList = new ArrayList<PCEPNotificationObject>();
684 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
685 // notifications.add(new CompositeNotifyObject(notificationsList));
686 // PCEPNotificationMessage specMessage = new PCEPNotificationMessage(notifications);
687 // assertEquals(deserMsg("src/test/resources/PCNtf.1.bin").toString(), asList((Message) specMessage).toString());
689 // notifications = new ArrayList<CompositeNotifyObject>();
690 // notificationsList = new ArrayList<PCEPNotificationObject>();
691 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
692 // List<PCEPRequestParameterObject> requestsList = new ArrayList<PCEPRequestParameterObject>();
693 // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3,
694 // 1, false, false));
695 // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
696 // specMessage = new PCEPNotificationMessage(notifications);
697 // assertEquals(deserMsg("src/test/resources/PCNtf.2.bin").toString(), asList((Message) specMessage).toString());
699 // notifications = new ArrayList<CompositeNotifyObject>();
700 // notificationsList = new ArrayList<PCEPNotificationObject>();
701 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
702 // requestsList = new ArrayList<PCEPRequestParameterObject>();
703 // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
704 // 10, false, false));
705 // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
706 // specMessage = new PCEPNotificationMessage(notifications);
707 // assertEquals(deserMsg("src/test/resources/PCNtf.3.bin").toString(), asList((Message) specMessage).toString());
709 // notifications = new ArrayList<CompositeNotifyObject>();
710 // notificationsList = new ArrayList<PCEPNotificationObject>();
711 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
712 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 2));
713 // notificationsList.add(new PCEPNotificationObject((short) 2, (short) 1));
714 // notificationsList.add(new PCEPNotificationObject((short) 2, (short) 2));
715 // notifications.add(new CompositeNotifyObject(notificationsList));
716 // specMessage = new PCEPNotificationMessage(notifications);
717 // assertEquals(deserMsg("src/test/resources/PCNtf.4.bin").toString(), asList((Message) specMessage).toString());
719 // notifications = new ArrayList<CompositeNotifyObject>();
720 // notificationsList = new ArrayList<PCEPNotificationObject>();
721 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
722 // requestsList = new ArrayList<PCEPRequestParameterObject>();
723 // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
724 // 10, false, false));
725 // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
726 // notificationsList = new ArrayList<PCEPNotificationObject>();
727 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
728 // notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
729 // requestsList = new ArrayList<PCEPRequestParameterObject>();
730 // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
731 // 10, false, false));
732 // requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1,
733 // 10, false, false));
734 // notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
735 // specMessage = new PCEPNotificationMessage(notifications);
736 // assertEquals(deserMsg("src/test/resources/PCNtf.5.bin").toString(), asList((Message) specMessage).toString());
740 // public void testErrorMessageValidatoinFromBin() throws IOException, PCEPDeserializerException,
741 // PCEPDocumentedException,
742 // DeserializerException, DocumentedException {
743 // List<PCEPErrorObject> errorsList = new ArrayList<PCEPErrorObject>();
744 // errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
746 // PCEPErrorMessage specMessage = new PCEPErrorMessage(errorsList);
747 // assertEquals(deserMsg("src/test/resources/PCErr.1.bin").toString(), asList((Message) specMessage).toString());
749 // List<PCEPRequestParameterObject> requests = new ArrayList<PCEPRequestParameterObject>();
750 // requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1,
753 // List<CompositeErrorObject> errors = new ArrayList<CompositeErrorObject>();
754 // errors.add(new CompositeErrorObject(requests, errorsList));
756 // specMessage = new PCEPErrorMessage(errors);
757 // assertEquals(deserMsg("src/test/resources/PCErr.2.bin").toString(), asList((Message) specMessage).toString());
759 // specMessage = new PCEPErrorMessage(new PCEPOpenObject(0, 0, 0), errorsList, null);
760 // assertEquals(deserMsg("src/test/resources/PCErr.3.bin").toString(), asList((Message) specMessage).toString());
762 // requests = new ArrayList<PCEPRequestParameterObject>();
763 // requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53,
766 // errors = new ArrayList<CompositeErrorObject>();
767 // errors.add(new CompositeErrorObject(requests, errorsList));
769 // specMessage = new PCEPErrorMessage(errors);
770 // assertEquals(deserMsg("src/test/resources/PCErr.3b.bin").toString(), asList((Message) specMessage).toString());
772 // errorsList = new ArrayList<PCEPErrorObject>();
773 // errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
774 // errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
775 // errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
777 // specMessage = new PCEPErrorMessage(null, errorsList, null);
778 // assertEquals(deserMsg("src/test/resources/PCErr.4.bin").toString(), asList((Message) specMessage).toString());
780 // requests = new ArrayList<PCEPRequestParameterObject>();
781 // requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53,
784 // errorsList = new ArrayList<PCEPErrorObject>();
785 // errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
787 // errors = new ArrayList<CompositeErrorObject>();
788 // errors.add(new CompositeErrorObject(requests, errorsList));
789 // errors.add(new CompositeErrorObject(requests, errorsList));
791 // specMessage = new PCEPErrorMessage(errors);
792 // assertEquals(deserMsg("src/test/resources/PCErr.5.bin").toString(), asList((Message) specMessage).toString());