KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jeantessier > dependency > TestTextPrinter


1 /*
2  * Copyright (c) 2001-2005, Jean Tessier
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Jean Tessier nor the names of his contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */

32
33 package com.jeantessier.dependency;
34
35 import java.io.*;
36
37 import junit.framework.*;
38
39 public class TestTextPrinter extends TestCase {
40     private NodeFactory factory;
41     private StringWriter out;
42     private TextPrinter visitor;
43
44     protected void setUp() throws Exception JavaDoc {
45         factory = new NodeFactory();
46         out = new StringWriter();
47         visitor = new TextPrinter(new PrintWriter(out));
48     }
49
50     public void testShowInboundsPackageTrueWithInferred() throws IOException {
51         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
52         factory.createPackage("empty");
53
54         visitor.setShowInbounds(true);
55         visitor.setShowOutbounds(false);
56
57         visitor.traverseNodes(factory.getPackages().values());
58
59         int lineNumber = 0;
60         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
61
62         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
63         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
64         assertEquals("line " + ++lineNumber, " <-- outbound *", in.readLine());
65         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
66
67         assertEquals("End of file", null, in.readLine());
68     }
69
70     public void testShowInboundsPackageTrueWithConfirmed() throws IOException {
71         factory.createPackage("outbound", true).addDependency(factory.createPackage("inbound", true));
72         factory.createPackage("empty", true);
73
74         visitor.setShowInbounds(true);
75         visitor.setShowOutbounds(false);
76
77         visitor.traverseNodes(factory.getPackages().values());
78
79         int lineNumber = 0;
80         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
81
82         assertEquals("line " + ++lineNumber, "empty", in.readLine());
83         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
84         assertEquals("line " + ++lineNumber, " <-- outbound", in.readLine());
85         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
86
87         assertEquals("End of file", null, in.readLine());
88     }
89
90     public void testShowInboundsPackageFalseWithInferred() throws IOException {
91         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
92         factory.createPackage("empty");
93
94         visitor.setShowInbounds(false);
95         visitor.setShowOutbounds(false);
96
97         visitor.traverseNodes(factory.getPackages().values());
98
99         int lineNumber = 0;
100         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
101
102         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
103         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
104         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
105
106         assertEquals("End of file", null, in.readLine());
107     }
108
109     public void testShowInboundsPackageFalseWithConfirmed() throws IOException {
110         factory.createPackage("outbound", true).addDependency(factory.createPackage("inbound", true));
111         factory.createPackage("empty", true);
112
113         visitor.setShowInbounds(false);
114         visitor.setShowOutbounds(false);
115
116         visitor.traverseNodes(factory.getPackages().values());
117
118         int lineNumber = 0;
119         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
120
121         assertEquals("line " + ++lineNumber, "empty", in.readLine());
122         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
123         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
124
125         assertEquals("End of file", null, in.readLine());
126     }
127
128     public void testShowInboundsClassTrueWithInferred() throws IOException {
129         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
130         factory.createClass("empty.Empty");
131
132         visitor.setShowInbounds(true);
133         visitor.setShowOutbounds(false);
134
135         visitor.traverseNodes(factory.getPackages().values());
136
137         int lineNumber = 0;
138         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
139
140         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
141         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
142         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
143         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
144         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound *", in.readLine());
145         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
146         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
147
148         assertEquals("End of file", null, in.readLine());
149     }
150
151     public void testShowInboundsClassTrueWithConfirmed() throws IOException {
152         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
153         factory.createClass("empty.Empty", true);
154
155         visitor.setShowInbounds(true);
156         visitor.setShowOutbounds(false);
157
158         visitor.traverseNodes(factory.getPackages().values());
159
160         int lineNumber = 0;
161         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
162
163         assertEquals("line " + ++lineNumber, "empty", in.readLine());
164         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
165         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
166         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
167         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound", in.readLine());
168         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
169         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
170
171         assertEquals("End of file", null, in.readLine());
172     }
173
174     public void testShowInboundsClassFalseWithInferred() throws IOException {
175         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
176         factory.createClass("empty.Empty");
177
178         visitor.setShowInbounds(false);
179         visitor.setShowOutbounds(false);
180
181         visitor.traverseNodes(factory.getPackages().values());
182
183         int lineNumber = 0;
184         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
185
186         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
187         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
188         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
189         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
190         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
191         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
192
193         assertEquals("End of file", null, in.readLine());
194     }
195
196     public void testShowInboundsClassFalseWithConfirmed() throws IOException {
197         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
198         factory.createClass("empty.Empty", true);
199
200         visitor.setShowInbounds(false);
201         visitor.setShowOutbounds(false);
202
203         visitor.traverseNodes(factory.getPackages().values());
204
205         int lineNumber = 0;
206         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
207
208         assertEquals("line " + ++lineNumber, "empty", in.readLine());
209         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
210         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
211         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
212         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
213         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
214
215         assertEquals("End of file", null, in.readLine());
216     }
217
218     public void testShowInboundsFeatureTrueWithInferred() throws IOException {
219         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
220         factory.createFeature("empty.Empty.empty()");
221
222         visitor.setShowInbounds(true);
223         visitor.setShowOutbounds(false);
224
225         visitor.traverseNodes(factory.getPackages().values());
226
227         int lineNumber = 0;
228         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
229
230         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
231         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
232         assertEquals("line " + ++lineNumber, " empty() *", in.readLine());
233         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
234         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
235         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
236         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
237         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
238         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
239         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
240
241         assertEquals("End of file", null, in.readLine());
242     }
243
244     public void testShowInboundsFeatureTrueWithConfirmed() throws IOException {
245         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
246         factory.createFeature("empty.Empty.empty()", true);
247
248         visitor.setShowInbounds(true);
249         visitor.setShowOutbounds(false);
250
251         visitor.traverseNodes(factory.getPackages().values());
252
253         int lineNumber = 0;
254         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
255
256         assertEquals("line " + ++lineNumber, "empty", in.readLine());
257         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
258         assertEquals("line " + ++lineNumber, " empty()", in.readLine());
259         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
260         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
261         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
262         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
263         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
264         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
265         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
266
267         assertEquals("End of file", null, in.readLine());
268     }
269
270     public void testShowInboundsFeatureFalseWithInferred() throws IOException {
271         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
272         factory.createFeature("empty.Empty.empty()");
273
274         visitor.setShowInbounds(false);
275         visitor.setShowOutbounds(false);
276
277         visitor.traverseNodes(factory.getPackages().values());
278
279         int lineNumber = 0;
280         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
281
282         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
283         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
284         assertEquals("line " + ++lineNumber, " empty() *", in.readLine());
285         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
286         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
287         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
288         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
289         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
290         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
291
292         assertEquals("End of file", null, in.readLine());
293     }
294
295     public void testShowInboundsFeatureFalseWithConfirmed() throws IOException {
296         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
297         factory.createFeature("empty.Empty.empty()", true);
298
299         visitor.setShowInbounds(false);
300         visitor.setShowOutbounds(false);
301
302         visitor.traverseNodes(factory.getPackages().values());
303
304         int lineNumber = 0;
305         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
306
307         assertEquals("line " + ++lineNumber, "empty", in.readLine());
308         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
309         assertEquals("line " + ++lineNumber, " empty()", in.readLine());
310         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
311         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
312         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
313         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
314         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
315         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
316
317         assertEquals("End of file", null, in.readLine());
318     }
319
320     public void testShowOutboundsPackageTrueWithInferred() throws IOException {
321         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
322         factory.createPackage("empty");
323
324         visitor.setShowInbounds(false);
325         visitor.setShowOutbounds(true);
326
327         visitor.traverseNodes(factory.getPackages().values());
328
329         int lineNumber = 0;
330         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
331
332         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
333         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
334         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
335         assertEquals("line " + ++lineNumber, " --> inbound *", in.readLine());
336
337         assertEquals("End of file", null, in.readLine());
338     }
339
340     public void testShowOutboundsPackageTrueWithConfirmed() throws IOException {
341         factory.createPackage("outbound", true).addDependency(factory.createPackage("inbound", true));
342         factory.createPackage("empty", true);
343
344         visitor.setShowInbounds(false);
345         visitor.setShowOutbounds(true);
346
347         visitor.traverseNodes(factory.getPackages().values());
348
349         int lineNumber = 0;
350         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
351
352         assertEquals("line " + ++lineNumber, "empty", in.readLine());
353         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
354         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
355         assertEquals("line " + ++lineNumber, " --> inbound", in.readLine());
356
357         assertEquals("End of file", null, in.readLine());
358     }
359
360     public void testShowOutboundsPackageFalseWithInferred() throws IOException {
361         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
362         factory.createPackage("empty");
363
364         visitor.setShowInbounds(false);
365         visitor.setShowOutbounds(false);
366
367         visitor.traverseNodes(factory.getPackages().values());
368
369         int lineNumber = 0;
370         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
371
372         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
373         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
374         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
375
376         assertEquals("End of file", null, in.readLine());
377     }
378
379     public void testShowOutboundsPackageFalseWithConfirmed() throws IOException {
380         factory.createPackage("outbound", true).addDependency(factory.createPackage("inbound", true));
381         factory.createPackage("empty", true);
382
383         visitor.setShowInbounds(false);
384         visitor.setShowOutbounds(false);
385
386         visitor.traverseNodes(factory.getPackages().values());
387
388         int lineNumber = 0;
389         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
390
391         assertEquals("line " + ++lineNumber, "empty", in.readLine());
392         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
393         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
394
395         assertEquals("End of file", null, in.readLine());
396     }
397
398     public void testShowOutboundsClassTrueWithInferred() throws IOException {
399         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
400         factory.createClass("empty.Empty");
401
402         visitor.setShowInbounds(false);
403         visitor.setShowOutbounds(true);
404
405         visitor.traverseNodes(factory.getPackages().values());
406
407         int lineNumber = 0;
408         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
409
410         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
411         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
412         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
413         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
414         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
415         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
416         assertEquals("line " + ++lineNumber, " --> inbound.Inbound *", in.readLine());
417
418         assertEquals("End of file", null, in.readLine());
419     }
420
421     public void testShowOutboundsClassTrueWithConfirmed() throws IOException {
422         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
423         factory.createClass("empty.Empty", true);
424
425         visitor.setShowInbounds(false);
426         visitor.setShowOutbounds(true);
427
428         visitor.traverseNodes(factory.getPackages().values());
429
430         int lineNumber = 0;
431         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
432
433         assertEquals("line " + ++lineNumber, "empty", in.readLine());
434         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
435         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
436         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
437         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
438         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
439         assertEquals("line " + ++lineNumber, " --> inbound.Inbound", in.readLine());
440
441         assertEquals("End of file", null, in.readLine());
442     }
443
444     public void testShowOutboundsClassFalseWithInferred() throws IOException {
445         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
446         factory.createClass("empty.Empty");
447
448         visitor.setShowInbounds(false);
449         visitor.setShowOutbounds(false);
450
451         visitor.traverseNodes(factory.getPackages().values());
452
453         int lineNumber = 0;
454         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
455
456         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
457         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
458         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
459         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
460         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
461         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
462
463         assertEquals("End of file", null, in.readLine());
464     }
465
466     public void testShowOutboundsClassFalseWithConfirmed() throws IOException {
467         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
468         factory.createClass("empty.Empty", true);
469
470         visitor.setShowInbounds(false);
471         visitor.setShowOutbounds(false);
472
473         visitor.traverseNodes(factory.getPackages().values());
474
475         int lineNumber = 0;
476         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
477
478         assertEquals("line " + ++lineNumber, "empty", in.readLine());
479         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
480         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
481         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
482         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
483         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
484
485         assertEquals("End of file", null, in.readLine());
486     }
487
488     public void testShowOutboundsFeatureTrueWithInferred() throws IOException {
489         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
490         factory.createFeature("empty.Empty.empty()");
491
492         visitor.setShowInbounds(false);
493         visitor.setShowOutbounds(true);
494
495         visitor.traverseNodes(factory.getPackages().values());
496
497         int lineNumber = 0;
498         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
499
500         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
501         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
502         assertEquals("line " + ++lineNumber, " empty() *", in.readLine());
503         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
504         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
505         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
506         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
507         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
508         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
509         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
510
511         assertEquals("End of file", null, in.readLine());
512     }
513
514     public void testShowOutboundsFeatureTrueWithConfirmed() throws IOException {
515         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
516         factory.createFeature("empty.Empty.empty()", true);
517
518         visitor.setShowInbounds(false);
519         visitor.setShowOutbounds(true);
520
521         visitor.traverseNodes(factory.getPackages().values());
522
523         int lineNumber = 0;
524         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
525
526         assertEquals("line " + ++lineNumber, "empty", in.readLine());
527         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
528         assertEquals("line " + ++lineNumber, " empty()", in.readLine());
529         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
530         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
531         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
532         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
533         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
534         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
535         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
536
537         assertEquals("End of file", null, in.readLine());
538     }
539
540     public void testShowOutboundsFeatureFalseWithInferred() throws IOException {
541         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
542         factory.createFeature("empty.Empty.empty()");
543
544         visitor.setShowInbounds(false);
545         visitor.setShowOutbounds(false);
546
547         visitor.traverseNodes(factory.getPackages().values());
548
549         int lineNumber = 0;
550         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
551
552         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
553         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
554         assertEquals("line " + ++lineNumber, " empty() *", in.readLine());
555         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
556         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
557         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
558         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
559         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
560         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
561
562         assertEquals("End of file", null, in.readLine());
563     }
564
565     public void testShowOutboundsFeatureFalseWithConfirmed() throws IOException {
566         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
567         factory.createFeature("empty.Empty.empty()", true);
568
569         visitor.setShowInbounds(false);
570         visitor.setShowOutbounds(false);
571
572         visitor.traverseNodes(factory.getPackages().values());
573
574         int lineNumber = 0;
575         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
576
577         assertEquals("line " + ++lineNumber, "empty", in.readLine());
578         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
579         assertEquals("line " + ++lineNumber, " empty()", in.readLine());
580         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
581         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
582         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
583         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
584         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
585         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
586
587         assertEquals("End of file", null, in.readLine());
588     }
589     
590     public void testShowEmptyPackageTrueWithInferred() throws IOException {
591         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
592         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
593         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
594         factory.createPackage("empty");
595
596         visitor.setShowEmptyNodes(true);
597
598         visitor.traverseNodes(factory.getPackages().values());
599
600         int lineNumber = 0;
601         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
602
603         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
604         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
605         assertEquals("line " + ++lineNumber, " <-- outbound *", in.readLine());
606         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
607         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound *", in.readLine());
608         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
609         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
610         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
611         assertEquals("line " + ++lineNumber, " --> inbound *", in.readLine());
612         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
613         assertEquals("line " + ++lineNumber, " --> inbound.Inbound *", in.readLine());
614         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
615         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
616
617         assertEquals("End of file", null, in.readLine());
618     }
619     
620     public void testSetFlagInferredToFalse() throws IOException {
621         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
622         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
623         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
624         factory.createPackage("empty");
625
626         visitor.setShowInferred(false);
627
628         visitor.traverseNodes(factory.getPackages().values());
629
630         int lineNumber = 0;
631         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
632
633         assertEquals("line " + ++lineNumber, "empty", in.readLine());
634         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
635         assertEquals("line " + ++lineNumber, " <-- outbound", in.readLine());
636         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
637         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound", in.readLine());
638         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
639         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
640         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
641         assertEquals("line " + ++lineNumber, " --> inbound", in.readLine());
642         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
643         assertEquals("line " + ++lineNumber, " --> inbound.Inbound", in.readLine());
644         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
645         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
646
647         assertEquals("End of file", null, in.readLine());
648     }
649     
650     public void testShowEmptyPackageTrueWithConfirmed() throws IOException {
651         factory.createPackage("outbound", true).addDependency(factory.createPackage("inbound", true));
652         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
653         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
654         factory.createPackage("empty", true);
655
656         visitor.setShowEmptyNodes(true);
657
658         visitor.traverseNodes(factory.getPackages().values());
659
660         int lineNumber = 0;
661         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
662
663         assertEquals("line " + ++lineNumber, "empty", in.readLine());
664         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
665         assertEquals("line " + ++lineNumber, " <-- outbound", in.readLine());
666         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
667         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound", in.readLine());
668         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
669         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
670         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
671         assertEquals("line " + ++lineNumber, " --> inbound", in.readLine());
672         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
673         assertEquals("line " + ++lineNumber, " --> inbound.Inbound", in.readLine());
674         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
675         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
676
677         assertEquals("End of file", null, in.readLine());
678     }
679
680     public void testShowEmptyPackageFalseWithInferred() throws IOException {
681         factory.createPackage("outbound").addDependency(factory.createPackage("inbound"));
682         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
683         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
684         factory.createPackage("empty");
685
686         visitor.setShowEmptyNodes(false);
687
688         visitor.traverseNodes(factory.getPackages().values());
689
690         int lineNumber = 0;
691         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
692
693         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
694         assertEquals("line " + ++lineNumber, " <-- outbound *", in.readLine());
695         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
696         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound *", in.readLine());
697         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
698         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
699         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
700         assertEquals("line " + ++lineNumber, " --> inbound *", in.readLine());
701         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
702         assertEquals("line " + ++lineNumber, " --> inbound.Inbound *", in.readLine());
703         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
704         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
705
706         assertEquals("End of file", null, in.readLine());
707     }
708
709     public void testShowEmptyPackageFalseWithConfirmed() throws IOException {
710         factory.createPackage("outbound", true).addDependency(factory.createPackage("inbound", true));
711         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
712         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
713         factory.createPackage("empty", true);
714
715         visitor.setShowEmptyNodes(false);
716
717         visitor.traverseNodes(factory.getPackages().values());
718
719         int lineNumber = 0;
720         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
721
722         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
723         assertEquals("line " + ++lineNumber, " <-- outbound", in.readLine());
724         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
725         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound", in.readLine());
726         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
727         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
728         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
729         assertEquals("line " + ++lineNumber, " --> inbound", in.readLine());
730         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
731         assertEquals("line " + ++lineNumber, " --> inbound.Inbound", in.readLine());
732         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
733         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
734
735         assertEquals("End of file", null, in.readLine());
736     }
737
738     public void testShowEmptyClassTrueWithInferred() throws IOException {
739         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
740         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
741         factory.createClass("empty.Empty");
742
743         visitor.setShowEmptyNodes(true);
744
745         visitor.traverseNodes(factory.getPackages().values());
746
747         int lineNumber = 0;
748         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
749
750         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
751         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
752         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
753         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
754         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound *", in.readLine());
755         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
756         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
757         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
758         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
759         assertEquals("line " + ++lineNumber, " --> inbound.Inbound *", in.readLine());
760         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
761         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
762
763         assertEquals("End of file", null, in.readLine());
764     }
765
766     public void testShowEmptyClassTrueWithConfirmed() throws IOException {
767         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
768         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
769         factory.createClass("empty.Empty", true);
770
771         visitor.setShowEmptyNodes(true);
772
773         visitor.traverseNodes(factory.getPackages().values());
774
775         int lineNumber = 0;
776         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
777
778         assertEquals("line " + ++lineNumber, "empty", in.readLine());
779         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
780         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
781         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
782         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound", in.readLine());
783         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
784         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
785         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
786         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
787         assertEquals("line " + ++lineNumber, " --> inbound.Inbound", in.readLine());
788         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
789         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
790
791         assertEquals("End of file", null, in.readLine());
792     }
793
794     public void testShowEmptyClassFalseWithInferred() throws IOException {
795         factory.createClass("outbound.Outbound").addDependency(factory.createClass("inbound.Inbound"));
796         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
797         factory.createClass("empty.Empty");
798
799         visitor.setShowEmptyNodes(false);
800
801         visitor.traverseNodes(factory.getPackages().values());
802
803         int lineNumber = 0;
804         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
805
806         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
807         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
808         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound *", in.readLine());
809         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
810         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
811         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
812         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
813         assertEquals("line " + ++lineNumber, " --> inbound.Inbound *", in.readLine());
814         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
815         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
816
817         assertEquals("End of file", null, in.readLine());
818     }
819
820     public void testShowEmptyClassFalseWithConfirmed() throws IOException {
821         factory.createClass("outbound.Outbound", true).addDependency(factory.createClass("inbound.Inbound", true));
822         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
823         factory.createClass("empty.Empty", true);
824
825         visitor.setShowEmptyNodes(false);
826
827         visitor.traverseNodes(factory.getPackages().values());
828
829         int lineNumber = 0;
830         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
831
832         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
833         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
834         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound", in.readLine());
835         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
836         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
837         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
838         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
839         assertEquals("line " + ++lineNumber, " --> inbound.Inbound", in.readLine());
840         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
841         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
842
843         assertEquals("End of file", null, in.readLine());
844     }
845
846     public void testShowEmptyFeatureTrueWithInferred() throws IOException {
847         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
848         factory.createFeature("empty.Empty.empty()");
849
850         visitor.setShowEmptyNodes(true);
851
852         visitor.traverseNodes(factory.getPackages().values());
853
854         int lineNumber = 0;
855         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
856
857         assertEquals("line " + ++lineNumber, "empty *", in.readLine());
858         assertEquals("line " + ++lineNumber, " Empty *", in.readLine());
859         assertEquals("line " + ++lineNumber, " empty() *", in.readLine());
860         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
861         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
862         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
863         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
864         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
865         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
866         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
867         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
868
869         assertEquals("End of file", null, in.readLine());
870     }
871
872     public void testShowEmptyFeatureTrueWithConfirmed() throws IOException {
873         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
874         factory.createFeature("empty.Empty.empty()", true);
875
876         visitor.setShowEmptyNodes(true);
877
878         visitor.traverseNodes(factory.getPackages().values());
879
880         int lineNumber = 0;
881         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
882
883         assertEquals("line " + ++lineNumber, "empty", in.readLine());
884         assertEquals("line " + ++lineNumber, " Empty", in.readLine());
885         assertEquals("line " + ++lineNumber, " empty()", in.readLine());
886         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
887         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
888         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
889         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
890         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
891         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
892         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
893         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
894
895         assertEquals("End of file", null, in.readLine());
896     }
897
898     public void testShowEmptyFeatureFalseWithInferred() throws IOException {
899         factory.createFeature("outbound.Outbound.outbound()").addDependency(factory.createFeature("inbound.Inbound.inbound()"));
900         factory.createFeature("empty.Empty.empty()");
901
902         visitor.setShowEmptyNodes(false);
903
904         visitor.traverseNodes(factory.getPackages().values());
905
906         int lineNumber = 0;
907         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
908
909         assertEquals("line " + ++lineNumber, "inbound *", in.readLine());
910         assertEquals("line " + ++lineNumber, " Inbound *", in.readLine());
911         assertEquals("line " + ++lineNumber, " inbound() *", in.readLine());
912         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound() *", in.readLine());
913         assertEquals("line " + ++lineNumber, "outbound *", in.readLine());
914         assertEquals("line " + ++lineNumber, " Outbound *", in.readLine());
915         assertEquals("line " + ++lineNumber, " outbound() *", in.readLine());
916         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound() *", in.readLine());
917
918         assertEquals("End of file", null, in.readLine());
919     }
920
921     public void testShowEmptyFeatureFalseWithConfirmed() throws IOException {
922         factory.createFeature("outbound.Outbound.outbound()", true).addDependency(factory.createFeature("inbound.Inbound.inbound()", true));
923         factory.createFeature("empty.Empty.empty()", true);
924
925         visitor.setShowEmptyNodes(false);
926
927         visitor.traverseNodes(factory.getPackages().values());
928
929         int lineNumber = 0;
930         BufferedReader in = new BufferedReader(new StringReader(out.toString()));
931
932         assertEquals("line " + ++lineNumber, "inbound", in.readLine());
933         assertEquals("line " + ++lineNumber, " Inbound", in.readLine());
934         assertEquals("line " + ++lineNumber, " inbound()", in.readLine());
935         assertEquals("line " + ++lineNumber, " <-- outbound.Outbound.outbound()", in.readLine());
936         assertEquals("line " + ++lineNumber, "outbound", in.readLine());
937         assertEquals("line " + ++lineNumber, " Outbound", in.readLine());
938         assertEquals("line " + ++lineNumber, " outbound()", in.readLine());
939         assertEquals("line " + ++lineNumber, " --> inbound.Inbound.inbound()", in.readLine());
940
941         assertEquals("End of file", null, in.readLine());
942     }
943 }
944
Popular Tags