1 | |
package org.apache.maven.plugin.surefire; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.io.File; |
23 | |
import java.lang.reflect.Constructor; |
24 | |
import org.apache.maven.plugin.surefire.report.FileReporterFactory; |
25 | |
import org.apache.maven.surefire.booter.StartupReportConfiguration; |
26 | |
import org.apache.maven.surefire.util.ReflectionUtils; |
27 | |
import org.apache.maven.surefire.util.SurefireReflectionException; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
public class CommonReflector |
33 | |
{ |
34 | |
private final Class startupReportConfiguration; |
35 | |
|
36 | |
private final ClassLoader surefireClassLoader; |
37 | |
|
38 | |
public CommonReflector( ClassLoader surefireClassLoader ) |
39 | 0 | { |
40 | 0 | this.surefireClassLoader = surefireClassLoader; |
41 | |
|
42 | |
try |
43 | |
{ |
44 | 0 | startupReportConfiguration = surefireClassLoader.loadClass( StartupReportConfiguration.class.getName() ); |
45 | |
} |
46 | 0 | catch ( ClassNotFoundException e ) |
47 | |
{ |
48 | 0 | throw new SurefireReflectionException( e ); |
49 | 0 | } |
50 | 0 | } |
51 | |
|
52 | |
public Object createReportingReporterFactory( StartupReportConfiguration startupReportConfiguration ) |
53 | |
{ |
54 | 0 | Class[] args = new Class[]{ this.startupReportConfiguration }; |
55 | 0 | Object src = createStartupReportConfiguration( startupReportConfiguration ); |
56 | 0 | Object[] params = new Object[]{ src }; |
57 | 0 | return ReflectionUtils.instantiateObject( FileReporterFactory.class.getName(), args, params, |
58 | |
surefireClassLoader ); |
59 | |
} |
60 | |
|
61 | |
|
62 | |
Object createStartupReportConfiguration( StartupReportConfiguration reporterConfiguration ) |
63 | |
{ |
64 | 0 | Constructor constructor = ReflectionUtils.getConstructor( this.startupReportConfiguration, |
65 | |
new Class[]{ boolean.class, boolean.class, |
66 | |
String.class, boolean.class, boolean.class, |
67 | |
File.class, boolean.class, String.class, |
68 | |
String.class, boolean.class } ); |
69 | |
|
70 | 0 | final Object[] params = |
71 | |
{ new Boolean( reporterConfiguration.isUseFile() ), new Boolean( reporterConfiguration.isPrintSummary() ), |
72 | |
reporterConfiguration.getReportFormat(), |
73 | |
new Boolean( reporterConfiguration.isRedirectTestOutputToFile() ), |
74 | |
new Boolean( reporterConfiguration.isDisableXmlReport() ), reporterConfiguration.getReportsDirectory(), |
75 | |
new Boolean( reporterConfiguration.isTrimStackTrace() ), reporterConfiguration.getReportNameSuffix(), |
76 | |
reporterConfiguration.getConfigurationHash(), |
77 | |
Boolean.valueOf( reporterConfiguration.isRequiresRunHistory() ) }; |
78 | 0 | return ReflectionUtils.newInstance( constructor, params ); |
79 | |
} |
80 | |
|
81 | |
} |