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 @SuppressWarnings("unused")
30 NodeConnector of1 = new NodeConnector(
31 NodeConnector.NodeConnectorIDType.OPENFLOW, new String(
32 "0xDEADBEEFCAFE0001L"), n1);
34 // If we reach this point the exception was not raised
35 // which should have been the case
36 Assert.assertTrue(false);
37 } catch (ConstructionException e) {
38 // If we reach this point the exception has been raised
40 System.out.println("Got exception as expected!:" + e);
41 Assert.assertTrue(true);
46 public void testNodeConnectorONEPKOfWrongType() {
48 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
49 @SuppressWarnings("unused")
50 NodeConnector onepk1 = new NodeConnector(
51 NodeConnector.NodeConnectorIDType.ONEPK, new Long(
52 0xDEADBEEFCAFE0001L), n1);
54 // If we reach this point the exception was not raised
55 // which should have been the case
56 Assert.assertTrue(false);
57 } catch (ConstructionException e) {
58 // If we reach this point the exception has been raised
60 System.out.println("Got exception as expected!:" + e);
61 Assert.assertTrue(true);
66 public void testNodeConnectorPCEPOfWrongType() {
68 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
69 @SuppressWarnings("unused")
70 NodeConnector pcep1 = new NodeConnector(
71 NodeConnector.NodeConnectorIDType.PCEP, new Long(
72 0xDEADBEEFCAFE0001L), n1);
74 // If we reach this point the exception was not raised
75 // which should have been the case
76 Assert.assertTrue(false);
77 } catch (ConstructionException e) {
78 // If we reach this point the exception has been raised
80 System.out.println("Got exception as expected!:" + e);
81 Assert.assertTrue(true);
86 public void testNodeConnectorOpenFlowOfCorrectType() {
88 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
89 NodeConnector of1 = new NodeConnector(
90 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
93 // If we reach this point the exception has not been
94 // raised so we passed the test
95 System.out.println("Got node:" + of1);
96 Assert.assertTrue(true);
97 } catch (ConstructionException e) {
98 // If we reach this point the exception was raised
99 // which is not expected
100 Assert.assertTrue(false);
105 public void testNodeConnectorONEPKOfCorrectType() {
107 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
108 NodeConnector onepk1 = new NodeConnector(
109 NodeConnector.NodeConnectorIDType.ONEPK, new String(
112 // If we reach this point the exception has not been
113 // raised so we passed the test
114 System.out.println("Got node:" + onepk1);
115 Assert.assertTrue(true);
116 } catch (ConstructionException e) {
117 // If we reach this point the exception was raised
118 // which is not expected
119 Assert.assertTrue(false);
124 public void testNodeConnectorPCEPOfCorrectType() {
126 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
127 NodeConnector pcep1 = new NodeConnector(
128 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
131 // If we reach this point the exception has not been
132 // raised so we passed the test
133 System.out.println("Got node:" + pcep1);
134 Assert.assertTrue(true);
135 } catch (ConstructionException e) {
136 // If we reach this point the exception was raised
137 // which is not expected
138 Assert.assertTrue(false);
143 public void testTwoOpenFlowNodeConnectorEquals() {
145 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
146 NodeConnector of1 = new NodeConnector(
147 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
148 (short) 0xCAFE), n1);
149 NodeConnector of2 = new NodeConnector(
150 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
151 (short) 0xCAFE), n1);
153 Assert.assertTrue(of1.equals(of2));
154 } catch (ConstructionException e) {
155 // If we reach this point the exception was raised
156 // which is not expected
157 Assert.assertTrue(false);
162 public void testTwoONEPKNodeConnectorEquals() {
164 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
165 NodeConnector onepk1 = new NodeConnector(
166 NodeConnector.NodeConnectorIDType.ONEPK, new String(
168 NodeConnector onepk2 = new NodeConnector(
169 NodeConnector.NodeConnectorIDType.ONEPK, new String(
172 Assert.assertTrue(onepk1.equals(onepk2));
173 } catch (ConstructionException e) {
174 // If we reach this point the exception was raised
175 // which is not expected
176 Assert.assertTrue(false);
181 public void testTwoPCEPNodeConnectorEquals() {
183 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
184 NodeConnector pcep1 = new NodeConnector(
185 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
187 NodeConnector pcep2 = new NodeConnector(
188 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
191 Assert.assertTrue(pcep1.equals(pcep2));
192 } catch (ConstructionException e) {
193 // If we reach this point the exception was raised
194 // which is not expected
195 Assert.assertTrue(false);
200 public void testTwoOpenFlowNodeConnectorDifferents() {
202 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
203 NodeConnector of1 = new NodeConnector(
204 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
205 (short) 0xCAFE), n1);
206 NodeConnector of2 = new NodeConnector(
207 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
208 (short) 0xBEEF), n1);
210 Assert.assertTrue(!of1.equals(of2));
211 } catch (ConstructionException e) {
212 // If we reach this point the exception was raised
213 // which is not expected
214 Assert.assertTrue(false);
219 public void testTwoONEPKNodeConnectorDifferents() {
221 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
222 NodeConnector onepk1 = new NodeConnector(
223 NodeConnector.NodeConnectorIDType.ONEPK, new String(
225 NodeConnector onepk2 = new NodeConnector(
226 NodeConnector.NodeConnectorIDType.ONEPK, new String(
229 Assert.assertTrue(!onepk1.equals(onepk2));
230 } catch (ConstructionException e) {
231 // If we reach this point the exception was raised
232 // which is not expected
233 Assert.assertTrue(false);
238 public void testTwoPCEPNodeConnectorDifferents() {
240 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
241 NodeConnector pcep1 = new NodeConnector(
242 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
244 NodeConnector pcep2 = new NodeConnector(
245 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
248 Assert.assertTrue(!pcep1.equals(pcep2));
249 } catch (ConstructionException e) {
250 // If we reach this point the exception was raised
251 // which is not expected
252 Assert.assertTrue(false);
257 public void testTwoOpenFlowNodeConnectorDifferentsNodes() {
259 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
260 Node n2 = new Node(Node.NodeIDType.OPENFLOW, new Long(111L));
261 NodeConnector of1 = new NodeConnector(
262 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
263 (short) 0xCAFE), n1);
264 NodeConnector of2 = new NodeConnector(
265 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
266 (short) 0xCAFE), n2);
268 Assert.assertTrue(!of1.equals(of2));
269 } catch (ConstructionException e) {
270 // If we reach this point the exception was raised
271 // which is not expected
272 Assert.assertTrue(false);
277 public void testTwoONEPKNodeConnectorDifferentsNodes() {
279 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
280 Node n2 = new Node(Node.NodeIDType.ONEPK, new String("Router2"));
281 NodeConnector onepk1 = new NodeConnector(
282 NodeConnector.NodeConnectorIDType.ONEPK, new String(
284 NodeConnector onepk2 = new NodeConnector(
285 NodeConnector.NodeConnectorIDType.ONEPK, new String(
288 Assert.assertTrue(!onepk1.equals(onepk2));
289 } catch (ConstructionException e) {
290 // If we reach this point the exception was raised
291 // which is not expected
292 Assert.assertTrue(false);
297 public void testTwoPCEPNodeConnectorDifferentsNodes() {
299 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
300 Node n2 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 1L));
301 NodeConnector pcep1 = new NodeConnector(
302 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
304 NodeConnector pcep2 = new NodeConnector(
305 NodeConnector.NodeConnectorIDType.PCEP, new Integer(
308 Assert.assertTrue(!pcep1.equals(pcep2));
309 } catch (ConstructionException e) {
310 // If we reach this point the exception was raised
311 // which is not expected
312 Assert.assertTrue(false);
316 @SuppressWarnings("unused")
318 public void testIncompatibleNodes() {
320 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
321 NodeConnector nc1 = new NodeConnector(
322 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
324 // Exception is expected if not raised test will fail
325 Assert.assertTrue(false);
326 } catch (ConstructionException e) {
330 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
331 NodeConnector nc1 = new NodeConnector(
332 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
334 // Exception is expected if not raised test will fail
335 Assert.assertTrue(false);
336 } catch (ConstructionException e) {
340 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
341 NodeConnector nc1 = new NodeConnector(
342 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
343 new Short((short) 0), n1);
344 // Exception is expected if not raised test will fail
345 Assert.assertTrue(false);
346 } catch (ConstructionException e) {
350 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
351 NodeConnector nc1 = new NodeConnector(
352 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
354 // Exception is expected if not raised test will fail
355 Assert.assertTrue(false);
356 } catch (ConstructionException e) {
360 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
361 NodeConnector nc1 = new NodeConnector(
362 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
363 new String("towardPCEP1"), n1);
364 // Exception is expected if not raised test will fail
365 Assert.assertTrue(false);
366 } catch (ConstructionException e) {
370 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
371 NodeConnector nc1 = new NodeConnector(
372 NodeConnector.NodeConnectorIDType.ONEPK, new String(
374 // Exception is expected if not raised test will fail
375 Assert.assertTrue(false);
376 } catch (ConstructionException e) {
380 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
381 NodeConnector nc1 = new NodeConnector(
382 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
383 } catch (ConstructionException e) {
384 // Exception is NOT expected if raised test will fail
385 Assert.assertTrue(false);
388 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
389 NodeConnector nc1 = new NodeConnector(
390 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
392 } catch (ConstructionException e) {
393 // Exception is NOT expected if raised test will fail
394 Assert.assertTrue(false);
398 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
399 NodeConnector nc1 = new NodeConnector(
400 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
402 } catch (ConstructionException e) {
403 // Exception is NOT expected if raised test will fail
404 Assert.assertTrue(false);
408 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
409 NodeConnector nc1 = new NodeConnector(
410 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
412 // Exception is expected if not raised test will fail
413 Assert.assertTrue(false);
414 } catch (ConstructionException e) {
418 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
419 NodeConnector nc1 = new NodeConnector(
420 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
422 // Exception is expected if not raised test will fail
423 Assert.assertTrue(false);
424 } catch (ConstructionException e) {
428 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
429 NodeConnector nc1 = new NodeConnector(
430 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
431 new Short((short) 0), n1);
432 // Exception is expected if not raised test will fail
433 Assert.assertTrue(false);
434 } catch (ConstructionException e) {
438 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
439 NodeConnector nc1 = new NodeConnector(
440 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
442 } catch (ConstructionException e) {
443 // Exception is NOT expected if raised test will fail
444 Assert.assertTrue(false);
448 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
449 NodeConnector nc1 = new NodeConnector(
450 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
451 new String("towardPCEP1"), n1);
452 } catch (ConstructionException e) {
453 // Exception is NOT expected if raised test will fail
454 Assert.assertTrue(false);
458 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
459 NodeConnector nc1 = new NodeConnector(
460 NodeConnector.NodeConnectorIDType.ONEPK, new String(
462 } catch (ConstructionException e) {
463 // Exception is NOT expected if raised test will fail
464 Assert.assertTrue(false);
468 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
469 NodeConnector nc1 = new NodeConnector(
470 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
471 // Exception is expected if not raised test will fail
472 Assert.assertTrue(false);
473 } catch (ConstructionException e) {
477 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
478 NodeConnector nc1 = new NodeConnector(
479 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
481 // Exception is expected if not raised test will fail
482 Assert.assertTrue(false);
483 } catch (ConstructionException e) {
487 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
488 NodeConnector nc1 = new NodeConnector(
489 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
491 // Exception is expected if not raised test will fail
492 Assert.assertTrue(false);
493 } catch (ConstructionException e) {
497 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
498 NodeConnector nc1 = new NodeConnector(
499 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
501 } catch (ConstructionException e) {
502 // Exception is NOT expected if raised test will fail
503 Assert.assertTrue(false);
507 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
508 NodeConnector nc1 = new NodeConnector(
509 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
511 } catch (ConstructionException e) {
512 // Exception is NOT expected if raised test will fail
513 Assert.assertTrue(false);
517 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
518 NodeConnector nc1 = new NodeConnector(
519 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
520 new Short((short) 0), n1);
521 } catch (ConstructionException e) {
522 // Exception is NOT expected if raised test will fail
523 Assert.assertTrue(false);
527 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
528 NodeConnector nc1 = new NodeConnector(
529 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
531 // Exception is expected if not raised test will fail
532 Assert.assertTrue(false);
533 } catch (ConstructionException e) {
537 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
538 NodeConnector nc1 = new NodeConnector(
539 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
540 new String("towardPCEP1"), n1);
541 // Exception is expected if not raised test will fail
542 Assert.assertTrue(false);
543 } catch (ConstructionException e) {
547 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
548 NodeConnector nc1 = new NodeConnector(
549 NodeConnector.NodeConnectorIDType.ONEPK, new String(
551 // Exception is expected if not raised test will fail
552 Assert.assertTrue(false);
553 } catch (ConstructionException e) {
557 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
558 NodeConnector nc1 = new NodeConnector(
559 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
560 // Exception is expected if not raised test will fail
561 Assert.assertTrue(false);
562 } catch (ConstructionException e) {
566 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
567 NodeConnector nc1 = new NodeConnector(
568 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
570 // Exception is expected if not raised test will fail
571 Assert.assertTrue(false);
572 } catch (ConstructionException e) {
576 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
577 NodeConnector nc1 = new NodeConnector(
578 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
580 // Exception is expected if not raised test will fail
581 Assert.assertTrue(false);
582 } catch (ConstructionException e) {
587 public void testConversionToStringAndBack() {
589 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
590 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
591 NodeConnector nc1 = new NodeConnector(
592 NodeConnector.NodeConnectorIDType.PCEP2ONEPK, new Integer(
594 String nc1Str = nc1.toString();
595 System.out.println("NodeConnector String = " + nc1Str);
596 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
598 // Make sure we got a nodeconnector
599 Assert.assertTrue(nc1FromStr != null);
601 // Now the converted nodeconnector need to be the same of the
603 Assert.assertTrue(nc1.equals(nc1FromStr));
604 } catch (ConstructionException e) {
605 // Fail if exception raised
606 Assert.assertTrue(false);
610 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
611 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
612 NodeConnector nc1 = new NodeConnector(
613 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
614 new Integer(0x10), n1);
615 String nc1Str = nc1.toString();
616 System.out.println("NodeConnector String = " + nc1Str);
617 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
619 // Make sure we got a nodeconnector
620 Assert.assertTrue(nc1FromStr != null);
622 // Now the converted nodeconnector need to be the same of the
624 Assert.assertTrue(nc1.equals(nc1FromStr));
625 } catch (ConstructionException e) {
626 // Fail if exception raised
627 Assert.assertTrue(false);
631 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
632 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
633 NodeConnector nc1 = new NodeConnector(
634 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0x10),
636 String nc1Str = nc1.toString();
637 System.out.println("NodeConnector String = " + nc1Str);
638 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
640 // Make sure we got a nodeconnector
641 Assert.assertTrue(nc1FromStr != null);
643 // Now the converted nodeconnector need to be the same of the
645 Assert.assertTrue(nc1.equals(nc1FromStr));
646 } catch (ConstructionException e) {
647 // Fail if exception raised
648 Assert.assertTrue(false);
652 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
653 NodeConnector nc1 = new NodeConnector(
654 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
657 String nc1Str = nc1.toString();
658 System.out.println("NodeConnector String = " + nc1Str);
659 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
661 // Make sure we got a nodeconnector
662 Assert.assertTrue(nc1FromStr != null);
664 // Now the converted nodeconnector need to be the same of the
666 Assert.assertTrue(nc1.equals(nc1FromStr));
667 } catch (ConstructionException e) {
668 // Fail if exception raised
669 Assert.assertTrue(false);
673 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
674 NodeConnector nc1 = new NodeConnector(
675 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
676 new String("towardOPENFLOW1"), n1);
678 String nc1Str = nc1.toString();
679 System.out.println("NodeConnector String = " + nc1Str);
680 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
682 // Make sure we got a nodeconnector
683 Assert.assertTrue(nc1FromStr != null);
685 // Now the converted nodeconnector need to be the same of the
687 Assert.assertTrue(nc1.equals(nc1FromStr));
688 } catch (ConstructionException e) {
689 // Fail if exception raised
690 Assert.assertTrue(false);
694 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
695 NodeConnector nc1 = new NodeConnector(
696 NodeConnector.NodeConnectorIDType.ONEPK, new String(
699 String nc1Str = nc1.toString();
700 System.out.println("NodeConnector String = " + nc1Str);
701 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
703 // Make sure we got a nodeconnector
704 Assert.assertTrue(nc1FromStr != null);
706 // Now the converted nodeconnector need to be the same of the
708 Assert.assertTrue(nc1.equals(nc1FromStr));
709 } catch (ConstructionException e) {
710 // Fail if exception raised
711 Assert.assertTrue(false);
715 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(
716 0xDEADBEEFCAFE0001L));
717 NodeConnector nc1 = new NodeConnector(
718 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
719 (short) 0xCAFE), n1);
721 String nc1Str = nc1.toString();
722 System.out.println("NodeConnector String = " + nc1Str);
723 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
725 // Make sure we got a nodeconnector
726 Assert.assertTrue(nc1FromStr != null);
728 // Now the converted nodeconnector need to be the same of the
730 Assert.assertTrue(nc1.equals(nc1FromStr));
731 } catch (ConstructionException e) {
732 // Fail if exception raised
733 Assert.assertTrue(false);
737 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
738 NodeConnector nc1 = new NodeConnector(
739 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
742 String nc1Str = nc1.toString();
743 System.out.println("NodeConnector String = " + nc1Str);
744 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
746 // Make sure we got a nodeconnector
747 Assert.assertTrue(nc1FromStr != null);
749 // Now the converted nodeconnector need to be the same of the
751 Assert.assertTrue(nc1.equals(nc1FromStr));
752 } catch (ConstructionException e) {
753 // Fail if exception raised
754 Assert.assertTrue(false);
758 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
759 NodeConnector nc1 = new NodeConnector(
760 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
761 new Short((short) 0x11), n1);
763 String nc1Str = nc1.toString();
764 System.out.println("NodeConnector String = " + nc1Str);
765 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
767 // Make sure we got a nodeconnector
768 Assert.assertTrue(nc1FromStr != null);
770 // Now the converted nodeconnector need to be the same of the
772 Assert.assertTrue(nc1.equals(nc1FromStr));
773 } catch (ConstructionException e) {
774 // Fail if exception raised
775 Assert.assertTrue(false);
780 public void testNodeConnectorSpecialType() {
782 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
783 NodeConnector specialNc = new NodeConnector(
784 NodeConnector.NodeConnectorIDType.CONTROLLER,
785 NodeConnector.SPECIALNODECONNECTORID, n);
786 System.out.println("Special NC = " + specialNc);
787 // We expect to reach this point succesfully
788 Assert.assertTrue(true);
789 } catch (ConstructionException e) {
790 // If this expection is raised the test is failing
791 System.out.println("Got exception as expected!:" + e);
792 Assert.assertTrue(false);
796 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
797 NodeConnector specialNc = new NodeConnector(
798 NodeConnector.NodeConnectorIDType.ALL,
799 NodeConnector.SPECIALNODECONNECTORID, n);
800 System.out.println("Special NC = " + specialNc);
801 // We expect to reach this point succesfully
802 Assert.assertTrue(true);
803 } catch (ConstructionException e) {
804 // If this expection is raised the test is failing
805 System.out.println("Got exception as expected!:" + e);
806 Assert.assertTrue(false);
810 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
811 NodeConnector specialNc = new NodeConnector(
812 NodeConnector.NodeConnectorIDType.SWSTACK,
813 NodeConnector.SPECIALNODECONNECTORID, n);
814 System.out.println("Special NC = " + specialNc);
815 // We expect to reach this point succesfully
816 Assert.assertTrue(true);
817 } catch (ConstructionException e) {
818 // If this expection is raised the test is failing
819 System.out.println("Got exception as expected!:" + e);
820 Assert.assertTrue(false);
824 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
825 NodeConnector specialNc = new NodeConnector(
826 NodeConnector.NodeConnectorIDType.HWPATH,
827 NodeConnector.SPECIALNODECONNECTORID, n);
828 System.out.println("Special NC = " + specialNc);
829 // We expect to reach this point succesfully
830 Assert.assertTrue(true);
831 } catch (ConstructionException e) {
832 // If this expection is raised the test is failing
833 System.out.println("Got exception as expected!:" + e);
834 Assert.assertTrue(false);
838 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
839 NodeConnector specialNc = new NodeConnector(
840 NodeConnector.NodeConnectorIDType.CONTROLLER,
841 NodeConnector.SPECIALNODECONNECTORID, n);
842 System.out.println("Special NC = " + specialNc);
843 // We expect to reach this point succesfully
844 Assert.assertTrue(true);
845 } catch (ConstructionException e) {
846 // If this expection is raised the test is failing
847 System.out.println("Got exception as expected!:" + e);
848 Assert.assertTrue(false);
852 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
853 NodeConnector specialNc = new NodeConnector(
854 NodeConnector.NodeConnectorIDType.ALL,
855 NodeConnector.SPECIALNODECONNECTORID, n);
856 System.out.println("Special NC = " + specialNc);
857 // We expect to reach this point succesfully
858 Assert.assertTrue(true);
859 } catch (ConstructionException e) {
860 // If this expection is raised the test is failing
861 System.out.println("Got exception as expected!:" + e);
862 Assert.assertTrue(false);
866 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
867 NodeConnector specialNc = new NodeConnector(
868 NodeConnector.NodeConnectorIDType.SWSTACK,
869 NodeConnector.SPECIALNODECONNECTORID, n);
870 System.out.println("Special NC = " + specialNc);
871 // We expect to reach this point succesfully
872 Assert.assertTrue(true);
873 } catch (ConstructionException e) {
874 // If this expection is raised the test is failing
875 System.out.println("Got exception as expected!:" + e);
876 Assert.assertTrue(false);
880 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
881 NodeConnector specialNc = new NodeConnector(
882 NodeConnector.NodeConnectorIDType.HWPATH,
883 NodeConnector.SPECIALNODECONNECTORID, n);
884 System.out.println("Special NC = " + specialNc);
885 // We expect to reach this point succesfully
886 Assert.assertTrue(true);
887 } catch (ConstructionException e) {
888 // If this expection is raised the test is failing
889 System.out.println("Got exception as expected!:" + e);
890 Assert.assertTrue(false);
894 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
895 NodeConnector specialNc = new NodeConnector(
896 NodeConnector.NodeConnectorIDType.CONTROLLER,
897 NodeConnector.SPECIALNODECONNECTORID, n);
898 System.out.println("Special NC = " + specialNc);
899 // We expect to reach this point succesfully
900 Assert.assertTrue(true);
901 } catch (ConstructionException e) {
902 // If this expection is raised the test is failing
903 System.out.println("Got exception as expected!:" + e);
904 Assert.assertTrue(false);
908 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
909 NodeConnector specialNc = new NodeConnector(
910 NodeConnector.NodeConnectorIDType.ALL,
911 NodeConnector.SPECIALNODECONNECTORID, n);
912 System.out.println("Special NC = " + specialNc);
913 // We expect to reach this point succesfully
914 Assert.assertTrue(true);
915 } catch (ConstructionException e) {
916 // If this expection is raised the test is failing
917 System.out.println("Got exception as expected!:" + e);
918 Assert.assertTrue(false);
922 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
923 NodeConnector specialNc = new NodeConnector(
924 NodeConnector.NodeConnectorIDType.SWSTACK,
925 NodeConnector.SPECIALNODECONNECTORID, n);
926 System.out.println("Special NC = " + specialNc);
927 // We expect to reach this point succesfully
928 Assert.assertTrue(true);
929 } catch (ConstructionException e) {
930 // If this expection is raised the test is failing
931 System.out.println("Got exception as expected!:" + e);
932 Assert.assertTrue(false);
936 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
937 NodeConnector specialNc = new NodeConnector(
938 NodeConnector.NodeConnectorIDType.HWPATH,
939 NodeConnector.SPECIALNODECONNECTORID, n);
940 System.out.println("Special NC = " + specialNc);
941 // We expect to reach this point succesfully
942 Assert.assertTrue(true);
943 } catch (ConstructionException e) {
944 // If this expection is raised the test is failing
945 System.out.println("Got exception as expected!:" + e);
946 Assert.assertTrue(false);
951 public void testToStringConversionForOpenFlow() {
953 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
954 NodeConnector nc = new NodeConnector(
955 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
958 NodeConnector ofFromStr = null;
960 ofFromStr = NodeConnector.fromStringNoNode("0x2ab", n);
962 // Make sure we got a nodeconnector
963 Assert.assertTrue(ofFromStr != null);
965 // Now the converted nodeconnector need to be the same of the
967 Assert.assertTrue(nc.equals(ofFromStr));
969 ofFromStr = NodeConnector.fromStringNoNode("0x2AB", n);
971 // Make sure we got a nodeconnector
972 Assert.assertTrue(ofFromStr != null);
974 // Now the converted nodeconnector need to be the same of the
976 Assert.assertTrue(nc.equals(ofFromStr));
978 ofFromStr = NodeConnector.fromStringNoNode("683", n);
980 // Make sure we got a nodeconnector
981 Assert.assertTrue(ofFromStr != null);
983 // Now the converted nodeconnector need to be the same of the
985 Assert.assertTrue(nc.equals(ofFromStr));
986 } catch (Exception e) {
987 // If this expection is raised the test is failing
988 System.out.println("Got exception as expected!:" + e);
989 Assert.assertTrue(false);
993 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
994 NodeConnector nc = new NodeConnector(
995 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
998 NodeConnector ofFromStr = null;
1000 ofFromStr = NodeConnector.fromStringNoNode("-13570", n);
1002 // Make sure we got a nodeconnector
1003 Assert.assertTrue(ofFromStr != null);
1005 // Now the converted nodeconnector need to be the same of the
1007 Assert.assertTrue(nc.equals(ofFromStr));
1008 } catch (Exception e) {
1009 // If this expection is raised the test is failing
1010 System.out.println("Got exception as expected!:" + e);
1011 Assert.assertTrue(false);
1016 public void testConversionToStringAndBackSpecialPorts() {
1018 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1019 NodeConnector specialNc = new NodeConnector(
1020 NodeConnector.NodeConnectorIDType.CONTROLLER,
1021 NodeConnector.SPECIALNODECONNECTORID, n);
1023 String specialNcStr = specialNc.toString();
1024 System.out.println("NodeConnector String obtained= " + specialNc);
1025 NodeConnector specialNcFromStr = NodeConnector
1026 .fromString(specialNcStr);
1028 // Make sure we got a nodeconnector
1029 Assert.assertTrue(specialNcFromStr != null);
1031 // Now the converted nodeconnector need to be the same of the
1033 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1034 } catch (ConstructionException e) {
1035 // Fail if exception raised
1036 Assert.assertTrue(false);
1040 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1041 NodeConnector specialNc = new NodeConnector(
1042 NodeConnector.NodeConnectorIDType.ALL,
1043 NodeConnector.SPECIALNODECONNECTORID, n);
1045 String specialNcStr = specialNc.toString();
1046 System.out.println("NodeConnector String obtained= " + specialNc);
1047 NodeConnector specialNcFromStr = NodeConnector
1048 .fromString(specialNcStr);
1050 // Make sure we got a nodeconnector
1051 Assert.assertTrue(specialNcFromStr != null);
1053 // Now the converted nodeconnector need to be the same of the
1055 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1056 } catch (ConstructionException e) {
1057 // Fail if exception raised
1058 Assert.assertTrue(false);
1062 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1063 NodeConnector specialNc = new NodeConnector(
1064 NodeConnector.NodeConnectorIDType.HWPATH,
1065 NodeConnector.SPECIALNODECONNECTORID, n);
1067 String specialNcStr = specialNc.toString();
1068 System.out.println("NodeConnector String obtained= " + specialNc);
1069 NodeConnector specialNcFromStr = NodeConnector
1070 .fromString(specialNcStr);
1072 // Make sure we got a nodeconnector
1073 Assert.assertTrue(specialNcFromStr != null);
1075 // Now the converted nodeconnector need to be the same of the
1077 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1078 } catch (ConstructionException e) {
1079 // Fail if exception raised
1080 Assert.assertTrue(false);
1084 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1085 NodeConnector specialNc = new NodeConnector(
1086 NodeConnector.NodeConnectorIDType.SWSTACK,
1087 NodeConnector.SPECIALNODECONNECTORID, n);
1089 String specialNcStr = specialNc.toString();
1090 System.out.println("NodeConnector String obtained= " + specialNc);
1091 NodeConnector specialNcFromStr = NodeConnector
1092 .fromString(specialNcStr);
1094 // Make sure we got a nodeconnector
1095 Assert.assertTrue(specialNcFromStr != null);
1097 // Now the converted nodeconnector need to be the same of the
1099 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1100 } catch (ConstructionException e) {
1101 // Fail if exception raised
1102 Assert.assertTrue(false);
1106 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1107 NodeConnector specialNc = new NodeConnector(
1108 NodeConnector.NodeConnectorIDType.CONTROLLER,
1109 NodeConnector.SPECIALNODECONNECTORID, n);
1111 String specialNcStr = specialNc.toString();
1112 System.out.println("NodeConnector String obtained= " + specialNc);
1113 NodeConnector specialNcFromStr = NodeConnector
1114 .fromString(specialNcStr);
1116 // Make sure we got a nodeconnector
1117 Assert.assertTrue(specialNcFromStr != null);
1119 // Now the converted nodeconnector need to be the same of the
1121 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1122 } catch (ConstructionException e) {
1123 // Fail if exception raised
1124 Assert.assertTrue(false);
1128 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1129 NodeConnector specialNc = new NodeConnector(
1130 NodeConnector.NodeConnectorIDType.ALL,
1131 NodeConnector.SPECIALNODECONNECTORID, n);
1133 String specialNcStr = specialNc.toString();
1134 System.out.println("NodeConnector String obtained= " + specialNc);
1135 NodeConnector specialNcFromStr = NodeConnector
1136 .fromString(specialNcStr);
1138 // Make sure we got a nodeconnector
1139 Assert.assertTrue(specialNcFromStr != null);
1141 // Now the converted nodeconnector need to be the same of the
1143 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1144 } catch (ConstructionException e) {
1145 // Fail if exception raised
1146 Assert.assertTrue(false);
1150 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1151 NodeConnector specialNc = new NodeConnector(
1152 NodeConnector.NodeConnectorIDType.HWPATH,
1153 NodeConnector.SPECIALNODECONNECTORID, n);
1155 String specialNcStr = specialNc.toString();
1156 System.out.println("NodeConnector String obtained= " + specialNc);
1157 NodeConnector specialNcFromStr = NodeConnector
1158 .fromString(specialNcStr);
1160 // Make sure we got a nodeconnector
1161 Assert.assertTrue(specialNcFromStr != null);
1163 // Now the converted nodeconnector need to be the same of the
1165 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1166 } catch (ConstructionException e) {
1167 // Fail if exception raised
1168 Assert.assertTrue(false);
1172 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1173 NodeConnector specialNc = new NodeConnector(
1174 NodeConnector.NodeConnectorIDType.SWSTACK,
1175 NodeConnector.SPECIALNODECONNECTORID, n);
1177 String specialNcStr = specialNc.toString();
1178 System.out.println("NodeConnector String obtained= " + specialNc);
1179 NodeConnector specialNcFromStr = NodeConnector
1180 .fromString(specialNcStr);
1182 // Make sure we got a nodeconnector
1183 Assert.assertTrue(specialNcFromStr != null);
1185 // Now the converted nodeconnector need to be the same of the
1187 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1188 } catch (ConstructionException e) {
1189 // Fail if exception raised
1190 Assert.assertTrue(false);
1194 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1195 NodeConnector specialNc = new NodeConnector(
1196 NodeConnector.NodeConnectorIDType.CONTROLLER,
1197 NodeConnector.SPECIALNODECONNECTORID, n);
1199 String specialNcStr = specialNc.toString();
1200 System.out.println("NodeConnector String obtained= " + specialNc);
1201 NodeConnector specialNcFromStr = NodeConnector
1202 .fromString(specialNcStr);
1204 // Make sure we got a nodeconnector
1205 Assert.assertTrue(specialNcFromStr != null);
1207 // Now the converted nodeconnector need to be the same of the
1209 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1210 } catch (ConstructionException e) {
1211 // Fail if exception raised
1212 Assert.assertTrue(false);
1216 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1217 NodeConnector specialNc = new NodeConnector(
1218 NodeConnector.NodeConnectorIDType.ALL,
1219 NodeConnector.SPECIALNODECONNECTORID, n);
1221 String specialNcStr = specialNc.toString();
1222 System.out.println("NodeConnector String obtained= " + specialNc);
1223 NodeConnector specialNcFromStr = NodeConnector
1224 .fromString(specialNcStr);
1226 // Make sure we got a nodeconnector
1227 Assert.assertTrue(specialNcFromStr != null);
1229 // Now the converted nodeconnector need to be the same of the
1231 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1232 } catch (ConstructionException e) {
1233 // Fail if exception raised
1234 Assert.assertTrue(false);
1238 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1239 NodeConnector specialNc = new NodeConnector(
1240 NodeConnector.NodeConnectorIDType.HWPATH,
1241 NodeConnector.SPECIALNODECONNECTORID, n);
1243 String specialNcStr = specialNc.toString();
1244 System.out.println("NodeConnector String obtained= " + specialNc);
1245 NodeConnector specialNcFromStr = NodeConnector
1246 .fromString(specialNcStr);
1248 // Make sure we got a nodeconnector
1249 Assert.assertTrue(specialNcFromStr != null);
1251 // Now the converted nodeconnector need to be the same of the
1253 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1254 } catch (ConstructionException e) {
1255 // Fail if exception raised
1256 Assert.assertTrue(false);
1260 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1261 NodeConnector specialNc = new NodeConnector(
1262 NodeConnector.NodeConnectorIDType.SWSTACK,
1263 NodeConnector.SPECIALNODECONNECTORID, n);
1265 String specialNcStr = specialNc.toString();
1266 System.out.println("NodeConnector String obtained= " + specialNc);
1267 NodeConnector specialNcFromStr = NodeConnector
1268 .fromString(specialNcStr);
1270 // Make sure we got a nodeconnector
1271 Assert.assertTrue(specialNcFromStr != null);
1273 // Now the converted nodeconnector need to be the same of the
1275 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1276 } catch (ConstructionException e) {
1277 // Fail if exception raised
1278 Assert.assertTrue(false);