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.cli.CommandLineOption;
27  import org.apache.maven.surefire.report.ReporterConfiguration;
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  
33  /**
34   * Represents the surefire configuration that passes all the way into the provider
35   * classloader and the provider.
36   * <br>
37   *
38   * @author Jason van Zyl
39   * @author Emmanuel Venisse
40   * @author Kristian Rosenvold
41   */
42  public class ProviderConfiguration
43  {
44      private final DirectoryScannerParameters dirScannerParams;
45  
46      private final ReporterConfiguration reporterConfiguration;
47  
48      private final TestArtifactInfo testArtifact;
49  
50      private final TestRequest testSuiteDefinition;
51  
52      private final RunOrderParameters runOrderParameters;
53  
54      private final Map<String, String> providerProperties;
55  
56      private final boolean failIfNoTests;
57  
58      private final TypeEncodedValue forkTestSet;
59  
60      private final boolean readTestsFromInStream;
61  
62      private final List<CommandLineOption> mainCliOptions;
63  
64      private final int skipAfterFailureCount;
65  
66      private final Shutdown shutdown;
67  
68      private final Integer systemExitTimeout;
69  
70      @SuppressWarnings( "checkstyle:parameternumber" )
71      public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
72                                    RunOrderParameters runOrderParameters, boolean failIfNoTests,
73                                    ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
74                                    TestRequest testSuiteDefinition, Map<String, String> providerProperties,
75                                    TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream,
76                                    List<CommandLineOption> mainCliOptions, int skipAfterFailureCount,
77                                    Shutdown shutdown, Integer systemExitTimeout )
78      {
79          this.runOrderParameters = runOrderParameters;
80          this.providerProperties = providerProperties;
81          this.reporterConfiguration = reporterConfiguration;
82          this.testArtifact = testArtifact;
83          this.testSuiteDefinition = testSuiteDefinition;
84          this.dirScannerParams = directoryScannerParameters;
85          this.failIfNoTests = failIfNoTests;
86          this.forkTestSet = typeEncodedTestSet;
87          this.readTestsFromInStream = readTestsFromInStream;
88          this.mainCliOptions = mainCliOptions;
89          this.skipAfterFailureCount = skipAfterFailureCount;
90          this.shutdown = shutdown;
91          this.systemExitTimeout = systemExitTimeout;
92      }
93  
94      public ReporterConfiguration getReporterConfiguration()
95      {
96          return reporterConfiguration;
97      }
98  
99  
100     public boolean isFailIfNoTests()
101     {
102         return failIfNoTests;
103     }
104 
105     public File getBaseDir()
106     {
107         return dirScannerParams.getTestClassesDirectory();
108     }
109 
110 
111     public DirectoryScannerParameters getDirScannerParams()
112     {
113         return dirScannerParams;
114     }
115 
116     @Deprecated
117     public List getIncludes()
118     {
119         return dirScannerParams.getIncludes();
120     }
121 
122     @Deprecated
123     public List getExcludes()
124     {
125         return dirScannerParams.getExcludes();
126     }
127 
128     public TestArtifactInfo getTestArtifact()
129     {
130         return testArtifact;
131     }
132 
133     public TestRequest getTestSuiteDefinition()
134     {
135         return testSuiteDefinition;
136     }
137 
138     public Map<String, String> getProviderProperties()
139     {
140         return providerProperties;
141     }
142 
143     public TypeEncodedValue getTestForFork()
144     {
145         return forkTestSet;
146     }
147 
148     public RunOrderParameters getRunOrderParameters()
149     {
150         return runOrderParameters;
151     }
152 
153     public boolean isReadTestsFromInStream()
154     {
155         return readTestsFromInStream;
156     }
157 
158     public List<CommandLineOption> getMainCliOptions()
159     {
160         return mainCliOptions;
161     }
162 
163     public int getSkipAfterFailureCount()
164     {
165         return skipAfterFailureCount;
166     }
167 
168     public Shutdown getShutdown()
169     {
170         return shutdown;
171     }
172 
173     public Integer getSystemExitTimeout()
174     {
175         return systemExitTimeout;
176     }
177 
178     public long systemExitTimeout( long fallback )
179     {
180         return systemExitTimeout == null || systemExitTimeout < 0 ? fallback : systemExitTimeout;
181     }
182 }