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.plugin.surefire.report.FileReporterFactory;
24 import org.apache.maven.surefire.providerapi.ProviderParameters;
25 import org.apache.maven.surefire.report.ConsoleLogger;
26 import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
27 import org.apache.maven.surefire.report.ReporterConfiguration;
28 import org.apache.maven.surefire.report.ReporterFactory;
29 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
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.DirectoryScanner;
34
35
36
37
38 public class BaseProviderFactory
39 implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware, TestRequestAware,
40 ProviderPropertiesAware, ProviderParameters, TestArtifactInfoAware
41 {
42 private Properties providerProperties;
43
44 private DirectoryScannerParameters directoryScannerParameters;
45
46 private ReporterConfiguration reporterConfiguration;
47
48 private ClassLoader testClassLoader;
49
50 private TestRequest testRequest;
51
52 private TestArtifactInfo testArtifactInfo;
53
54 private static final Integer ROOT_CHANNEl = new Integer( 0 );
55
56
57 private final ReporterFactory reporterFactory;
58
59 public BaseProviderFactory( ReporterFactory reporterFactory )
60 {
61 this.reporterFactory = reporterFactory;
62 }
63
64 public DirectoryScanner getDirectoryScanner()
65 {
66 if ( directoryScannerParameters == null )
67 {
68 return null;
69 }
70 return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
71 directoryScannerParameters.getIncludes(),
72 directoryScannerParameters.getExcludes(),
73 directoryScannerParameters.getRunOrder() );
74 }
75
76 public ReporterFactory getReporterFactory()
77 {
78 return reporterFactory;
79 }
80
81 public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScannerParameters )
82 {
83 this.directoryScannerParameters = directoryScannerParameters;
84 }
85
86 public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
87 {
88 this.reporterConfiguration = reporterConfiguration;
89 }
90
91 public void setClassLoaders( ClassLoader surefireClassLoader, ClassLoader testClassLoader )
92 {
93 this.testClassLoader = testClassLoader;
94 }
95
96 public ConsoleLogger getConsoleLogger()
97 {
98
99 if ( getReporterFactory() instanceof FileReporterFactory )
100 {
101 return new DefaultDirectConsoleReporter( reporterConfiguration.getOriginalSystemOut() );
102 }
103 return new ForkingRunListener( reporterConfiguration.getOriginalSystemOut(), ROOT_CHANNEl.intValue(),
104 reporterConfiguration.isTrimStackTrace().booleanValue() );
105 }
106
107 public void setTestRequest( TestRequest testRequest )
108 {
109 this.testRequest = testRequest;
110 }
111
112 public DirectoryScannerParameters getDirectoryScannerParameters()
113 {
114 return directoryScannerParameters;
115 }
116
117 public ReporterConfiguration getReporterConfiguration()
118 {
119 return reporterConfiguration;
120 }
121
122 public TestRequest getTestRequest()
123 {
124 return testRequest;
125 }
126
127 public ClassLoader getTestClassLoader()
128 {
129 return testClassLoader;
130 }
131
132 public void setProviderProperties( Properties providerProperties )
133 {
134 this.providerProperties = providerProperties;
135 }
136
137 public Properties getProviderProperties()
138 {
139 return providerProperties;
140 }
141
142 public TestArtifactInfo getTestArtifactInfo()
143 {
144 return testArtifactInfo;
145 }
146
147 public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
148 {
149 this.testArtifactInfo = testArtifactInfo;
150 }
151
152 }