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 boolean failIfNoTests;
58  
59      private final TypeEncodedValue forkTestSet;
60  
61      private final boolean readTestsFromInStream;
62  
63      private final List<CommandLineOption> mainCliOptions;
64  
65      private final int skipAfterFailureCount;
66  
67      private final Shutdown shutdown;
68  
69      private final Integer systemExitTimeout;
70  
71      @SuppressWarnings( "checkstyle:parameternumber" )
72      public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
73                                    RunOrderParameters runOrderParameters, boolean failIfNoTests,
74                                    ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
75                                    TestRequest testSuiteDefinition, Map<String, String> providerProperties,
76                                    TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream,
77                                    List<CommandLineOption> mainCliOptions, int skipAfterFailureCount,
78                                    Shutdown shutdown, Integer systemExitTimeout )
79      {
80          this.runOrderParameters = runOrderParameters;
81          this.providerProperties = providerProperties;
82          this.reporterConfiguration = reporterConfiguration;
83          this.testArtifact = testArtifact;
84          this.testSuiteDefinition = testSuiteDefinition;
85          this.dirScannerParams = directoryScannerParameters;
86          this.failIfNoTests = failIfNoTests;
87          this.forkTestSet = typeEncodedTestSet;
88          this.readTestsFromInStream = readTestsFromInStream;
89          this.mainCliOptions = mainCliOptions;
90          this.skipAfterFailureCount = skipAfterFailureCount;
91          this.shutdown = shutdown;
92          this.systemExitTimeout = systemExitTimeout;
93      }
94  
95      public ReporterConfiguration getReporterConfiguration()
96      {
97          return reporterConfiguration;
98      }
99  
100     public boolean isFailIfNoTests()
101     {
102         return failIfNoTests;
103     }
104 
105     public File getBaseDir()
106     {
107         return dirScannerParams.getTestClassesDirectory();
108     }
109 
110     public DirectoryScannerParameters getDirScannerParams()
111     {
112         return dirScannerParams;
113     }
114 
115     @Deprecated
116     public List getIncludes()
117     {
118         return dirScannerParams.getIncludes();
119     }
120 
121     @Deprecated
122     public List getExcludes()
123     {
124         return dirScannerParams.getExcludes();
125     }
126 
127     public TestArtifactInfo getTestArtifact()
128     {
129         return testArtifact;
130     }
131 
132     public TestRequest getTestSuiteDefinition()
133     {
134         return testSuiteDefinition;
135     }
136 
137     public Map<String, String> getProviderProperties()
138     {
139         return providerProperties;
140     }
141 
142     public TypeEncodedValue getTestForFork()
143     {
144         return forkTestSet;
145     }
146 
147     public RunOrderParameters getRunOrderParameters()
148     {
149         return runOrderParameters;
150     }
151 
152     public boolean isReadTestsFromInStream()
153     {
154         return readTestsFromInStream;
155     }
156 
157     public List<CommandLineOption> getMainCliOptions()
158     {
159         return mainCliOptions;
160     }
161 
162     public int getSkipAfterFailureCount()
163     {
164         return skipAfterFailureCount;
165     }
166 
167     public Shutdown getShutdown()
168     {
169         return shutdown;
170     }
171 
172     public Integer getSystemExitTimeout()
173     {
174         return systemExitTimeout;
175     }
176 
177     public long systemExitTimeout( long fallback )
178     {
179         return systemExitTimeout == null || systemExitTimeout < 0 ? fallback : systemExitTimeout;
180     }
181 }