Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MulticastingReporter |
|
| 2.125;2.125 |
1 | package org.apache.maven.surefire.report; | |
2 | ||
3 | /* | |
4 | * Licensed to the Apache Software Foundation (ASF) under one | |
5 | * or more contributor license agreements. See the NOTICE file | |
6 | * distributed with this work for additional information | |
7 | * regarding copyright ownership. The ASF licenses this file | |
8 | * to you under the Apache License, Version 2.0 (the | |
9 | * "License"); you may not use this file except in compliance | |
10 | * with the License. You may obtain a copy of the License at | |
11 | * | |
12 | * http://www.apache.org/licenses/LICENSE-2.0 | |
13 | * | |
14 | * Unless required by applicable law or agreed to in writing, | |
15 | * software distributed under the License is distributed on an | |
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
17 | * KIND, either express or implied. See the License for the | |
18 | * specific language governing permissions and limitations | |
19 | * under the License. | |
20 | */ | |
21 | ||
22 | import java.util.Iterator; | |
23 | import java.util.List; | |
24 | ||
25 | /** | |
26 | * A reporter that broadcasts to other reporters | |
27 | * | |
28 | * @author Kristian Rosenvold | |
29 | */ | |
30 | public class MulticastingReporter | |
31 | implements RunReporter, Reporter | |
32 | { | |
33 | private final List target; | |
34 | ||
35 | public MulticastingReporter( List target ) | |
36 | 0 | { |
37 | 0 | this.target = target; |
38 | 0 | } |
39 | ||
40 | public void testSetStarting( ReportEntry report ) | |
41 | throws ReporterException | |
42 | { | |
43 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
44 | { | |
45 | 0 | ( (Reporter) it.next() ).testSetStarting( report ); |
46 | } | |
47 | 0 | } |
48 | ||
49 | public void testSetCompleted( ReportEntry report ) | |
50 | { | |
51 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
52 | { | |
53 | try | |
54 | { | |
55 | 0 | ( (Reporter) it.next() ).testSetCompleted( report ); |
56 | } | |
57 | 0 | catch ( ReporterException e ) |
58 | { | |
59 | // Added in commit r331325 in ReporterManager. This smells fishy. What's this about ? | |
60 | 0 | } |
61 | ||
62 | } | |
63 | 0 | } |
64 | ||
65 | ||
66 | public void runStarting() | |
67 | { | |
68 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
69 | { | |
70 | 0 | Object next = it.next(); |
71 | 0 | if ( next instanceof RunReporter ) |
72 | { | |
73 | 0 | ( (RunReporter) next ).runStarting(); |
74 | } | |
75 | 0 | } |
76 | 0 | } |
77 | ||
78 | public void runCompleted() | |
79 | { | |
80 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
81 | { | |
82 | 0 | Object next = it.next(); |
83 | 0 | if ( next instanceof RunReporter ) |
84 | { | |
85 | 0 | ( (RunReporter) next ).runCompleted(); |
86 | } | |
87 | 0 | } |
88 | 0 | } |
89 | ||
90 | ||
91 | public void testStarting( ReportEntry report ) | |
92 | { | |
93 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
94 | { | |
95 | 0 | ( (Reporter) it.next() ).testStarting( report ); |
96 | } | |
97 | 0 | } |
98 | ||
99 | public void testSucceeded( ReportEntry report ) | |
100 | { | |
101 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
102 | { | |
103 | 0 | ( (Reporter) it.next() ).testSucceeded( report ); |
104 | } | |
105 | 0 | } |
106 | ||
107 | public void testError( ReportEntry report, String stdOut, String stdErr ) | |
108 | { | |
109 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
110 | { | |
111 | 0 | ( (Reporter) it.next() ).testError( report, stdOut, stdErr ); |
112 | } | |
113 | 0 | } |
114 | ||
115 | public void testFailed( ReportEntry report, String stdOut, String stdErr ) | |
116 | { | |
117 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
118 | { | |
119 | 0 | ( (Reporter) it.next() ).testFailed( report, stdOut, stdErr ); |
120 | } | |
121 | 0 | } |
122 | ||
123 | public void testSkipped( ReportEntry report ) | |
124 | { | |
125 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
126 | { | |
127 | 0 | ( (Reporter) it.next() ).testSkipped( report ); |
128 | } | |
129 | 0 | } |
130 | ||
131 | public void writeDetailMessage( String message ) | |
132 | { | |
133 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
134 | { | |
135 | 0 | Reporter reporter = ( (Reporter) it.next() ); |
136 | 0 | reporter.writeDetailMessage( message ); |
137 | 0 | } |
138 | 0 | } |
139 | ||
140 | public void writeMessage( String message ) | |
141 | { | |
142 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
143 | { | |
144 | 0 | ( (Reporter) it.next() ).writeMessage( message ); |
145 | } | |
146 | 0 | } |
147 | ||
148 | public void writeFooter( String footer ) | |
149 | { | |
150 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
151 | { | |
152 | 0 | ( (Reporter) it.next() ).writeFooter( footer ); |
153 | } | |
154 | 0 | } |
155 | ||
156 | public void reset() | |
157 | { | |
158 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
159 | { | |
160 | 0 | ( (Reporter) it.next() ).reset(); |
161 | } | |
162 | 0 | } |
163 | ||
164 | public void testError( ReportEntry report ) | |
165 | { | |
166 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
167 | { | |
168 | 0 | ( (Reporter) it.next() ).testError( report ); |
169 | } | |
170 | 0 | } |
171 | ||
172 | public void testFailed( ReportEntry report ) | |
173 | { | |
174 | 0 | for ( Iterator it = target.iterator(); it.hasNext(); ) |
175 | { | |
176 | 0 | ( (Reporter) it.next() ).testFailed( report ); |
177 | } | |
178 | 0 | } |
179 | ||
180 | } |