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 | |
import org.apache.maven.surefire.report.ReporterException; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
public class ConsoleReporter |
37 | |
{ |
38 | |
public static final String BRIEF = "brief"; |
39 | |
|
40 | |
public static final String PLAIN = "plain"; |
41 | |
|
42 | |
private static final String TEST_SET_STARTING_PREFIX = "Running "; |
43 | |
|
44 | |
private static final int BUFFER_SIZE = 4096; |
45 | |
|
46 | |
private final PrintWriter writer; |
47 | |
|
48 | |
|
49 | |
public ConsoleReporter( PrintStream originalSystemOut ) |
50 | 0 | { |
51 | 0 | OutputStreamWriter out = new OutputStreamWriter( new BufferedOutputStream( originalSystemOut, BUFFER_SIZE ) ); |
52 | 0 | this.writer = new PrintWriter( out ); |
53 | 0 | } |
54 | |
|
55 | |
public void testSetStarting( ReportEntry report ) |
56 | |
throws ReporterException |
57 | |
{ |
58 | 0 | writeMessage( getTestSetStartingMessage( report ) ); |
59 | 0 | } |
60 | |
|
61 | |
public void writeMessage( String message ) |
62 | |
{ |
63 | 0 | if ( writer != null ) |
64 | |
{ |
65 | 0 | writer.print( message ); |
66 | |
|
67 | 0 | writer.flush(); |
68 | |
} |
69 | 0 | } |
70 | |
|
71 | |
public void writeLnMessage( String message ) |
72 | |
{ |
73 | 0 | if ( writer != null ) |
74 | |
{ |
75 | 0 | writer.println( message ); |
76 | |
|
77 | 0 | writer.flush(); |
78 | |
} |
79 | 0 | } |
80 | |
|
81 | |
public void testSetCompleted( WrappedReportEntry report, TestSetStats testSetStats, List<String> testResults ) |
82 | |
throws ReporterException |
83 | |
{ |
84 | 0 | writeMessage( testSetStats.getTestSetSummary( report ) ); |
85 | |
|
86 | 0 | if ( testResults != null ) |
87 | |
{ |
88 | 0 | for ( String testResult : testResults ) |
89 | |
{ |
90 | 0 | writeLnMessage( testResult ); |
91 | |
} |
92 | |
} |
93 | 0 | } |
94 | |
|
95 | |
|
96 | |
public void reset() |
97 | |
{ |
98 | 0 | if ( writer != null ) |
99 | |
{ |
100 | 0 | writer.flush(); |
101 | |
} |
102 | 0 | } |
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
static String getTestSetStartingMessage( ReportEntry report ) |
112 | |
{ |
113 | 0 | StringBuilder message = new StringBuilder(); |
114 | 0 | message.append( TEST_SET_STARTING_PREFIX ); |
115 | 0 | message.append( report.getNameWithGroup() ); |
116 | |
|
117 | 0 | message.append( "\n" ); |
118 | 0 | return message.toString(); |
119 | |
} |
120 | |
|
121 | |
|
122 | |
} |