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 org.apache.maven.plugin.surefire.report.StatelessXmlReporter;
22 import org.apache.maven.plugin.surefire.report.TestSetStats;
23 import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
24 import org.apache.maven.surefire.api.util.ReflectionUtils;
25 import org.apache.maven.surefire.extensions.StatelessReportEventListener;
26 import org.apache.maven.surefire.extensions.StatelessReporter;
27
28
29
30
31
32
33
34
35
36
37
38 public class SurefireStatelessReporter
39 extends StatelessReporter<WrappedReportEntry, TestSetStats, DefaultStatelessReportMojoConfiguration> {
40
41
42
43 public SurefireStatelessReporter() {
44 this(false, "3.0.2");
45 }
46
47
48
49
50
51
52 public SurefireStatelessReporter(boolean disable, String version) {
53 setDisable(disable);
54 setVersion(version);
55 }
56
57 @Override
58 public StatelessReportEventListener<WrappedReportEntry, TestSetStats> createListener(
59 DefaultStatelessReportMojoConfiguration configuration) {
60 return new StatelessXmlReporter(
61 configuration.getReportsDirectory(),
62 configuration.getReportNameSuffix(),
63 configuration.isTrimStackTrace(),
64 configuration.getRerunFailingTestsCount(),
65 configuration.getTestClassMethodRunHistory(),
66 configuration.getXsdSchemaLocation(),
67 getVersion(),
68 false,
69 false,
70 false,
71 false,
72 configuration.isEnableOutErrElements(),
73 configuration.isEnablePropertiesElement());
74 }
75
76 @Override
77 public Object clone(ClassLoader target) {
78 try {
79 Class<?> cls = ReflectionUtils.reloadClass(target, this);
80 Object clone = cls.newInstance();
81
82 cls.getMethod("setDisable", boolean.class).invoke(clone, isDisable());
83 cls.getMethod("setVersion", String.class).invoke(clone, getVersion());
84
85 return clone;
86 } catch (ReflectiveOperationException e) {
87 throw new IllegalStateException(e.getLocalizedMessage());
88 }
89 }
90 }