View Javadoc

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.List;
23  
24  /**
25   * A reporter that broadcasts to other reporters
26   *
27   * @author Kristian Rosenvold
28   */
29  public class MulticastingReporter
30      implements Reporter
31  {
32      private final Reporter[] target;
33      private final int size;
34  
35      public MulticastingReporter( List target )
36      {
37          size = target.size();
38          this.target = (Reporter[]) target.toArray( new Reporter[target.size()] );
39      }
40  
41      public void testSetStarting( ReportEntry report )
42      {
43          for (int i = 0; i < size; i++){
44              target[i].testSetStarting( report );
45          }
46      }
47  
48      public void testSetCompleted( ReportEntry report )
49      {
50          for (int i = 0; i < size; i++){
51              target[i].testSetCompleted( report );
52          }
53      }
54  
55  
56      public void testStarting( ReportEntry report )
57      {
58          for (int i = 0; i < size; i++){
59              target[i].testStarting( report );
60          }
61      }
62  
63      public void testSucceeded( ReportEntry report )
64      {
65          for (int i = 0; i < size; i++){
66              target[i].testSucceeded( report );
67          }
68      }
69  
70      public void testError( ReportEntry report, String stdOut, String stdErr )
71      {
72          for (int i = 0; i < size; i++){
73              target[i].testError( report, stdOut, stdErr );
74          }
75      }
76  
77      public void testFailed( ReportEntry report, String stdOut, String stdErr )
78      {
79          for (int i = 0; i < size; i++){
80              target[i].testFailed( report, stdOut, stdErr );
81          }
82      }
83  
84      public void testSkipped( ReportEntry report )
85      {
86          for (int i = 0; i < size; i++){
87              target[i].testSkipped( report );
88          }
89      }
90  
91      public void writeMessage( String message )
92      {
93          for (int i = 0; i < size; i++){
94              target[i].writeMessage( message );
95          }
96      }
97  
98      public void writeMessage( byte[] b, int off, int len )
99      {
100         for (int i = 0; i < size; i++){
101             target[i].writeMessage( b, off, len );
102         }
103     }
104 
105     public void reset()
106     {
107         for (int i = 0; i < size; i++){
108             target[i].reset();
109         }
110     }
111 
112 }