1 | |
package org.apache.maven.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.util.Iterator; |
23 | |
import java.util.List; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
public class ReporterManager |
54 | |
{ |
55 | |
private final RunStatistics runStatisticsForThis; |
56 | |
|
57 | |
private final MulticastingReporter multicastingReporter; |
58 | |
|
59 | 0 | private final SystemStreamCapturer consoleCapturer = new SystemStreamCapturer(); |
60 | |
|
61 | |
public ReporterManager( List reports, RunStatistics runStatisticsForThis ) |
62 | 0 | { |
63 | 0 | multicastingReporter = new MulticastingReporter( reports ); |
64 | 0 | this.runStatisticsForThis = runStatisticsForThis; |
65 | 0 | } |
66 | |
|
67 | |
public synchronized void writeMessage( String message ) |
68 | |
{ |
69 | 0 | multicastingReporter.writeMessage( message ); |
70 | 0 | } |
71 | |
|
72 | |
public synchronized void writeConsoleMessage( String message ) |
73 | |
{ |
74 | 0 | multicastingReporter.writeConsoleMessage( message ); |
75 | 0 | } |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public synchronized void runStarting() |
82 | |
{ |
83 | 0 | multicastingReporter.runStarting(); |
84 | 0 | } |
85 | |
|
86 | |
public synchronized void runCompleted() |
87 | |
{ |
88 | 0 | multicastingReporter.runCompleted(); |
89 | 0 | multicastingReporter.writeFooter( "" ); |
90 | 0 | multicastingReporter.writeFooter( "Results :" ); |
91 | 0 | multicastingReporter.writeFooter( "" ); |
92 | 0 | if ( runStatisticsForThis.hadFailures() ) |
93 | |
{ |
94 | 0 | multicastingReporter.writeFooter( "Failed tests: " ); |
95 | 0 | for ( Iterator iterator = this.runStatisticsForThis.getFailureSources().iterator(); iterator.hasNext(); ) |
96 | |
{ |
97 | 0 | multicastingReporter.writeFooter( " " + iterator.next() ); |
98 | |
} |
99 | 0 | multicastingReporter.writeFooter( "" ); |
100 | |
} |
101 | 0 | if ( runStatisticsForThis.hadErrors() ) |
102 | |
{ |
103 | 0 | writeFooter( "Tests in error: " ); |
104 | 0 | for ( Iterator iterator = this.runStatisticsForThis.getErrorSources().iterator(); iterator.hasNext(); ) |
105 | |
{ |
106 | 0 | multicastingReporter.writeFooter( " " + iterator.next() ); |
107 | |
} |
108 | 0 | multicastingReporter.writeFooter( "" ); |
109 | |
} |
110 | 0 | multicastingReporter.writeFooter( runStatisticsForThis.getSummary() ); |
111 | 0 | multicastingReporter.writeFooter( "" ); |
112 | 0 | consoleCapturer.restoreStreams(); |
113 | 0 | } |
114 | |
|
115 | |
public synchronized void writeFooter( String footer ) |
116 | |
{ |
117 | 0 | multicastingReporter.writeFooter( footer ); |
118 | 0 | } |
119 | |
|
120 | |
|
121 | |
public synchronized void testSetStarting( ReportEntry report ) |
122 | |
throws ReporterException |
123 | |
{ |
124 | 0 | multicastingReporter.testSetStarting( report ); |
125 | 0 | } |
126 | |
|
127 | |
public synchronized void testSetCompleted( ReportEntry report ) |
128 | |
{ |
129 | 0 | multicastingReporter.testSetCompleted( report ); |
130 | 0 | } |
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public synchronized void testStarting( ReportEntry report ) |
137 | |
{ |
138 | 0 | multicastingReporter.testStarting( report ); |
139 | 0 | } |
140 | |
|
141 | |
public synchronized void testSucceeded( ReportEntry report ) |
142 | |
{ |
143 | 0 | consoleCapturer.clearCapturedContent(); |
144 | 0 | runStatisticsForThis.incrementCompletedCount(); |
145 | 0 | multicastingReporter.testSucceeded( report ); |
146 | 0 | } |
147 | |
|
148 | |
public synchronized void testError( ReportEntry reportEntry ) |
149 | |
{ |
150 | 0 | testError( reportEntry, consoleCapturer.getStdOutLog(), consoleCapturer.getStdErrLog() ); |
151 | 0 | } |
152 | |
|
153 | |
public synchronized void testError( ReportEntry reportEntry, String stdOutLog, String stdErrLog ) |
154 | |
{ |
155 | 0 | multicastingReporter.testError( reportEntry, stdOutLog, stdErrLog ); |
156 | 0 | runStatisticsForThis.incrementErrorsCount(); |
157 | 0 | runStatisticsForThis.incrementCompletedCount(); |
158 | 0 | runStatisticsForThis.addErrorSource( reportEntry.getName() ); |
159 | 0 | consoleCapturer.clearCapturedContent(); |
160 | 0 | } |
161 | |
|
162 | |
public synchronized void testFailed( ReportEntry reportEntry ) |
163 | |
{ |
164 | 0 | testFailed( reportEntry, consoleCapturer.getStdOutLog(), consoleCapturer.getStdErrLog() ); |
165 | 0 | } |
166 | |
|
167 | |
|
168 | |
public synchronized void testFailed( ReportEntry reportEntry, String stdOutLog, String stdErrLog ) |
169 | |
{ |
170 | 0 | multicastingReporter.testFailed( reportEntry, stdOutLog, stdErrLog ); |
171 | 0 | runStatisticsForThis.incrementFailureCount(); |
172 | 0 | runStatisticsForThis.incrementCompletedCount(); |
173 | 0 | runStatisticsForThis.addFailureSource( reportEntry.getName() ); |
174 | 0 | consoleCapturer.clearCapturedContent(); |
175 | 0 | } |
176 | |
|
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
public synchronized void testSkipped( ReportEntry report ) |
182 | |
{ |
183 | 0 | consoleCapturer.clearCapturedContent(); |
184 | 0 | runStatisticsForThis.incrementSkippedCount(); |
185 | 0 | runStatisticsForThis.incrementCompletedCount(); |
186 | 0 | multicastingReporter.testSkipped( report ); |
187 | 0 | } |
188 | |
|
189 | |
public synchronized void reset() |
190 | |
{ |
191 | 0 | multicastingReporter.reset(); |
192 | 0 | } |
193 | |
|
194 | |
} |