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.Properties;
25  import org.apache.maven.surefire.report.ReporterConfiguration;
26  import org.apache.maven.surefire.testset.DirectoryScannerParameters;
27  import org.apache.maven.surefire.testset.RunOrderParameters;
28  import org.apache.maven.surefire.testset.TestArtifactInfo;
29  import org.apache.maven.surefire.testset.TestRequest;
30  
31  /**
32   * Represents the surefire configuration that passes all the way into the provider
33   * classloader and the provider.
34   * <p/>
35   *
36   * @author Jason van Zyl
37   * @author Emmanuel Venisse
38   * @author Kristian Rosenvold
39   */
40  public class ProviderConfiguration
41  {
42      /**
43       * @noinspection UnusedDeclaration
44       */
45      public static final int TESTS_SUCCEEDED_EXIT_CODE = 0;
46  
47      public static final int TESTS_FAILED_EXIT_CODE = 255;
48  
49      public static final int NO_TESTS_EXIT_CODE = 254;
50  
51      private final DirectoryScannerParameters dirScannerParams;
52  
53      private final ReporterConfiguration reporterConfiguration;
54  
55      private final TestArtifactInfo testArtifact;
56  
57      private final TestRequest testSuiteDefinition;
58  
59      private final RunOrderParameters runOrderParameters;
60  
61      private final Properties providerProperties;
62  
63      private final boolean failIfNoTests;
64  
65      private final TypeEncodedValue forkTestSet;
66  
67      private final boolean readTestsFromInStream;
68  
69      public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters,
70                                    RunOrderParameters runOrderParameters, boolean failIfNoTests,
71                                    ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
72                                    TestRequest testSuiteDefinition, Properties providerProperties,
73                                    TypeEncodedValue typeEncodedTestSet, boolean readTestsFromInStream )
74      {
75          this.runOrderParameters = runOrderParameters;
76          this.providerProperties = providerProperties;
77          this.reporterConfiguration = reporterConfiguration;
78          this.testArtifact = testArtifact;
79          this.testSuiteDefinition = testSuiteDefinition;
80          this.dirScannerParams = directoryScannerParameters;
81          this.failIfNoTests = failIfNoTests;
82          this.forkTestSet = typeEncodedTestSet;
83          this.readTestsFromInStream = readTestsFromInStream;
84      }
85  
86  
87      public ReporterConfiguration getReporterConfiguration()
88      {
89          return reporterConfiguration;
90      }
91  
92  
93      public Boolean isFailIfNoTests()
94      {
95          return ( failIfNoTests ) ? Boolean.TRUE : Boolean.FALSE;
96      }
97  
98      public File getBaseDir()
99      {
100         return dirScannerParams.getTestClassesDirectory();
101     }
102 
103 
104     public DirectoryScannerParameters getDirScannerParams()
105     {
106         return dirScannerParams;
107     }
108 
109     public List getIncludes()
110     {
111         return dirScannerParams.getIncludes();
112     }
113 
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 Properties 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 
145     public boolean isReadTestsFromInStream()
146     {
147         return readTestsFromInStream;
148     }
149 }