3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
11 * @file NodeConnectorTest.java
13 * @brief Unit Tests for NodeConnector element
15 * Unit Tests for NodeConnector element
17 package org.opendaylight.controller.sal.core;
19 import java.util.UUID;
21 import org.junit.Assert;
22 import org.junit.Test;
24 public class NodeConnectorTest {
26 public void testNodeConnectorOpenFlowOfWrongType() {
28 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
29 NodeConnector of1 = new NodeConnector(
30 NodeConnector.NodeConnectorIDType.OPENFLOW, new String(
31 "0xDEADBEEFCAFE0001L"), n1);
33 // If we reach this point the exception was not raised
34 // which should have been the case
35 Assert.assertTrue(false);
36 } catch (ConstructionException e) {
37 // If we reach this point the exception has been raised
39 System.out.println("Got exception as expected!:" + e);
40 Assert.assertTrue(true);
45 public void testNodeConnectorONEPKOfWrongType() {
47 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
48 NodeConnector onepk1 = new NodeConnector(
49 NodeConnector.NodeConnectorIDType.ONEPK, new Long(
50 0xDEADBEEFCAFE0001L), n1);
52 // If we reach this point the exception was not raised
53 // which should have been the case
54 Assert.assertTrue(false);
55 } catch (ConstructionException e) {
56 // If we reach this point the exception has been raised
58 System.out.println("Got exception as expected!:" + e);
59 Assert.assertTrue(true);
64 public void testNodeConnectorPCEPOfWrongType() {
66 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
67 NodeConnector pcep1 = new NodeConnector(
68 NodeConnector.NodeConnectorIDType.PCEP, new Long(
69 0xDEADBEEFCAFE0001L), n1);
71 // If we reach this point the exception was not raised
72 // which should have been the case
73 Assert.assertTrue(false);
74 } catch (ConstructionException e) {
75 // If we reach this point the exception has been raised
77 System.out.println("Got exception as expected!:" + e);
78 Assert.assertTrue(true);
83 public void testNodeConnectorOpenFlowOfCorrectType() {
85 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
86 NodeConnector of1 = new NodeConnector(
87 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
90 // If we reach this point the exception has not been
91 // raised so we passed the test
92 System.out.println("Got node:" + of1);
93 Assert.assertTrue(true);
94 } catch (ConstructionException e) {
95 // If we reach this point the exception was raised
96 // which is not expected
97 Assert.assertTrue(false);
102 public void testNodeConnectorONEPKOfCorrectType() {
104 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
105 NodeConnector onepk1 = new NodeConnector(
106 NodeConnector.NodeConnectorIDType.ONEPK, new String(
109 // If we reach this point the exception has not been
110 // raised so we passed the test
111 System.out.println("Got node:" + onepk1);
112 Assert.assertTrue(true);
113 } catch (ConstructionException e) {
114 // If we reach this point the exception was raised
115 // which is not expected
116 Assert.assertTrue(false);
121 public void testNodeConnectorPCEPOfCorrectType() {
123 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
124 NodeConnector pcep1 = new NodeConnector(
125 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
128 // If we reach this point the exception has not been
129 // raised so we passed the test
130 System.out.println("Got node:" + pcep1);
131 Assert.assertTrue(true);
132 } catch (ConstructionException e) {
133 // If we reach this point the exception was raised
134 // which is not expected
135 Assert.assertTrue(false);
140 public void testTwoOpenFlowNodeConnectorEquals() {
142 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
143 NodeConnector of1 = new NodeConnector(
144 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
145 (short) 0xCAFE), n1);
146 NodeConnector of2 = new NodeConnector(
147 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
148 (short) 0xCAFE), n1);
150 Assert.assertTrue(of1.equals(of2));
151 } catch (ConstructionException e) {
152 // If we reach this point the exception was raised
153 // which is not expected
154 Assert.assertTrue(false);
159 public void testTwoONEPKNodeConnectorEquals() {
161 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
162 NodeConnector onepk1 = new NodeConnector(
163 NodeConnector.NodeConnectorIDType.ONEPK, new String(
165 NodeConnector onepk2 = new NodeConnector(
166 NodeConnector.NodeConnectorIDType.ONEPK, new String(
169 Assert.assertTrue(onepk1.equals(onepk2));
170 } catch (ConstructionException e) {
171 // If we reach this point the exception was raised
172 // which is not expected
173 Assert.assertTrue(false);
178 public void testTwoPCEPNodeConnectorEquals() {
180 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
181 NodeConnector pcep1 = new NodeConnector(
182 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
184 NodeConnector pcep2 = new NodeConnector(
185 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
188 Assert.assertTrue(pcep1.equals(pcep2));
189 } catch (ConstructionException e) {
190 // If we reach this point the exception was raised
191 // which is not expected
192 Assert.assertTrue(false);
197 public void testTwoOpenFlowNodeConnectorDifferents() {
199 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
200 NodeConnector of1 = new NodeConnector(
201 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
202 (short) 0xCAFE), n1);
203 NodeConnector of2 = new NodeConnector(
204 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
205 (short) 0xBEEF), n1);
207 Assert.assertTrue(!of1.equals(of2));
208 } catch (ConstructionException e) {
209 // If we reach this point the exception was raised
210 // which is not expected
211 Assert.assertTrue(false);
216 public void testTwoONEPKNodeConnectorDifferents() {
218 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
219 NodeConnector onepk1 = new NodeConnector(
220 NodeConnector.NodeConnectorIDType.ONEPK, new String(
222 NodeConnector onepk2 = new NodeConnector(
223 NodeConnector.NodeConnectorIDType.ONEPK, new String(
226 Assert.assertTrue(!onepk1.equals(onepk2));
227 } catch (ConstructionException e) {
228 // If we reach this point the exception was raised
229 // which is not expected
230 Assert.assertTrue(false);
235 public void testTwoPCEPNodeConnectorDifferents() {
237 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
238 NodeConnector pcep1 = new NodeConnector(
239 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
241 NodeConnector pcep2 = new NodeConnector(
242 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
245 Assert.assertTrue(!pcep1.equals(pcep2));
246 } catch (ConstructionException e) {
247 // If we reach this point the exception was raised
248 // which is not expected
249 Assert.assertTrue(false);
254 public void testTwoOpenFlowNodeConnectorDifferentsNodes() {
256 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
257 Node n2 = new Node(Node.NodeIDType.OPENFLOW, new Long(111L));
258 NodeConnector of1 = new NodeConnector(
259 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
260 (short) 0xCAFE), n1);
261 NodeConnector of2 = new NodeConnector(
262 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
263 (short) 0xCAFE), n2);
265 Assert.assertTrue(!of1.equals(of2));
266 } catch (ConstructionException e) {
267 // If we reach this point the exception was raised
268 // which is not expected
269 Assert.assertTrue(false);
274 public void testTwoONEPKNodeConnectorDifferentsNodes() {
276 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
277 Node n2 = new Node(Node.NodeIDType.ONEPK, new String("Router2"));
278 NodeConnector onepk1 = new NodeConnector(
279 NodeConnector.NodeConnectorIDType.ONEPK, new String(
281 NodeConnector onepk2 = new NodeConnector(
282 NodeConnector.NodeConnectorIDType.ONEPK, new String(
285 Assert.assertTrue(!onepk1.equals(onepk2));
286 } catch (ConstructionException e) {
287 // If we reach this point the exception was raised
288 // which is not expected
289 Assert.assertTrue(false);
294 public void testTwoPCEPNodeConnectorDifferentsNodes() {
296 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
297 Node n2 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 1L));
298 NodeConnector pcep1 = new NodeConnector(
299 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
301 NodeConnector pcep2 = new NodeConnector(
302 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
305 Assert.assertTrue(!pcep1.equals(pcep2));
306 } catch (ConstructionException e) {
307 // If we reach this point the exception was raised
308 // which is not expected
309 Assert.assertTrue(false);
314 public void testIncompatibleNodes() {
316 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
317 NodeConnector nc1 = new NodeConnector(
318 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
320 // Exception is expected if not raised test will fail
321 Assert.assertTrue(false);
322 } catch (ConstructionException e) {
326 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
327 NodeConnector nc1 = new NodeConnector(
328 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
330 // Exception is expected if not raised test will fail
331 Assert.assertTrue(false);
332 } catch (ConstructionException e) {
336 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
337 NodeConnector nc1 = new NodeConnector(
338 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
339 new Short((short) 0), n1);
340 // Exception is expected if not raised test will fail
341 Assert.assertTrue(false);
342 } catch (ConstructionException e) {
346 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
347 NodeConnector nc1 = new NodeConnector(
348 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
350 // Exception is expected if not raised test will fail
351 Assert.assertTrue(false);
352 } catch (ConstructionException e) {
356 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
357 NodeConnector nc1 = new NodeConnector(
358 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
359 new String("towardPCEP1"), n1);
360 // Exception is expected if not raised test will fail
361 Assert.assertTrue(false);
362 } catch (ConstructionException e) {
366 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
367 NodeConnector nc1 = new NodeConnector(
368 NodeConnector.NodeConnectorIDType.ONEPK, new String(
370 // Exception is expected if not raised test will fail
371 Assert.assertTrue(false);
372 } catch (ConstructionException e) {
376 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
377 NodeConnector nc1 = new NodeConnector(
378 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
379 } catch (ConstructionException e) {
380 // Exception is NOT expected if raised test will fail
381 Assert.assertTrue(false);
384 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
385 NodeConnector nc1 = new NodeConnector(
386 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
388 } catch (ConstructionException e) {
389 // Exception is NOT expected if raised test will fail
390 Assert.assertTrue(false);
394 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
395 NodeConnector nc1 = new NodeConnector(
396 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
398 } catch (ConstructionException e) {
399 // Exception is NOT expected if raised test will fail
400 Assert.assertTrue(false);
404 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
405 NodeConnector nc1 = new NodeConnector(
406 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
408 // Exception is expected if not raised test will fail
409 Assert.assertTrue(false);
410 } catch (ConstructionException e) {
414 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
415 NodeConnector nc1 = new NodeConnector(
416 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
418 // Exception is expected if not raised test will fail
419 Assert.assertTrue(false);
420 } catch (ConstructionException e) {
424 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
425 NodeConnector nc1 = new NodeConnector(
426 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
427 new Short((short) 0), n1);
428 // Exception is expected if not raised test will fail
429 Assert.assertTrue(false);
430 } catch (ConstructionException e) {
434 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
435 NodeConnector nc1 = new NodeConnector(
436 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
438 } catch (ConstructionException e) {
439 // Exception is NOT expected if raised test will fail
440 Assert.assertTrue(false);
444 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
445 NodeConnector nc1 = new NodeConnector(
446 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
447 new String("towardPCEP1"), n1);
448 } catch (ConstructionException e) {
449 // Exception is NOT expected if raised test will fail
450 Assert.assertTrue(false);
454 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
455 NodeConnector nc1 = new NodeConnector(
456 NodeConnector.NodeConnectorIDType.ONEPK, new String(
458 } catch (ConstructionException e) {
459 // Exception is NOT expected if raised test will fail
460 Assert.assertTrue(false);
464 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
465 NodeConnector nc1 = new NodeConnector(
466 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
467 // Exception is expected if not raised test will fail
468 Assert.assertTrue(false);
469 } catch (ConstructionException e) {
473 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
474 NodeConnector nc1 = new NodeConnector(
475 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
477 // Exception is expected if not raised test will fail
478 Assert.assertTrue(false);
479 } catch (ConstructionException e) {
483 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
484 NodeConnector nc1 = new NodeConnector(
485 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
487 // Exception is expected if not raised test will fail
488 Assert.assertTrue(false);
489 } catch (ConstructionException e) {
493 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
494 NodeConnector nc1 = new NodeConnector(
495 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
497 } catch (ConstructionException e) {
498 // Exception is NOT expected if raised test will fail
499 Assert.assertTrue(false);
503 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
504 NodeConnector nc1 = new NodeConnector(
505 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
507 } catch (ConstructionException e) {
508 // Exception is NOT expected if raised test will fail
509 Assert.assertTrue(false);
513 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
514 NodeConnector nc1 = new NodeConnector(
515 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
516 new Short((short) 0), n1);
517 } catch (ConstructionException e) {
518 // Exception is NOT expected if raised test will fail
519 Assert.assertTrue(false);
523 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
524 NodeConnector nc1 = new NodeConnector(
525 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
527 // Exception is expected if not raised test will fail
528 Assert.assertTrue(false);
529 } catch (ConstructionException e) {
533 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
534 NodeConnector nc1 = new NodeConnector(
535 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
536 new String("towardPCEP1"), n1);
537 // Exception is expected if not raised test will fail
538 Assert.assertTrue(false);
539 } catch (ConstructionException e) {
543 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
544 NodeConnector nc1 = new NodeConnector(
545 NodeConnector.NodeConnectorIDType.ONEPK, new String(
547 // Exception is expected if not raised test will fail
548 Assert.assertTrue(false);
549 } catch (ConstructionException e) {
553 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
554 NodeConnector nc1 = new NodeConnector(
555 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
556 // Exception is expected if not raised test will fail
557 Assert.assertTrue(false);
558 } catch (ConstructionException e) {
562 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
563 NodeConnector nc1 = new NodeConnector(
564 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
566 // Exception is expected if not raised test will fail
567 Assert.assertTrue(false);
568 } catch (ConstructionException e) {
572 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
573 NodeConnector nc1 = new NodeConnector(
574 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
576 // Exception is expected if not raised test will fail
577 Assert.assertTrue(false);
578 } catch (ConstructionException e) {
583 public void testConversionToStringAndBack() {
585 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
586 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
587 NodeConnector nc1 = new NodeConnector(
588 NodeConnector.NodeConnectorIDType.PCEP2ONEPK, new Integer(
590 String nc1Str = nc1.toString();
591 System.out.println("NodeConnector String = " + nc1Str);
592 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
594 // Make sure we got a nodeconnector
595 Assert.assertTrue(nc1FromStr != null);
597 // Now the converted nodeconnector need to be the same of the
599 Assert.assertTrue(nc1.equals(nc1FromStr));
600 } catch (ConstructionException e) {
601 // Fail if exception raised
602 Assert.assertTrue(false);
606 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
607 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
608 NodeConnector nc1 = new NodeConnector(
609 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
610 new Integer(0x10), n1);
611 String nc1Str = nc1.toString();
612 System.out.println("NodeConnector String = " + nc1Str);
613 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
615 // Make sure we got a nodeconnector
616 Assert.assertTrue(nc1FromStr != null);
618 // Now the converted nodeconnector need to be the same of the
620 Assert.assertTrue(nc1.equals(nc1FromStr));
621 } catch (ConstructionException e) {
622 // Fail if exception raised
623 Assert.assertTrue(false);
627 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
628 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
629 NodeConnector nc1 = new NodeConnector(
630 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0x10),
632 String nc1Str = nc1.toString();
633 System.out.println("NodeConnector String = " + nc1Str);
634 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
636 // Make sure we got a nodeconnector
637 Assert.assertTrue(nc1FromStr != null);
639 // Now the converted nodeconnector need to be the same of the
641 Assert.assertTrue(nc1.equals(nc1FromStr));
642 } catch (ConstructionException e) {
643 // Fail if exception raised
644 Assert.assertTrue(false);
648 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
649 NodeConnector nc1 = new NodeConnector(
650 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
653 String nc1Str = nc1.toString();
654 System.out.println("NodeConnector String = " + nc1Str);
655 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
657 // Make sure we got a nodeconnector
658 Assert.assertTrue(nc1FromStr != null);
660 // Now the converted nodeconnector need to be the same of the
662 Assert.assertTrue(nc1.equals(nc1FromStr));
663 } catch (ConstructionException e) {
664 // Fail if exception raised
665 Assert.assertTrue(false);
669 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
670 NodeConnector nc1 = new NodeConnector(
671 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
672 new String("towardOPENFLOW1"), n1);
674 String nc1Str = nc1.toString();
675 System.out.println("NodeConnector String = " + nc1Str);
676 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
678 // Make sure we got a nodeconnector
679 Assert.assertTrue(nc1FromStr != null);
681 // Now the converted nodeconnector need to be the same of the
683 Assert.assertTrue(nc1.equals(nc1FromStr));
684 } catch (ConstructionException e) {
685 // Fail if exception raised
686 Assert.assertTrue(false);
690 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
691 NodeConnector nc1 = new NodeConnector(
692 NodeConnector.NodeConnectorIDType.ONEPK, new String(
695 String nc1Str = nc1.toString();
696 System.out.println("NodeConnector String = " + nc1Str);
697 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
699 // Make sure we got a nodeconnector
700 Assert.assertTrue(nc1FromStr != null);
702 // Now the converted nodeconnector need to be the same of the
704 Assert.assertTrue(nc1.equals(nc1FromStr));
705 } catch (ConstructionException e) {
706 // Fail if exception raised
707 Assert.assertTrue(false);
711 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(
712 0xDEADBEEFCAFE0001L));
713 NodeConnector nc1 = new NodeConnector(
714 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
715 (short) 0xCAFE), n1);
717 String nc1Str = nc1.toString();
718 System.out.println("NodeConnector String = " + nc1Str);
719 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
721 // Make sure we got a nodeconnector
722 Assert.assertTrue(nc1FromStr != null);
724 // Now the converted nodeconnector need to be the same of the
726 Assert.assertTrue(nc1.equals(nc1FromStr));
727 } catch (ConstructionException e) {
728 // Fail if exception raised
729 Assert.assertTrue(false);
733 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
734 NodeConnector nc1 = new NodeConnector(
735 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
738 String nc1Str = nc1.toString();
739 System.out.println("NodeConnector String = " + nc1Str);
740 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
742 // Make sure we got a nodeconnector
743 Assert.assertTrue(nc1FromStr != null);
745 // Now the converted nodeconnector need to be the same of the
747 Assert.assertTrue(nc1.equals(nc1FromStr));
748 } catch (ConstructionException e) {
749 // Fail if exception raised
750 Assert.assertTrue(false);
754 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
755 NodeConnector nc1 = new NodeConnector(
756 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
757 new Short((short) 0x11), n1);
759 String nc1Str = nc1.toString();
760 System.out.println("NodeConnector String = " + nc1Str);
761 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
763 // Make sure we got a nodeconnector
764 Assert.assertTrue(nc1FromStr != null);
766 // Now the converted nodeconnector need to be the same of the
768 Assert.assertTrue(nc1.equals(nc1FromStr));
769 } catch (ConstructionException e) {
770 // Fail if exception raised
771 Assert.assertTrue(false);
776 public void testNodeConnectorSpecialType() {
778 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
779 NodeConnector specialNc = new NodeConnector(
780 NodeConnector.NodeConnectorIDType.CONTROLLER,
781 NodeConnector.SPECIALNODECONNECTORID, n);
782 System.out.println("Special NC = " + specialNc);
783 // We expect to reach this point succesfully
784 Assert.assertTrue(true);
785 } catch (ConstructionException e) {
786 // If this expection is raised the test is failing
787 System.out.println("Got exception as expected!:" + e);
788 Assert.assertTrue(false);
792 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
793 NodeConnector specialNc = new NodeConnector(
794 NodeConnector.NodeConnectorIDType.ALL,
795 NodeConnector.SPECIALNODECONNECTORID, n);
796 System.out.println("Special NC = " + specialNc);
797 // We expect to reach this point succesfully
798 Assert.assertTrue(true);
799 } catch (ConstructionException e) {
800 // If this expection is raised the test is failing
801 System.out.println("Got exception as expected!:" + e);
802 Assert.assertTrue(false);
806 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
807 NodeConnector specialNc = new NodeConnector(
808 NodeConnector.NodeConnectorIDType.SWSTACK,
809 NodeConnector.SPECIALNODECONNECTORID, n);
810 System.out.println("Special NC = " + specialNc);
811 // We expect to reach this point succesfully
812 Assert.assertTrue(true);
813 } catch (ConstructionException e) {
814 // If this expection is raised the test is failing
815 System.out.println("Got exception as expected!:" + e);
816 Assert.assertTrue(false);
820 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
821 NodeConnector specialNc = new NodeConnector(
822 NodeConnector.NodeConnectorIDType.HWPATH,
823 NodeConnector.SPECIALNODECONNECTORID, n);
824 System.out.println("Special NC = " + specialNc);
825 // We expect to reach this point succesfully
826 Assert.assertTrue(true);
827 } catch (ConstructionException e) {
828 // If this expection is raised the test is failing
829 System.out.println("Got exception as expected!:" + e);
830 Assert.assertTrue(false);
834 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
835 NodeConnector specialNc = new NodeConnector(
836 NodeConnector.NodeConnectorIDType.CONTROLLER,
837 NodeConnector.SPECIALNODECONNECTORID, n);
838 System.out.println("Special NC = " + specialNc);
839 // We expect to reach this point succesfully
840 Assert.assertTrue(true);
841 } catch (ConstructionException e) {
842 // If this expection is raised the test is failing
843 System.out.println("Got exception as expected!:" + e);
844 Assert.assertTrue(false);
848 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
849 NodeConnector specialNc = new NodeConnector(
850 NodeConnector.NodeConnectorIDType.ALL,
851 NodeConnector.SPECIALNODECONNECTORID, n);
852 System.out.println("Special NC = " + specialNc);
853 // We expect to reach this point succesfully
854 Assert.assertTrue(true);
855 } catch (ConstructionException e) {
856 // If this expection is raised the test is failing
857 System.out.println("Got exception as expected!:" + e);
858 Assert.assertTrue(false);
862 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
863 NodeConnector specialNc = new NodeConnector(
864 NodeConnector.NodeConnectorIDType.SWSTACK,
865 NodeConnector.SPECIALNODECONNECTORID, n);
866 System.out.println("Special NC = " + specialNc);
867 // We expect to reach this point succesfully
868 Assert.assertTrue(true);
869 } catch (ConstructionException e) {
870 // If this expection is raised the test is failing
871 System.out.println("Got exception as expected!:" + e);
872 Assert.assertTrue(false);
876 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
877 NodeConnector specialNc = new NodeConnector(
878 NodeConnector.NodeConnectorIDType.HWPATH,
879 NodeConnector.SPECIALNODECONNECTORID, n);
880 System.out.println("Special NC = " + specialNc);
881 // We expect to reach this point succesfully
882 Assert.assertTrue(true);
883 } catch (ConstructionException e) {
884 // If this expection is raised the test is failing
885 System.out.println("Got exception as expected!:" + e);
886 Assert.assertTrue(false);
890 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
891 NodeConnector specialNc = new NodeConnector(
892 NodeConnector.NodeConnectorIDType.CONTROLLER,
893 NodeConnector.SPECIALNODECONNECTORID, n);
894 System.out.println("Special NC = " + specialNc);
895 // We expect to reach this point succesfully
896 Assert.assertTrue(true);
897 } catch (ConstructionException e) {
898 // If this expection is raised the test is failing
899 System.out.println("Got exception as expected!:" + e);
900 Assert.assertTrue(false);
904 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
905 NodeConnector specialNc = new NodeConnector(
906 NodeConnector.NodeConnectorIDType.ALL,
907 NodeConnector.SPECIALNODECONNECTORID, n);
908 System.out.println("Special NC = " + specialNc);
909 // We expect to reach this point succesfully
910 Assert.assertTrue(true);
911 } catch (ConstructionException e) {
912 // If this expection is raised the test is failing
913 System.out.println("Got exception as expected!:" + e);
914 Assert.assertTrue(false);
918 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
919 NodeConnector specialNc = new NodeConnector(
920 NodeConnector.NodeConnectorIDType.SWSTACK,
921 NodeConnector.SPECIALNODECONNECTORID, n);
922 System.out.println("Special NC = " + specialNc);
923 // We expect to reach this point succesfully
924 Assert.assertTrue(true);
925 } catch (ConstructionException e) {
926 // If this expection is raised the test is failing
927 System.out.println("Got exception as expected!:" + e);
928 Assert.assertTrue(false);
932 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
933 NodeConnector specialNc = new NodeConnector(
934 NodeConnector.NodeConnectorIDType.HWPATH,
935 NodeConnector.SPECIALNODECONNECTORID, n);
936 System.out.println("Special NC = " + specialNc);
937 // We expect to reach this point succesfully
938 Assert.assertTrue(true);
939 } catch (ConstructionException e) {
940 // If this expection is raised the test is failing
941 System.out.println("Got exception as expected!:" + e);
942 Assert.assertTrue(false);
947 public void testToStringConversionForOpenFlow() {
949 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
950 NodeConnector nc = new NodeConnector(
951 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
954 NodeConnector ofFromStr = null;
956 ofFromStr = NodeConnector.fromStringNoNode("0x2ab", n);
958 // Make sure we got a nodeconnector
959 Assert.assertTrue(ofFromStr != null);
961 // Now the converted nodeconnector need to be the same of the
963 Assert.assertTrue(nc.equals(ofFromStr));
965 ofFromStr = NodeConnector.fromStringNoNode("0x2AB", n);
967 // Make sure we got a nodeconnector
968 Assert.assertTrue(ofFromStr != null);
970 // Now the converted nodeconnector need to be the same of the
972 Assert.assertTrue(nc.equals(ofFromStr));
974 ofFromStr = NodeConnector.fromStringNoNode("683", n);
976 // Make sure we got a nodeconnector
977 Assert.assertTrue(ofFromStr != null);
979 // Now the converted nodeconnector need to be the same of the
981 Assert.assertTrue(nc.equals(ofFromStr));
982 } catch (Exception e) {
983 // If this expection is raised the test is failing
984 System.out.println("Got exception as expected!:" + e);
985 Assert.assertTrue(false);
989 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
990 NodeConnector nc = new NodeConnector(
991 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
994 NodeConnector ofFromStr = null;
996 ofFromStr = NodeConnector.fromStringNoNode("-13570", n);
998 // Make sure we got a nodeconnector
999 Assert.assertTrue(ofFromStr != null);
1001 // Now the converted nodeconnector need to be the same of the
1003 Assert.assertTrue(nc.equals(ofFromStr));
1004 } catch (Exception e) {
1005 // If this expection is raised the test is failing
1006 System.out.println("Got exception as expected!:" + e);
1007 Assert.assertTrue(false);
1012 public void testConversionToStringAndBackSpecialPorts() {
1014 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1015 NodeConnector specialNc = new NodeConnector(
1016 NodeConnector.NodeConnectorIDType.CONTROLLER,
1017 NodeConnector.SPECIALNODECONNECTORID, n);
1019 String specialNcStr = specialNc.toString();
1020 System.out.println("NodeConnector String obtained= " + specialNc);
1021 NodeConnector specialNcFromStr = NodeConnector
1022 .fromString(specialNcStr);
1024 // Make sure we got a nodeconnector
1025 Assert.assertTrue(specialNcFromStr != null);
1027 // Now the converted nodeconnector need to be the same of the
1029 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1030 } catch (ConstructionException e) {
1031 // Fail if exception raised
1032 Assert.assertTrue(false);
1036 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1037 NodeConnector specialNc = new NodeConnector(
1038 NodeConnector.NodeConnectorIDType.ALL,
1039 NodeConnector.SPECIALNODECONNECTORID, n);
1041 String specialNcStr = specialNc.toString();
1042 System.out.println("NodeConnector String obtained= " + specialNc);
1043 NodeConnector specialNcFromStr = NodeConnector
1044 .fromString(specialNcStr);
1046 // Make sure we got a nodeconnector
1047 Assert.assertTrue(specialNcFromStr != null);
1049 // Now the converted nodeconnector need to be the same of the
1051 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1052 } catch (ConstructionException e) {
1053 // Fail if exception raised
1054 Assert.assertTrue(false);
1058 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1059 NodeConnector specialNc = new NodeConnector(
1060 NodeConnector.NodeConnectorIDType.HWPATH,
1061 NodeConnector.SPECIALNODECONNECTORID, n);
1063 String specialNcStr = specialNc.toString();
1064 System.out.println("NodeConnector String obtained= " + specialNc);
1065 NodeConnector specialNcFromStr = NodeConnector
1066 .fromString(specialNcStr);
1068 // Make sure we got a nodeconnector
1069 Assert.assertTrue(specialNcFromStr != null);
1071 // Now the converted nodeconnector need to be the same of the
1073 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1074 } catch (ConstructionException e) {
1075 // Fail if exception raised
1076 Assert.assertTrue(false);
1080 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1081 NodeConnector specialNc = new NodeConnector(
1082 NodeConnector.NodeConnectorIDType.SWSTACK,
1083 NodeConnector.SPECIALNODECONNECTORID, n);
1085 String specialNcStr = specialNc.toString();
1086 System.out.println("NodeConnector String obtained= " + specialNc);
1087 NodeConnector specialNcFromStr = NodeConnector
1088 .fromString(specialNcStr);
1090 // Make sure we got a nodeconnector
1091 Assert.assertTrue(specialNcFromStr != null);
1093 // Now the converted nodeconnector need to be the same of the
1095 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1096 } catch (ConstructionException e) {
1097 // Fail if exception raised
1098 Assert.assertTrue(false);
1102 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1103 NodeConnector specialNc = new NodeConnector(
1104 NodeConnector.NodeConnectorIDType.CONTROLLER,
1105 NodeConnector.SPECIALNODECONNECTORID, n);
1107 String specialNcStr = specialNc.toString();
1108 System.out.println("NodeConnector String obtained= " + specialNc);
1109 NodeConnector specialNcFromStr = NodeConnector
1110 .fromString(specialNcStr);
1112 // Make sure we got a nodeconnector
1113 Assert.assertTrue(specialNcFromStr != null);
1115 // Now the converted nodeconnector need to be the same of the
1117 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1118 } catch (ConstructionException e) {
1119 // Fail if exception raised
1120 Assert.assertTrue(false);
1124 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1125 NodeConnector specialNc = new NodeConnector(
1126 NodeConnector.NodeConnectorIDType.ALL,
1127 NodeConnector.SPECIALNODECONNECTORID, n);
1129 String specialNcStr = specialNc.toString();
1130 System.out.println("NodeConnector String obtained= " + specialNc);
1131 NodeConnector specialNcFromStr = NodeConnector
1132 .fromString(specialNcStr);
1134 // Make sure we got a nodeconnector
1135 Assert.assertTrue(specialNcFromStr != null);
1137 // Now the converted nodeconnector need to be the same of the
1139 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1140 } catch (ConstructionException e) {
1141 // Fail if exception raised
1142 Assert.assertTrue(false);
1146 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1147 NodeConnector specialNc = new NodeConnector(
1148 NodeConnector.NodeConnectorIDType.HWPATH,
1149 NodeConnector.SPECIALNODECONNECTORID, n);
1151 String specialNcStr = specialNc.toString();
1152 System.out.println("NodeConnector String obtained= " + specialNc);
1153 NodeConnector specialNcFromStr = NodeConnector
1154 .fromString(specialNcStr);
1156 // Make sure we got a nodeconnector
1157 Assert.assertTrue(specialNcFromStr != null);
1159 // Now the converted nodeconnector need to be the same of the
1161 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1162 } catch (ConstructionException e) {
1163 // Fail if exception raised
1164 Assert.assertTrue(false);
1168 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1169 NodeConnector specialNc = new NodeConnector(
1170 NodeConnector.NodeConnectorIDType.SWSTACK,
1171 NodeConnector.SPECIALNODECONNECTORID, n);
1173 String specialNcStr = specialNc.toString();
1174 System.out.println("NodeConnector String obtained= " + specialNc);
1175 NodeConnector specialNcFromStr = NodeConnector
1176 .fromString(specialNcStr);
1178 // Make sure we got a nodeconnector
1179 Assert.assertTrue(specialNcFromStr != null);
1181 // Now the converted nodeconnector need to be the same of the
1183 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1184 } catch (ConstructionException e) {
1185 // Fail if exception raised
1186 Assert.assertTrue(false);
1190 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1191 NodeConnector specialNc = new NodeConnector(
1192 NodeConnector.NodeConnectorIDType.CONTROLLER,
1193 NodeConnector.SPECIALNODECONNECTORID, n);
1195 String specialNcStr = specialNc.toString();
1196 System.out.println("NodeConnector String obtained= " + specialNc);
1197 NodeConnector specialNcFromStr = NodeConnector
1198 .fromString(specialNcStr);
1200 // Make sure we got a nodeconnector
1201 Assert.assertTrue(specialNcFromStr != null);
1203 // Now the converted nodeconnector need to be the same of the
1205 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1206 } catch (ConstructionException e) {
1207 // Fail if exception raised
1208 Assert.assertTrue(false);
1212 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1213 NodeConnector specialNc = new NodeConnector(
1214 NodeConnector.NodeConnectorIDType.ALL,
1215 NodeConnector.SPECIALNODECONNECTORID, n);
1217 String specialNcStr = specialNc.toString();
1218 System.out.println("NodeConnector String obtained= " + specialNc);
1219 NodeConnector specialNcFromStr = NodeConnector
1220 .fromString(specialNcStr);
1222 // Make sure we got a nodeconnector
1223 Assert.assertTrue(specialNcFromStr != null);
1225 // Now the converted nodeconnector need to be the same of the
1227 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1228 } catch (ConstructionException e) {
1229 // Fail if exception raised
1230 Assert.assertTrue(false);
1234 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1235 NodeConnector specialNc = new NodeConnector(
1236 NodeConnector.NodeConnectorIDType.HWPATH,
1237 NodeConnector.SPECIALNODECONNECTORID, n);
1239 String specialNcStr = specialNc.toString();
1240 System.out.println("NodeConnector String obtained= " + specialNc);
1241 NodeConnector specialNcFromStr = NodeConnector
1242 .fromString(specialNcStr);
1244 // Make sure we got a nodeconnector
1245 Assert.assertTrue(specialNcFromStr != null);
1247 // Now the converted nodeconnector need to be the same of the
1249 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1250 } catch (ConstructionException e) {
1251 // Fail if exception raised
1252 Assert.assertTrue(false);
1256 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1257 NodeConnector specialNc = new NodeConnector(
1258 NodeConnector.NodeConnectorIDType.SWSTACK,
1259 NodeConnector.SPECIALNODECONNECTORID, n);
1261 String specialNcStr = specialNc.toString();
1262 System.out.println("NodeConnector String obtained= " + specialNc);
1263 NodeConnector specialNcFromStr = NodeConnector
1264 .fromString(specialNcStr);
1266 // Make sure we got a nodeconnector
1267 Assert.assertTrue(specialNcFromStr != null);
1269 // Now the converted nodeconnector need to be the same of the
1271 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1272 } catch (ConstructionException e) {
1273 // Fail if exception raised
1274 Assert.assertTrue(false);