Fixing warnings in the sal sub-project.
[controller.git] / opendaylight / sal / api / src / test / java / org / opendaylight / controller / sal / core / NodeConnectorTest.java
1
2 /*
3  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
4  *
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
8  */
9
10 /**
11  * @file   NodeConnectorTest.java
12  *
13  * @brief  Unit Tests for NodeConnector element
14  *
15  * Unit Tests for NodeConnector element
16  */
17 package org.opendaylight.controller.sal.core;
18
19 import java.util.UUID;
20
21 import org.junit.Assert;
22 import org.junit.Test;
23
24 public class NodeConnectorTest {
25     @Test
26     public void testNodeConnectorOpenFlowOfWrongType() {
27         try {
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);
33
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
39             // and so test passed
40             System.out.println("Got exception as expected!:" + e);
41             Assert.assertTrue(true);
42         }
43     }
44
45     @Test
46     public void testNodeConnectorONEPKOfWrongType() {
47         try {
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);
53
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
59             // and so test passed
60             System.out.println("Got exception as expected!:" + e);
61             Assert.assertTrue(true);
62         }
63     }
64
65     @Test
66     public void testNodeConnectorPCEPOfWrongType() {
67         try {
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);
73
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
79             // and so test passed
80             System.out.println("Got exception as expected!:" + e);
81             Assert.assertTrue(true);
82         }
83     }
84
85     @Test
86     public void testNodeConnectorOpenFlowOfCorrectType() {
87         try {
88             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
89             NodeConnector of1 = new NodeConnector(
90                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
91                             (short) 0xCAFE), n1);
92
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);
101         }
102     }
103
104     @Test
105     public void testNodeConnectorONEPKOfCorrectType() {
106         try {
107             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
108             NodeConnector onepk1 = new NodeConnector(
109                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
110                             "Gi1/0/1"), n1);
111
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);
120         }
121     }
122
123     @Test
124     public void testNodeConnectorPCEPOfCorrectType() {
125         try {
126             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
127             NodeConnector pcep1 = new NodeConnector(
128                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
129                             0xDEADBEEF), n1);
130
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);
139         }
140     }
141
142     @Test
143     public void testTwoOpenFlowNodeConnectorEquals() {
144         try {
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);
152
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);
158         }
159     }
160
161     @Test
162     public void testTwoONEPKNodeConnectorEquals() {
163         try {
164             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
165             NodeConnector onepk1 = new NodeConnector(
166                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
167                             "Gi1/0/1"), n1);
168             NodeConnector onepk2 = new NodeConnector(
169                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
170                             "Gi1/0/1"), n1);
171
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);
177         }
178     }
179
180     @Test
181     public void testTwoPCEPNodeConnectorEquals() {
182         try {
183             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
184             NodeConnector pcep1 = new NodeConnector(
185                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
186                             0xDEADBEEF), n1);
187             NodeConnector pcep2 = new NodeConnector(
188                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
189                             0xDEADBEEF), n1);
190
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);
196         }
197     }
198
199     @Test
200     public void testTwoOpenFlowNodeConnectorDifferents() {
201         try {
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);
209
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);
215         }
216     }
217
218     @Test
219     public void testTwoONEPKNodeConnectorDifferents() {
220         try {
221             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
222             NodeConnector onepk1 = new NodeConnector(
223                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
224                             "Gi1/0/1"), n1);
225             NodeConnector onepk2 = new NodeConnector(
226                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
227                             "Gi1/0/2"), n1);
228
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);
234         }
235     }
236
237     @Test
238     public void testTwoPCEPNodeConnectorDifferents() {
239         try {
240             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
241             NodeConnector pcep1 = new NodeConnector(
242                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
243                             0xDEADBEEF), n1);
244             NodeConnector pcep2 = new NodeConnector(
245                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
246                             0xCAFECAFE), n1);
247
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);
253         }
254     }
255
256     @Test
257     public void testTwoOpenFlowNodeConnectorDifferentsNodes() {
258         try {
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);
267
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);
273         }
274     }
275
276     @Test
277     public void testTwoONEPKNodeConnectorDifferentsNodes() {
278         try {
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(
283                             "Gi1/0/1"), n1);
284             NodeConnector onepk2 = new NodeConnector(
285                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
286                             "Gi1/0/1"), n2);
287
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);
293         }
294     }
295
296     @Test
297     public void testTwoPCEPNodeConnectorDifferentsNodes() {
298         try {
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(
303                             0xDEADBEEF), n1);
304             NodeConnector pcep2 = new NodeConnector(
305                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
306                             0xDEADBEEF), n2);
307
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);
313         }
314     }
315
316     @SuppressWarnings("unused")
317     @Test
318     public void testIncompatibleNodes() {
319         try {
320             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
321             NodeConnector nc1 = new NodeConnector(
322                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
323                             (short) 0), n1);
324             // Exception is expected if not raised test will fail
325             Assert.assertTrue(false);
326         } catch (ConstructionException e) {
327         }
328
329         try {
330             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
331             NodeConnector nc1 = new NodeConnector(
332                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
333                             (short) 0), n1);
334             // Exception is expected if not raised test will fail
335             Assert.assertTrue(false);
336         } catch (ConstructionException e) {
337         }
338
339         try {
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) {
347         }
348
349         try {
350             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
351             NodeConnector nc1 = new NodeConnector(
352                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
353                             "towardPCEP1"), n1);
354             // Exception is expected if not raised test will fail
355             Assert.assertTrue(false);
356         } catch (ConstructionException e) {
357         }
358
359         try {
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) {
367         }
368
369         try {
370             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
371             NodeConnector nc1 = new NodeConnector(
372                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
373                             "Gi1/0/1"), n1);
374             // Exception is expected if not raised test will fail
375             Assert.assertTrue(false);
376         } catch (ConstructionException e) {
377         }
378
379         try {
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);
386         }
387         try {
388             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
389             NodeConnector nc1 = new NodeConnector(
390                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
391                     new Integer(0), n1);
392         } catch (ConstructionException e) {
393             // Exception is NOT expected if raised test will fail
394             Assert.assertTrue(false);
395         }
396
397         try {
398             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
399             NodeConnector nc1 = new NodeConnector(
400                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
401                     new Integer(0), n1);
402         } catch (ConstructionException e) {
403             // Exception is NOT expected if raised test will fail
404             Assert.assertTrue(false);
405         }
406
407         try {
408             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
409             NodeConnector nc1 = new NodeConnector(
410                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
411                             (short) 0), n1);
412             // Exception is expected if not raised test will fail
413             Assert.assertTrue(false);
414         } catch (ConstructionException e) {
415         }
416
417         try {
418             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
419             NodeConnector nc1 = new NodeConnector(
420                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
421                             (short) 0), n1);
422             // Exception is expected if not raised test will fail
423             Assert.assertTrue(false);
424         } catch (ConstructionException e) {
425         }
426
427         try {
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) {
435         }
436
437         try {
438             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
439             NodeConnector nc1 = new NodeConnector(
440                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
441                             "towardPCEP1"), n1);
442         } catch (ConstructionException e) {
443             // Exception is NOT expected if raised test will fail
444             Assert.assertTrue(false);
445         }
446
447         try {
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);
455         }
456
457         try {
458             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
459             NodeConnector nc1 = new NodeConnector(
460                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
461                             "Gi1/0/1"), n1);
462         } catch (ConstructionException e) {
463             // Exception is NOT expected if raised test will fail
464             Assert.assertTrue(false);
465         }
466
467         try {
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) {
474         }
475
476         try {
477             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
478             NodeConnector nc1 = new NodeConnector(
479                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
480                     new Integer(0), n1);
481             // Exception is expected if not raised test will fail
482             Assert.assertTrue(false);
483         } catch (ConstructionException e) {
484         }
485
486         try {
487             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
488             NodeConnector nc1 = new NodeConnector(
489                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
490                     new Integer(0), n1);
491             // Exception is expected if not raised test will fail
492             Assert.assertTrue(false);
493         } catch (ConstructionException e) {
494         }
495
496         try {
497             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
498             NodeConnector nc1 = new NodeConnector(
499                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
500                             (short) 0), n1);
501         } catch (ConstructionException e) {
502             // Exception is NOT expected if raised test will fail
503             Assert.assertTrue(false);
504         }
505
506         try {
507             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
508             NodeConnector nc1 = new NodeConnector(
509                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
510                             (short) 0), n1);
511         } catch (ConstructionException e) {
512             // Exception is NOT expected if raised test will fail
513             Assert.assertTrue(false);
514         }
515
516         try {
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);
524         }
525
526         try {
527             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
528             NodeConnector nc1 = new NodeConnector(
529                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
530                             "towardPCEP1"), n1);
531             // Exception is expected if not raised test will fail
532             Assert.assertTrue(false);
533         } catch (ConstructionException e) {
534         }
535
536         try {
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) {
544         }
545
546         try {
547             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
548             NodeConnector nc1 = new NodeConnector(
549                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
550                             "Gi1/0/1"), n1);
551             // Exception is expected if not raised test will fail
552             Assert.assertTrue(false);
553         } catch (ConstructionException e) {
554         }
555
556         try {
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) {
563         }
564
565         try {
566             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
567             NodeConnector nc1 = new NodeConnector(
568                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
569                     new Integer(0), n1);
570             // Exception is expected if not raised test will fail
571             Assert.assertTrue(false);
572         } catch (ConstructionException e) {
573         }
574
575         try {
576             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
577             NodeConnector nc1 = new NodeConnector(
578                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
579                     new Integer(0), n1);
580             // Exception is expected if not raised test will fail
581             Assert.assertTrue(false);
582         } catch (ConstructionException e) {
583         }
584     }
585
586     @Test
587     public void testConversionToStringAndBack() {
588         try {
589             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
590                     0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
591             NodeConnector nc1 = new NodeConnector(
592                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK, new Integer(
593                             0xDEADBEEF), n1);
594             String nc1Str = nc1.toString();
595             System.out.println("NodeConnector String = " + nc1Str);
596             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
597
598             // Make sure we got a nodeconnector
599             Assert.assertTrue(nc1FromStr != null);
600
601             // Now the converted nodeconnector need to be the same of the
602             // original one
603             Assert.assertTrue(nc1.equals(nc1FromStr));
604         } catch (ConstructionException e) {
605             // Fail if exception raised
606             Assert.assertTrue(false);
607         }
608
609         try {
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);
618
619             // Make sure we got a nodeconnector
620             Assert.assertTrue(nc1FromStr != null);
621
622             // Now the converted nodeconnector need to be the same of the
623             // original one
624             Assert.assertTrue(nc1.equals(nc1FromStr));
625         } catch (ConstructionException e) {
626             // Fail if exception raised
627             Assert.assertTrue(false);
628         }
629
630         try {
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),
635                     n1);
636             String nc1Str = nc1.toString();
637             System.out.println("NodeConnector String = " + nc1Str);
638             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
639
640             // Make sure we got a nodeconnector
641             Assert.assertTrue(nc1FromStr != null);
642
643             // Now the converted nodeconnector need to be the same of the
644             // original one
645             Assert.assertTrue(nc1.equals(nc1FromStr));
646         } catch (ConstructionException e) {
647             // Fail if exception raised
648             Assert.assertTrue(false);
649         }
650
651         try {
652             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
653             NodeConnector nc1 = new NodeConnector(
654                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
655                             "towardPCEP1"), n1);
656
657             String nc1Str = nc1.toString();
658             System.out.println("NodeConnector String = " + nc1Str);
659             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
660
661             // Make sure we got a nodeconnector
662             Assert.assertTrue(nc1FromStr != null);
663
664             // Now the converted nodeconnector need to be the same of the
665             // original one
666             Assert.assertTrue(nc1.equals(nc1FromStr));
667         } catch (ConstructionException e) {
668             // Fail if exception raised
669             Assert.assertTrue(false);
670         }
671
672         try {
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);
677
678             String nc1Str = nc1.toString();
679             System.out.println("NodeConnector String = " + nc1Str);
680             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
681
682             // Make sure we got a nodeconnector
683             Assert.assertTrue(nc1FromStr != null);
684
685             // Now the converted nodeconnector need to be the same of the
686             // original one
687             Assert.assertTrue(nc1.equals(nc1FromStr));
688         } catch (ConstructionException e) {
689             // Fail if exception raised
690             Assert.assertTrue(false);
691         }
692
693         try {
694             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
695             NodeConnector nc1 = new NodeConnector(
696                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
697                             "Gi1/0/1"), n1);
698
699             String nc1Str = nc1.toString();
700             System.out.println("NodeConnector String = " + nc1Str);
701             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
702
703             // Make sure we got a nodeconnector
704             Assert.assertTrue(nc1FromStr != null);
705
706             // Now the converted nodeconnector need to be the same of the
707             // original one
708             Assert.assertTrue(nc1.equals(nc1FromStr));
709         } catch (ConstructionException e) {
710             // Fail if exception raised
711             Assert.assertTrue(false);
712         }
713
714         try {
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);
720
721             String nc1Str = nc1.toString();
722             System.out.println("NodeConnector String = " + nc1Str);
723             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
724
725             // Make sure we got a nodeconnector
726             Assert.assertTrue(nc1FromStr != null);
727
728             // Now the converted nodeconnector need to be the same of the
729             // original one
730             Assert.assertTrue(nc1.equals(nc1FromStr));
731         } catch (ConstructionException e) {
732             // Fail if exception raised
733             Assert.assertTrue(false);
734         }
735
736         try {
737             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
738             NodeConnector nc1 = new NodeConnector(
739                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
740                             (short) 0x10), n1);
741
742             String nc1Str = nc1.toString();
743             System.out.println("NodeConnector String = " + nc1Str);
744             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
745
746             // Make sure we got a nodeconnector
747             Assert.assertTrue(nc1FromStr != null);
748
749             // Now the converted nodeconnector need to be the same of the
750             // original one
751             Assert.assertTrue(nc1.equals(nc1FromStr));
752         } catch (ConstructionException e) {
753             // Fail if exception raised
754             Assert.assertTrue(false);
755         }
756
757         try {
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);
762
763             String nc1Str = nc1.toString();
764             System.out.println("NodeConnector String = " + nc1Str);
765             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
766
767             // Make sure we got a nodeconnector
768             Assert.assertTrue(nc1FromStr != null);
769
770             // Now the converted nodeconnector need to be the same of the
771             // original one
772             Assert.assertTrue(nc1.equals(nc1FromStr));
773         } catch (ConstructionException e) {
774             // Fail if exception raised
775             Assert.assertTrue(false);
776         }
777     }
778
779     @Test
780     public void testNodeConnectorSpecialType() {
781         try {
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);
793         }
794
795         try {
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);
807         }
808
809         try {
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);
821         }
822
823         try {
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);
835         }
836
837         try {
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);
849         }
850
851         try {
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);
863         }
864
865         try {
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);
877         }
878
879         try {
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);
891         }
892
893         try {
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);
905         }
906
907         try {
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);
919         }
920
921         try {
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);
933         }
934
935         try {
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);
947         }
948     }
949
950     @Test
951     public void testToStringConversionForOpenFlow() {
952         try {
953             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
954             NodeConnector nc = new NodeConnector(
955                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
956                             (short) 0x2AB), n);
957
958             NodeConnector ofFromStr = null;
959
960             ofFromStr = NodeConnector.fromStringNoNode("0x2ab", n);
961
962             // Make sure we got a nodeconnector
963             Assert.assertTrue(ofFromStr != null);
964
965             // Now the converted nodeconnector need to be the same of the
966             // original one
967             Assert.assertTrue(nc.equals(ofFromStr));
968
969             ofFromStr = NodeConnector.fromStringNoNode("0x2AB", n);
970
971             // Make sure we got a nodeconnector
972             Assert.assertTrue(ofFromStr != null);
973
974             // Now the converted nodeconnector need to be the same of the
975             // original one
976             Assert.assertTrue(nc.equals(ofFromStr));
977
978             ofFromStr = NodeConnector.fromStringNoNode("683", n);
979
980             // Make sure we got a nodeconnector
981             Assert.assertTrue(ofFromStr != null);
982
983             // Now the converted nodeconnector need to be the same of the
984             // original one
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);
990         }
991
992         try {
993             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
994             NodeConnector nc = new NodeConnector(
995                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
996                             (short) 0xcafe), n);
997
998             NodeConnector ofFromStr = null;
999
1000             ofFromStr = NodeConnector.fromStringNoNode("-13570", n);
1001
1002             // Make sure we got a nodeconnector
1003             Assert.assertTrue(ofFromStr != null);
1004
1005             // Now the converted nodeconnector need to be the same of the
1006             // original one
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);
1012         }
1013     }
1014
1015     @Test
1016     public void testConversionToStringAndBackSpecialPorts() {
1017         try {
1018             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1019             NodeConnector specialNc = new NodeConnector(
1020                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1021                     NodeConnector.SPECIALNODECONNECTORID, n);
1022
1023             String specialNcStr = specialNc.toString();
1024             System.out.println("NodeConnector String obtained= " + specialNc);
1025             NodeConnector specialNcFromStr = NodeConnector
1026                     .fromString(specialNcStr);
1027
1028             // Make sure we got a nodeconnector
1029             Assert.assertTrue(specialNcFromStr != null);
1030
1031             // Now the converted nodeconnector need to be the same of the
1032             // original one
1033             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1034         } catch (ConstructionException e) {
1035             // Fail if exception raised
1036             Assert.assertTrue(false);
1037         }
1038
1039         try {
1040             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1041             NodeConnector specialNc = new NodeConnector(
1042                     NodeConnector.NodeConnectorIDType.ALL,
1043                     NodeConnector.SPECIALNODECONNECTORID, n);
1044
1045             String specialNcStr = specialNc.toString();
1046             System.out.println("NodeConnector String obtained= " + specialNc);
1047             NodeConnector specialNcFromStr = NodeConnector
1048                     .fromString(specialNcStr);
1049
1050             // Make sure we got a nodeconnector
1051             Assert.assertTrue(specialNcFromStr != null);
1052
1053             // Now the converted nodeconnector need to be the same of the
1054             // original one
1055             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1056         } catch (ConstructionException e) {
1057             // Fail if exception raised
1058             Assert.assertTrue(false);
1059         }
1060
1061         try {
1062             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1063             NodeConnector specialNc = new NodeConnector(
1064                     NodeConnector.NodeConnectorIDType.HWPATH,
1065                     NodeConnector.SPECIALNODECONNECTORID, n);
1066
1067             String specialNcStr = specialNc.toString();
1068             System.out.println("NodeConnector String obtained= " + specialNc);
1069             NodeConnector specialNcFromStr = NodeConnector
1070                     .fromString(specialNcStr);
1071
1072             // Make sure we got a nodeconnector
1073             Assert.assertTrue(specialNcFromStr != null);
1074
1075             // Now the converted nodeconnector need to be the same of the
1076             // original one
1077             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1078         } catch (ConstructionException e) {
1079             // Fail if exception raised
1080             Assert.assertTrue(false);
1081         }
1082
1083         try {
1084             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1085             NodeConnector specialNc = new NodeConnector(
1086                     NodeConnector.NodeConnectorIDType.SWSTACK,
1087                     NodeConnector.SPECIALNODECONNECTORID, n);
1088
1089             String specialNcStr = specialNc.toString();
1090             System.out.println("NodeConnector String obtained= " + specialNc);
1091             NodeConnector specialNcFromStr = NodeConnector
1092                     .fromString(specialNcStr);
1093
1094             // Make sure we got a nodeconnector
1095             Assert.assertTrue(specialNcFromStr != null);
1096
1097             // Now the converted nodeconnector need to be the same of the
1098             // original one
1099             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1100         } catch (ConstructionException e) {
1101             // Fail if exception raised
1102             Assert.assertTrue(false);
1103         }
1104
1105         try {
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);
1110
1111             String specialNcStr = specialNc.toString();
1112             System.out.println("NodeConnector String obtained= " + specialNc);
1113             NodeConnector specialNcFromStr = NodeConnector
1114                     .fromString(specialNcStr);
1115
1116             // Make sure we got a nodeconnector
1117             Assert.assertTrue(specialNcFromStr != null);
1118
1119             // Now the converted nodeconnector need to be the same of the
1120             // original one
1121             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1122         } catch (ConstructionException e) {
1123             // Fail if exception raised
1124             Assert.assertTrue(false);
1125         }
1126
1127         try {
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);
1132
1133             String specialNcStr = specialNc.toString();
1134             System.out.println("NodeConnector String obtained= " + specialNc);
1135             NodeConnector specialNcFromStr = NodeConnector
1136                     .fromString(specialNcStr);
1137
1138             // Make sure we got a nodeconnector
1139             Assert.assertTrue(specialNcFromStr != null);
1140
1141             // Now the converted nodeconnector need to be the same of the
1142             // original one
1143             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1144         } catch (ConstructionException e) {
1145             // Fail if exception raised
1146             Assert.assertTrue(false);
1147         }
1148
1149         try {
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);
1154
1155             String specialNcStr = specialNc.toString();
1156             System.out.println("NodeConnector String obtained= " + specialNc);
1157             NodeConnector specialNcFromStr = NodeConnector
1158                     .fromString(specialNcStr);
1159
1160             // Make sure we got a nodeconnector
1161             Assert.assertTrue(specialNcFromStr != null);
1162
1163             // Now the converted nodeconnector need to be the same of the
1164             // original one
1165             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1166         } catch (ConstructionException e) {
1167             // Fail if exception raised
1168             Assert.assertTrue(false);
1169         }
1170
1171         try {
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);
1176
1177             String specialNcStr = specialNc.toString();
1178             System.out.println("NodeConnector String obtained= " + specialNc);
1179             NodeConnector specialNcFromStr = NodeConnector
1180                     .fromString(specialNcStr);
1181
1182             // Make sure we got a nodeconnector
1183             Assert.assertTrue(specialNcFromStr != null);
1184
1185             // Now the converted nodeconnector need to be the same of the
1186             // original one
1187             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1188         } catch (ConstructionException e) {
1189             // Fail if exception raised
1190             Assert.assertTrue(false);
1191         }
1192
1193         try {
1194             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1195             NodeConnector specialNc = new NodeConnector(
1196                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1197                     NodeConnector.SPECIALNODECONNECTORID, n);
1198
1199             String specialNcStr = specialNc.toString();
1200             System.out.println("NodeConnector String obtained= " + specialNc);
1201             NodeConnector specialNcFromStr = NodeConnector
1202                     .fromString(specialNcStr);
1203
1204             // Make sure we got a nodeconnector
1205             Assert.assertTrue(specialNcFromStr != null);
1206
1207             // Now the converted nodeconnector need to be the same of the
1208             // original one
1209             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1210         } catch (ConstructionException e) {
1211             // Fail if exception raised
1212             Assert.assertTrue(false);
1213         }
1214
1215         try {
1216             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1217             NodeConnector specialNc = new NodeConnector(
1218                     NodeConnector.NodeConnectorIDType.ALL,
1219                     NodeConnector.SPECIALNODECONNECTORID, n);
1220
1221             String specialNcStr = specialNc.toString();
1222             System.out.println("NodeConnector String obtained= " + specialNc);
1223             NodeConnector specialNcFromStr = NodeConnector
1224                     .fromString(specialNcStr);
1225
1226             // Make sure we got a nodeconnector
1227             Assert.assertTrue(specialNcFromStr != null);
1228
1229             // Now the converted nodeconnector need to be the same of the
1230             // original one
1231             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1232         } catch (ConstructionException e) {
1233             // Fail if exception raised
1234             Assert.assertTrue(false);
1235         }
1236
1237         try {
1238             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1239             NodeConnector specialNc = new NodeConnector(
1240                     NodeConnector.NodeConnectorIDType.HWPATH,
1241                     NodeConnector.SPECIALNODECONNECTORID, n);
1242
1243             String specialNcStr = specialNc.toString();
1244             System.out.println("NodeConnector String obtained= " + specialNc);
1245             NodeConnector specialNcFromStr = NodeConnector
1246                     .fromString(specialNcStr);
1247
1248             // Make sure we got a nodeconnector
1249             Assert.assertTrue(specialNcFromStr != null);
1250
1251             // Now the converted nodeconnector need to be the same of the
1252             // original one
1253             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1254         } catch (ConstructionException e) {
1255             // Fail if exception raised
1256             Assert.assertTrue(false);
1257         }
1258
1259         try {
1260             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1261             NodeConnector specialNc = new NodeConnector(
1262                     NodeConnector.NodeConnectorIDType.SWSTACK,
1263                     NodeConnector.SPECIALNODECONNECTORID, n);
1264
1265             String specialNcStr = specialNc.toString();
1266             System.out.println("NodeConnector String obtained= " + specialNc);
1267             NodeConnector specialNcFromStr = NodeConnector
1268                     .fromString(specialNcStr);
1269
1270             // Make sure we got a nodeconnector
1271             Assert.assertTrue(specialNcFromStr != null);
1272
1273             // Now the converted nodeconnector need to be the same of the
1274             // original one
1275             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1276         } catch (ConstructionException e) {
1277             // Fail if exception raised
1278             Assert.assertTrue(false);
1279         }
1280     }
1281 }