1 package org.apache.maven.plugin.surefire.report;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.BufferedOutputStream;
23 import java.io.OutputStreamWriter;
24 import java.io.PrintStream;
25 import java.io.PrintWriter;
26 import java.util.List;
27 import org.apache.maven.surefire.report.ReportEntry;
28
29
30
31
32
33
34
35 public class ConsoleReporter
36 {
37 public static final String BRIEF = "brief";
38
39 public static final String PLAIN = "plain";
40
41 private static final String TEST_SET_STARTING_PREFIX = "Running ";
42
43 private static final int BUFFER_SIZE = 4096;
44
45 private final PrintWriter writer;
46
47 public ConsoleReporter( PrintStream originalSystemOut )
48 {
49 OutputStreamWriter out = new OutputStreamWriter( new BufferedOutputStream( originalSystemOut, BUFFER_SIZE ) );
50 writer = new PrintWriter( out );
51 }
52
53 public void testSetStarting( ReportEntry report )
54 {
55 writeMessage( getTestSetStartingMessage( report ) );
56 }
57
58 public void writeMessage( String message )
59 {
60 writer.print( message );
61 writer.flush();
62 }
63
64 public void writeLnMessage( String message )
65 {
66 writer.println( message );
67 writer.flush();
68 }
69
70 public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List<String> testResults )
71 {
72 writeMessage( testSetStats.getTestSetSummary( report ) );
73
74 if ( testResults != null )
75 {
76 for ( String testResult : testResults )
77 {
78 writeLnMessage( testResult );
79 }
80 }
81 }
82
83
84 public void reset()
85 {
86 writer.flush();
87 }
88
89
90
91
92
93
94
95
96 static String getTestSetStartingMessage( ReportEntry report )
97 {
98 return TEST_SET_STARTING_PREFIX + report.getNameWithGroup() + "\n";
99 }
100
101
102 }