1 package org.apache.maven.plugin.surefire.extensions.junit5;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.surefire.extensions.DefaultStatelessReportMojoConfiguration;
23 import org.apache.maven.plugin.surefire.extensions.SurefireStatelessReporter;
24 import org.apache.maven.plugin.surefire.report.StatelessXmlReporter;
25 import org.apache.maven.plugin.surefire.report.TestSetStats;
26 import org.apache.maven.plugin.surefire.report.WrappedReportEntry;
27 import org.apache.maven.surefire.extensions.StatelessReportEventListener;
28
29
30
31
32
33
34
35
36 public class JUnit5Xml30StatelessReporter
37 extends SurefireStatelessReporter
38 {
39
40
41
42
43
44 private boolean usePhrasedFileName;
45
46
47
48
49
50
51 private boolean usePhrasedTestSuiteClassName;
52
53
54
55
56
57
58 private boolean usePhrasedTestCaseClassName;
59
60
61
62
63
64
65 private boolean usePhrasedTestCaseMethodName;
66
67 public boolean getUsePhrasedFileName()
68 {
69 return usePhrasedFileName;
70 }
71
72 public void setUsePhrasedFileName( boolean usePhrasedFileName )
73 {
74 this.usePhrasedFileName = usePhrasedFileName;
75 }
76
77 public boolean getUsePhrasedTestSuiteClassName()
78 {
79 return usePhrasedTestSuiteClassName;
80 }
81
82 public void setUsePhrasedTestSuiteClassName( boolean usePhrasedTestSuiteClassName )
83 {
84 this.usePhrasedTestSuiteClassName = usePhrasedTestSuiteClassName;
85 }
86
87 public boolean getUsePhrasedTestCaseClassName()
88 {
89 return usePhrasedTestCaseClassName;
90 }
91
92 public void setUsePhrasedTestCaseClassName( boolean usePhrasedTestCaseClassName )
93 {
94 this.usePhrasedTestCaseClassName = usePhrasedTestCaseClassName;
95 }
96
97 public boolean getUsePhrasedTestCaseMethodName()
98 {
99 return usePhrasedTestCaseMethodName;
100 }
101
102 public void setUsePhrasedTestCaseMethodName( boolean usePhrasedTestCaseMethodName )
103 {
104 this.usePhrasedTestCaseMethodName = usePhrasedTestCaseMethodName;
105 }
106
107 @Override
108 public StatelessReportEventListener<WrappedReportEntry, TestSetStats> createListener(
109 DefaultStatelessReportMojoConfiguration configuration )
110 {
111 return new StatelessXmlReporter( configuration.getReportsDirectory(),
112 configuration.getReportNameSuffix(),
113 configuration.isTrimStackTrace(),
114 configuration.getRerunFailingTestsCount(),
115 configuration.getTestClassMethodRunHistory(),
116 configuration.getXsdSchemaLocation(),
117 getVersion(),
118 getUsePhrasedFileName(),
119 getUsePhrasedTestSuiteClassName(),
120 getUsePhrasedTestCaseClassName(),
121 getUsePhrasedTestCaseMethodName() );
122 }
123
124 @Override
125 public Object clone( ClassLoader target )
126 {
127 try
128 {
129 Object clone = super.clone( target );
130
131 Class<?> cls = clone.getClass();
132 cls.getMethod( "setUsePhrasedFileName", boolean.class )
133 .invoke( clone, getUsePhrasedFileName() );
134 cls.getMethod( "setUsePhrasedTestSuiteClassName", boolean.class )
135 .invoke( clone, getUsePhrasedTestSuiteClassName() );
136 cls.getMethod( "setUsePhrasedTestCaseClassName", boolean.class )
137 .invoke( clone, getUsePhrasedTestCaseClassName() );
138 cls.getMethod( "setUsePhrasedTestCaseMethodName", boolean.class )
139 .invoke( clone, getUsePhrasedTestCaseMethodName() );
140
141 return clone;
142 }
143 catch ( ReflectiveOperationException e )
144 {
145 throw new IllegalStateException( e.getLocalizedMessage() );
146 }
147 }
148
149 @Override
150 public String toString()
151 {
152 return "JUnit5Xml30StatelessReporter{"
153 + "version=" + getVersion()
154 + ", disable=" + isDisable()
155 + ", usePhrasedFileName=" + getUsePhrasedFileName()
156 + ", usePhrasedTestSuiteClassName=" + getUsePhrasedTestSuiteClassName()
157 + ", usePhrasedTestCaseClassName=" + getUsePhrasedTestCaseClassName()
158 + ", usePhrasedTestCaseMethodName=" + getUsePhrasedTestCaseMethodName()
159 + '}';
160 }
161 }