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 org.apache.maven.surefire.report.ReporterConfiguration;
23 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
24 import org.apache.maven.surefire.testset.TestArtifactInfo;
25 import org.apache.maven.surefire.testset.TestRequest;
26
27 import java.io.File;
28 import java.util.List;
29 import java.util.Properties;
30
31
32
33
34
35
36
37
38
39
40
41 public class ProviderConfiguration
42 {
43
44
45
46 public static final int TESTS_SUCCEEDED_EXIT_CODE = 0;
47
48 public static final int TESTS_FAILED_EXIT_CODE = 255;
49
50 public static final int NO_TESTS_EXIT_CODE = 254;
51
52 private final DirectoryScannerParameters dirScannerParams;
53
54 private final ReporterConfiguration reporterConfiguration;
55
56 private final TestArtifactInfo testArtifact;
57
58 private final TestRequest testSuiteDefinition;
59
60 private final Properties providerProperties;
61
62 private final boolean failIfNoTests;
63
64 private final Object forkTestSet;
65
66 public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters, boolean failIfNoTests,
67 ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
68 TestRequest testSuiteDefinition, Properties providerProperties, Object forkTestSet )
69 {
70 this.providerProperties = providerProperties;
71 this.reporterConfiguration = reporterConfiguration;
72 this.testArtifact = testArtifact;
73 this.testSuiteDefinition = testSuiteDefinition;
74 this.dirScannerParams = directoryScannerParameters;
75 this.failIfNoTests = failIfNoTests;
76 this.forkTestSet = forkTestSet;
77 }
78
79
80 public ReporterConfiguration getReporterConfiguration()
81 {
82 return reporterConfiguration;
83 }
84
85
86 public Boolean isFailIfNoTests()
87 {
88 return ( failIfNoTests ) ? Boolean.TRUE : Boolean.FALSE;
89 }
90
91 public File getBaseDir()
92 {
93 return dirScannerParams.getTestClassesDirectory();
94 }
95
96
97 public DirectoryScannerParameters getDirScannerParams()
98 {
99 return dirScannerParams;
100 }
101
102 public Object[] getDirScannerParamsArray()
103 {
104 if ( dirScannerParams == null )
105 {
106 return null;
107 }
108 return new Object[]{ dirScannerParams.getTestClassesDirectory(), dirScannerParams.getIncludes(),
109 dirScannerParams.getExcludes() };
110 }
111
112 public List getIncludes()
113 {
114 return dirScannerParams.getIncludes();
115 }
116
117 public List getExcludes()
118 {
119 return dirScannerParams.getExcludes();
120 }
121
122 public TestArtifactInfo getTestArtifact()
123 {
124 return testArtifact;
125 }
126
127 public TestRequest getTestSuiteDefinition()
128 {
129 return testSuiteDefinition;
130 }
131
132 public Properties getProviderProperties()
133 {
134 return providerProperties;
135 }
136
137 public Object getTestForFork()
138 {
139 return forkTestSet;
140 }
141
142 public String getTestForForkString()
143 {
144 if ( forkTestSet instanceof File )
145 {
146 return forkTestSet.toString();
147 }
148 return (String) forkTestSet;
149 }
150
151 public boolean isSurefireForkReturnCode( int returnCode )
152 {
153 return TESTS_SUCCEEDED_EXIT_CODE == returnCode ||
154 NO_TESTS_EXIT_CODE == returnCode ||
155 TESTS_FAILED_EXIT_CODE == returnCode;
156
157 }
158
159
160 }