1 /* Copyright (C) 2005-2009  Egon Willighagen <egonw@users.sf.net>
2  *                    2007  Rajarshi Guha <rajarshi@users.sf.net>
3  *
4  * Contact: cdk-devel@lists.sourceforge.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation; either version 2.1
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 package org.openscience.cdk.tools;
21 
22 import java.io.ByteArrayOutputStream;
23 import java.io.PrintStream;
24 
25 import org.junit.Assert;
26 import org.junit.Test;
27 
28 /**
29  * @cdk.module test-core
30  */
31 public class SystemOutLoggingToolTest extends AbstractLoggingToolTest {
32 
33     @Test
testLoggingTool_Class()34     public void testLoggingTool_Class() throws Exception {
35         ILoggingTool logger = new SystemOutLoggingTool(this.getClass());
36         Assert.assertNotNull(logger);
37     }
38 
39     @Test
testDebug_Object()40     public void testDebug_Object() throws Exception {
41         // set up things such that we can test the actual output
42         PrintStream stdout = System.out;
43         ByteArrayOutputStream out = new ByteArrayOutputStream();
44         System.setErr(new PrintStream(out));
45 
46         // do the testing
47         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
48         logger.setDebugEnabled(true);
49         logger.debug(this);
50         Assert.assertTrue(out.toString().contains("DEBUG"));
51         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
52 
53         // reset the STDOUT
54         System.setErr(stdout);
55     }
56 
57     @Test
58     @Override
testDebug_Object_Object()59     public void testDebug_Object_Object() throws Exception {
60         // set up things such that we can test the actual output
61         PrintStream stdout = System.out;
62         ByteArrayOutputStream out = new ByteArrayOutputStream();
63         System.setErr(new PrintStream(out));
64 
65         // do the testing
66         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
67         logger.setDebugEnabled(true);
68         logger.debug(this, this);
69         Assert.assertTrue(out.toString().contains("DEBUG"));
70         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
71 
72         // reset the STDOUT
73         System.setErr(stdout);
74     }
75 
76     @Test
77     @Override
testDebug_Object_int()78     public void testDebug_Object_int() throws Exception {
79         // set up things such that we can test the actual output
80         PrintStream stdout = System.out;
81         ByteArrayOutputStream out = new ByteArrayOutputStream();
82         System.setErr(new PrintStream(out));
83 
84         // do the testing
85         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
86         logger.setDebugEnabled(true);
87         logger.debug(this, 1);
88         Assert.assertTrue(out.toString().contains("DEBUG"));
89         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
90         Assert.assertTrue(out.toString().contains("1"));
91 
92         // reset the STDOUT
93         System.setErr(stdout);
94     }
95 
96     @Test
97     @Override
testDebug_Object_double()98     public void testDebug_Object_double() throws Exception {
99         // set up things such that we can test the actual output
100         PrintStream stdout = System.out;
101         ByteArrayOutputStream out = new ByteArrayOutputStream();
102         System.setErr(new PrintStream(out));
103 
104         // do the testing
105         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
106         logger.setDebugEnabled(true);
107         logger.debug(this, 1.0);
108         Assert.assertTrue(out.toString().contains("DEBUG"));
109         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
110         Assert.assertTrue(out.toString().contains("1.0"));
111 
112         // reset the STDOUT
113         System.setErr(stdout);
114     }
115 
116     @Test
117     @Override
testDebug_Object_boolean()118     public void testDebug_Object_boolean() throws Exception {
119         // set up things such that we can test the actual output
120         PrintStream stdout = System.out;
121         ByteArrayOutputStream out = new ByteArrayOutputStream();
122         System.setErr(new PrintStream(out));
123 
124         // do the testing
125         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
126         logger.setDebugEnabled(true);
127         logger.debug(this, true);
128         Assert.assertTrue(out.toString().contains("DEBUG"));
129         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
130         Assert.assertTrue(out.toString().contains("true"));
131 
132         // reset the STDOUT
133         System.setErr(stdout);
134     }
135 
136     @Test
137     @Override
testDebug_Object_Object_Object_Object_Object()138     public void testDebug_Object_Object_Object_Object_Object() throws Exception {
139         // set up things such that we can test the actual output
140         PrintStream stdout = System.out;
141         ByteArrayOutputStream out = new ByteArrayOutputStream();
142         System.setErr(new PrintStream(out));
143 
144         // do the testing
145         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
146         logger.setDebugEnabled(true);
147         logger.debug(this);
148         Assert.assertTrue(out.toString().contains("DEBUG"));
149         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
150 
151         // reset the STDOUT
152         System.setErr(stdout);
153     }
154 
155     @Test
156     @Override
testDebug_Object_Object_Object_Object()157     public void testDebug_Object_Object_Object_Object() throws Exception {
158         // set up things such that we can test the actual output
159         PrintStream stdout = System.out;
160         ByteArrayOutputStream out = new ByteArrayOutputStream();
161         System.setErr(new PrintStream(out));
162 
163         // do the testing
164         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
165         logger.setDebugEnabled(true);
166         logger.debug(this, this, this, this);
167         Assert.assertTrue(out.toString().contains("DEBUG"));
168         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
169 
170         // reset the STDOUT
171         System.setErr(stdout);
172     }
173 
174     @Test
175     @Override
testDebug_Object_Object_Object()176     public void testDebug_Object_Object_Object() throws Exception {
177         // set up things such that we can test the actual output
178         PrintStream stdout = System.out;
179         ByteArrayOutputStream out = new ByteArrayOutputStream();
180         System.setErr(new PrintStream(out));
181 
182         // do the testing
183         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
184         logger.setDebugEnabled(true);
185         logger.debug(this, this, this);
186         Assert.assertTrue(out.toString().contains("DEBUG"));
187         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
188 
189         // reset the STDOUT
190         System.setErr(stdout);
191     }
192 
193     @Test
194     @Override
testError_Object()195     public void testError_Object() throws Exception {
196         // set up things such that we can test the actual output
197         PrintStream stdout = System.out;
198         ByteArrayOutputStream out = new ByteArrayOutputStream();
199         System.setErr(new PrintStream(out));
200 
201         // do the testing
202         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
203         logger.setDebugEnabled(true);
204         logger.error(this);
205         Assert.assertTrue(out.toString().contains("ERROR"));
206         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
207 
208         // reset the STDOUT
209         System.setErr(stdout);
210     }
211 
212     @Test
213     @Override
testError_Object_Object()214     public void testError_Object_Object() throws Exception {
215         // set up things such that we can test the actual output
216         PrintStream stdout = System.out;
217         ByteArrayOutputStream out = new ByteArrayOutputStream();
218         System.setErr(new PrintStream(out));
219 
220         // do the testing
221         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
222         logger.setDebugEnabled(true);
223         logger.error(this, this);
224         Assert.assertTrue(out.toString().contains("ERROR"));
225         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
226 
227         // reset the STDOUT
228         System.setErr(stdout);
229     }
230 
231     @Test
232     @Override
testError_Object_int()233     public void testError_Object_int() throws Exception {
234         // set up things such that we can test the actual output
235         PrintStream stdout = System.out;
236         ByteArrayOutputStream out = new ByteArrayOutputStream();
237         System.setErr(new PrintStream(out));
238 
239         // do the testing
240         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
241         logger.setDebugEnabled(true);
242         logger.error(this, 1);
243         Assert.assertTrue(out.toString().contains("ERROR"));
244         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
245         Assert.assertTrue(out.toString().contains("1"));
246 
247         // reset the STDOUT
248         System.setErr(stdout);
249     }
250 
251     @Test
252     @Override
testError_Object_double()253     public void testError_Object_double() throws Exception {
254         // set up things such that we can test the actual output
255         PrintStream stdout = System.out;
256         ByteArrayOutputStream out = new ByteArrayOutputStream();
257         System.setErr(new PrintStream(out));
258 
259         // do the testing
260         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
261         logger.setDebugEnabled(true);
262         logger.error(this, 1.0);
263         Assert.assertTrue(out.toString().contains("ERROR"));
264         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
265         Assert.assertTrue(out.toString().contains("1.0"));
266 
267         // reset the STDOUT
268         System.setErr(stdout);
269     }
270 
271     @Test
272     @Override
testError_Object_boolean()273     public void testError_Object_boolean() throws Exception {
274         // set up things such that we can test the actual output
275         PrintStream stdout = System.out;
276         ByteArrayOutputStream out = new ByteArrayOutputStream();
277         System.setErr(new PrintStream(out));
278 
279         // do the testing
280         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
281         logger.setDebugEnabled(true);
282         logger.error(this, true);
283         Assert.assertTrue(out.toString().contains("ERROR"));
284         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
285         Assert.assertTrue(out.toString().contains("true"));
286 
287         // reset the STDOUT
288         System.setErr(stdout);
289     }
290 
291     @Test
292     @Override
testError_Object_Object_Object_Object_Object()293     public void testError_Object_Object_Object_Object_Object() throws Exception {
294         // set up things such that we can test the actual output
295         PrintStream stdout = System.out;
296         ByteArrayOutputStream out = new ByteArrayOutputStream();
297         System.setErr(new PrintStream(out));
298 
299         // do the testing
300         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
301         logger.setDebugEnabled(true);
302         logger.error(this, this, this, this, this);
303         Assert.assertTrue(out.toString().contains("ERROR"));
304         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
305 
306         // reset the STDOUT
307         System.setErr(stdout);
308     }
309 
310     @Test
311     @Override
testError_Object_Object_Object_Object()312     public void testError_Object_Object_Object_Object() throws Exception {
313         // set up things such that we can test the actual output
314         PrintStream stdout = System.out;
315         ByteArrayOutputStream out = new ByteArrayOutputStream();
316         System.setErr(new PrintStream(out));
317 
318         // do the testing
319         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
320         logger.setDebugEnabled(true);
321         logger.error(this, this, this, this);
322         Assert.assertTrue(out.toString().contains("ERROR"));
323         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
324 
325         // reset the STDOUT
326         System.setErr(stdout);
327     }
328 
329     @Test
330     @Override
testError_Object_Object_Object()331     public void testError_Object_Object_Object() throws Exception {
332         // set up things such that we can test the actual output
333         PrintStream stdout = System.out;
334         ByteArrayOutputStream out = new ByteArrayOutputStream();
335         System.setErr(new PrintStream(out));
336 
337         // do the testing
338         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
339         logger.setDebugEnabled(true);
340         logger.error(this, this, this);
341         Assert.assertTrue(out.toString().contains("ERROR"));
342         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
343 
344         // reset the STDOUT
345         System.setErr(stdout);
346     }
347 
348     @Test
349     @Override
testWarn_Object()350     public void testWarn_Object() throws Exception {
351         // set up things such that we can test the actual output
352         PrintStream stdout = System.out;
353         ByteArrayOutputStream out = new ByteArrayOutputStream();
354         System.setErr(new PrintStream(out));
355 
356         // do the testing
357         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
358         logger.setDebugEnabled(true);
359         logger.warn(this);
360         Assert.assertTrue(out.toString().contains("WARN"));
361         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
362 
363         // reset the STDOUT
364         System.setErr(stdout);
365     }
366 
367     @Test
368     @Override
testWarn_Object_Object()369     public void testWarn_Object_Object() throws Exception {
370         // set up things such that we can test the actual output
371         PrintStream stdout = System.out;
372         ByteArrayOutputStream out = new ByteArrayOutputStream();
373         System.setErr(new PrintStream(out));
374 
375         // do the testing
376         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
377         logger.setDebugEnabled(true);
378         logger.warn(this, this);
379         Assert.assertTrue(out.toString().contains("WARN"));
380         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
381 
382         // reset the STDOUT
383         System.setErr(stdout);
384     }
385 
386     @Test
387     @Override
testWarn_Object_int()388     public void testWarn_Object_int() throws Exception {
389         // set up things such that we can test the actual output
390         PrintStream stdout = System.out;
391         ByteArrayOutputStream out = new ByteArrayOutputStream();
392         System.setErr(new PrintStream(out));
393 
394         // do the testing
395         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
396         logger.setDebugEnabled(true);
397         logger.warn(this, 1);
398         Assert.assertTrue(out.toString().contains("WARN"));
399         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
400         Assert.assertTrue(out.toString().contains("1"));
401 
402         // reset the STDOUT
403         System.setErr(stdout);
404     }
405 
406     @Test
407     @Override
testWarn_Object_double()408     public void testWarn_Object_double() throws Exception {
409         // set up things such that we can test the actual output
410         PrintStream stdout = System.out;
411         ByteArrayOutputStream out = new ByteArrayOutputStream();
412         System.setErr(new PrintStream(out));
413 
414         // do the testing
415         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
416         logger.setDebugEnabled(true);
417         logger.warn(this, 1.0);
418         Assert.assertTrue(out.toString().contains("WARN"));
419         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
420         Assert.assertTrue(out.toString().contains("1.0"));
421 
422         // reset the STDOUT
423         System.setErr(stdout);
424     }
425 
426     @Test
427     @Override
testWarn_Object_boolean()428     public void testWarn_Object_boolean() throws Exception {
429         // set up things such that we can test the actual output
430         PrintStream stdout = System.out;
431         ByteArrayOutputStream out = new ByteArrayOutputStream();
432         System.setErr(new PrintStream(out));
433 
434         // do the testing
435         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
436         logger.setDebugEnabled(true);
437         logger.warn(this, true);
438         Assert.assertTrue(out.toString().contains("WARN"));
439         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
440         Assert.assertTrue(out.toString().contains("true"));
441 
442         // reset the STDOUT
443         System.setErr(stdout);
444     }
445 
446     @Test
447     @Override
testWarn_Object_Object_Object_Object_Object()448     public void testWarn_Object_Object_Object_Object_Object() throws Exception {
449         // set up things such that we can test the actual output
450         PrintStream stdout = System.out;
451         ByteArrayOutputStream out = new ByteArrayOutputStream();
452         System.setErr(new PrintStream(out));
453 
454         // do the testing
455         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
456         logger.setDebugEnabled(true);
457         logger.warn(this, this, this, this, this);
458         Assert.assertTrue(out.toString().contains("WARN"));
459         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
460 
461         // reset the STDOUT
462         System.setErr(stdout);
463     }
464 
465     @Test
466     @Override
testWarn_Object_Object_Object_Object()467     public void testWarn_Object_Object_Object_Object() throws Exception {
468         // set up things such that we can test the actual output
469         PrintStream stdout = System.out;
470         ByteArrayOutputStream out = new ByteArrayOutputStream();
471         System.setErr(new PrintStream(out));
472 
473         // do the testing
474         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
475         logger.setDebugEnabled(true);
476         logger.warn(this, this, this, this);
477         Assert.assertTrue(out.toString().contains("WARN"));
478         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
479 
480         // reset the STDOUT
481         System.setErr(stdout);
482     }
483 
484     @Test
485     @Override
testWarn_Object_Object_Object()486     public void testWarn_Object_Object_Object() throws Exception {
487         // set up things such that we can test the actual output
488         PrintStream stdout = System.out;
489         ByteArrayOutputStream out = new ByteArrayOutputStream();
490         System.setErr(new PrintStream(out));
491 
492         // do the testing
493         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
494         logger.setDebugEnabled(true);
495         logger.warn(this, this, this);
496         Assert.assertTrue(out.toString().contains("WARN"));
497         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
498 
499         // reset the STDOUT
500         System.setErr(stdout);
501     }
502 
503     @Test
504     @Override
testInfo_Object()505     public void testInfo_Object() throws Exception {
506         // set up things such that we can test the actual output
507         PrintStream stdout = System.out;
508         ByteArrayOutputStream out = new ByteArrayOutputStream();
509         System.setErr(new PrintStream(out));
510 
511         // do the testing
512         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
513         logger.setDebugEnabled(true);
514         logger.info(this);
515         Assert.assertTrue(out.toString().contains("INFO"));
516         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
517 
518         // reset the STDOUT
519         System.setErr(stdout);
520     }
521 
522     @Test
523     @Override
testInfo_Object_Object()524     public void testInfo_Object_Object() throws Exception {
525         // set up things such that we can test the actual output
526         PrintStream stdout = System.out;
527         ByteArrayOutputStream out = new ByteArrayOutputStream();
528         System.setErr(new PrintStream(out));
529 
530         // do the testing
531         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
532         logger.setDebugEnabled(true);
533         logger.info(this, this);
534         Assert.assertTrue(out.toString().contains("INFO"));
535         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
536 
537         // reset the STDOUT
538         System.setErr(stdout);
539     }
540 
541     @Test
542     @Override
testInfo_Object_int()543     public void testInfo_Object_int() throws Exception {
544         // set up things such that we can test the actual output
545         PrintStream stdout = System.out;
546         ByteArrayOutputStream out = new ByteArrayOutputStream();
547         System.setErr(new PrintStream(out));
548 
549         // do the testing
550         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
551         logger.setDebugEnabled(true);
552         logger.info(this, 1);
553         Assert.assertTrue(out.toString().contains("INFO"));
554         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
555         Assert.assertTrue(out.toString().contains("1"));
556 
557         // reset the STDOUT
558         System.setErr(stdout);
559     }
560 
561     @Test
562     @Override
testInfo_Object_double()563     public void testInfo_Object_double() throws Exception {
564         // set up things such that we can test the actual output
565         PrintStream stdout = System.out;
566         ByteArrayOutputStream out = new ByteArrayOutputStream();
567         System.setErr(new PrintStream(out));
568 
569         // do the testing
570         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
571         logger.setDebugEnabled(true);
572         logger.info(this, 1.0);
573         Assert.assertTrue(out.toString().contains("INFO"));
574         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
575         Assert.assertTrue(out.toString().contains("1.0"));
576 
577         // reset the STDOUT
578         System.setErr(stdout);
579     }
580 
581     @Test
582     @Override
testInfo_Object_boolean()583     public void testInfo_Object_boolean() throws Exception {
584         // set up things such that we can test the actual output
585         PrintStream stdout = System.out;
586         ByteArrayOutputStream out = new ByteArrayOutputStream();
587         System.setErr(new PrintStream(out));
588 
589         // do the testing
590         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
591         logger.setDebugEnabled(true);
592         logger.info(this, true);
593         Assert.assertTrue(out.toString().contains("INFO"));
594         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
595         Assert.assertTrue(out.toString().contains("true"));
596 
597         // reset the STDOUT
598         System.setErr(stdout);
599     }
600 
601     @Test
602     @Override
testInfo_Object_Object_Object_Object_Object()603     public void testInfo_Object_Object_Object_Object_Object() throws Exception {
604         // set up things such that we can test the actual output
605         PrintStream stdout = System.out;
606         ByteArrayOutputStream out = new ByteArrayOutputStream();
607         System.setErr(new PrintStream(out));
608 
609         // do the testing
610         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
611         logger.setDebugEnabled(true);
612         logger.info(this, this, this, this, this);
613         Assert.assertTrue(out.toString().contains("INFO"));
614         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
615 
616         // reset the STDOUT
617         System.setErr(stdout);
618     }
619 
620     @Test
621     @Override
testInfo_Object_Object_Object_Object()622     public void testInfo_Object_Object_Object_Object() throws Exception {
623         // set up things such that we can test the actual output
624         PrintStream stdout = System.out;
625         ByteArrayOutputStream out = new ByteArrayOutputStream();
626         System.setErr(new PrintStream(out));
627 
628         // do the testing
629         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
630         logger.setDebugEnabled(true);
631         logger.info(this, this, this, this);
632         Assert.assertTrue(out.toString().contains("INFO"));
633         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
634 
635         // reset the STDOUT
636         System.setErr(stdout);
637     }
638 
639     @Test
640     @Override
testInfo_Object_Object_Object()641     public void testInfo_Object_Object_Object() throws Exception {
642         // set up things such that we can test the actual output
643         PrintStream stdout = System.out;
644         ByteArrayOutputStream out = new ByteArrayOutputStream();
645         System.setErr(new PrintStream(out));
646 
647         // do the testing
648         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
649         logger.setDebugEnabled(true);
650         logger.info(this, this, this);
651         Assert.assertTrue(out.toString().contains("INFO"));
652         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
653 
654         // reset the STDOUT
655         System.setErr(stdout);
656     }
657 
658     @Test
659     @Override
testFatal_Object()660     public void testFatal_Object() throws Exception {
661         // set up things such that we can test the actual output
662         PrintStream stdout = System.out;
663         ByteArrayOutputStream out = new ByteArrayOutputStream();
664         System.setErr(new PrintStream(out));
665 
666         // do the testing
667         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
668         logger.setDebugEnabled(true);
669         logger.fatal(this);
670         Assert.assertTrue(out.toString().contains("FATAL"));
671         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
672 
673         // reset the STDOUT
674         System.setErr(stdout);
675     }
676 
677     @Test
678     @Override
testSetStackLength_int()679     public void testSetStackLength_int() throws Exception {
680         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
681         logger.setStackLength(20);
682     }
683 
684     @Test
685     @Override
testDumpClasspath()686     public void testDumpClasspath() throws Exception {
687         // set up things such that we can test the actual output
688         PrintStream stdout = System.out;
689         ByteArrayOutputStream out = new ByteArrayOutputStream();
690         System.setErr(new PrintStream(out));
691 
692         // do the testing
693         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
694         logger.setDebugEnabled(true);
695         logger.dumpClasspath();
696         Assert.assertTrue(out.toString().contains("DEBUG"));
697         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
698         Assert.assertTrue(out.toString().contains("java.class.path"));
699 
700         // reset the STDOUT
701         System.setErr(stdout);
702     }
703 
704     @Test
705     @Override
testDumpSystemProperties()706     public void testDumpSystemProperties() throws Exception {
707         // set up things such that we can test the actual output
708         PrintStream stdout = System.out;
709         ByteArrayOutputStream out = new ByteArrayOutputStream();
710         System.setErr(new PrintStream(out));
711 
712         // do the testing
713         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
714         logger.setDebugEnabled(true);
715         logger.dumpSystemProperties();
716         Assert.assertTrue(out.toString().contains("DEBUG"));
717         Assert.assertTrue(out.toString().contains(this.getClass().getName()));
718         Assert.assertTrue(out.toString().contains("os.name"));
719         Assert.assertTrue(out.toString().contains("os.version"));
720         Assert.assertTrue(out.toString().contains("os.arch"));
721         Assert.assertTrue(out.toString().contains("java.version"));
722         Assert.assertTrue(out.toString().contains("java.vendor"));
723 
724         // reset the STDOUT
725         System.setErr(stdout);
726     }
727 
728     @Test
729     @Override
testIsDebugEnabled()730     public void testIsDebugEnabled() throws Exception {
731         SystemOutLoggingTool logger = new SystemOutLoggingTool(this.getClass());
732         // the default must be not the debug
733         Assert.assertFalse(logger.isDebugEnabled());
734         // but we can overwrite it here...
735         logger.setDebugEnabled(true);
736         Assert.assertTrue(logger.isDebugEnabled());
737         logger.setDebugEnabled(false);
738         Assert.assertFalse(logger.isDebugEnabled());
739     }
740 
741     @Test
testCreate()742     public void testCreate() throws Exception {
743         ILoggingTool logger = SystemOutLoggingTool.create(this.getClass());
744         Assert.assertNotNull(logger);
745     }
746 
747     @Override
getLoggingTool()748     public ILoggingTool getLoggingTool() {
749         return new SystemOutLoggingTool(this.getClass());
750     }
751 }
752