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;
23 import org.opendaylight.controller.sal.core.ConstructionException;
24 import org.opendaylight.controller.sal.core.Node;
25 import org.opendaylight.controller.sal.core.NodeConnector;
27 public class NodeConnectorTest {
29 public void testNodeConnectorOpenFlowOfWrongType() {
31 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
32 NodeConnector of1 = new NodeConnector(
33 NodeConnector.NodeConnectorIDType.OPENFLOW, new String(
34 "0xDEADBEEFCAFE0001L"), n1);
36 // If we reach this point the exception was not raised
37 // which should have been the case
38 Assert.assertTrue(false);
39 } catch (ConstructionException e) {
40 // If we reach this point the exception has been raised
42 System.out.println("Got exception as expected!:" + e);
43 Assert.assertTrue(true);
48 public void testNodeConnectorONEPKOfWrongType() {
50 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
51 NodeConnector onepk1 = new NodeConnector(
52 NodeConnector.NodeConnectorIDType.ONEPK, new Long(
53 0xDEADBEEFCAFE0001L), n1);
55 // If we reach this point the exception was not raised
56 // which should have been the case
57 Assert.assertTrue(false);
58 } catch (ConstructionException e) {
59 // If we reach this point the exception has been raised
61 System.out.println("Got exception as expected!:" + e);
62 Assert.assertTrue(true);
67 public void testNodeConnectorPCEPOfWrongType() {
69 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
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);
317 public void testIncompatibleNodes() {
319 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
320 NodeConnector nc1 = new NodeConnector(
321 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
323 // Exception is expected if not raised test will fail
324 Assert.assertTrue(false);
325 } catch (ConstructionException e) {
329 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
330 NodeConnector nc1 = new NodeConnector(
331 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
333 // Exception is expected if not raised test will fail
334 Assert.assertTrue(false);
335 } catch (ConstructionException e) {
339 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
340 NodeConnector nc1 = new NodeConnector(
341 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
342 new Short((short) 0), n1);
343 // Exception is expected if not raised test will fail
344 Assert.assertTrue(false);
345 } catch (ConstructionException e) {
349 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
350 NodeConnector nc1 = new NodeConnector(
351 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
353 // Exception is expected if not raised test will fail
354 Assert.assertTrue(false);
355 } catch (ConstructionException e) {
359 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
360 NodeConnector nc1 = new NodeConnector(
361 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
362 new String("towardPCEP1"), n1);
363 // Exception is expected if not raised test will fail
364 Assert.assertTrue(false);
365 } catch (ConstructionException e) {
369 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
370 NodeConnector nc1 = new NodeConnector(
371 NodeConnector.NodeConnectorIDType.ONEPK, new String(
373 // Exception is expected if not raised test will fail
374 Assert.assertTrue(false);
375 } catch (ConstructionException e) {
379 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
380 NodeConnector nc1 = new NodeConnector(
381 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
382 } catch (ConstructionException e) {
383 // Exception is NOT expected if raised test will fail
384 Assert.assertTrue(false);
387 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
388 NodeConnector nc1 = new NodeConnector(
389 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
391 } catch (ConstructionException e) {
392 // Exception is NOT expected if raised test will fail
393 Assert.assertTrue(false);
397 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
398 NodeConnector nc1 = new NodeConnector(
399 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
401 } catch (ConstructionException e) {
402 // Exception is NOT expected if raised test will fail
403 Assert.assertTrue(false);
407 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
408 NodeConnector nc1 = new NodeConnector(
409 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
411 // Exception is expected if not raised test will fail
412 Assert.assertTrue(false);
413 } catch (ConstructionException e) {
417 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
418 NodeConnector nc1 = new NodeConnector(
419 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
421 // Exception is expected if not raised test will fail
422 Assert.assertTrue(false);
423 } catch (ConstructionException e) {
427 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
428 NodeConnector nc1 = new NodeConnector(
429 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
430 new Short((short) 0), n1);
431 // Exception is expected if not raised test will fail
432 Assert.assertTrue(false);
433 } catch (ConstructionException e) {
437 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
438 NodeConnector nc1 = new NodeConnector(
439 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
441 } catch (ConstructionException e) {
442 // Exception is NOT expected if raised test will fail
443 Assert.assertTrue(false);
447 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
448 NodeConnector nc1 = new NodeConnector(
449 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
450 new String("towardPCEP1"), n1);
451 } catch (ConstructionException e) {
452 // Exception is NOT expected if raised test will fail
453 Assert.assertTrue(false);
457 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
458 NodeConnector nc1 = new NodeConnector(
459 NodeConnector.NodeConnectorIDType.ONEPK, new String(
461 } catch (ConstructionException e) {
462 // Exception is NOT expected if raised test will fail
463 Assert.assertTrue(false);
467 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
468 NodeConnector nc1 = new NodeConnector(
469 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
470 // Exception is expected if not raised test will fail
471 Assert.assertTrue(false);
472 } catch (ConstructionException e) {
476 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
477 NodeConnector nc1 = new NodeConnector(
478 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
480 // Exception is expected if not raised test will fail
481 Assert.assertTrue(false);
482 } catch (ConstructionException e) {
486 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
487 NodeConnector nc1 = new NodeConnector(
488 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
490 // Exception is expected if not raised test will fail
491 Assert.assertTrue(false);
492 } catch (ConstructionException e) {
496 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
497 NodeConnector nc1 = new NodeConnector(
498 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
500 } catch (ConstructionException e) {
501 // Exception is NOT expected if raised test will fail
502 Assert.assertTrue(false);
506 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
507 NodeConnector nc1 = new NodeConnector(
508 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
510 } catch (ConstructionException e) {
511 // Exception is NOT expected if raised test will fail
512 Assert.assertTrue(false);
516 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
517 NodeConnector nc1 = new NodeConnector(
518 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
519 new Short((short) 0), n1);
520 } catch (ConstructionException e) {
521 // Exception is NOT expected if raised test will fail
522 Assert.assertTrue(false);
526 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
527 NodeConnector nc1 = new NodeConnector(
528 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
530 // Exception is expected if not raised test will fail
531 Assert.assertTrue(false);
532 } catch (ConstructionException e) {
536 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
537 NodeConnector nc1 = new NodeConnector(
538 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
539 new String("towardPCEP1"), n1);
540 // Exception is expected if not raised test will fail
541 Assert.assertTrue(false);
542 } catch (ConstructionException e) {
546 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
547 NodeConnector nc1 = new NodeConnector(
548 NodeConnector.NodeConnectorIDType.ONEPK, new String(
550 // Exception is expected if not raised test will fail
551 Assert.assertTrue(false);
552 } catch (ConstructionException e) {
556 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
557 NodeConnector nc1 = new NodeConnector(
558 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
559 // Exception is expected if not raised test will fail
560 Assert.assertTrue(false);
561 } catch (ConstructionException e) {
565 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
566 NodeConnector nc1 = new NodeConnector(
567 NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
569 // Exception is expected if not raised test will fail
570 Assert.assertTrue(false);
571 } catch (ConstructionException e) {
575 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
576 NodeConnector nc1 = new NodeConnector(
577 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
579 // Exception is expected if not raised test will fail
580 Assert.assertTrue(false);
581 } catch (ConstructionException e) {
586 public void testConversionToStringAndBack() {
588 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
589 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
590 NodeConnector nc1 = new NodeConnector(
591 NodeConnector.NodeConnectorIDType.PCEP2ONEPK, new Integer(
593 String nc1Str = nc1.toString();
594 System.out.println("NodeConnector String = " + nc1Str);
595 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
597 // Make sure we got a nodeconnector
598 Assert.assertTrue(nc1FromStr != null);
600 // Now the converted nodeconnector need to be the same of the
602 Assert.assertTrue(nc1.equals(nc1FromStr));
603 } catch (ConstructionException e) {
604 // Fail if exception raised
605 Assert.assertTrue(false);
609 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
610 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
611 NodeConnector nc1 = new NodeConnector(
612 NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
613 new Integer(0x10), n1);
614 String nc1Str = nc1.toString();
615 System.out.println("NodeConnector String = " + nc1Str);
616 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
618 // Make sure we got a nodeconnector
619 Assert.assertTrue(nc1FromStr != null);
621 // Now the converted nodeconnector need to be the same of the
623 Assert.assertTrue(nc1.equals(nc1FromStr));
624 } catch (ConstructionException e) {
625 // Fail if exception raised
626 Assert.assertTrue(false);
630 Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
631 0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
632 NodeConnector nc1 = new NodeConnector(
633 NodeConnector.NodeConnectorIDType.PCEP, new Integer(0x10),
635 String nc1Str = nc1.toString();
636 System.out.println("NodeConnector String = " + nc1Str);
637 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
639 // Make sure we got a nodeconnector
640 Assert.assertTrue(nc1FromStr != null);
642 // Now the converted nodeconnector need to be the same of the
644 Assert.assertTrue(nc1.equals(nc1FromStr));
645 } catch (ConstructionException e) {
646 // Fail if exception raised
647 Assert.assertTrue(false);
651 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
652 NodeConnector nc1 = new NodeConnector(
653 NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
656 String nc1Str = nc1.toString();
657 System.out.println("NodeConnector String = " + nc1Str);
658 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
660 // Make sure we got a nodeconnector
661 Assert.assertTrue(nc1FromStr != null);
663 // Now the converted nodeconnector need to be the same of the
665 Assert.assertTrue(nc1.equals(nc1FromStr));
666 } catch (ConstructionException e) {
667 // Fail if exception raised
668 Assert.assertTrue(false);
672 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
673 NodeConnector nc1 = new NodeConnector(
674 NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
675 new String("towardOPENFLOW1"), n1);
677 String nc1Str = nc1.toString();
678 System.out.println("NodeConnector String = " + nc1Str);
679 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
681 // Make sure we got a nodeconnector
682 Assert.assertTrue(nc1FromStr != null);
684 // Now the converted nodeconnector need to be the same of the
686 Assert.assertTrue(nc1.equals(nc1FromStr));
687 } catch (ConstructionException e) {
688 // Fail if exception raised
689 Assert.assertTrue(false);
693 Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
694 NodeConnector nc1 = new NodeConnector(
695 NodeConnector.NodeConnectorIDType.ONEPK, new String(
698 String nc1Str = nc1.toString();
699 System.out.println("NodeConnector String = " + nc1Str);
700 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
702 // Make sure we got a nodeconnector
703 Assert.assertTrue(nc1FromStr != null);
705 // Now the converted nodeconnector need to be the same of the
707 Assert.assertTrue(nc1.equals(nc1FromStr));
708 } catch (ConstructionException e) {
709 // Fail if exception raised
710 Assert.assertTrue(false);
714 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(
715 0xDEADBEEFCAFE0001L));
716 NodeConnector nc1 = new NodeConnector(
717 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
718 (short) 0xCAFE), n1);
720 String nc1Str = nc1.toString();
721 System.out.println("NodeConnector String = " + nc1Str);
722 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
724 // Make sure we got a nodeconnector
725 Assert.assertTrue(nc1FromStr != null);
727 // Now the converted nodeconnector need to be the same of the
729 Assert.assertTrue(nc1.equals(nc1FromStr));
730 } catch (ConstructionException e) {
731 // Fail if exception raised
732 Assert.assertTrue(false);
736 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
737 NodeConnector nc1 = new NodeConnector(
738 NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
741 String nc1Str = nc1.toString();
742 System.out.println("NodeConnector String = " + nc1Str);
743 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
745 // Make sure we got a nodeconnector
746 Assert.assertTrue(nc1FromStr != null);
748 // Now the converted nodeconnector need to be the same of the
750 Assert.assertTrue(nc1.equals(nc1FromStr));
751 } catch (ConstructionException e) {
752 // Fail if exception raised
753 Assert.assertTrue(false);
757 Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
758 NodeConnector nc1 = new NodeConnector(
759 NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
760 new Short((short) 0x11), n1);
762 String nc1Str = nc1.toString();
763 System.out.println("NodeConnector String = " + nc1Str);
764 NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
766 // Make sure we got a nodeconnector
767 Assert.assertTrue(nc1FromStr != null);
769 // Now the converted nodeconnector need to be the same of the
771 Assert.assertTrue(nc1.equals(nc1FromStr));
772 } catch (ConstructionException e) {
773 // Fail if exception raised
774 Assert.assertTrue(false);
779 public void testNodeConnectorSpecialType() {
781 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
782 NodeConnector specialNc = new NodeConnector(
783 NodeConnector.NodeConnectorIDType.CONTROLLER,
784 NodeConnector.SPECIALNODECONNECTORID, n);
785 System.out.println("Special NC = " + specialNc);
786 // We expect to reach this point succesfully
787 Assert.assertTrue(true);
788 } catch (ConstructionException e) {
789 // If this expection is raised the test is failing
790 System.out.println("Got exception as expected!:" + e);
791 Assert.assertTrue(false);
795 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
796 NodeConnector specialNc = new NodeConnector(
797 NodeConnector.NodeConnectorIDType.ALL,
798 NodeConnector.SPECIALNODECONNECTORID, n);
799 System.out.println("Special NC = " + specialNc);
800 // We expect to reach this point succesfully
801 Assert.assertTrue(true);
802 } catch (ConstructionException e) {
803 // If this expection is raised the test is failing
804 System.out.println("Got exception as expected!:" + e);
805 Assert.assertTrue(false);
809 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
810 NodeConnector specialNc = new NodeConnector(
811 NodeConnector.NodeConnectorIDType.SWSTACK,
812 NodeConnector.SPECIALNODECONNECTORID, n);
813 System.out.println("Special NC = " + specialNc);
814 // We expect to reach this point succesfully
815 Assert.assertTrue(true);
816 } catch (ConstructionException e) {
817 // If this expection is raised the test is failing
818 System.out.println("Got exception as expected!:" + e);
819 Assert.assertTrue(false);
823 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
824 NodeConnector specialNc = new NodeConnector(
825 NodeConnector.NodeConnectorIDType.HWPATH,
826 NodeConnector.SPECIALNODECONNECTORID, n);
827 System.out.println("Special NC = " + specialNc);
828 // We expect to reach this point succesfully
829 Assert.assertTrue(true);
830 } catch (ConstructionException e) {
831 // If this expection is raised the test is failing
832 System.out.println("Got exception as expected!:" + e);
833 Assert.assertTrue(false);
837 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
838 NodeConnector specialNc = new NodeConnector(
839 NodeConnector.NodeConnectorIDType.CONTROLLER,
840 NodeConnector.SPECIALNODECONNECTORID, n);
841 System.out.println("Special NC = " + specialNc);
842 // We expect to reach this point succesfully
843 Assert.assertTrue(true);
844 } catch (ConstructionException e) {
845 // If this expection is raised the test is failing
846 System.out.println("Got exception as expected!:" + e);
847 Assert.assertTrue(false);
851 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
852 NodeConnector specialNc = new NodeConnector(
853 NodeConnector.NodeConnectorIDType.ALL,
854 NodeConnector.SPECIALNODECONNECTORID, n);
855 System.out.println("Special NC = " + specialNc);
856 // We expect to reach this point succesfully
857 Assert.assertTrue(true);
858 } catch (ConstructionException e) {
859 // If this expection is raised the test is failing
860 System.out.println("Got exception as expected!:" + e);
861 Assert.assertTrue(false);
865 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
866 NodeConnector specialNc = new NodeConnector(
867 NodeConnector.NodeConnectorIDType.SWSTACK,
868 NodeConnector.SPECIALNODECONNECTORID, n);
869 System.out.println("Special NC = " + specialNc);
870 // We expect to reach this point succesfully
871 Assert.assertTrue(true);
872 } catch (ConstructionException e) {
873 // If this expection is raised the test is failing
874 System.out.println("Got exception as expected!:" + e);
875 Assert.assertTrue(false);
879 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
880 NodeConnector specialNc = new NodeConnector(
881 NodeConnector.NodeConnectorIDType.HWPATH,
882 NodeConnector.SPECIALNODECONNECTORID, n);
883 System.out.println("Special NC = " + specialNc);
884 // We expect to reach this point succesfully
885 Assert.assertTrue(true);
886 } catch (ConstructionException e) {
887 // If this expection is raised the test is failing
888 System.out.println("Got exception as expected!:" + e);
889 Assert.assertTrue(false);
893 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
894 NodeConnector specialNc = new NodeConnector(
895 NodeConnector.NodeConnectorIDType.CONTROLLER,
896 NodeConnector.SPECIALNODECONNECTORID, n);
897 System.out.println("Special NC = " + specialNc);
898 // We expect to reach this point succesfully
899 Assert.assertTrue(true);
900 } catch (ConstructionException e) {
901 // If this expection is raised the test is failing
902 System.out.println("Got exception as expected!:" + e);
903 Assert.assertTrue(false);
907 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
908 NodeConnector specialNc = new NodeConnector(
909 NodeConnector.NodeConnectorIDType.ALL,
910 NodeConnector.SPECIALNODECONNECTORID, n);
911 System.out.println("Special NC = " + specialNc);
912 // We expect to reach this point succesfully
913 Assert.assertTrue(true);
914 } catch (ConstructionException e) {
915 // If this expection is raised the test is failing
916 System.out.println("Got exception as expected!:" + e);
917 Assert.assertTrue(false);
921 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
922 NodeConnector specialNc = new NodeConnector(
923 NodeConnector.NodeConnectorIDType.SWSTACK,
924 NodeConnector.SPECIALNODECONNECTORID, n);
925 System.out.println("Special NC = " + specialNc);
926 // We expect to reach this point succesfully
927 Assert.assertTrue(true);
928 } catch (ConstructionException e) {
929 // If this expection is raised the test is failing
930 System.out.println("Got exception as expected!:" + e);
931 Assert.assertTrue(false);
935 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
936 NodeConnector specialNc = new NodeConnector(
937 NodeConnector.NodeConnectorIDType.HWPATH,
938 NodeConnector.SPECIALNODECONNECTORID, n);
939 System.out.println("Special NC = " + specialNc);
940 // We expect to reach this point succesfully
941 Assert.assertTrue(true);
942 } catch (ConstructionException e) {
943 // If this expection is raised the test is failing
944 System.out.println("Got exception as expected!:" + e);
945 Assert.assertTrue(false);
950 public void testToStringConversionForOpenFlow() {
952 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
953 NodeConnector nc = new NodeConnector(
954 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
957 NodeConnector ofFromStr = null;
959 ofFromStr = NodeConnector.fromStringNoNode("0x2ab", n);
961 // Make sure we got a nodeconnector
962 Assert.assertTrue(ofFromStr != null);
964 // Now the converted nodeconnector need to be the same of the
966 Assert.assertTrue(nc.equals(ofFromStr));
968 ofFromStr = NodeConnector.fromStringNoNode("0x2AB", n);
970 // Make sure we got a nodeconnector
971 Assert.assertTrue(ofFromStr != null);
973 // Now the converted nodeconnector need to be the same of the
975 Assert.assertTrue(nc.equals(ofFromStr));
977 ofFromStr = NodeConnector.fromStringNoNode("683", n);
979 // Make sure we got a nodeconnector
980 Assert.assertTrue(ofFromStr != null);
982 // Now the converted nodeconnector need to be the same of the
984 Assert.assertTrue(nc.equals(ofFromStr));
985 } catch (Exception e) {
986 // If this expection is raised the test is failing
987 System.out.println("Got exception as expected!:" + e);
988 Assert.assertTrue(false);
992 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
993 NodeConnector nc = new NodeConnector(
994 NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
997 NodeConnector ofFromStr = null;
999 ofFromStr = NodeConnector.fromStringNoNode("-13570", n);
1001 // Make sure we got a nodeconnector
1002 Assert.assertTrue(ofFromStr != null);
1004 // Now the converted nodeconnector need to be the same of the
1006 Assert.assertTrue(nc.equals(ofFromStr));
1007 } catch (Exception e) {
1008 // If this expection is raised the test is failing
1009 System.out.println("Got exception as expected!:" + e);
1010 Assert.assertTrue(false);
1015 public void testConversionToStringAndBackSpecialPorts() {
1017 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1018 NodeConnector specialNc = new NodeConnector(
1019 NodeConnector.NodeConnectorIDType.CONTROLLER,
1020 NodeConnector.SPECIALNODECONNECTORID, n);
1022 String specialNcStr = specialNc.toString();
1023 System.out.println("NodeConnector String obtained= " + specialNc);
1024 NodeConnector specialNcFromStr = NodeConnector
1025 .fromString(specialNcStr);
1027 // Make sure we got a nodeconnector
1028 Assert.assertTrue(specialNcFromStr != null);
1030 // Now the converted nodeconnector need to be the same of the
1032 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1033 } catch (ConstructionException e) {
1034 // Fail if exception raised
1035 Assert.assertTrue(false);
1039 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1040 NodeConnector specialNc = new NodeConnector(
1041 NodeConnector.NodeConnectorIDType.ALL,
1042 NodeConnector.SPECIALNODECONNECTORID, n);
1044 String specialNcStr = specialNc.toString();
1045 System.out.println("NodeConnector String obtained= " + specialNc);
1046 NodeConnector specialNcFromStr = NodeConnector
1047 .fromString(specialNcStr);
1049 // Make sure we got a nodeconnector
1050 Assert.assertTrue(specialNcFromStr != null);
1052 // Now the converted nodeconnector need to be the same of the
1054 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1055 } catch (ConstructionException e) {
1056 // Fail if exception raised
1057 Assert.assertTrue(false);
1061 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1062 NodeConnector specialNc = new NodeConnector(
1063 NodeConnector.NodeConnectorIDType.HWPATH,
1064 NodeConnector.SPECIALNODECONNECTORID, n);
1066 String specialNcStr = specialNc.toString();
1067 System.out.println("NodeConnector String obtained= " + specialNc);
1068 NodeConnector specialNcFromStr = NodeConnector
1069 .fromString(specialNcStr);
1071 // Make sure we got a nodeconnector
1072 Assert.assertTrue(specialNcFromStr != null);
1074 // Now the converted nodeconnector need to be the same of the
1076 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1077 } catch (ConstructionException e) {
1078 // Fail if exception raised
1079 Assert.assertTrue(false);
1083 Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1084 NodeConnector specialNc = new NodeConnector(
1085 NodeConnector.NodeConnectorIDType.SWSTACK,
1086 NodeConnector.SPECIALNODECONNECTORID, n);
1088 String specialNcStr = specialNc.toString();
1089 System.out.println("NodeConnector String obtained= " + specialNc);
1090 NodeConnector specialNcFromStr = NodeConnector
1091 .fromString(specialNcStr);
1093 // Make sure we got a nodeconnector
1094 Assert.assertTrue(specialNcFromStr != null);
1096 // Now the converted nodeconnector need to be the same of the
1098 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1099 } catch (ConstructionException e) {
1100 // Fail if exception raised
1101 Assert.assertTrue(false);
1105 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1106 NodeConnector specialNc = new NodeConnector(
1107 NodeConnector.NodeConnectorIDType.CONTROLLER,
1108 NodeConnector.SPECIALNODECONNECTORID, n);
1110 String specialNcStr = specialNc.toString();
1111 System.out.println("NodeConnector String obtained= " + specialNc);
1112 NodeConnector specialNcFromStr = NodeConnector
1113 .fromString(specialNcStr);
1115 // Make sure we got a nodeconnector
1116 Assert.assertTrue(specialNcFromStr != null);
1118 // Now the converted nodeconnector need to be the same of the
1120 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1121 } catch (ConstructionException e) {
1122 // Fail if exception raised
1123 Assert.assertTrue(false);
1127 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1128 NodeConnector specialNc = new NodeConnector(
1129 NodeConnector.NodeConnectorIDType.ALL,
1130 NodeConnector.SPECIALNODECONNECTORID, n);
1132 String specialNcStr = specialNc.toString();
1133 System.out.println("NodeConnector String obtained= " + specialNc);
1134 NodeConnector specialNcFromStr = NodeConnector
1135 .fromString(specialNcStr);
1137 // Make sure we got a nodeconnector
1138 Assert.assertTrue(specialNcFromStr != null);
1140 // Now the converted nodeconnector need to be the same of the
1142 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1143 } catch (ConstructionException e) {
1144 // Fail if exception raised
1145 Assert.assertTrue(false);
1149 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1150 NodeConnector specialNc = new NodeConnector(
1151 NodeConnector.NodeConnectorIDType.HWPATH,
1152 NodeConnector.SPECIALNODECONNECTORID, n);
1154 String specialNcStr = specialNc.toString();
1155 System.out.println("NodeConnector String obtained= " + specialNc);
1156 NodeConnector specialNcFromStr = NodeConnector
1157 .fromString(specialNcStr);
1159 // Make sure we got a nodeconnector
1160 Assert.assertTrue(specialNcFromStr != null);
1162 // Now the converted nodeconnector need to be the same of the
1164 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1165 } catch (ConstructionException e) {
1166 // Fail if exception raised
1167 Assert.assertTrue(false);
1171 Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1172 NodeConnector specialNc = new NodeConnector(
1173 NodeConnector.NodeConnectorIDType.SWSTACK,
1174 NodeConnector.SPECIALNODECONNECTORID, n);
1176 String specialNcStr = specialNc.toString();
1177 System.out.println("NodeConnector String obtained= " + specialNc);
1178 NodeConnector specialNcFromStr = NodeConnector
1179 .fromString(specialNcStr);
1181 // Make sure we got a nodeconnector
1182 Assert.assertTrue(specialNcFromStr != null);
1184 // Now the converted nodeconnector need to be the same of the
1186 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1187 } catch (ConstructionException e) {
1188 // Fail if exception raised
1189 Assert.assertTrue(false);
1193 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1194 NodeConnector specialNc = new NodeConnector(
1195 NodeConnector.NodeConnectorIDType.CONTROLLER,
1196 NodeConnector.SPECIALNODECONNECTORID, n);
1198 String specialNcStr = specialNc.toString();
1199 System.out.println("NodeConnector String obtained= " + specialNc);
1200 NodeConnector specialNcFromStr = NodeConnector
1201 .fromString(specialNcStr);
1203 // Make sure we got a nodeconnector
1204 Assert.assertTrue(specialNcFromStr != null);
1206 // Now the converted nodeconnector need to be the same of the
1208 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1209 } catch (ConstructionException e) {
1210 // Fail if exception raised
1211 Assert.assertTrue(false);
1215 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1216 NodeConnector specialNc = new NodeConnector(
1217 NodeConnector.NodeConnectorIDType.ALL,
1218 NodeConnector.SPECIALNODECONNECTORID, n);
1220 String specialNcStr = specialNc.toString();
1221 System.out.println("NodeConnector String obtained= " + specialNc);
1222 NodeConnector specialNcFromStr = NodeConnector
1223 .fromString(specialNcStr);
1225 // Make sure we got a nodeconnector
1226 Assert.assertTrue(specialNcFromStr != null);
1228 // Now the converted nodeconnector need to be the same of the
1230 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1231 } catch (ConstructionException e) {
1232 // Fail if exception raised
1233 Assert.assertTrue(false);
1237 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1238 NodeConnector specialNc = new NodeConnector(
1239 NodeConnector.NodeConnectorIDType.HWPATH,
1240 NodeConnector.SPECIALNODECONNECTORID, n);
1242 String specialNcStr = specialNc.toString();
1243 System.out.println("NodeConnector String obtained= " + specialNc);
1244 NodeConnector specialNcFromStr = NodeConnector
1245 .fromString(specialNcStr);
1247 // Make sure we got a nodeconnector
1248 Assert.assertTrue(specialNcFromStr != null);
1250 // Now the converted nodeconnector need to be the same of the
1252 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1253 } catch (ConstructionException e) {
1254 // Fail if exception raised
1255 Assert.assertTrue(false);
1259 Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1260 NodeConnector specialNc = new NodeConnector(
1261 NodeConnector.NodeConnectorIDType.SWSTACK,
1262 NodeConnector.SPECIALNODECONNECTORID, n);
1264 String specialNcStr = specialNc.toString();
1265 System.out.println("NodeConnector String obtained= " + specialNc);
1266 NodeConnector specialNcFromStr = NodeConnector
1267 .fromString(specialNcStr);
1269 // Make sure we got a nodeconnector
1270 Assert.assertTrue(specialNcFromStr != null);
1272 // Now the converted nodeconnector need to be the same of the
1274 Assert.assertTrue(specialNc.equals(specialNcFromStr));
1275 } catch (ConstructionException e) {
1276 // Fail if exception raised
1277 Assert.assertTrue(false);