1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.surefire.extensions;
20
21 import java.io.File;
22 import java.io.PrintStream;
23
24 import org.apache.maven.plugin.surefire.report.ConsoleOutputFileReporter;
25 import org.apache.maven.plugin.surefire.report.DirectConsoleOutput;
26 import org.apache.maven.surefire.api.util.ReflectionUtils;
27 import org.apache.maven.surefire.extensions.ConsoleOutputReportEventListener;
28 import org.apache.maven.surefire.extensions.ConsoleOutputReporter;
29
30
31
32
33
34
35
36
37
38
39
40 public class SurefireConsoleOutputReporter extends ConsoleOutputReporter {
41 @Override
42 public ConsoleOutputReportEventListener createListener(
43 File reportsDirectory, String reportNameSuffix, Integer forkNumber) {
44 return new ConsoleOutputFileReporter(reportsDirectory, reportNameSuffix, false, forkNumber, getEncoding());
45 }
46
47 @Override
48 public ConsoleOutputReportEventListener createListener(PrintStream out, PrintStream err) {
49 return new DirectConsoleOutput(out, err);
50 }
51
52 @Override
53 public Object clone(ClassLoader target) {
54 try {
55 Class<?> cls = ReflectionUtils.reloadClass(target, this);
56 Object clone = cls.newInstance();
57
58 cls.getMethod("setDisable", boolean.class).invoke(clone, isDisable());
59 cls.getMethod("setEncoding", String.class).invoke(clone, getEncoding());
60
61 return clone;
62 } catch (ReflectiveOperationException e) {
63 throw new IllegalStateException(e.getLocalizedMessage());
64 }
65 }
66
67 @Override
68 public String toString() {
69 return "SurefireConsoleOutputReporter{" + "disable=" + isDisable() + ", encoding=" + getEncoding() + '}';
70 }
71 }