Initial opendaylight infrastructure commit!!
[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 import org.opendaylight.controller.sal.core.ConstructionException;
24 import org.opendaylight.controller.sal.core.Node;
25 import org.opendaylight.controller.sal.core.NodeConnector;
26
27 public class NodeConnectorTest {
28     @Test
29     public void testNodeConnectorOpenFlowOfWrongType() {
30         try {
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);
35
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
41             // and so test passed
42             System.out.println("Got exception as expected!:" + e);
43             Assert.assertTrue(true);
44         }
45     }
46
47     @Test
48     public void testNodeConnectorONEPKOfWrongType() {
49         try {
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);
54
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
60             // and so test passed
61             System.out.println("Got exception as expected!:" + e);
62             Assert.assertTrue(true);
63         }
64     }
65
66     @Test
67     public void testNodeConnectorPCEPOfWrongType() {
68         try {
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);
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     @Test
317     public void testIncompatibleNodes() {
318         try {
319             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
320             NodeConnector nc1 = new NodeConnector(
321                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
322                             (short) 0), n1);
323             // Exception is expected if not raised test will fail
324             Assert.assertTrue(false);
325         } catch (ConstructionException e) {
326         }
327
328         try {
329             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
330             NodeConnector nc1 = new NodeConnector(
331                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
332                             (short) 0), n1);
333             // Exception is expected if not raised test will fail
334             Assert.assertTrue(false);
335         } catch (ConstructionException e) {
336         }
337
338         try {
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) {
346         }
347
348         try {
349             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
350             NodeConnector nc1 = new NodeConnector(
351                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
352                             "towardPCEP1"), n1);
353             // Exception is expected if not raised test will fail
354             Assert.assertTrue(false);
355         } catch (ConstructionException e) {
356         }
357
358         try {
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) {
366         }
367
368         try {
369             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
370             NodeConnector nc1 = new NodeConnector(
371                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
372                             "Gi1/0/1"), n1);
373             // Exception is expected if not raised test will fail
374             Assert.assertTrue(false);
375         } catch (ConstructionException e) {
376         }
377
378         try {
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);
385         }
386         try {
387             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
388             NodeConnector nc1 = new NodeConnector(
389                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
390                     new Integer(0), n1);
391         } catch (ConstructionException e) {
392             // Exception is NOT expected if raised test will fail
393             Assert.assertTrue(false);
394         }
395
396         try {
397             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
398             NodeConnector nc1 = new NodeConnector(
399                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
400                     new Integer(0), n1);
401         } catch (ConstructionException e) {
402             // Exception is NOT expected if raised test will fail
403             Assert.assertTrue(false);
404         }
405
406         try {
407             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
408             NodeConnector nc1 = new NodeConnector(
409                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
410                             (short) 0), n1);
411             // Exception is expected if not raised test will fail
412             Assert.assertTrue(false);
413         } catch (ConstructionException e) {
414         }
415
416         try {
417             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
418             NodeConnector nc1 = new NodeConnector(
419                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
420                             (short) 0), n1);
421             // Exception is expected if not raised test will fail
422             Assert.assertTrue(false);
423         } catch (ConstructionException e) {
424         }
425
426         try {
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) {
434         }
435
436         try {
437             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
438             NodeConnector nc1 = new NodeConnector(
439                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
440                             "towardPCEP1"), n1);
441         } catch (ConstructionException e) {
442             // Exception is NOT expected if raised test will fail
443             Assert.assertTrue(false);
444         }
445
446         try {
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);
454         }
455
456         try {
457             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
458             NodeConnector nc1 = new NodeConnector(
459                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
460                             "Gi1/0/1"), n1);
461         } catch (ConstructionException e) {
462             // Exception is NOT expected if raised test will fail
463             Assert.assertTrue(false);
464         }
465
466         try {
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) {
473         }
474
475         try {
476             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
477             NodeConnector nc1 = new NodeConnector(
478                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
479                     new Integer(0), n1);
480             // Exception is expected if not raised test will fail
481             Assert.assertTrue(false);
482         } catch (ConstructionException e) {
483         }
484
485         try {
486             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
487             NodeConnector nc1 = new NodeConnector(
488                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
489                     new Integer(0), n1);
490             // Exception is expected if not raised test will fail
491             Assert.assertTrue(false);
492         } catch (ConstructionException e) {
493         }
494
495         try {
496             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
497             NodeConnector nc1 = new NodeConnector(
498                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
499                             (short) 0), n1);
500         } catch (ConstructionException e) {
501             // Exception is NOT expected if raised test will fail
502             Assert.assertTrue(false);
503         }
504
505         try {
506             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
507             NodeConnector nc1 = new NodeConnector(
508                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
509                             (short) 0), n1);
510         } catch (ConstructionException e) {
511             // Exception is NOT expected if raised test will fail
512             Assert.assertTrue(false);
513         }
514
515         try {
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);
523         }
524
525         try {
526             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
527             NodeConnector nc1 = new NodeConnector(
528                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
529                             "towardPCEP1"), n1);
530             // Exception is expected if not raised test will fail
531             Assert.assertTrue(false);
532         } catch (ConstructionException e) {
533         }
534
535         try {
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) {
543         }
544
545         try {
546             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
547             NodeConnector nc1 = new NodeConnector(
548                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
549                             "Gi1/0/1"), n1);
550             // Exception is expected if not raised test will fail
551             Assert.assertTrue(false);
552         } catch (ConstructionException e) {
553         }
554
555         try {
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) {
562         }
563
564         try {
565             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
566             NodeConnector nc1 = new NodeConnector(
567                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
568                     new Integer(0), n1);
569             // Exception is expected if not raised test will fail
570             Assert.assertTrue(false);
571         } catch (ConstructionException e) {
572         }
573
574         try {
575             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
576             NodeConnector nc1 = new NodeConnector(
577                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
578                     new Integer(0), n1);
579             // Exception is expected if not raised test will fail
580             Assert.assertTrue(false);
581         } catch (ConstructionException e) {
582         }
583     }
584
585     @Test
586     public void testConversionToStringAndBack() {
587         try {
588             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
589                     0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
590             NodeConnector nc1 = new NodeConnector(
591                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK, new Integer(
592                             0xDEADBEEF), n1);
593             String nc1Str = nc1.toString();
594             System.out.println("NodeConnector String = " + nc1Str);
595             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
596
597             // Make sure we got a nodeconnector
598             Assert.assertTrue(nc1FromStr != null);
599
600             // Now the converted nodeconnector need to be the same of the
601             // original one
602             Assert.assertTrue(nc1.equals(nc1FromStr));
603         } catch (ConstructionException e) {
604             // Fail if exception raised
605             Assert.assertTrue(false);
606         }
607
608         try {
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);
617
618             // Make sure we got a nodeconnector
619             Assert.assertTrue(nc1FromStr != null);
620
621             // Now the converted nodeconnector need to be the same of the
622             // original one
623             Assert.assertTrue(nc1.equals(nc1FromStr));
624         } catch (ConstructionException e) {
625             // Fail if exception raised
626             Assert.assertTrue(false);
627         }
628
629         try {
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),
634                     n1);
635             String nc1Str = nc1.toString();
636             System.out.println("NodeConnector String = " + nc1Str);
637             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
638
639             // Make sure we got a nodeconnector
640             Assert.assertTrue(nc1FromStr != null);
641
642             // Now the converted nodeconnector need to be the same of the
643             // original one
644             Assert.assertTrue(nc1.equals(nc1FromStr));
645         } catch (ConstructionException e) {
646             // Fail if exception raised
647             Assert.assertTrue(false);
648         }
649
650         try {
651             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
652             NodeConnector nc1 = new NodeConnector(
653                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
654                             "towardPCEP1"), n1);
655
656             String nc1Str = nc1.toString();
657             System.out.println("NodeConnector String = " + nc1Str);
658             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
659
660             // Make sure we got a nodeconnector
661             Assert.assertTrue(nc1FromStr != null);
662
663             // Now the converted nodeconnector need to be the same of the
664             // original one
665             Assert.assertTrue(nc1.equals(nc1FromStr));
666         } catch (ConstructionException e) {
667             // Fail if exception raised
668             Assert.assertTrue(false);
669         }
670
671         try {
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);
676
677             String nc1Str = nc1.toString();
678             System.out.println("NodeConnector String = " + nc1Str);
679             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
680
681             // Make sure we got a nodeconnector
682             Assert.assertTrue(nc1FromStr != null);
683
684             // Now the converted nodeconnector need to be the same of the
685             // original one
686             Assert.assertTrue(nc1.equals(nc1FromStr));
687         } catch (ConstructionException e) {
688             // Fail if exception raised
689             Assert.assertTrue(false);
690         }
691
692         try {
693             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
694             NodeConnector nc1 = new NodeConnector(
695                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
696                             "Gi1/0/1"), n1);
697
698             String nc1Str = nc1.toString();
699             System.out.println("NodeConnector String = " + nc1Str);
700             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
701
702             // Make sure we got a nodeconnector
703             Assert.assertTrue(nc1FromStr != null);
704
705             // Now the converted nodeconnector need to be the same of the
706             // original one
707             Assert.assertTrue(nc1.equals(nc1FromStr));
708         } catch (ConstructionException e) {
709             // Fail if exception raised
710             Assert.assertTrue(false);
711         }
712
713         try {
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);
719
720             String nc1Str = nc1.toString();
721             System.out.println("NodeConnector String = " + nc1Str);
722             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
723
724             // Make sure we got a nodeconnector
725             Assert.assertTrue(nc1FromStr != null);
726
727             // Now the converted nodeconnector need to be the same of the
728             // original one
729             Assert.assertTrue(nc1.equals(nc1FromStr));
730         } catch (ConstructionException e) {
731             // Fail if exception raised
732             Assert.assertTrue(false);
733         }
734
735         try {
736             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
737             NodeConnector nc1 = new NodeConnector(
738                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
739                             (short) 0x10), n1);
740
741             String nc1Str = nc1.toString();
742             System.out.println("NodeConnector String = " + nc1Str);
743             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
744
745             // Make sure we got a nodeconnector
746             Assert.assertTrue(nc1FromStr != null);
747
748             // Now the converted nodeconnector need to be the same of the
749             // original one
750             Assert.assertTrue(nc1.equals(nc1FromStr));
751         } catch (ConstructionException e) {
752             // Fail if exception raised
753             Assert.assertTrue(false);
754         }
755
756         try {
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);
761
762             String nc1Str = nc1.toString();
763             System.out.println("NodeConnector String = " + nc1Str);
764             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
765
766             // Make sure we got a nodeconnector
767             Assert.assertTrue(nc1FromStr != null);
768
769             // Now the converted nodeconnector need to be the same of the
770             // original one
771             Assert.assertTrue(nc1.equals(nc1FromStr));
772         } catch (ConstructionException e) {
773             // Fail if exception raised
774             Assert.assertTrue(false);
775         }
776     }
777
778     @Test
779     public void testNodeConnectorSpecialType() {
780         try {
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);
792         }
793
794         try {
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);
806         }
807
808         try {
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);
820         }
821
822         try {
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);
834         }
835
836         try {
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);
848         }
849
850         try {
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);
862         }
863
864         try {
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);
876         }
877
878         try {
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);
890         }
891
892         try {
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);
904         }
905
906         try {
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);
918         }
919
920         try {
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);
932         }
933
934         try {
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);
946         }
947     }
948
949     @Test
950     public void testToStringConversionForOpenFlow() {
951         try {
952             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
953             NodeConnector nc = new NodeConnector(
954                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
955                             (short) 0x2AB), n);
956
957             NodeConnector ofFromStr = null;
958
959             ofFromStr = NodeConnector.fromStringNoNode("0x2ab", n);
960
961             // Make sure we got a nodeconnector
962             Assert.assertTrue(ofFromStr != null);
963
964             // Now the converted nodeconnector need to be the same of the
965             // original one
966             Assert.assertTrue(nc.equals(ofFromStr));
967
968             ofFromStr = NodeConnector.fromStringNoNode("0x2AB", n);
969
970             // Make sure we got a nodeconnector
971             Assert.assertTrue(ofFromStr != null);
972
973             // Now the converted nodeconnector need to be the same of the
974             // original one
975             Assert.assertTrue(nc.equals(ofFromStr));
976
977             ofFromStr = NodeConnector.fromStringNoNode("683", n);
978
979             // Make sure we got a nodeconnector
980             Assert.assertTrue(ofFromStr != null);
981
982             // Now the converted nodeconnector need to be the same of the
983             // original one
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);
989         }
990
991         try {
992             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
993             NodeConnector nc = new NodeConnector(
994                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
995                             (short) 0xcafe), n);
996
997             NodeConnector ofFromStr = null;
998
999             ofFromStr = NodeConnector.fromStringNoNode("-13570", n);
1000
1001             // Make sure we got a nodeconnector
1002             Assert.assertTrue(ofFromStr != null);
1003
1004             // Now the converted nodeconnector need to be the same of the
1005             // original one
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);
1011         }
1012     }
1013
1014     @Test
1015     public void testConversionToStringAndBackSpecialPorts() {
1016         try {
1017             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1018             NodeConnector specialNc = new NodeConnector(
1019                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1020                     NodeConnector.SPECIALNODECONNECTORID, n);
1021
1022             String specialNcStr = specialNc.toString();
1023             System.out.println("NodeConnector String obtained= " + specialNc);
1024             NodeConnector specialNcFromStr = NodeConnector
1025                     .fromString(specialNcStr);
1026
1027             // Make sure we got a nodeconnector
1028             Assert.assertTrue(specialNcFromStr != null);
1029
1030             // Now the converted nodeconnector need to be the same of the
1031             // original one
1032             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1033         } catch (ConstructionException e) {
1034             // Fail if exception raised
1035             Assert.assertTrue(false);
1036         }
1037
1038         try {
1039             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1040             NodeConnector specialNc = new NodeConnector(
1041                     NodeConnector.NodeConnectorIDType.ALL,
1042                     NodeConnector.SPECIALNODECONNECTORID, n);
1043
1044             String specialNcStr = specialNc.toString();
1045             System.out.println("NodeConnector String obtained= " + specialNc);
1046             NodeConnector specialNcFromStr = NodeConnector
1047                     .fromString(specialNcStr);
1048
1049             // Make sure we got a nodeconnector
1050             Assert.assertTrue(specialNcFromStr != null);
1051
1052             // Now the converted nodeconnector need to be the same of the
1053             // original one
1054             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1055         } catch (ConstructionException e) {
1056             // Fail if exception raised
1057             Assert.assertTrue(false);
1058         }
1059
1060         try {
1061             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1062             NodeConnector specialNc = new NodeConnector(
1063                     NodeConnector.NodeConnectorIDType.HWPATH,
1064                     NodeConnector.SPECIALNODECONNECTORID, n);
1065
1066             String specialNcStr = specialNc.toString();
1067             System.out.println("NodeConnector String obtained= " + specialNc);
1068             NodeConnector specialNcFromStr = NodeConnector
1069                     .fromString(specialNcStr);
1070
1071             // Make sure we got a nodeconnector
1072             Assert.assertTrue(specialNcFromStr != null);
1073
1074             // Now the converted nodeconnector need to be the same of the
1075             // original one
1076             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1077         } catch (ConstructionException e) {
1078             // Fail if exception raised
1079             Assert.assertTrue(false);
1080         }
1081
1082         try {
1083             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1084             NodeConnector specialNc = new NodeConnector(
1085                     NodeConnector.NodeConnectorIDType.SWSTACK,
1086                     NodeConnector.SPECIALNODECONNECTORID, n);
1087
1088             String specialNcStr = specialNc.toString();
1089             System.out.println("NodeConnector String obtained= " + specialNc);
1090             NodeConnector specialNcFromStr = NodeConnector
1091                     .fromString(specialNcStr);
1092
1093             // Make sure we got a nodeconnector
1094             Assert.assertTrue(specialNcFromStr != null);
1095
1096             // Now the converted nodeconnector need to be the same of the
1097             // original one
1098             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1099         } catch (ConstructionException e) {
1100             // Fail if exception raised
1101             Assert.assertTrue(false);
1102         }
1103
1104         try {
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);
1109
1110             String specialNcStr = specialNc.toString();
1111             System.out.println("NodeConnector String obtained= " + specialNc);
1112             NodeConnector specialNcFromStr = NodeConnector
1113                     .fromString(specialNcStr);
1114
1115             // Make sure we got a nodeconnector
1116             Assert.assertTrue(specialNcFromStr != null);
1117
1118             // Now the converted nodeconnector need to be the same of the
1119             // original one
1120             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1121         } catch (ConstructionException e) {
1122             // Fail if exception raised
1123             Assert.assertTrue(false);
1124         }
1125
1126         try {
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);
1131
1132             String specialNcStr = specialNc.toString();
1133             System.out.println("NodeConnector String obtained= " + specialNc);
1134             NodeConnector specialNcFromStr = NodeConnector
1135                     .fromString(specialNcStr);
1136
1137             // Make sure we got a nodeconnector
1138             Assert.assertTrue(specialNcFromStr != null);
1139
1140             // Now the converted nodeconnector need to be the same of the
1141             // original one
1142             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1143         } catch (ConstructionException e) {
1144             // Fail if exception raised
1145             Assert.assertTrue(false);
1146         }
1147
1148         try {
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);
1153
1154             String specialNcStr = specialNc.toString();
1155             System.out.println("NodeConnector String obtained= " + specialNc);
1156             NodeConnector specialNcFromStr = NodeConnector
1157                     .fromString(specialNcStr);
1158
1159             // Make sure we got a nodeconnector
1160             Assert.assertTrue(specialNcFromStr != null);
1161
1162             // Now the converted nodeconnector need to be the same of the
1163             // original one
1164             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1165         } catch (ConstructionException e) {
1166             // Fail if exception raised
1167             Assert.assertTrue(false);
1168         }
1169
1170         try {
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);
1175
1176             String specialNcStr = specialNc.toString();
1177             System.out.println("NodeConnector String obtained= " + specialNc);
1178             NodeConnector specialNcFromStr = NodeConnector
1179                     .fromString(specialNcStr);
1180
1181             // Make sure we got a nodeconnector
1182             Assert.assertTrue(specialNcFromStr != null);
1183
1184             // Now the converted nodeconnector need to be the same of the
1185             // original one
1186             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1187         } catch (ConstructionException e) {
1188             // Fail if exception raised
1189             Assert.assertTrue(false);
1190         }
1191
1192         try {
1193             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1194             NodeConnector specialNc = new NodeConnector(
1195                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1196                     NodeConnector.SPECIALNODECONNECTORID, n);
1197
1198             String specialNcStr = specialNc.toString();
1199             System.out.println("NodeConnector String obtained= " + specialNc);
1200             NodeConnector specialNcFromStr = NodeConnector
1201                     .fromString(specialNcStr);
1202
1203             // Make sure we got a nodeconnector
1204             Assert.assertTrue(specialNcFromStr != null);
1205
1206             // Now the converted nodeconnector need to be the same of the
1207             // original one
1208             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1209         } catch (ConstructionException e) {
1210             // Fail if exception raised
1211             Assert.assertTrue(false);
1212         }
1213
1214         try {
1215             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1216             NodeConnector specialNc = new NodeConnector(
1217                     NodeConnector.NodeConnectorIDType.ALL,
1218                     NodeConnector.SPECIALNODECONNECTORID, n);
1219
1220             String specialNcStr = specialNc.toString();
1221             System.out.println("NodeConnector String obtained= " + specialNc);
1222             NodeConnector specialNcFromStr = NodeConnector
1223                     .fromString(specialNcStr);
1224
1225             // Make sure we got a nodeconnector
1226             Assert.assertTrue(specialNcFromStr != null);
1227
1228             // Now the converted nodeconnector need to be the same of the
1229             // original one
1230             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1231         } catch (ConstructionException e) {
1232             // Fail if exception raised
1233             Assert.assertTrue(false);
1234         }
1235
1236         try {
1237             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1238             NodeConnector specialNc = new NodeConnector(
1239                     NodeConnector.NodeConnectorIDType.HWPATH,
1240                     NodeConnector.SPECIALNODECONNECTORID, n);
1241
1242             String specialNcStr = specialNc.toString();
1243             System.out.println("NodeConnector String obtained= " + specialNc);
1244             NodeConnector specialNcFromStr = NodeConnector
1245                     .fromString(specialNcStr);
1246
1247             // Make sure we got a nodeconnector
1248             Assert.assertTrue(specialNcFromStr != null);
1249
1250             // Now the converted nodeconnector need to be the same of the
1251             // original one
1252             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1253         } catch (ConstructionException e) {
1254             // Fail if exception raised
1255             Assert.assertTrue(false);
1256         }
1257
1258         try {
1259             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1260             NodeConnector specialNc = new NodeConnector(
1261                     NodeConnector.NodeConnectorIDType.SWSTACK,
1262                     NodeConnector.SPECIALNODECONNECTORID, n);
1263
1264             String specialNcStr = specialNc.toString();
1265             System.out.println("NodeConnector String obtained= " + specialNc);
1266             NodeConnector specialNcFromStr = NodeConnector
1267                     .fromString(specialNcStr);
1268
1269             // Make sure we got a nodeconnector
1270             Assert.assertTrue(specialNcFromStr != null);
1271
1272             // Now the converted nodeconnector need to be the same of the
1273             // original one
1274             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1275         } catch (ConstructionException e) {
1276             // Fail if exception raised
1277             Assert.assertTrue(false);
1278         }
1279     }
1280 }