1 | |
package org.apache.maven.surefire.booter; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.Properties; |
23 | |
import org.apache.maven.surefire.providerapi.ProviderParameters; |
24 | |
import org.apache.maven.surefire.report.ConsoleLogger; |
25 | |
import org.apache.maven.surefire.report.DefaultDirectConsoleReporter; |
26 | |
import org.apache.maven.surefire.report.ReporterConfiguration; |
27 | |
import org.apache.maven.surefire.report.ReporterFactory; |
28 | |
import org.apache.maven.surefire.testset.DirectoryScannerParameters; |
29 | |
import org.apache.maven.surefire.testset.RunOrderParameters; |
30 | |
import org.apache.maven.surefire.testset.TestArtifactInfo; |
31 | |
import org.apache.maven.surefire.testset.TestRequest; |
32 | |
import org.apache.maven.surefire.util.DefaultDirectoryScanner; |
33 | |
import org.apache.maven.surefire.util.DefaultRunOrderCalculator; |
34 | |
import org.apache.maven.surefire.util.DirectoryScanner; |
35 | |
import org.apache.maven.surefire.util.RunOrderCalculator; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
public class BaseProviderFactory |
41 | |
implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware, TestRequestAware, |
42 | |
ProviderPropertiesAware, ProviderParameters, TestArtifactInfoAware, RunOrderParametersAware |
43 | |
{ |
44 | |
|
45 | |
private Properties providerProperties; |
46 | |
|
47 | |
private DirectoryScannerParameters directoryScannerParameters; |
48 | |
|
49 | |
private ReporterConfiguration reporterConfiguration; |
50 | |
|
51 | |
private RunOrderParameters runOrderParameters; |
52 | |
|
53 | |
private ClassLoader testClassLoader; |
54 | |
|
55 | |
private TestRequest testRequest; |
56 | |
|
57 | |
private TestArtifactInfo testArtifactInfo; |
58 | |
|
59 | 0 | private static final Integer ROOT_CHANNEl = new Integer( 0 ); |
60 | |
|
61 | |
|
62 | |
private final ReporterFactory reporterFactory; |
63 | |
|
64 | |
private final boolean insideFork; |
65 | |
|
66 | |
|
67 | |
public BaseProviderFactory( ReporterFactory reporterFactory, Boolean insideFork ) |
68 | 0 | { |
69 | 0 | this.reporterFactory = reporterFactory; |
70 | 0 | this.insideFork = insideFork.booleanValue(); |
71 | 0 | } |
72 | |
|
73 | |
public DirectoryScanner getDirectoryScanner() |
74 | |
{ |
75 | 0 | if ( directoryScannerParameters == null ) |
76 | |
{ |
77 | 0 | return null; |
78 | |
} |
79 | 0 | return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(), |
80 | |
directoryScannerParameters.getIncludes(), |
81 | |
directoryScannerParameters.getExcludes() ); |
82 | |
} |
83 | |
|
84 | |
private int getThreadCount() |
85 | |
{ |
86 | 0 | final String threadcount = (String) providerProperties.get( "threadcount" ); |
87 | 0 | return threadcount == null ? 1 : Integer.parseInt( threadcount ); |
88 | |
} |
89 | |
|
90 | |
public RunOrderCalculator getRunOrderCalculator() |
91 | |
{ |
92 | 0 | if ( directoryScannerParameters == null ) |
93 | |
{ |
94 | 0 | return null; |
95 | |
} |
96 | 0 | return new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() ); |
97 | |
} |
98 | |
|
99 | |
public ReporterFactory getReporterFactory() |
100 | |
{ |
101 | 0 | return reporterFactory; |
102 | |
} |
103 | |
|
104 | |
public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScannerParameters ) |
105 | |
{ |
106 | 0 | this.directoryScannerParameters = directoryScannerParameters; |
107 | 0 | } |
108 | |
|
109 | |
public void setReporterConfiguration( ReporterConfiguration reporterConfiguration ) |
110 | |
{ |
111 | 0 | this.reporterConfiguration = reporterConfiguration; |
112 | 0 | } |
113 | |
|
114 | |
public void setClassLoaders( ClassLoader surefireClassLoader, ClassLoader testClassLoader ) |
115 | |
{ |
116 | 0 | this.testClassLoader = testClassLoader; |
117 | 0 | } |
118 | |
|
119 | |
public ConsoleLogger getConsoleLogger() |
120 | |
{ |
121 | 0 | if ( insideFork ) |
122 | |
{ |
123 | 0 | return new ForkingRunListener( reporterConfiguration.getOriginalSystemOut(), ROOT_CHANNEl.intValue(), |
124 | |
reporterConfiguration.isTrimStackTrace().booleanValue() ); |
125 | |
} |
126 | 0 | return new DefaultDirectConsoleReporter( reporterConfiguration.getOriginalSystemOut() ); |
127 | |
} |
128 | |
|
129 | |
public void setTestRequest( TestRequest testRequest ) |
130 | |
{ |
131 | 0 | this.testRequest = testRequest; |
132 | 0 | } |
133 | |
|
134 | |
public DirectoryScannerParameters getDirectoryScannerParameters() |
135 | |
{ |
136 | 0 | return directoryScannerParameters; |
137 | |
} |
138 | |
|
139 | |
public ReporterConfiguration getReporterConfiguration() |
140 | |
{ |
141 | 0 | return reporterConfiguration; |
142 | |
} |
143 | |
|
144 | |
public TestRequest getTestRequest() |
145 | |
{ |
146 | 0 | return testRequest; |
147 | |
} |
148 | |
|
149 | |
public ClassLoader getTestClassLoader() |
150 | |
{ |
151 | 0 | return testClassLoader; |
152 | |
} |
153 | |
|
154 | |
public void setProviderProperties( Properties providerProperties ) |
155 | |
{ |
156 | 0 | this.providerProperties = providerProperties; |
157 | 0 | } |
158 | |
|
159 | |
public Properties getProviderProperties() |
160 | |
{ |
161 | 0 | return providerProperties; |
162 | |
} |
163 | |
|
164 | |
public TestArtifactInfo getTestArtifactInfo() |
165 | |
{ |
166 | 0 | return testArtifactInfo; |
167 | |
} |
168 | |
|
169 | |
public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo ) |
170 | |
{ |
171 | 0 | this.testArtifactInfo = testArtifactInfo; |
172 | 0 | } |
173 | |
|
174 | |
public void setRunOrderParameters( RunOrderParameters runOrderParameters ) |
175 | |
{ |
176 | 0 | this.runOrderParameters = runOrderParameters; |
177 | 0 | } |
178 | |
|
179 | |
} |