BUG-47 : unfinished PCEP migration to generated DTOs.
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / PCEPObjectParserTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.pcep.impl;
9
10
11 /**
12  * Used resources<br/>
13  * <br/>
14  * PCEPOpenObject3.bin<br/>
15  * objClass: 1<br/>
16  * objType: 1<br/>
17  * objLength: 8<br/>
18  * version: 1<br/>
19  * Flags:<br/>
20  * - processing: true<br/>
21  * - ignored: true<br/>
22  * <br/>
23  * keepAlive: 30<br/>
24  * deadTimer: 120<br/>
25  * sessionId: 1<br/>
26  * tlvs:NO<br/>
27  * <br/>
28  * PCEPBandwidthObject1LowerBounds.bin<br/>
29  * objClass: 5 <br/>
30  * objType: 1<br/>
31  * objLength: 16<br/>
32  * version: 1<br/>
33  * Flags:<br/>
34  * - processing: true<br/>
35  * - ignored: true<br/>
36  * <br/>
37  * Bandwidth: 0<br/>
38  * <br/>
39  * PCEPBandwidthObject2UpperBounds.bin<br/>
40  * objClass: 5 <br/>
41  * objType: 1<br/>
42  * objLength: 16<br/>
43  * version: 1<br/>
44  * Flags:<br/>
45  * - processing: true<br/>
46  * - ignored: true<br/>
47  * <br/>
48  * Bandwidth: 0xFFFFFFFF<br/>
49  * <br/>
50  * PCEPEndPointsObject1IPv4.bin<br/>
51  * objClass: 4 <br/>
52  * objType: 1<br/>
53  * objLength: 12<br/>
54  * version: 1<br/>
55  * Flags:<br/>
56  * - processing: true<br/>
57  * - ignored: true<br/>
58  * <br/>
59  * src IP: 0xA2F5110E <br/>
60  * dest IP: 0xFFFFFFFF <br/>
61  * <br/>
62  * PCEPEndPointsObject2IPv6.bin<br/>
63  * objClass: 4 <br/>
64  * objType: 2<br/>
65  * objLength: 36<br/>
66  * version: 1<br/>
67  * Flags:<br/>
68  * - processing: true<br/>
69  * - ignored: true<br/>
70  * <br/>
71  * src IP: 0xFFFFFFFFF FFFFFFFFF FFFFFFFFF FFFFFFFFF<br/>
72  * dest IP: 0x00025DD2 FFECA1B6 581E9F50 00000000 <br/>
73  * <br/>
74  * PCEPErrorObject1.bin<br/>
75  * objClass: 13 (RP)<br/>
76  * objType: 1<br/>
77  * objLength: 8<br/>
78  * version: 1<br/>
79  * Flags:<br/>
80  * - processing: false<br/>
81  * - ignored: false<br/>
82  * <br/>
83  * Error-type: 1<br/>
84  * Error-value: 1<br/>
85  * Tlvs: NO<br/>
86  * <br/>
87  * PCEPErrorObject2Invalid.bin<br/>
88  * objClass: 13 (RP)<br/>
89  * objType: 1<br/>
90  * objLength: 8<br/>
91  * version: 1<br/>
92  * Flags:<br/>
93  * - processing: false<br/>
94  * - ignored: false<br/>
95  * <br/>
96  * Error-type: 3<br/>
97  * Error-value: 0<br/>
98  * Tlvs: NO<br/>
99  * <br/>
100  * PCEPErrorObject3.bin<br/>
101  * objClass: 13 (RP)<br/>
102  * objType: 1<br/>
103  * objLength: 8<br/>
104  * version: 1<br/>
105  * Flags:<br/>
106  * - processing: false<br/>
107  * - ignored: false<br/>
108  * <br/>
109  * Error-type: 2<br/>
110  * Error-value: 0<br/>
111  * Tlvs: NO<br/>
112  * <br/>
113  * PCEPLspaObject1LowerBounds.bin<br/>
114  * objClass: 9<br/>
115  * objType: 1<br/>
116  * objLength: 20<br/>
117  * version: 1<br/>
118  * Flags:<br/>
119  * - processing: true<br/>
120  * - ignored: true<br/>
121  * <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/>
128  * <br/>
129  * PCEPLspaObject2UpperBounds.bin<br/>
130  * objClass: 9<br/>
131  * objType: 1<br/>
132  * objLength: 20<br/>
133  * version: 1<br/>
134  * Flags:<br/>
135  * - processing: true<br/>
136  * - ignored: true<br/>
137  * <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/>
144  * <br/>
145  * PCEPLspaObject3RandVals.bin<br/>
146  * objClass: 9<br/>
147  * objType: 1<br/>
148  * objLength: 20<br/>
149  * version: 1<br/>
150  * Flags:<br/>
151  * - processing: true<br/>
152  * - ignored: true<br/>
153  * <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/>
160  * <br/>
161  * NoPathObject1WithTLV.bin<br/>
162  * objClass: 3 (RP)<br/>
163  * objType: 1<br/>
164  * objLength: 16<br/>
165  * version: 1<br/>
166  * Flags:<br/>
167  * - processing: false<br/>
168  * - ignored: false<br/>
169  * <br/>
170  * Nature of Issue: 2<br/>
171  * No-Path flags:<br/>
172  * - C: true<br/>
173  * <br/>
174  * tlvs:<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/>
180  * 
181  * <br/>
182  * NoPathObject2WithoutTLV.bin<br/>
183  * objClass: 3 (RP)<br/>
184  * objType: 1<br/>
185  * objLength: 8<br/>
186  * version: 1<br/>
187  * Flags:<br/>
188  * - processing: false<br/>
189  * - ignored: true<br/>
190  * <br/>
191  * Nature of Issue: 16<br/>
192  * No-Path flags:<br/>
193  * - C: false<br/>
194  * <br/>
195  * tlvs:NO<br/>
196  * <br/>
197  * PCEPNotificationObject1WithTlv.bin <br/>
198  * objClass: 12<br/>
199  * objType: 1<br/>
200  * objLength: 16<br/>
201  * version: 1<br/>
202  * Flags:<br/>
203  * - processing: false<br/>
204  * - ignored: false<br/>
205  * <br/>
206  * NT: 1<br/>
207  * NV: 1<br/>
208  * Tlvs:<br/>
209  * - OverloaderDuration(0xFF0000A2L)<br/>
210  * <br/>
211  * PCEPNotificationObject2WithoutTlv.bin <br/>
212  * objClass: 12<br/>
213  * objType: 1<br/>
214  * objLength: 8<br/>
215  * version: 1<br/>
216  * Flags:<br/>
217  * - processing: false<br/>
218  * - ignored: false<br/>
219  * <br/>
220  * NT: 0xFF<br/>
221  * NV: 0xFF<br/>
222  * Tlvs: NO<br/>
223  * <br/>
224  * PCEPOpenObject1.bin<br/>
225  * objClass: 1<br/>
226  * objType: 1<br/>
227  * objLength: 28<br/>
228  * version: 1<br/>
229  * Flags:<br/>
230  * - processing: false<br/>
231  * - ignored: false<br/>
232  * <br/>
233  * keepAlive: 30<br/>
234  * deadTimer: 120<br/>
235  * sessionId: 1<br/>
236  * tlvs:<br/>
237  * - PCEPStatefulCapability<br/>
238  * - LSPStateDBVersionTlv<br/>
239  * - NodeIdentifierTlv<br/>
240  * <br/>
241  * PCEPOpenObject2UpperBoundsNoTlv.bin<br/>
242  * objClass: 1<br/>
243  * objType: 1<br/>
244  * objLength: 34<br/>
245  * version: 1<br/>
246  * Flags:<br/>
247  * - processing: false<br/>
248  * - ignored: false<br/>
249  * <br/>
250  * keepAlive: 0xFF<br/>
251  * deadTimer: 0xFF<br/>
252  * sessionId: 0xFF<br/>
253  * tlvs: NO<br/>
254  * <br/>
255  * PCEPRPObject1.bin<br/>
256  * objClass: 2 (RP)<br/>
257  * objType: 1<br/>
258  * objLength: 12<br/>
259  * version: 1<br/>
260  * Flags:<br/>
261  * - processing: false<br/>
262  * - ignored: false<br/>
263  * <br/>
264  * RP flags:<br/>
265  * - loose/strict: true<br/>
266  * - Bi-directional: false<br/>
267  * - Reoptimization: false<br/>
268  * - Priority: 5<br/>
269  * Request ID: 0xDEADBEEF<br/>
270  * tlvs: NO<br/>
271  * <br/>
272  * PCEPSvecObject1_10ReqIDs.bin <br/>
273  * objClass: 11<br/>
274  * objType: 1<br/>
275  * objLength: 48<br/>
276  * version: 1<br/>
277  * Flags:<br/>
278  * - processing: true<br/>
279  * - ignored: false<br/>
280  * <br/>
281  * Flags:<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/>
296  * <br/>
297  * PCEPSvecObject2.bin <br/>
298  * objClass: 11<br/>
299  * objType: 1<br/>
300  * objLength: 08<br/>
301  * version: 1<br/>
302  * Flags:<br/>
303  * - processing: false<br/>
304  * - ignored: false<br/>
305  * <br/>
306  * Flags:<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/>
313  * objClass: 17 <br/>
314  * objType: 1 <br/>
315  * objLength: 20 <br/>
316  * version: 1 <br/>
317  * Flags: <br/>
318  * - fail: true <br/>
319  * Subobjects: <br/>
320  * - XROIPv4PreffixSubobject(192.168.0.0/16, exclude, node) <br/>
321  * - XROASnumber(0x1234) <br/>
322  */
323 public class PCEPObjectParserTest {
324
325         // @Mock
326         // private HandlerRegistry registry;
327         //
328         // IPv4Address ipv4addr = new IPv4Address(new byte[] { (byte) 192, (byte) 168, 1, 8 });
329         //
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 });
333         //
334         // @SuppressWarnings("unchecked")
335         // private static <T extends PCEPObject> void serDeserTest(final String srcFile, final T specObject) throws
336         // IOException,
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));
341         //
342         // assertEquals(specObject, deserSpecObj);
343         // assertArrayEquals(bytesFromFile, serSpecObj);
344         // }
345         //
346         // /**
347         // * Standard serialization test<br/>
348         // * Used resources:<br/>
349         // * - PCEPOpenObject1.bin<br/>
350         // *
351         // * @throws PCEPDeserializerException
352         // * @throws IOException
353         // * @throws PCEPDocumentedException
354         // */
355         // @Test
356         // @Ignore
357         // // FIXME: temporary
358         // public void testObjectDeserialization() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
359         // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
360         // }
361         //
362         // @Test
363         // public void testUnknownClass() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
364         //
365         // final PCEPObject obj =
366         // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPObject1UnknownClass.bin")).get(
367         // 0);
368         //
369         // // assertTrue(obj instanceof UnknownObject);
370         // // assertEquals(((UnknownObject) obj).getError(), PCEPErrors.UNRECOGNIZED_OBJ_CLASS);
371         // }
372         //
373         // // @Test
374         // // public void testUnknownType() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
375         // // final PCEPObject obj =
376         // PCEPObjectFactory.parseObjects(ByteArray.fileToBytes("src/test/resources/PCEPObject2UnknownType.bin")).get(0);
377         // //
378         // // assertTrue(obj instanceof UnknownObject);
379         // // assertEquals(((UnknownObject) obj).getError(), PCEPErrors.UNRECOGNIZED_OBJ_TYPE);
380         // // }
381         // //
382         // // @Test
383         // // public void testCloseObjSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
384         // // serDeserTest("src/test/resources/PCEPCloseObject1.bin", new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG));
385         // // }
386         //
387         // @Test
388         // @Ignore
389         // // FIXME BUG-89
390         // public void testLoadBalancingObjSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException
391         // {
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));
395         // }
396         //
397         // @Test
398         // public void testLspObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
399         // serDeserTest("src/test/resources/PCEPLspObject1NoTlvsUpperBounds.bin", new PCEPLspObject(0xFFFFF, true, false,
400         // true, false, null));
401         // }
402         //
403         // @Test
404         // public void testERObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
405         // final byte[] bytesFromFile =
406         // ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin");
407         //
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() {
414         //
415         // @Override
416         // public Class<? extends DataContainer> getImplementedInterface() {
417         // // TODO Auto-generated method stub
418         // return null;
419         // }
420         //
421         // @Override
422         // public Boolean isProcessingRule() {
423         // return false;
424         // }
425         //
426         // @Override
427         // public Boolean isIgnore() {
428         // return false;
429         // }
430         // };
431         //
432         // final ExplicitRouteSubobject specObj = (ExplicitRouteSubobject)
433         // registry.getObjectParser(PCEPExplicitRouteObjectParser.TYPE, PCEPExplicitRouteObjectParser.CLASS).parseObject(h,
434         // bytesFromFile);
435         //
436         // System.out.println(specObj.toString());
437         //
438         // //final byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObj));
439         // //assertArrayEquals(bytesFromFile, bytesActual);
440         // }
441         //
442         // @Test
443         // public void testIRObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
444         // final byte[] bytesFromFile =
445         // ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin");
446         //
447         // final PCEPIncludeRouteObject specObj = (PCEPIncludeRouteObject)
448         // PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
449         //
450         // assertEquals(8, specObj.getSubobjects().size());
451         //
452         // final byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObj));
453         // assertArrayEquals(bytesFromFile, bytesActual);
454         // }
455         //
456         // @Test
457         // public void tesRRObjectSerDeser() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
458         // final byte[] bytesFromFile =
459         // ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin");
460         //
461         // final PCEPReportedRouteObject specObj = (PCEPReportedRouteObject)
462         // PCEPObjectFactory.parseObjects(bytesFromFile).get(0);
463         //
464         // assertEquals(6, specObj.getSubobjects().size());
465         //
466         // final byte[] bytesActual = PCEPObjectFactory.put(Arrays.asList((PCEPObject) specObj));
467         // assertArrayEquals(bytesFromFile, bytesActual);
468         // }
469         //
470         // /**
471         // * Test for upper/lower bounds (Serialization/Deserialization)<br/>
472         // * Used resources:<br/>
473         // * - PCEPBandwidthObject2UpperBounds.bin<br/>
474         // * - PCEPBandwidthObject1LowerBounds.bin<br/>
475         // *
476         // * @throws IOException
477         // * @throws PCEPDeserializerException
478         // * @throws PCEPDocumentedException
479         // */
480         // @Test
481         // @Ignore
482         // // FIXME BUG-89
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));
486         // }
487         //
488         // /**
489         // * Test for upper/lower bounds of IPv4 EndPoints (Serialization/Deserialization)<br/>
490         // * Used resources:<br/>
491         // * - PCEPEndPointsObject1IPv4.bin<br/>
492         // *
493         // * @throws IOException
494         // * @throws PCEPDeserializerException
495         // * @throws PCEPDocumentedException
496         // */
497         // @Test
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)));
504         // }
505         //
506         // /**
507         // * Test for upper/lower bounds of IPv6 EndPoints (Serialization/Deserialization)<br/>
508         // * Used resources:<br/>
509         // * - PCEPEndPointsObject2IPv6.bin<br/>
510         // *
511         // * @throws IOException
512         // * @throws PCEPDeserializerException
513         // * @throws PCEPDocumentedException
514         // */
515         // @Test
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)
519         // 0xA1,
520         // (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte)
521         // 0x00, };
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 };
525         //
526         // serDeserTest("src/test/resources/PCEPEndPointsObject2IPv6.bin",
527         // new PCEPEndPointsObject<IPv6Address>(new IPv6Address(srcIPBytes), new IPv6Address(destIPBytes)));
528         // }
529         //
530         // /**
531         // * Test of Serialization/Deserialization of PCEPErrorObjectParser.<br/>
532         // * <br/>
533         // * Used resources:<br/>
534         // * - PCEPErrorObject1.bin<br/>
535         // * - PCEPErrorObject3.bin<br/>
536         // *
537         // * @throws PCEPDeserializerException
538         // * @throws IOException
539         // * @throws PCEPDocumentedException
540         // */
541         // @Test
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));
547         // }
548         //
549         // /**
550         // * Test of validity of PCEPErrorObjectParser. Expect throwed NoSuchElementException.<br/>
551         // * <br/>
552         // * Used resources:<br/>
553         // * - PCEPErrorObject2Invalid.bin<br/>
554         // *
555         // * @throws NoSuchElementException
556         // * @throws IOException
557         // * @throws PCEPDocumentedException
558         // */
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);
562         // }
563         //
564         // /**
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/>
570         // *
571         // * @throws IOException
572         // * @throws PCEPDeserializerException
573         // * @throws PCEPDocumentedException
574         // */
575         // @Test
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));
583         // }
584         //
585         // @Test
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");
590         //
591         // final PCEPMetricObject metricObjectLB = (PCEPMetricObject)
592         // PCEPObjectFactory.parseObjects(bytesFromFileLB).get(0);
593         // final PCEPMetricObject metricObjectUB = (PCEPMetricObject)
594         // PCEPObjectFactory.parseObjects(bytesFromFileUB).get(0);
595         //
596         // assertEquals(new PCEPMetricObject(false, false, new IGPMetric(0), true, true), metricObjectLB);
597         // assertEquals(new PCEPMetricObject(false, true, new TEMetric(4026531840L), true, true), metricObjectUB);
598         //
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);
603         // }
604         //
605         // /**
606         // * Standard deserialization test + specific test without tlv<br/>
607         // * Used resources:<br/>
608         // * - NoPathObject1WithTLV.bin<br/>
609         // * - NoPathObject2WithoutTLV.bin<br/>
610         // *
611         // * @throws PCEPDeserializerException
612         // * @throws IOException
613         // * @throws PCEPDocumentedException
614         // */
615         // @Test
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,
621         // false));
622         // serDeserTest("src/test/resources/NoPathObject2WithoutTLV.bin", new PCEPNoPathObject((short) 0x10, false, true));
623         //
624         // }
625         //
626         // /**
627         // * Standard serialization test + without tlv<br/>
628         // * Used resources:<br/>
629         // * - NoPathObject1WithTLV.bin<br/>
630         // * - NoPathObject2WithoutTLV.bin<br/>
631         // *
632         // * @throws PCEPDeserializerException
633         // * @throws IOException
634         // * @throws PCEPDocumentedException
635         // */
636         // @Test
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);
643         //
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);
648         // }
649         //
650         // /**
651         // * Specific test with/without tlvs (Ser/Deser)<br/>
652         // * Used resources:<br/>
653         // * - PCEPNotificationObject1WithTlv.bin - PCEPNotificationObject2WithoutTlv.bin
654         // *
655         // * @throws PCEPDeserializerException
656         // * @throws IOException
657         // * @throws PCEPDocumentedException
658         // */
659         // @Test
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,
667         // (short) 0xFF));
668         // }
669         //
670         // /**
671         // * Standard ser deser test<br/>
672         // * used resources:<br/>
673         // * - PCEPOpenObject1.bin
674         // *
675         // * @throws PCEPDeserializerException
676         // * @throws IOException
677         // * @throws PCEPDocumentedException
678         // */
679         // @Test
680         // @Ignore
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);
690         // //
691         // // serDeserTest("src/test/resources/PCEPOpenObject1.bin", specObject);
692         // }
693         //
694         // /**
695         // * Specific test for upper bounds and without tlvs<br/>
696         // * Used resources:<br/>
697         // * - PCEPOpenObject2UpperBoundsNoTlv.bin
698         // *
699         // * @throws PCEPDeserializerException
700         // * @throws IOException
701         // * @throws PCEPDocumentedException
702         // */
703         // @Test
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,
708         // tlvs));
709         // serDeserTest("src/test/resources/PCEPOpenObject2UpperBoundsNoTlv.bin", new PCEPOpenObject(0xFF, 0xFF, 0xFF,
710         // null));
711         // }
712         //
713         // /**
714         // * Standard deserialization test<br/>
715         // * Used resources:<br/>
716         // * - PCEPRPObject1.bin
717         // *
718         // * @throws PCEPDeserializerException
719         // * @throws IOException
720         // * @throws PCEPDocumentedException
721         // */
722         // @Test
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,
726         // false, false));
727         // // serDeserTest(
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;
732         // //
733         // // {
734         // // this.add(new OrderTlv(0xFFFFFFFFL, 0x00000001L));
735         // // }
736         // // }, false, false));
737         // }
738         //
739         // /**
740         // * Test for upper/lower bounds of PCEPSvecObject (Serialization/Deserialization)<br/>
741         // * Used resources:<br/>
742         // * - PCEPSvecObject1_10ReqIDs.bin<br/>
743         // *
744         // * @throws IOException
745         // * @throws PCEPDeserializerException
746         // * @throws PCEPDocumentedException
747         // */
748         // @Test
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);
761         //
762         // serDeserTest("src/test/resources/PCEPSvecObject1_10ReqIDs.bin",
763         // new PCEPSvecObject(true, false, true, false, true, requestIDs, true));
764         // }
765         //
766         // /**
767         // * Test for lowest bounds of PCEPSvecObject (Serialization/Deserialization)<br/>
768         // * Used resources:<br/>
769         // * - PCEPSvecObject2.bin<br/>
770         // *
771         // * @throws IOException
772         // * @throws PCEPDeserializerException
773         // * @throws PCEPDocumentedException
774         // */
775         // @Test
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));
782         // }
783         //
784         // @Test
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));
790         // }
791         //
792         // /**
793         // * Test PCEPExcludeRouteObjectObject (Serialization/Deserialization)<br/>
794         // * Used resources:<br/>
795         // * - PCEPExcludeRouteObject.1.bin<br/>
796         // *
797         // * @throws IOException
798         // * @throws PCEPDeserializerException
799         // * @throws PCEPDocumentedException
800         // */
801         // @Test
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,
805         // (byte) 168,
806         // (byte) 100, (byte) 100 }), 16), true, XROSubobjectAttribute.NODE));
807         // xroSubobjects.add(new XROAsNumberSubobject(new AsNumber(0x1234L), false));
808         //
809         // }
810         //
811         // @Test
812         // public void tesObjectiveFunctionObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
813         // serDeserTest("src/test/resources/PCEPObjectiveFunctionObject.1.bin", new
814         // PCEPObjectiveFunctionObject(PCEPOFCodes.MBC, true, false));
815         // }
816         //
817         // @Test
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));
821         // }
822         //
823         // // FIXME: add at least one test with true value
824         // @Test
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));
830         // }
831         //
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>();
836         // // tlvs.add(tlv);
837         // // final PCEPOpenObject oo = new PCEPOpenObject(30, 120, 0, tlvs);
838         // // objs.add(oo);
839         // // final byte[] bytes = PCEPObjectFactory.put(objs);
840         // // final PCEPObject obj = PCEPObjectFactory.parseObjects(bytes).get(0);
841         // // assertEquals(oo, obj);
842         // // }
843         //
844         // @Test
845         // public void testErrorsMapping() {
846         // final PCEPErrorObjectParser.PCEPErrorsMaping mapper = PCEPErrorObjectParser.PCEPErrorsMaping.getInstance();
847         //
848         // for (final PCEPErrors error : PCEPErrors.values()) {
849         // final PCEPErrorIdentifier errorId = mapper.getFromErrorsEnum(error);
850         // assertEquals(error, mapper.getFromErrorIdentifier(errorId));
851         // }
852         // }
853         //
854         // @Test
855         // public void testOFCodesMapping() {
856         // final PCEPOFCodesMapping mapper = PCEPOFCodesMapping.getInstance();
857         //
858         // for (final PCEPOFCodes ofCode : PCEPOFCodes.values()) {
859         // final int ofCodeId = mapper.getFromOFCodesEnum(ofCode);
860         // assertEquals(ofCode, mapper.getFromCodeIdentifier(ofCodeId));
861         // }
862         // }
863         //
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);
870         //
871         // assertEquals(object, deserObj);
872         // }
873         //
874         // @Test
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,
880         // (byte) 168, 2, 1,
881         // (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1, (byte) 192, (byte) 168, 2, 1 }), 64), false));
882         //
883         // serDeserTestWithoutBin(new PCEPSecondaryExplicitRouteObject(eroSubobjects, true, false));
884         // }
885         //
886         // @Test
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));
891         //
892         // serDeserTestWithoutBin(new PCEPSecondaryRecordRouteObject(rroSubobjects, true, false));
893         // }
894         //
895         // @Test
896         // public void testP2MPEndpointsObjects() throws PCEPDeserializerException, PCEPDocumentedException {
897         // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(2, this.ipv4addr, Arrays.asList(this.ipv4addr,
898         // this.ipv4addr,
899         // this.ipv4addr), true, false));
900         // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv4Address>(1, this.ipv4addr, Arrays.asList(this.ipv4addr),
901         // true, false));
902         // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(2, this.ipv6addr, Arrays.asList(this.ipv6addr,
903         // this.ipv6addr,
904         // this.ipv6addr), true, false));
905         // serDeserTestWithoutBin(new PCEPP2MPEndPointsObject<IPv6Address>(1, this.ipv6addr, Arrays.asList(this.ipv6addr),
906         // true, false));
907         // }
908         //
909         // @Test
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,
914         // false));
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,
918         // false));
919         // }
920 }