35c54e79e387779eac7c0540084badb2da0b5ebc
[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             NodeConnector of1 = new NodeConnector(
30                     NodeConnector.NodeConnectorIDType.OPENFLOW, new String(
31                             "0xDEADBEEFCAFE0001L"), n1);
32
33             // If we reach this point the exception was not raised
34             // which should have been the case
35             Assert.assertTrue(false);
36         } catch (ConstructionException e) {
37             // If we reach this point the exception has been raised
38             // and so test passed
39             System.out.println("Got exception as expected!:" + e);
40             Assert.assertTrue(true);
41         }
42     }
43
44     @Test
45     public void testNodeConnectorONEPKOfWrongType() {
46         try {
47             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
48             NodeConnector onepk1 = new NodeConnector(
49                     NodeConnector.NodeConnectorIDType.ONEPK, new Long(
50                             0xDEADBEEFCAFE0001L), n1);
51
52             // If we reach this point the exception was not raised
53             // which should have been the case
54             Assert.assertTrue(false);
55         } catch (ConstructionException e) {
56             // If we reach this point the exception has been raised
57             // and so test passed
58             System.out.println("Got exception as expected!:" + e);
59             Assert.assertTrue(true);
60         }
61     }
62
63     @Test
64     public void testNodeConnectorPCEPOfWrongType() {
65         try {
66             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
67             NodeConnector pcep1 = new NodeConnector(
68                     NodeConnector.NodeConnectorIDType.PCEP, new Long(
69                             0xDEADBEEFCAFE0001L), n1);
70
71             // If we reach this point the exception was not raised
72             // which should have been the case
73             Assert.assertTrue(false);
74         } catch (ConstructionException e) {
75             // If we reach this point the exception has been raised
76             // and so test passed
77             System.out.println("Got exception as expected!:" + e);
78             Assert.assertTrue(true);
79         }
80     }
81
82     @Test
83     public void testNodeConnectorOpenFlowOfCorrectType() {
84         try {
85             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
86             NodeConnector of1 = new NodeConnector(
87                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
88                             (short) 0xCAFE), n1);
89
90             // If we reach this point the exception has not been
91             // raised so we passed the test
92             System.out.println("Got node:" + of1);
93             Assert.assertTrue(true);
94         } catch (ConstructionException e) {
95             // If we reach this point the exception was raised
96             // which is not expected
97             Assert.assertTrue(false);
98         }
99     }
100
101     @Test
102     public void testNodeConnectorONEPKOfCorrectType() {
103         try {
104             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
105             NodeConnector onepk1 = new NodeConnector(
106                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
107                             "Gi1/0/1"), n1);
108
109             // If we reach this point the exception has not been
110             // raised so we passed the test
111             System.out.println("Got node:" + onepk1);
112             Assert.assertTrue(true);
113         } catch (ConstructionException e) {
114             // If we reach this point the exception was raised
115             // which is not expected
116             Assert.assertTrue(false);
117         }
118     }
119
120     @Test
121     public void testNodeConnectorPCEPOfCorrectType() {
122         try {
123             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
124             NodeConnector pcep1 = new NodeConnector(
125                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
126                             0xDEADBEEF), n1);
127
128             // If we reach this point the exception has not been
129             // raised so we passed the test
130             System.out.println("Got node:" + pcep1);
131             Assert.assertTrue(true);
132         } catch (ConstructionException e) {
133             // If we reach this point the exception was raised
134             // which is not expected
135             Assert.assertTrue(false);
136         }
137     }
138
139     @Test
140     public void testTwoOpenFlowNodeConnectorEquals() {
141         try {
142             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
143             NodeConnector of1 = new NodeConnector(
144                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
145                             (short) 0xCAFE), n1);
146             NodeConnector of2 = new NodeConnector(
147                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
148                             (short) 0xCAFE), n1);
149
150             Assert.assertTrue(of1.equals(of2));
151         } catch (ConstructionException e) {
152             // If we reach this point the exception was raised
153             // which is not expected
154             Assert.assertTrue(false);
155         }
156     }
157
158     @Test
159     public void testTwoONEPKNodeConnectorEquals() {
160         try {
161             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
162             NodeConnector onepk1 = new NodeConnector(
163                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
164                             "Gi1/0/1"), n1);
165             NodeConnector onepk2 = new NodeConnector(
166                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
167                             "Gi1/0/1"), n1);
168
169             Assert.assertTrue(onepk1.equals(onepk2));
170         } catch (ConstructionException e) {
171             // If we reach this point the exception was raised
172             // which is not expected
173             Assert.assertTrue(false);
174         }
175     }
176
177     @Test
178     public void testTwoPCEPNodeConnectorEquals() {
179         try {
180             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
181             NodeConnector pcep1 = new NodeConnector(
182                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
183                             0xDEADBEEF), n1);
184             NodeConnector pcep2 = new NodeConnector(
185                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
186                             0xDEADBEEF), n1);
187
188             Assert.assertTrue(pcep1.equals(pcep2));
189         } catch (ConstructionException e) {
190             // If we reach this point the exception was raised
191             // which is not expected
192             Assert.assertTrue(false);
193         }
194     }
195
196     @Test
197     public void testTwoOpenFlowNodeConnectorDifferents() {
198         try {
199             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
200             NodeConnector of1 = new NodeConnector(
201                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
202                             (short) 0xCAFE), n1);
203             NodeConnector of2 = new NodeConnector(
204                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
205                             (short) 0xBEEF), n1);
206
207             Assert.assertTrue(!of1.equals(of2));
208         } catch (ConstructionException e) {
209             // If we reach this point the exception was raised
210             // which is not expected
211             Assert.assertTrue(false);
212         }
213     }
214
215     @Test
216     public void testTwoONEPKNodeConnectorDifferents() {
217         try {
218             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
219             NodeConnector onepk1 = new NodeConnector(
220                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
221                             "Gi1/0/1"), n1);
222             NodeConnector onepk2 = new NodeConnector(
223                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
224                             "Gi1/0/2"), n1);
225
226             Assert.assertTrue(!onepk1.equals(onepk2));
227         } catch (ConstructionException e) {
228             // If we reach this point the exception was raised
229             // which is not expected
230             Assert.assertTrue(false);
231         }
232     }
233
234     @Test
235     public void testTwoPCEPNodeConnectorDifferents() {
236         try {
237             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
238             NodeConnector pcep1 = new NodeConnector(
239                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
240                             0xDEADBEEF), n1);
241             NodeConnector pcep2 = new NodeConnector(
242                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
243                             0xCAFECAFE), n1);
244
245             Assert.assertTrue(!pcep1.equals(pcep2));
246         } catch (ConstructionException e) {
247             // If we reach this point the exception was raised
248             // which is not expected
249             Assert.assertTrue(false);
250         }
251     }
252
253     @Test
254     public void testTwoOpenFlowNodeConnectorDifferentsNodes() {
255         try {
256             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
257             Node n2 = new Node(Node.NodeIDType.OPENFLOW, new Long(111L));
258             NodeConnector of1 = new NodeConnector(
259                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
260                             (short) 0xCAFE), n1);
261             NodeConnector of2 = new NodeConnector(
262                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
263                             (short) 0xCAFE), n2);
264
265             Assert.assertTrue(!of1.equals(of2));
266         } catch (ConstructionException e) {
267             // If we reach this point the exception was raised
268             // which is not expected
269             Assert.assertTrue(false);
270         }
271     }
272
273     @Test
274     public void testTwoONEPKNodeConnectorDifferentsNodes() {
275         try {
276             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
277             Node n2 = new Node(Node.NodeIDType.ONEPK, new String("Router2"));
278             NodeConnector onepk1 = new NodeConnector(
279                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
280                             "Gi1/0/1"), n1);
281             NodeConnector onepk2 = new NodeConnector(
282                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
283                             "Gi1/0/1"), n2);
284
285             Assert.assertTrue(!onepk1.equals(onepk2));
286         } catch (ConstructionException e) {
287             // If we reach this point the exception was raised
288             // which is not expected
289             Assert.assertTrue(false);
290         }
291     }
292
293     @Test
294     public void testTwoPCEPNodeConnectorDifferentsNodes() {
295         try {
296             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
297             Node n2 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 1L));
298             NodeConnector pcep1 = new NodeConnector(
299                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
300                             0xDEADBEEF), n1);
301             NodeConnector pcep2 = new NodeConnector(
302                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(
303                             0xDEADBEEF), n2);
304
305             Assert.assertTrue(!pcep1.equals(pcep2));
306         } catch (ConstructionException e) {
307             // If we reach this point the exception was raised
308             // which is not expected
309             Assert.assertTrue(false);
310         }
311     }
312
313     @Test
314     public void testIncompatibleNodes() {
315         try {
316             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
317             NodeConnector nc1 = new NodeConnector(
318                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
319                             (short) 0), n1);
320             // Exception is expected if not raised test will fail
321             Assert.assertTrue(false);
322         } catch (ConstructionException e) {
323         }
324
325         try {
326             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
327             NodeConnector nc1 = new NodeConnector(
328                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
329                             (short) 0), n1);
330             // Exception is expected if not raised test will fail
331             Assert.assertTrue(false);
332         } catch (ConstructionException e) {
333         }
334
335         try {
336             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
337             NodeConnector nc1 = new NodeConnector(
338                     NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
339                     new Short((short) 0), n1);
340             // Exception is expected if not raised test will fail
341             Assert.assertTrue(false);
342         } catch (ConstructionException e) {
343         }
344
345         try {
346             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
347             NodeConnector nc1 = new NodeConnector(
348                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
349                             "towardPCEP1"), n1);
350             // Exception is expected if not raised test will fail
351             Assert.assertTrue(false);
352         } catch (ConstructionException e) {
353         }
354
355         try {
356             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
357             NodeConnector nc1 = new NodeConnector(
358                     NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
359                     new String("towardPCEP1"), n1);
360             // Exception is expected if not raised test will fail
361             Assert.assertTrue(false);
362         } catch (ConstructionException e) {
363         }
364
365         try {
366             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
367             NodeConnector nc1 = new NodeConnector(
368                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
369                             "Gi1/0/1"), n1);
370             // Exception is expected if not raised test will fail
371             Assert.assertTrue(false);
372         } catch (ConstructionException e) {
373         }
374
375         try {
376             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
377             NodeConnector nc1 = new NodeConnector(
378                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
379         } catch (ConstructionException e) {
380             // Exception is NOT expected if raised test will fail
381             Assert.assertTrue(false);
382         }
383         try {
384             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
385             NodeConnector nc1 = new NodeConnector(
386                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
387                     new Integer(0), n1);
388         } catch (ConstructionException e) {
389             // Exception is NOT expected if raised test will fail
390             Assert.assertTrue(false);
391         }
392
393         try {
394             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
395             NodeConnector nc1 = new NodeConnector(
396                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
397                     new Integer(0), n1);
398         } catch (ConstructionException e) {
399             // Exception is NOT expected if raised test will fail
400             Assert.assertTrue(false);
401         }
402
403         try {
404             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
405             NodeConnector nc1 = new NodeConnector(
406                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
407                             (short) 0), n1);
408             // Exception is expected if not raised test will fail
409             Assert.assertTrue(false);
410         } catch (ConstructionException e) {
411         }
412
413         try {
414             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
415             NodeConnector nc1 = new NodeConnector(
416                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
417                             (short) 0), n1);
418             // Exception is expected if not raised test will fail
419             Assert.assertTrue(false);
420         } catch (ConstructionException e) {
421         }
422
423         try {
424             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
425             NodeConnector nc1 = new NodeConnector(
426                     NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
427                     new Short((short) 0), n1);
428             // Exception is expected if not raised test will fail
429             Assert.assertTrue(false);
430         } catch (ConstructionException e) {
431         }
432
433         try {
434             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
435             NodeConnector nc1 = new NodeConnector(
436                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
437                             "towardPCEP1"), n1);
438         } catch (ConstructionException e) {
439             // Exception is NOT expected if raised test will fail
440             Assert.assertTrue(false);
441         }
442
443         try {
444             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
445             NodeConnector nc1 = new NodeConnector(
446                     NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
447                     new String("towardPCEP1"), n1);
448         } catch (ConstructionException e) {
449             // Exception is NOT expected if raised test will fail
450             Assert.assertTrue(false);
451         }
452
453         try {
454             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
455             NodeConnector nc1 = new NodeConnector(
456                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
457                             "Gi1/0/1"), n1);
458         } catch (ConstructionException e) {
459             // Exception is NOT expected if raised test will fail
460             Assert.assertTrue(false);
461         }
462
463         try {
464             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
465             NodeConnector nc1 = new NodeConnector(
466                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
467             // Exception is expected if not raised test will fail
468             Assert.assertTrue(false);
469         } catch (ConstructionException e) {
470         }
471
472         try {
473             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
474             NodeConnector nc1 = new NodeConnector(
475                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
476                     new Integer(0), n1);
477             // Exception is expected if not raised test will fail
478             Assert.assertTrue(false);
479         } catch (ConstructionException e) {
480         }
481
482         try {
483             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
484             NodeConnector nc1 = new NodeConnector(
485                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
486                     new Integer(0), n1);
487             // Exception is expected if not raised test will fail
488             Assert.assertTrue(false);
489         } catch (ConstructionException e) {
490         }
491
492         try {
493             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
494             NodeConnector nc1 = new NodeConnector(
495                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
496                             (short) 0), n1);
497         } catch (ConstructionException e) {
498             // Exception is NOT expected if raised test will fail
499             Assert.assertTrue(false);
500         }
501
502         try {
503             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
504             NodeConnector nc1 = new NodeConnector(
505                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
506                             (short) 0), n1);
507         } catch (ConstructionException e) {
508             // Exception is NOT expected if raised test will fail
509             Assert.assertTrue(false);
510         }
511
512         try {
513             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
514             NodeConnector nc1 = new NodeConnector(
515                     NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
516                     new Short((short) 0), n1);
517         } catch (ConstructionException e) {
518             // Exception is NOT expected if raised test will fail
519             Assert.assertTrue(false);
520         }
521
522         try {
523             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
524             NodeConnector nc1 = new NodeConnector(
525                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
526                             "towardPCEP1"), n1);
527             // Exception is expected if not raised test will fail
528             Assert.assertTrue(false);
529         } catch (ConstructionException e) {
530         }
531
532         try {
533             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
534             NodeConnector nc1 = new NodeConnector(
535                     NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
536                     new String("towardPCEP1"), n1);
537             // Exception is expected if not raised test will fail
538             Assert.assertTrue(false);
539         } catch (ConstructionException e) {
540         }
541
542         try {
543             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
544             NodeConnector nc1 = new NodeConnector(
545                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
546                             "Gi1/0/1"), n1);
547             // Exception is expected if not raised test will fail
548             Assert.assertTrue(false);
549         } catch (ConstructionException e) {
550         }
551
552         try {
553             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
554             NodeConnector nc1 = new NodeConnector(
555                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(0), n1);
556             // Exception is expected if not raised test will fail
557             Assert.assertTrue(false);
558         } catch (ConstructionException e) {
559         }
560
561         try {
562             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
563             NodeConnector nc1 = new NodeConnector(
564                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK,
565                     new Integer(0), n1);
566             // Exception is expected if not raised test will fail
567             Assert.assertTrue(false);
568         } catch (ConstructionException e) {
569         }
570
571         try {
572             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
573             NodeConnector nc1 = new NodeConnector(
574                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
575                     new Integer(0), n1);
576             // Exception is expected if not raised test will fail
577             Assert.assertTrue(false);
578         } catch (ConstructionException e) {
579         }
580     }
581
582     @Test
583     public void testConversionToStringAndBack() {
584         try {
585             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
586                     0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
587             NodeConnector nc1 = new NodeConnector(
588                     NodeConnector.NodeConnectorIDType.PCEP2ONEPK, new Integer(
589                             0xDEADBEEF), n1);
590             String nc1Str = nc1.toString();
591             System.out.println("NodeConnector String = " + nc1Str);
592             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
593
594             // Make sure we got a nodeconnector
595             Assert.assertTrue(nc1FromStr != null);
596
597             // Now the converted nodeconnector need to be the same of the
598             // original one
599             Assert.assertTrue(nc1.equals(nc1FromStr));
600         } catch (ConstructionException e) {
601             // Fail if exception raised
602             Assert.assertTrue(false);
603         }
604
605         try {
606             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
607                     0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
608             NodeConnector nc1 = new NodeConnector(
609                     NodeConnector.NodeConnectorIDType.PCEP2OPENFLOW,
610                     new Integer(0x10), n1);
611             String nc1Str = nc1.toString();
612             System.out.println("NodeConnector String = " + nc1Str);
613             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
614
615             // Make sure we got a nodeconnector
616             Assert.assertTrue(nc1FromStr != null);
617
618             // Now the converted nodeconnector need to be the same of the
619             // original one
620             Assert.assertTrue(nc1.equals(nc1FromStr));
621         } catch (ConstructionException e) {
622             // Fail if exception raised
623             Assert.assertTrue(false);
624         }
625
626         try {
627             Node n1 = new Node(Node.NodeIDType.PCEP, new UUID(
628                     0xDEADBEEFCAFE0001L, 0xDEADBEEFCAFE0002L));
629             NodeConnector nc1 = new NodeConnector(
630                     NodeConnector.NodeConnectorIDType.PCEP, new Integer(0x10),
631                     n1);
632             String nc1Str = nc1.toString();
633             System.out.println("NodeConnector String = " + nc1Str);
634             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
635
636             // Make sure we got a nodeconnector
637             Assert.assertTrue(nc1FromStr != null);
638
639             // Now the converted nodeconnector need to be the same of the
640             // original one
641             Assert.assertTrue(nc1.equals(nc1FromStr));
642         } catch (ConstructionException e) {
643             // Fail if exception raised
644             Assert.assertTrue(false);
645         }
646
647         try {
648             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
649             NodeConnector nc1 = new NodeConnector(
650                     NodeConnector.NodeConnectorIDType.ONEPK2PCEP, new String(
651                             "towardPCEP1"), n1);
652
653             String nc1Str = nc1.toString();
654             System.out.println("NodeConnector String = " + nc1Str);
655             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
656
657             // Make sure we got a nodeconnector
658             Assert.assertTrue(nc1FromStr != null);
659
660             // Now the converted nodeconnector need to be the same of the
661             // original one
662             Assert.assertTrue(nc1.equals(nc1FromStr));
663         } catch (ConstructionException e) {
664             // Fail if exception raised
665             Assert.assertTrue(false);
666         }
667
668         try {
669             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
670             NodeConnector nc1 = new NodeConnector(
671                     NodeConnector.NodeConnectorIDType.ONEPK2OPENFLOW,
672                     new String("towardOPENFLOW1"), n1);
673
674             String nc1Str = nc1.toString();
675             System.out.println("NodeConnector String = " + nc1Str);
676             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
677
678             // Make sure we got a nodeconnector
679             Assert.assertTrue(nc1FromStr != null);
680
681             // Now the converted nodeconnector need to be the same of the
682             // original one
683             Assert.assertTrue(nc1.equals(nc1FromStr));
684         } catch (ConstructionException e) {
685             // Fail if exception raised
686             Assert.assertTrue(false);
687         }
688
689         try {
690             Node n1 = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
691             NodeConnector nc1 = new NodeConnector(
692                     NodeConnector.NodeConnectorIDType.ONEPK, new String(
693                             "Gi1/0/1"), n1);
694
695             String nc1Str = nc1.toString();
696             System.out.println("NodeConnector String = " + nc1Str);
697             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
698
699             // Make sure we got a nodeconnector
700             Assert.assertTrue(nc1FromStr != null);
701
702             // Now the converted nodeconnector need to be the same of the
703             // original one
704             Assert.assertTrue(nc1.equals(nc1FromStr));
705         } catch (ConstructionException e) {
706             // Fail if exception raised
707             Assert.assertTrue(false);
708         }
709
710         try {
711             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(
712                     0xDEADBEEFCAFE0001L));
713             NodeConnector nc1 = new NodeConnector(
714                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
715                             (short) 0xCAFE), n1);
716
717             String nc1Str = nc1.toString();
718             System.out.println("NodeConnector String = " + nc1Str);
719             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
720
721             // Make sure we got a nodeconnector
722             Assert.assertTrue(nc1FromStr != null);
723
724             // Now the converted nodeconnector need to be the same of the
725             // original one
726             Assert.assertTrue(nc1.equals(nc1FromStr));
727         } catch (ConstructionException e) {
728             // Fail if exception raised
729             Assert.assertTrue(false);
730         }
731
732         try {
733             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
734             NodeConnector nc1 = new NodeConnector(
735                     NodeConnector.NodeConnectorIDType.OPENFLOW2PCEP, new Short(
736                             (short) 0x10), n1);
737
738             String nc1Str = nc1.toString();
739             System.out.println("NodeConnector String = " + nc1Str);
740             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
741
742             // Make sure we got a nodeconnector
743             Assert.assertTrue(nc1FromStr != null);
744
745             // Now the converted nodeconnector need to be the same of the
746             // original one
747             Assert.assertTrue(nc1.equals(nc1FromStr));
748         } catch (ConstructionException e) {
749             // Fail if exception raised
750             Assert.assertTrue(false);
751         }
752
753         try {
754             Node n1 = new Node(Node.NodeIDType.OPENFLOW, new Long(0x100L));
755             NodeConnector nc1 = new NodeConnector(
756                     NodeConnector.NodeConnectorIDType.OPENFLOW2ONEPK,
757                     new Short((short) 0x11), n1);
758
759             String nc1Str = nc1.toString();
760             System.out.println("NodeConnector String = " + nc1Str);
761             NodeConnector nc1FromStr = NodeConnector.fromString(nc1Str);
762
763             // Make sure we got a nodeconnector
764             Assert.assertTrue(nc1FromStr != null);
765
766             // Now the converted nodeconnector need to be the same of the
767             // original one
768             Assert.assertTrue(nc1.equals(nc1FromStr));
769         } catch (ConstructionException e) {
770             // Fail if exception raised
771             Assert.assertTrue(false);
772         }
773     }
774
775     @Test
776     public void testNodeConnectorSpecialType() {
777         try {
778             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
779             NodeConnector specialNc = new NodeConnector(
780                     NodeConnector.NodeConnectorIDType.CONTROLLER,
781                     NodeConnector.SPECIALNODECONNECTORID, n);
782             System.out.println("Special NC = " + specialNc);
783             // We expect to reach this point succesfully
784             Assert.assertTrue(true);
785         } catch (ConstructionException e) {
786             // If this expection is raised the test is failing
787             System.out.println("Got exception as expected!:" + e);
788             Assert.assertTrue(false);
789         }
790
791         try {
792             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
793             NodeConnector specialNc = new NodeConnector(
794                     NodeConnector.NodeConnectorIDType.ALL,
795                     NodeConnector.SPECIALNODECONNECTORID, n);
796             System.out.println("Special NC = " + specialNc);
797             // We expect to reach this point succesfully
798             Assert.assertTrue(true);
799         } catch (ConstructionException e) {
800             // If this expection is raised the test is failing
801             System.out.println("Got exception as expected!:" + e);
802             Assert.assertTrue(false);
803         }
804
805         try {
806             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
807             NodeConnector specialNc = new NodeConnector(
808                     NodeConnector.NodeConnectorIDType.SWSTACK,
809                     NodeConnector.SPECIALNODECONNECTORID, n);
810             System.out.println("Special NC = " + specialNc);
811             // We expect to reach this point succesfully
812             Assert.assertTrue(true);
813         } catch (ConstructionException e) {
814             // If this expection is raised the test is failing
815             System.out.println("Got exception as expected!:" + e);
816             Assert.assertTrue(false);
817         }
818
819         try {
820             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
821             NodeConnector specialNc = new NodeConnector(
822                     NodeConnector.NodeConnectorIDType.HWPATH,
823                     NodeConnector.SPECIALNODECONNECTORID, n);
824             System.out.println("Special NC = " + specialNc);
825             // We expect to reach this point succesfully
826             Assert.assertTrue(true);
827         } catch (ConstructionException e) {
828             // If this expection is raised the test is failing
829             System.out.println("Got exception as expected!:" + e);
830             Assert.assertTrue(false);
831         }
832
833         try {
834             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
835             NodeConnector specialNc = new NodeConnector(
836                     NodeConnector.NodeConnectorIDType.CONTROLLER,
837                     NodeConnector.SPECIALNODECONNECTORID, n);
838             System.out.println("Special NC = " + specialNc);
839             // We expect to reach this point succesfully
840             Assert.assertTrue(true);
841         } catch (ConstructionException e) {
842             // If this expection is raised the test is failing
843             System.out.println("Got exception as expected!:" + e);
844             Assert.assertTrue(false);
845         }
846
847         try {
848             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
849             NodeConnector specialNc = new NodeConnector(
850                     NodeConnector.NodeConnectorIDType.ALL,
851                     NodeConnector.SPECIALNODECONNECTORID, n);
852             System.out.println("Special NC = " + specialNc);
853             // We expect to reach this point succesfully
854             Assert.assertTrue(true);
855         } catch (ConstructionException e) {
856             // If this expection is raised the test is failing
857             System.out.println("Got exception as expected!:" + e);
858             Assert.assertTrue(false);
859         }
860
861         try {
862             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
863             NodeConnector specialNc = new NodeConnector(
864                     NodeConnector.NodeConnectorIDType.SWSTACK,
865                     NodeConnector.SPECIALNODECONNECTORID, n);
866             System.out.println("Special NC = " + specialNc);
867             // We expect to reach this point succesfully
868             Assert.assertTrue(true);
869         } catch (ConstructionException e) {
870             // If this expection is raised the test is failing
871             System.out.println("Got exception as expected!:" + e);
872             Assert.assertTrue(false);
873         }
874
875         try {
876             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
877             NodeConnector specialNc = new NodeConnector(
878                     NodeConnector.NodeConnectorIDType.HWPATH,
879                     NodeConnector.SPECIALNODECONNECTORID, n);
880             System.out.println("Special NC = " + specialNc);
881             // We expect to reach this point succesfully
882             Assert.assertTrue(true);
883         } catch (ConstructionException e) {
884             // If this expection is raised the test is failing
885             System.out.println("Got exception as expected!:" + e);
886             Assert.assertTrue(false);
887         }
888
889         try {
890             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
891             NodeConnector specialNc = new NodeConnector(
892                     NodeConnector.NodeConnectorIDType.CONTROLLER,
893                     NodeConnector.SPECIALNODECONNECTORID, n);
894             System.out.println("Special NC = " + specialNc);
895             // We expect to reach this point succesfully
896             Assert.assertTrue(true);
897         } catch (ConstructionException e) {
898             // If this expection is raised the test is failing
899             System.out.println("Got exception as expected!:" + e);
900             Assert.assertTrue(false);
901         }
902
903         try {
904             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
905             NodeConnector specialNc = new NodeConnector(
906                     NodeConnector.NodeConnectorIDType.ALL,
907                     NodeConnector.SPECIALNODECONNECTORID, n);
908             System.out.println("Special NC = " + specialNc);
909             // We expect to reach this point succesfully
910             Assert.assertTrue(true);
911         } catch (ConstructionException e) {
912             // If this expection is raised the test is failing
913             System.out.println("Got exception as expected!:" + e);
914             Assert.assertTrue(false);
915         }
916
917         try {
918             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
919             NodeConnector specialNc = new NodeConnector(
920                     NodeConnector.NodeConnectorIDType.SWSTACK,
921                     NodeConnector.SPECIALNODECONNECTORID, n);
922             System.out.println("Special NC = " + specialNc);
923             // We expect to reach this point succesfully
924             Assert.assertTrue(true);
925         } catch (ConstructionException e) {
926             // If this expection is raised the test is failing
927             System.out.println("Got exception as expected!:" + e);
928             Assert.assertTrue(false);
929         }
930
931         try {
932             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
933             NodeConnector specialNc = new NodeConnector(
934                     NodeConnector.NodeConnectorIDType.HWPATH,
935                     NodeConnector.SPECIALNODECONNECTORID, n);
936             System.out.println("Special NC = " + specialNc);
937             // We expect to reach this point succesfully
938             Assert.assertTrue(true);
939         } catch (ConstructionException e) {
940             // If this expection is raised the test is failing
941             System.out.println("Got exception as expected!:" + e);
942             Assert.assertTrue(false);
943         }
944     }
945
946     @Test
947     public void testToStringConversionForOpenFlow() {
948         try {
949             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
950             NodeConnector nc = new NodeConnector(
951                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
952                             (short) 0x2AB), n);
953
954             NodeConnector ofFromStr = null;
955
956             ofFromStr = NodeConnector.fromStringNoNode("0x2ab", n);
957
958             // Make sure we got a nodeconnector
959             Assert.assertTrue(ofFromStr != null);
960
961             // Now the converted nodeconnector need to be the same of the
962             // original one
963             Assert.assertTrue(nc.equals(ofFromStr));
964
965             ofFromStr = NodeConnector.fromStringNoNode("0x2AB", n);
966
967             // Make sure we got a nodeconnector
968             Assert.assertTrue(ofFromStr != null);
969
970             // Now the converted nodeconnector need to be the same of the
971             // original one
972             Assert.assertTrue(nc.equals(ofFromStr));
973
974             ofFromStr = NodeConnector.fromStringNoNode("683", n);
975
976             // Make sure we got a nodeconnector
977             Assert.assertTrue(ofFromStr != null);
978
979             // Now the converted nodeconnector need to be the same of the
980             // original one
981             Assert.assertTrue(nc.equals(ofFromStr));
982         } catch (Exception e) {
983             // If this expection is raised the test is failing
984             System.out.println("Got exception as expected!:" + e);
985             Assert.assertTrue(false);
986         }
987
988         try {
989             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
990             NodeConnector nc = new NodeConnector(
991                     NodeConnector.NodeConnectorIDType.OPENFLOW, new Short(
992                             (short) 0xcafe), n);
993
994             NodeConnector ofFromStr = null;
995
996             ofFromStr = NodeConnector.fromStringNoNode("-13570", n);
997
998             // Make sure we got a nodeconnector
999             Assert.assertTrue(ofFromStr != null);
1000
1001             // Now the converted nodeconnector need to be the same of the
1002             // original one
1003             Assert.assertTrue(nc.equals(ofFromStr));
1004         } catch (Exception e) {
1005             // If this expection is raised the test is failing
1006             System.out.println("Got exception as expected!:" + e);
1007             Assert.assertTrue(false);
1008         }
1009     }
1010
1011     @Test
1012     public void testConversionToStringAndBackSpecialPorts() {
1013         try {
1014             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1015             NodeConnector specialNc = new NodeConnector(
1016                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1017                     NodeConnector.SPECIALNODECONNECTORID, n);
1018
1019             String specialNcStr = specialNc.toString();
1020             System.out.println("NodeConnector String obtained= " + specialNc);
1021             NodeConnector specialNcFromStr = NodeConnector
1022                     .fromString(specialNcStr);
1023
1024             // Make sure we got a nodeconnector
1025             Assert.assertTrue(specialNcFromStr != null);
1026
1027             // Now the converted nodeconnector need to be the same of the
1028             // original one
1029             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1030         } catch (ConstructionException e) {
1031             // Fail if exception raised
1032             Assert.assertTrue(false);
1033         }
1034
1035         try {
1036             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1037             NodeConnector specialNc = new NodeConnector(
1038                     NodeConnector.NodeConnectorIDType.ALL,
1039                     NodeConnector.SPECIALNODECONNECTORID, n);
1040
1041             String specialNcStr = specialNc.toString();
1042             System.out.println("NodeConnector String obtained= " + specialNc);
1043             NodeConnector specialNcFromStr = NodeConnector
1044                     .fromString(specialNcStr);
1045
1046             // Make sure we got a nodeconnector
1047             Assert.assertTrue(specialNcFromStr != null);
1048
1049             // Now the converted nodeconnector need to be the same of the
1050             // original one
1051             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1052         } catch (ConstructionException e) {
1053             // Fail if exception raised
1054             Assert.assertTrue(false);
1055         }
1056
1057         try {
1058             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1059             NodeConnector specialNc = new NodeConnector(
1060                     NodeConnector.NodeConnectorIDType.HWPATH,
1061                     NodeConnector.SPECIALNODECONNECTORID, n);
1062
1063             String specialNcStr = specialNc.toString();
1064             System.out.println("NodeConnector String obtained= " + specialNc);
1065             NodeConnector specialNcFromStr = NodeConnector
1066                     .fromString(specialNcStr);
1067
1068             // Make sure we got a nodeconnector
1069             Assert.assertTrue(specialNcFromStr != null);
1070
1071             // Now the converted nodeconnector need to be the same of the
1072             // original one
1073             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1074         } catch (ConstructionException e) {
1075             // Fail if exception raised
1076             Assert.assertTrue(false);
1077         }
1078
1079         try {
1080             Node n = new Node(Node.NodeIDType.OPENFLOW, new Long(110L));
1081             NodeConnector specialNc = new NodeConnector(
1082                     NodeConnector.NodeConnectorIDType.SWSTACK,
1083                     NodeConnector.SPECIALNODECONNECTORID, n);
1084
1085             String specialNcStr = specialNc.toString();
1086             System.out.println("NodeConnector String obtained= " + specialNc);
1087             NodeConnector specialNcFromStr = NodeConnector
1088                     .fromString(specialNcStr);
1089
1090             // Make sure we got a nodeconnector
1091             Assert.assertTrue(specialNcFromStr != null);
1092
1093             // Now the converted nodeconnector need to be the same of the
1094             // original one
1095             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1096         } catch (ConstructionException e) {
1097             // Fail if exception raised
1098             Assert.assertTrue(false);
1099         }
1100
1101         try {
1102             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1103             NodeConnector specialNc = new NodeConnector(
1104                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1105                     NodeConnector.SPECIALNODECONNECTORID, n);
1106
1107             String specialNcStr = specialNc.toString();
1108             System.out.println("NodeConnector String obtained= " + specialNc);
1109             NodeConnector specialNcFromStr = NodeConnector
1110                     .fromString(specialNcStr);
1111
1112             // Make sure we got a nodeconnector
1113             Assert.assertTrue(specialNcFromStr != null);
1114
1115             // Now the converted nodeconnector need to be the same of the
1116             // original one
1117             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1118         } catch (ConstructionException e) {
1119             // Fail if exception raised
1120             Assert.assertTrue(false);
1121         }
1122
1123         try {
1124             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1125             NodeConnector specialNc = new NodeConnector(
1126                     NodeConnector.NodeConnectorIDType.ALL,
1127                     NodeConnector.SPECIALNODECONNECTORID, n);
1128
1129             String specialNcStr = specialNc.toString();
1130             System.out.println("NodeConnector String obtained= " + specialNc);
1131             NodeConnector specialNcFromStr = NodeConnector
1132                     .fromString(specialNcStr);
1133
1134             // Make sure we got a nodeconnector
1135             Assert.assertTrue(specialNcFromStr != null);
1136
1137             // Now the converted nodeconnector need to be the same of the
1138             // original one
1139             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1140         } catch (ConstructionException e) {
1141             // Fail if exception raised
1142             Assert.assertTrue(false);
1143         }
1144
1145         try {
1146             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1147             NodeConnector specialNc = new NodeConnector(
1148                     NodeConnector.NodeConnectorIDType.HWPATH,
1149                     NodeConnector.SPECIALNODECONNECTORID, n);
1150
1151             String specialNcStr = specialNc.toString();
1152             System.out.println("NodeConnector String obtained= " + specialNc);
1153             NodeConnector specialNcFromStr = NodeConnector
1154                     .fromString(specialNcStr);
1155
1156             // Make sure we got a nodeconnector
1157             Assert.assertTrue(specialNcFromStr != null);
1158
1159             // Now the converted nodeconnector need to be the same of the
1160             // original one
1161             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1162         } catch (ConstructionException e) {
1163             // Fail if exception raised
1164             Assert.assertTrue(false);
1165         }
1166
1167         try {
1168             Node n = new Node(Node.NodeIDType.PCEP, new UUID(0L, 0L));
1169             NodeConnector specialNc = new NodeConnector(
1170                     NodeConnector.NodeConnectorIDType.SWSTACK,
1171                     NodeConnector.SPECIALNODECONNECTORID, n);
1172
1173             String specialNcStr = specialNc.toString();
1174             System.out.println("NodeConnector String obtained= " + specialNc);
1175             NodeConnector specialNcFromStr = NodeConnector
1176                     .fromString(specialNcStr);
1177
1178             // Make sure we got a nodeconnector
1179             Assert.assertTrue(specialNcFromStr != null);
1180
1181             // Now the converted nodeconnector need to be the same of the
1182             // original one
1183             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1184         } catch (ConstructionException e) {
1185             // Fail if exception raised
1186             Assert.assertTrue(false);
1187         }
1188
1189         try {
1190             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1191             NodeConnector specialNc = new NodeConnector(
1192                     NodeConnector.NodeConnectorIDType.CONTROLLER,
1193                     NodeConnector.SPECIALNODECONNECTORID, n);
1194
1195             String specialNcStr = specialNc.toString();
1196             System.out.println("NodeConnector String obtained= " + specialNc);
1197             NodeConnector specialNcFromStr = NodeConnector
1198                     .fromString(specialNcStr);
1199
1200             // Make sure we got a nodeconnector
1201             Assert.assertTrue(specialNcFromStr != null);
1202
1203             // Now the converted nodeconnector need to be the same of the
1204             // original one
1205             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1206         } catch (ConstructionException e) {
1207             // Fail if exception raised
1208             Assert.assertTrue(false);
1209         }
1210
1211         try {
1212             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1213             NodeConnector specialNc = new NodeConnector(
1214                     NodeConnector.NodeConnectorIDType.ALL,
1215                     NodeConnector.SPECIALNODECONNECTORID, n);
1216
1217             String specialNcStr = specialNc.toString();
1218             System.out.println("NodeConnector String obtained= " + specialNc);
1219             NodeConnector specialNcFromStr = NodeConnector
1220                     .fromString(specialNcStr);
1221
1222             // Make sure we got a nodeconnector
1223             Assert.assertTrue(specialNcFromStr != null);
1224
1225             // Now the converted nodeconnector need to be the same of the
1226             // original one
1227             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1228         } catch (ConstructionException e) {
1229             // Fail if exception raised
1230             Assert.assertTrue(false);
1231         }
1232
1233         try {
1234             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1235             NodeConnector specialNc = new NodeConnector(
1236                     NodeConnector.NodeConnectorIDType.HWPATH,
1237                     NodeConnector.SPECIALNODECONNECTORID, n);
1238
1239             String specialNcStr = specialNc.toString();
1240             System.out.println("NodeConnector String obtained= " + specialNc);
1241             NodeConnector specialNcFromStr = NodeConnector
1242                     .fromString(specialNcStr);
1243
1244             // Make sure we got a nodeconnector
1245             Assert.assertTrue(specialNcFromStr != null);
1246
1247             // Now the converted nodeconnector need to be the same of the
1248             // original one
1249             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1250         } catch (ConstructionException e) {
1251             // Fail if exception raised
1252             Assert.assertTrue(false);
1253         }
1254
1255         try {
1256             Node n = new Node(Node.NodeIDType.ONEPK, new String("Router1"));
1257             NodeConnector specialNc = new NodeConnector(
1258                     NodeConnector.NodeConnectorIDType.SWSTACK,
1259                     NodeConnector.SPECIALNODECONNECTORID, n);
1260
1261             String specialNcStr = specialNc.toString();
1262             System.out.println("NodeConnector String obtained= " + specialNc);
1263             NodeConnector specialNcFromStr = NodeConnector
1264                     .fromString(specialNcStr);
1265
1266             // Make sure we got a nodeconnector
1267             Assert.assertTrue(specialNcFromStr != null);
1268
1269             // Now the converted nodeconnector need to be the same of the
1270             // original one
1271             Assert.assertTrue(specialNc.equals(specialNcFromStr));
1272         } catch (ConstructionException e) {
1273             // Fail if exception raised
1274             Assert.assertTrue(false);
1275         }
1276     }
1277 }