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;
14 * PCEPOpenObject3.bin<br/>
20 * - processing: true<br/>
21 * - ignored: true<br/>
28 * PCEPBandwidthObject1LowerBounds.bin<br/>
34 * - processing: true<br/>
35 * - ignored: true<br/>
39 * PCEPBandwidthObject2UpperBounds.bin<br/>
45 * - processing: true<br/>
46 * - ignored: true<br/>
48 * Bandwidth: 0xFFFFFFFF<br/>
50 * PCEPEndPointsObject1IPv4.bin<br/>
56 * - processing: true<br/>
57 * - ignored: true<br/>
59 * src IP: 0xA2F5110E <br/>
60 * dest IP: 0xFFFFFFFF <br/>
62 * PCEPEndPointsObject2IPv6.bin<br/>
68 * - processing: true<br/>
69 * - ignored: true<br/>
71 * src IP: 0xFFFFFFFFF FFFFFFFFF FFFFFFFFF FFFFFFFFF<br/>
72 * dest IP: 0x00025DD2 FFECA1B6 581E9F50 00000000 <br/>
74 * PCEPErrorObject1.bin<br/>
75 * objClass: 13 (RP)<br/>
80 * - processing: false<br/>
81 * - ignored: false<br/>
87 * PCEPErrorObject2Invalid.bin<br/>
88 * objClass: 13 (RP)<br/>
93 * - processing: false<br/>
94 * - ignored: false<br/>
100 * PCEPErrorObject3.bin<br/>
101 * objClass: 13 (RP)<br/>
106 * - processing: false<br/>
107 * - ignored: false<br/>
110 * Error-value: 0<br/>
113 * PCEPLspaObject1LowerBounds.bin<br/>
119 * - processing: true<br/>
120 * - ignored: true<br/>
122 * Exclude-any: 0x00000000L<br/>
123 * Include-any: 0x00000000L<br/>
124 * Include-all: 0x00000000L<br/>
125 * Setup Prio: 0x00<br/>
126 * Holding Prio: 0x00<br/>
127 * Flags: - L : false<br/>
129 * PCEPLspaObject2UpperBounds.bin<br/>
135 * - processing: true<br/>
136 * - ignored: true<br/>
138 * Exclude-any: 0xFFFFFFFFL<br/>
139 * Include-any: 0xFFFFFFFFL<br/>
140 * Include-all: 0xFFFFFFFFL<br/>
141 * Setup Prio: 0xFF<br/>
142 * Holding Prio: 0xFF<br/>
143 * Flags: - L : true<br/>
145 * PCEPLspaObject3RandVals.bin<br/>
151 * - processing: true<br/>
152 * - ignored: true<br/>
154 * Exclude-any: 0x20A1FEE3L<br/>
155 * Include-any: 0x1A025CC7L<br/>
156 * Include-all: 0x2BB66532L<br/>
157 * Setup Prio: 0x03<br/>
158 * Holding Prio: 0x02<br/>
159 * Flags: - L : true<br/>
161 * NoPathObject1WithTLV.bin<br/>
162 * objClass: 3 (RP)<br/>
167 * - processing: false<br/>
168 * - ignored: false<br/>
170 * Nature of Issue: 2<br/>
171 * No-Path flags:<br/>
175 * -- NO-PATH-VECTOR<br/>
176 * - flags (0x4000):<br/>
177 * - PCE currently unavailable: false<br/>
178 * - unknown destination: true<br/>
179 * - unknown source: false<br/>
182 * NoPathObject2WithoutTLV.bin<br/>
183 * objClass: 3 (RP)<br/>
188 * - processing: false<br/>
189 * - ignored: true<br/>
191 * Nature of Issue: 16<br/>
192 * No-Path flags:<br/>
197 * PCEPNotificationObject1WithTlv.bin <br/>
203 * - processing: false<br/>
204 * - ignored: false<br/>
209 * - OverloaderDuration(0xFF0000A2L)<br/>
211 * PCEPNotificationObject2WithoutTlv.bin <br/>
217 * - processing: false<br/>
218 * - ignored: false<br/>
224 * PCEPOpenObject1.bin<br/>
230 * - processing: false<br/>
231 * - ignored: false<br/>
234 * deadTimer: 120<br/>
237 * - PCEPStatefulCapability<br/>
238 * - LSPStateDBVersionTlv<br/>
239 * - NodeIdentifierTlv<br/>
241 * PCEPOpenObject2UpperBoundsNoTlv.bin<br/>
247 * - processing: false<br/>
248 * - ignored: false<br/>
250 * keepAlive: 0xFF<br/>
251 * deadTimer: 0xFF<br/>
252 * sessionId: 0xFF<br/>
255 * PCEPRPObject1.bin<br/>
256 * objClass: 2 (RP)<br/>
261 * - processing: false<br/>
262 * - ignored: false<br/>
265 * - loose/strict: true<br/>
266 * - Bi-directional: false<br/>
267 * - Reoptimization: false<br/>
269 * Request ID: 0xDEADBEEF<br/>
272 * PCEPSvecObject1_10ReqIDs.bin <br/>
278 * - processing: true<br/>
279 * - ignored: false<br/>
282 * - Link diverse: true<br/>
283 * - Node diverse: false<br/>
284 * - SRLG diverse: true<br/>
285 * Reques-ID-numbers:<br/>
286 * #1 - 0xFFFFFFFFL<br/>
287 * #2 - 0x00000000L<br/>
288 * #3 - 0x01234567L<br/>
289 * #4 - 0x89ABCDEFL<br/>
290 * #5 - 0xFEDCBA98L<br/>
291 * #6 - 0x76543210L<br/>
292 * #7 - 0x15825266L<br/>
293 * #8 - 0x48120BBEL<br/>
294 * #9 - 0x25FB7E52L<br/>
295 * #10 - 0xB2F2546BL<br/>
297 * PCEPSvecObject2.bin <br/>
303 * - processing: false<br/>
304 * - ignored: false<br/>
307 * - Link diverse: false<br/>
308 * - Node diverse: false<br/>
309 * - SRLG diverse: false<br/>
310 * Reques-ID-numbers:<br/>
311 * #1 - 0x000000FFL<br/>
312 * PCEPExcludeRouteObject.1.bin <br/>
315 * objLength: 20 <br/>
320 * - XROIPv4PreffixSubobject(192.168.0.0/16, exclude, node) <br/>
321 * - XROASnumber(0x1234) <br/>
323 public class PCEPObjectParserTest {
326 // private HandlerRegistry registry;
328 // IPv4Address ipv4addr = new IPv4Address(new byte[] { (byte) 192, (byte) 168, 1, 8 });
330 // IPv6Address ipv6addr = new IPv6Address(new byte[] { (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1,
331 // (byte) 192, (byte) 168,
332 // 2, 1, (byte) 192, (byte) 168, 2, 1 });
334 // @SuppressWarnings("unchecked")
335 // private static <T extends PCEPObject> void serDeserTest(final String srcFile, final T specObject) throws
337 // PCEPDeserializerException, PCEPDocumentedException {
338 // final byte[] bytesFromFile = ByteArray.fileToBytes(srcFile);
339 // final T deserSpecObj = (T) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
340 // final byte[] serSpecObj = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObject));
342 // assertEquals(specObject, deserSpecObj);
343 // assertArrayEquals(bytesFromFile, serSpecObj);
347 // * Standard serialization test<br/>
348 // * Used resources:<br/>
349 // * - PCEPOpenObject1.bin<br/>
351 // * @throws PCEPDeserializerException
352 // * @throws IOException
353 // * @throws PCEPDocumentedException
357 // // FIXME: temporary
358 // public void testObjectDeserialization() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
359 // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
363 // public void testUnknownClass() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
365 // final PCEPObject obj =
366 // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPObject1UnknownClass.bin")).get(
369 // // assertTrue(obj instanceof UnknownObject);
370 // // assertEquals(((UnknownObject) obj).getError(), PCEPErrors.UNRECOGNIZED_OBJ_CLASS);
374 // // public void testUnknownType() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
375 // // final PCEPObject obj =
376 // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPObject2UnknownType.bin")).get(0);
378 // // assertTrue(obj instanceof UnknownObject);
379 // // assertEquals(((UnknownObject) obj).getError(), PCEPErrors.UNRECOGNIZED_OBJ_TYPE);
383 // // public void testCloseObjSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
384 // // serDeserTest("src/test/resources/PCEPCloseObject1.bin", new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG));
390 // public void testLoadBalancingObjSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException
392 // serDeserTest("src/test/resources/PCEPLoadBalancingObject1.bin", new PCEPLoadBalancingObject(0xF1, new
393 // Bandwidth(new byte[] {
394 // (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }), true));
398 // public void testLspObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
399 // serDeserTest("src/test/resources/PCEPLspObject1NoTlvsUpperBounds.bin", new PCEPLspObject(0xFFFFF, true, false,
400 // true, false, null));
404 // public void testERObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
405 // final byte[] bytesFromFile =
406 // ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin");
408 // MockitoAnnotations.initMocks(this);
409 // PCEPExplicitRouteObjectParser parser = new PCEPExplicitRouteObjectParser(registry);
410 // doReturn(parser).when(registry).getObjectParser(PCEPExplicitRouteObjectParser.TYPE,
411 // PCEPExplicitRouteObjectParser.CLASS);
412 // doReturn(new EROAsNumberSubobjectParser()).when(registry).getSubobjectParser(EROAsNumberSubobjectParser.TYPE);
413 // ObjectHeader h = new ObjectHeader() {
416 // public Class<? extends DataContainer> getImplementedInterface() {
417 // // TODO Auto-generated method stub
422 // public Boolean isProcessingRule() {
427 // public Boolean isIgnore() {
432 // final ExplicitRouteSubobject specObj = (ExplicitRouteSubobject)
433 // registry.getObjectParser(PCEPExplicitRouteObjectParser.TYPE, PCEPExplicitRouteObjectParser.CLASS).parseObject(h,
436 // System.out.println(specObj.toString());
438 // //final byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObj));
439 // //assertArrayEquals(bytesFromFile, bytesActual);
443 // public void testIRObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
444 // final byte[] bytesFromFile =
445 // ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin");
447 // final PCEPIncludeRouteObject specObj = (PCEPIncludeRouteObject)
448 // PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
450 // assertEquals(8, specObj.getSubobjects().size());
452 // final byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObj));
453 // assertArrayEquals(bytesFromFile, bytesActual);
457 // public void tesRRObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
458 // final byte[] bytesFromFile =
459 // ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin");
461 // final PCEPReportedRouteObject specObj = (PCEPReportedRouteObject)
462 // PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
464 // assertEquals(6, specObj.getSubobjects().size());
466 // final byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObj));
467 // assertArrayEquals(bytesFromFile, bytesActual);
471 // * Test for upper/lower bounds (Serialization/Deserialization)<br/>
472 // * Used resources:<br/>
473 // * - PCEPBandwidthObject2UpperBounds.bin<br/>
474 // * - PCEPBandwidthObject1LowerBounds.bin<br/>
476 // * @throws IOException
477 // * @throws PCEPDeserializerException
478 // * @throws PCEPDocumentedException
483 // public void testBandwidthObjectBounds() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
484 // serDeserTest("src/test/resources/PCEPBandwidthObject1LowerBounds.bin",
485 // new PCEPRequestedPathBandwidthObject(new Bandwidth(new byte[] { 0, 0, 0, 0 }), true, true));
489 // * Test for upper/lower bounds of IPv4 EndPoints (Serialization/Deserialization)<br/>
490 // * Used resources:<br/>
491 // * - PCEPEndPointsObject1IPv4.bin<br/>
493 // * @throws IOException
494 // * @throws PCEPDeserializerException
495 // * @throws PCEPDocumentedException
498 // public void testEndPointsObjectSerDeserIPv4() throws IOException, PCEPDeserializerException,
499 // PCEPDocumentedException {
500 // final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
501 // final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
502 // serDeserTest("src/test/resources/PCEPEndPointsObject1IPv4.bin",
503 // new PCEPEndPointsObject<IPv4Address>(new IPv4Address(srcIPBytes), new IPv4Address(destIPBytes)));
507 // * Test for upper/lower bounds of IPv6 EndPoints (Serialization/Deserialization)<br/>
508 // * Used resources:<br/>
509 // * - PCEPEndPointsObject2IPv6.bin<br/>
511 // * @throws IOException
512 // * @throws PCEPDeserializerException
513 // * @throws PCEPDocumentedException
516 // public void testEndPointsObjectSerDeserIPv6() throws IOException, PCEPDeserializerException,
517 // PCEPDocumentedException {
518 // final byte[] destIPBytes = { (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte)
520 // (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)
522 // final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte)
523 // 0xFF, (byte) 0xFF,
524 // (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
526 // serDeserTest("src/test/resources/PCEPEndPointsObject2IPv6.bin",
527 // new PCEPEndPointsObject<IPv6Address>(new IPv6Address(srcIPBytes), new IPv6Address(destIPBytes)));
531 // * Test of Serialization/Deserialization of PCEPErrorObjectParser.<br/>
533 // * Used resources:<br/>
534 // * - PCEPErrorObject1.bin<br/>
535 // * - PCEPErrorObject3.bin<br/>
537 // * @throws PCEPDeserializerException
538 // * @throws IOException
539 // * @throws PCEPDocumentedException
542 // public void testErrorObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException,
543 // PCEPDocumentedException {
544 // serDeserTest("src/test/resources/PCEPErrorObject1.bin", new PCEPErrorObject(PCEPErrors.NON_OR_INVALID_OPEN_MSG));
545 // serDeserTest("src/test/resources/PCEPErrorObject3.bin", new
546 // PCEPErrorObject(PCEPErrors.CAPABILITY_NOT_SUPPORTED));
550 // * Test of validity of PCEPErrorObjectParser. Expect throwed NoSuchElementException.<br/>
552 // * Used resources:<br/>
553 // * - PCEPErrorObject2Invalid.bin<br/>
555 // * @throws NoSuchElementException
556 // * @throws IOException
557 // * @throws PCEPDocumentedException
559 // @Test(expected = PCEPDeserializerException.class)
560 // public void testUnknownError() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
561 // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject2Invalid.bin")).get(0);
565 // * Test for upper/lower bounds of PCEPLspaObject (Serialization/Deserialization)<br/>
566 // * Used resources:<br/>
567 // * - PCEPLspaObject1LowerBounds.bin<br/>
568 // * - PCEPLspaObject2UpperBounds.bin<br/>
569 // * - PCEPLspaObject3RandVals.bin<br/>
571 // * @throws IOException
572 // * @throws PCEPDeserializerException
573 // * @throws PCEPDocumentedException
576 // public void testLspaObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
577 // serDeserTest("src/test/resources/PCEPLspaObject2UpperBounds.bin",
578 // new PCEPLspaObject(0xFFFFFFFFL, 0xFFFFFFFFL, 0xFFFFFFFFL, (short) 0xFF, (short) 0xFF, false, true, true, true));
579 // serDeserTest("src/test/resources/PCEPLspaObject1LowerBounds.bin",
580 // new PCEPLspaObject(0x00000000L, 0x00000000L, 0x00000000L, (short) 0x00, (short) 0x00, false, false, true, true));
581 // serDeserTest("src/test/resources/PCEPLspaObject3RandVals.bin",
582 // new PCEPLspaObject(0x20A1FEE3L, 0x1A025CC7L, 0x2BB66532L, (short) 0x03, (short) 0x02, false, true, true, true));
586 // public void testMetricObjectSerDeserBounds() throws IOException, PCEPDeserializerException,
587 // PCEPDocumentedException {
588 // final byte[] bytesFromFileUB = ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin");
589 // final byte[] bytesFromFileLB = ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin");
591 // final PCEPMetricObject metricObjectLB = (PCEPMetricObject)
592 // PCEPObjectFactory.parseObjects(bytesFromFileLB).get(0);
593 // final PCEPMetricObject metricObjectUB = (PCEPMetricObject)
594 // PCEPObjectFactory.parseObjects(bytesFromFileUB).get(0);
596 // assertEquals(new PCEPMetricObject(false, false, new IGPMetric(0), true, true), metricObjectLB);
597 // assertEquals(new PCEPMetricObject(false, true, new TEMetric(4026531840L), true, true), metricObjectUB);
599 // final byte[] bytesActualLB = PCEPObjectFactory.put(Arrays.asList((PCEPObject) metricObjectLB));
600 // final byte[] bytesActualUB = PCEPObjectFactory.put(Arrays.asList((PCEPObject) metricObjectUB));
601 // assertArrayEquals(bytesFromFileLB, bytesActualLB);
602 // assertArrayEquals(bytesFromFileUB, bytesActualUB);
606 // * Standard deserialization test + specific test without tlv<br/>
607 // * Used resources:<br/>
608 // * - NoPathObject1WithTLV.bin<br/>
609 // * - NoPathObject2WithoutTLV.bin<br/>
611 // * @throws PCEPDeserializerException
612 // * @throws IOException
613 // * @throws PCEPDocumentedException
616 // public void testNoPathObjectDeserialization() throws PCEPDeserializerException, IOException,
617 // PCEPDocumentedException {
618 // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>(1);
619 // // tlvs.add(new NoPathVectorTlv(false, false, true, false, false, false));
620 // // serDeserTest("src/test/resources/NoPathObject1WithTLV.bin", new PCEPNoPathObject((short) 2, true, tlvs,
622 // serDeserTest("src/test/resources/NoPathObject2WithoutTLV.bin", new PCEPNoPathObject((short) 0x10, false, true));
627 // * Standard serialization test + without tlv<br/>
628 // * Used resources:<br/>
629 // * - NoPathObject1WithTLV.bin<br/>
630 // * - NoPathObject2WithoutTLV.bin<br/>
632 // * @throws PCEPDeserializerException
633 // * @throws IOException
634 // * @throws PCEPDocumentedException
637 // public void testNoPathObjectSerialization() throws IOException, PCEPDeserializerException,
638 // PCEPDocumentedException {
639 // byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/NoPathObject2WithoutTLV.bin");
640 // PCEPNoPathObject noPathObject = (PCEPNoPathObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
641 // byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) noPathObject));
642 // assertArrayEquals(bytesFromFile, bytesActual);
644 // bytesFromFile = ByteArray.fileToBytes("src/test/resources/NoPathObject1WithTLV.bin");
645 // noPathObject = (PCEPNoPathObject) PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
646 // bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) noPathObject));
647 // assertArrayEquals(bytesFromFile, bytesActual);
651 // * Specific test with/without tlvs (Ser/Deser)<br/>
652 // * Used resources:<br/>
653 // * - PCEPNotificationObject1WithTlv.bin - PCEPNotificationObject2WithoutTlv.bin
655 // * @throws PCEPDeserializerException
656 // * @throws IOException
657 // * @throws PCEPDocumentedException
660 // public void testNotifyObjectSerDeserWithTlv() throws PCEPDeserializerException, IOException,
661 // PCEPDocumentedException {
662 // // FINAL LIST<PCEPTLV> TLVS = NEW ARRAYLIST<PCEPTLV>(1);
663 // // TLVS.ADD(NEW OVERLOADEDDURATIONTLV(0XFF0000A2));
664 // // SERDESERTEST("src/test/resources/PCEPNotificationObject1WithTlv.bin", new PCEPNotificationObject((short) 1,
665 // (short) 1, tlvs));
666 // serDeserTest("src/test/resources/PCEPNotificationObject2WithoutTlv.bin", new PCEPNotificationObject((short) 0xFF,
671 // * Standard ser deser test<br/>
672 // * used resources:<br/>
673 // * - PCEPOpenObject1.bin
675 // * @throws PCEPDeserializerException
676 // * @throws IOException
677 // * @throws PCEPDocumentedException
681 // // FIXME: temporary
682 // public void testOpenObjectSerDeser() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
683 // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
684 // // tlvs.add(new PCEStatefulCapabilityTlv(false, true, true));
685 // // tlvs.add(new LSPStateDBVersionTlv(0x80));
686 // // final byte[] valueBytes = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC,
687 // (byte) 0xDE, (byte) 0xF0 };
688 // // tlvs.add(new NodeIdentifierTlv(valueBytes));
689 // // final PCEPOpenObject specObject = new PCEPOpenObject(30, 120, 1, tlvs);
691 // // serDeserTest("src/test/resources/PCEPOpenObject1.bin", specObject);
695 // * Specific test for upper bounds and without tlvs<br/>
696 // * Used resources:<br/>
697 // * - PCEPOpenObject2UpperBoundsNoTlv.bin
699 // * @throws PCEPDeserializerException
700 // * @throws IOException
701 // * @throws PCEPDocumentedException
704 // public void testOpenObjectBoundsWithoutTlvs() throws IOException, PCEPDeserializerException,
705 // PCEPDocumentedException {
706 // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
707 // // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
709 // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
714 // * Standard deserialization test<br/>
715 // * Used resources:<br/>
716 // * - PCEPRPObject1.bin
718 // * @throws PCEPDeserializerException
719 // * @throws IOException
720 // * @throws PCEPDocumentedException
723 // public void testRPObjectSerDeser() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
724 // serDeserTest("src/test/resources/PCEPRPObject1.bin",
725 // new PCEPRequestParameterObject(true, false, true, true, false, false, false, false, (short) 5, 0xdeadbeefL,
728 // // "src/test/resources/PCEPRPObject2.bin",
729 // // new PCEPRequestParameterObject(true, false, false, false, true, false, true, false, true, (short) 5,
730 // 0xdeadbeefL, new ArrayList<PCEPTlv>() {
731 // // private static final long serialVersionUID = 1L;
734 // // this.add(new OrderTlv(0xFFFFFFFFL, 0x00000001L));
736 // // }, false, false));
740 // * Test for upper/lower bounds of PCEPSvecObject (Serialization/Deserialization)<br/>
741 // * Used resources:<br/>
742 // * - PCEPSvecObject1_10ReqIDs.bin<br/>
744 // * @throws IOException
745 // * @throws PCEPDeserializerException
746 // * @throws PCEPDocumentedException
749 // public void testSvecObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
750 // final List<Long> requestIDs = new ArrayList<Long>(10);
751 // requestIDs.add(0xFFFFFFFFL);
752 // requestIDs.add(0x00000000L);
753 // requestIDs.add(0x01234567L);
754 // requestIDs.add(0x89ABCDEFL);
755 // requestIDs.add(0xFEDCBA98L);
756 // requestIDs.add(0x76543210L);
757 // requestIDs.add(0x15825266L);
758 // requestIDs.add(0x48120BBEL);
759 // requestIDs.add(0x25FB7E52L);
760 // requestIDs.add(0xB2F2546BL);
762 // serDeserTest("src/test/resources/PCEPSvecObject1_10ReqIDs.bin",
763 // new PCEPSvecObject(true, false, true, false, true, requestIDs, true));
767 // * Test for lowest bounds of PCEPSvecObject (Serialization/Deserialization)<br/>
768 // * Used resources:<br/>
769 // * - PCEPSvecObject2.bin<br/>
771 // * @throws IOException
772 // * @throws PCEPDeserializerException
773 // * @throws PCEPDocumentedException
776 // public void testSvecObjectSerDeserNoReqIDs() throws IOException, PCEPDeserializerException,
777 // PCEPDocumentedException {
778 // final List<Long> requestIDs = new ArrayList<Long>();
779 // requestIDs.add(0xFFL);
780 // serDeserTest("src/test/resources/PCEPSvecObject2.bin", new PCEPSvecObject(false, false, false, false, false,
781 // requestIDs, false));
785 // public void testClassTypeObject() throws PCEPDeserializerException, PCEPDocumentedException {
786 // final PCEPClassTypeObject ct = new PCEPClassTypeObject((short) 4);
787 // // final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
788 // // final byte[] bytes = parser.put(ct);
789 // // assertEquals(ct, parser.parse(bytes, true, false));
793 // * Test PCEPExcludeRouteObjectObject (Serialization/Deserialization)<br/>
794 // * Used resources:<br/>
795 // * - PCEPExcludeRouteObject.1.bin<br/>
797 // * @throws IOException
798 // * @throws PCEPDeserializerException
799 // * @throws PCEPDocumentedException
802 // public void testExcludeRouteObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
803 // final List<ExcludeRouteSubobject> xroSubobjects = new ArrayList<ExcludeRouteSubobject>();
804 // xroSubobjects.add(new XROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192,
806 // (byte) 100, (byte) 100 }), 16), true, XROSubobjectAttribute.NODE));
807 // xroSubobjects.add(new XROAsNumberSubobject(new AsNumber(0x1234L), false));
812 // public void tesObjectiveFunctionObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
813 // serDeserTest("src/test/resources/PCEPObjectiveFunctionObject.1.bin", new
814 // PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false));
818 // public void tesGlobalConstraintsObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
819 // serDeserTest("src/test/resources/PCEPGlobalConstraintsObject.1.bin",
820 // new PCEPGlobalConstraintsObject((short) 1, (short) 0, (short) 100, (short) 0xFF, true, false));
823 // // FIXME: add at least one test with true value
825 // public void openObjectWithTlv() throws PCEPDeserializerException, PCEPDocumentedException {
826 // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, false, false));
827 // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, false, true));
828 // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, false));
829 // // this.testOpenObjectWithSpecTlv(new PCEStatefulCapabilityTlv(false, true, true));
832 // // private void testOpenObjectWithSpecTlv(final PCEPTlv tlv) throws PCEPDeserializerException,
833 // PCEPDocumentedException {
834 // // final List<PCEPObject> objs = new ArrayList<PCEPObject>();
835 // // final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
837 // // final PCEPOpenObject oo = new PCEPOpenObject(30, 120, 0, tlvs);
839 // // final byte[] bytes = PCEPObjectFactory.put(objs);
840 // // final PCEPObject obj = PCEPObjectFactory.parseObjects(bytes).get(0);
841 // // assertEquals(oo, obj);
845 // public void testErrorsMapping() {
846 // final PCEPErrorObjectParser.PCEPErrorsMaping mapper = PCEPErrorObjectParser.PCEPErrorsMaping.getInstance();
848 // for (final PCEPErrors error : PCEPErrors.values()) {
849 // final PCEPErrorIdentifier errorId = mapper.getFromErrorsEnum(error);
850 // assertEquals(error, mapper.getFromErrorIdentifier(errorId));
855 // public void testOFCodesMapping() {
856 // final PCEPOFCodesMapping mapper = PCEPOFCodesMapping.getInstance();
858 // for (final PCEPOFCodes ofCode : PCEPOFCodes.values()) {
859 // final int ofCodeId = mapper.getFromOFCodesEnum(ofCode);
860 // assertEquals(ofCode, mapper.getFromCodeIdentifier(ofCodeId));
864 // @SuppressWarnings("unchecked")
865 // private static <T extends PCEPObject> void serDeserTestWithoutBin(final T object) throws
866 // PCEPDeserializerException,
867 // PCEPDocumentedException {
868 // final byte[] serBytes = PCEPObjectFactory.put(Arrays.asList((PCEPObject) object));
869 // final T deserObj = (T) PCEPObjectFactory.parseObjects(serBytes).get(0);
871 // assertEquals(object, deserObj);
875 // public void testSERObjects() throws PCEPDocumentedException, PCEPDeserializerException {
876 // final List<ExplicitRouteSubobject> eroSubobjects = new ArrayList<ExplicitRouteSubobject>();
877 // eroSubobjects.add(new EROIPPrefixSubobject<IPv4Prefix>(new IPv4Prefix(new IPv4Address(new byte[] { (byte) 192,
878 // (byte) 168, 1, 8 }), 16), false));
879 // eroSubobjects.add(new EROIPPrefixSubobject<IPv6Prefix>(new IPv6Prefix(new IPv6Address(new byte[] { (byte) 192,
881 // (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 }), 64), false));
883 // serDeserTestWithoutBin(new PCEPSecondaryExplicitRouteObject(eroSubobjects, true, false));
887 // public void testSRRObject() throws PCEPDocumentedException, PCEPDeserializerException {
888 // final List<ReportedRouteSubobject> rroSubobjects = new ArrayList<ReportedRouteSubobject>();
889 // rroSubobjects.add(new RROIPAddressSubobject<IPv4Prefix>(new IPv4Prefix(this.ipv4addr, 16), true, false));
890 // rroSubobjects.add(new RROIPAddressSubobject<IPv6Prefix>(new IPv6Prefix(this.ipv6addr, 64), false, true));
892 // serDeserTestWithoutBin(new PCEPSecondaryRecordRouteObject(rroSubobjects, true, false));
896 // public void testP2MPEndpointsObjects() throws PCEPDeserializerException, PCEPDocumentedException {
897 // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(2, this.ipv4addr, Arrays.asList(this.ipv4addr,
899 // this.ipv4addr), true, false));
900 // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(1, this.ipv4addr, Arrays.asList(this.ipv4addr),
902 // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(2, this.ipv6addr, Arrays.asList(this.ipv6addr,
904 // this.ipv6addr), true, false));
905 // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(1, this.ipv6addr, Arrays.asList(this.ipv6addr),
910 // public void testUnreachedDestinationObjects() throws PCEPDeserializerException, PCEPDocumentedException {
911 // serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv4Address>(Arrays.asList(this.ipv4addr,
912 // this.ipv4addr, this.ipv4addr), true, false));
913 // serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv4Address>(Arrays.asList(this.ipv4addr), true,
915 // serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv6Address>(Arrays.asList(this.ipv6addr,
916 // this.ipv6addr, this.ipv6addr), true, false));
917 // serDeserTestWithoutBin(new PCEPUnreachedDestinationObject<IPv6Address>(Arrays.asList(this.ipv6addr), true,