View Javadoc
1   package org.apache.maven.surefire.booter;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  import java.util.List;
24  import java.util.Map;
25  
26  import org.apache.maven.surefire.api.booter.Shutdown;
27  import org.apache.maven.surefire.api.cli.CommandLineOption;
28  import org.apache.maven.surefire.api.report.ReporterConfiguration;
29  import org.apache.maven.surefire.api.testset.DirectoryScannerParameters;
30  import org.apache.maven.surefire.api.testset.RunOrderParameters;
31  import org.apache.maven.surefire.api.testset.TestArtifactInfo;
32  import org.apache.maven.surefire.api.testset.TestRequest;
33  
34  /**
35   * Represents the surefire configuration that passes all the way into the provider
36   * classloader and the provider.
37   * <br>
38   *
39   * @author Jason van Zyl
40   * @author Emmanuel Venisse
41   * @author Kristian Rosenvold
42   */
43  public class ProviderConfiguration
44  {
45      private final DirectoryScannerParameters dirScannerParams;
46  
47      private final ReporterConfiguration reporterConfiguration;
48  
49      private final TestArtifactInfo testArtifact;
50  
51      private final TestRequest testSuiteDefinition;
52  
53      private final RunOrderParameters runOrderParameters;
54  
55      private final Map<String, String> providerProperties;
56  
57      private final TypeEncodedValue forkTestSet;
58  
59      private final boolean readTestsFromInStream;
60  
61      private final List<CommandLineOption> mainCliOptions;
62  
63      private final int skipAfterFailureCount;
64  
65      private final Shutdown shutdown;
66  
67      private final Integer systemExitTimeout;
68  
69      @SuppressWarnings( "checkstyle:parameternumber" )
70      public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
71                                    RunOrderParameters runOrderParameters,
72                                    ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
73                                    TestRequest testSuiteDefinition, Map<String, String> providerProperties,
74                                    TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream,
75                                    List<CommandLineOption> mainCliOptions, int skipAfterFailureCount,
76                                    Shutdown shutdown, Integer systemExitTimeout )
77      {
78          this.runOrderParameters = runOrderParameters;
79          this.providerProperties = providerProperties;
80          this.reporterConfiguration = reporterConfiguration;
81          this.testArtifact = testArtifact;
82          this.testSuiteDefinition = testSuiteDefinition;
83          this.dirScannerParams = directoryScannerParameters;
84          this.forkTestSet = typeEncodedTestSet;
85          this.readTestsFromInStream = readTestsFromInStream;
86          this.mainCliOptions = mainCliOptions;
87          this.skipAfterFailureCount = skipAfterFailureCount;
88          this.shutdown = shutdown;
89          this.systemExitTimeout = systemExitTimeout;
90      }
91  
92      public ReporterConfiguration getReporterConfiguration()
93      {
94          return reporterConfiguration;
95      }
96  
97      public File getBaseDir()
98      {
99          return dirScannerParams.getTestClassesDirectory();
100     }
101 
102     public DirectoryScannerParameters getDirScannerParams()
103     {
104         return dirScannerParams;
105     }
106 
107     @Deprecated
108     public List getIncludes()
109     {
110         return dirScannerParams.getIncludes();
111     }
112 
113     @Deprecated
114     public List getExcludes()
115     {
116         return dirScannerParams.getExcludes();
117     }
118 
119     public TestArtifactInfo getTestArtifact()
120     {
121         return testArtifact;
122     }
123 
124     public TestRequest getTestSuiteDefinition()
125     {
126         return testSuiteDefinition;
127     }
128 
129     public Map<String, String> getProviderProperties()
130     {
131         return providerProperties;
132     }
133 
134     public TypeEncodedValue getTestForFork()
135     {
136         return forkTestSet;
137     }
138 
139     public RunOrderParameters getRunOrderParameters()
140     {
141         return runOrderParameters;
142     }
143 
144     public boolean isReadTestsFromInStream()
145     {
146         return readTestsFromInStream;
147     }
148 
149     public List<CommandLineOption> getMainCliOptions()
150     {
151         return mainCliOptions;
152     }
153 
154     public int getSkipAfterFailureCount()
155     {
156         return skipAfterFailureCount;
157     }
158 
159     public Shutdown getShutdown()
160     {
161         return shutdown;
162     }
163 
164     public Integer getSystemExitTimeout()
165     {
166         return systemExitTimeout;
167     }
168 
169     public long systemExitTimeout( long fallback )
170     {
171         return systemExitTimeout == null || systemExitTimeout < 0 ? fallback : systemExitTimeout;
172     }
173 }