Coverage Report - org.apache.maven.surefire.booter.BaseProviderFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseProviderFactory
0%
0/38
0%
0/8
1,35
 
 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.util.Properties;
 23  
 import org.apache.maven.surefire.providerapi.ProviderParameters;
 24  
 import org.apache.maven.surefire.report.ConsoleLogger;
 25  
 import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
 26  
 import org.apache.maven.surefire.report.ReporterConfiguration;
 27  
 import org.apache.maven.surefire.report.ReporterFactory;
 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  
 import org.apache.maven.surefire.util.DefaultDirectoryScanner;
 33  
 import org.apache.maven.surefire.util.DefaultRunOrderCalculator;
 34  
 import org.apache.maven.surefire.util.DefaultScanResult;
 35  
 import org.apache.maven.surefire.util.DirectoryScanner;
 36  
 import org.apache.maven.surefire.util.RunOrderCalculator;
 37  
 import org.apache.maven.surefire.util.ScanResult;
 38  
 
 39  
 /**
 40  
  * @author Kristian Rosenvold
 41  
  */
 42  
 public class BaseProviderFactory
 43  
     implements DirectoryScannerParametersAware, ReporterConfigurationAware, SurefireClassLoadersAware, TestRequestAware,
 44  
     ProviderPropertiesAware, ProviderParameters, TestArtifactInfoAware, RunOrderParametersAware
 45  
 {
 46  
 
 47  
     private Properties providerProperties;
 48  
 
 49  
     private DirectoryScannerParameters directoryScannerParameters;
 50  
 
 51  
     private ReporterConfiguration reporterConfiguration;
 52  
 
 53  
     private RunOrderParameters runOrderParameters;
 54  
 
 55  
     private ClassLoader testClassLoader;
 56  
 
 57  
     private TestRequest testRequest;
 58  
 
 59  
     private TestArtifactInfo testArtifactInfo;
 60  
 
 61  0
     private static final Integer ROOT_CHANNEl = new Integer( 0 );
 62  
 
 63  
 
 64  
     private final ReporterFactory reporterFactory;
 65  
 
 66  
     private final boolean insideFork;
 67  
 
 68  
 
 69  
     public BaseProviderFactory( ReporterFactory reporterFactory, Boolean insideFork )
 70  0
     {
 71  0
         this.reporterFactory = reporterFactory;
 72  0
         this.insideFork = insideFork.booleanValue();
 73  0
     }
 74  
 
 75  
     public DirectoryScanner getDirectoryScanner()
 76  
     {
 77  0
         if ( directoryScannerParameters == null )
 78  
         {
 79  0
             return null;
 80  
         }
 81  0
         return new DefaultDirectoryScanner( directoryScannerParameters.getTestClassesDirectory(),
 82  
                                             directoryScannerParameters.getIncludes(),
 83  
                                             directoryScannerParameters.getExcludes(),
 84  
                                             directoryScannerParameters.getSpecificTests() );
 85  
     }
 86  
 
 87  
     public ScanResult getScanResult()
 88  
     {
 89  0
         return DefaultScanResult.from( providerProperties );
 90  
     }
 91  
 
 92  
     private int getThreadCount()
 93  
     {
 94  0
         final String threadcount = (String) providerProperties.get( ProviderParameterNames.THREADCOUNT_PROP );
 95  0
         return threadcount == null ? 1 : Integer.parseInt( threadcount );
 96  
     }
 97  
 
 98  
     public RunOrderCalculator getRunOrderCalculator()
 99  
     {
 100  0
         if ( directoryScannerParameters == null )
 101  
         {
 102  0
             return null;
 103  
         }
 104  0
         return new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() );
 105  
     }
 106  
 
 107  
     public ReporterFactory getReporterFactory()
 108  
     {
 109  0
         return reporterFactory;
 110  
     }
 111  
 
 112  
     public void setDirectoryScannerParameters( DirectoryScannerParameters directoryScannerParameters )
 113  
     {
 114  0
         this.directoryScannerParameters = directoryScannerParameters;
 115  0
     }
 116  
 
 117  
     public void setReporterConfiguration( ReporterConfiguration reporterConfiguration )
 118  
     {
 119  0
         this.reporterConfiguration = reporterConfiguration;
 120  0
     }
 121  
 
 122  
     public void setClassLoaders( ClassLoader surefireClassLoader, ClassLoader testClassLoader )
 123  
     {
 124  0
         this.testClassLoader = testClassLoader;
 125  0
     }
 126  
 
 127  
     public ConsoleLogger getConsoleLogger()
 128  
     {
 129  0
         if ( insideFork )
 130  
         {
 131  0
             return new ForkingRunListener( reporterConfiguration.getOriginalSystemOut(), ROOT_CHANNEl.intValue(),
 132  
                                            reporterConfiguration.isTrimStackTrace().booleanValue() );
 133  
         }
 134  0
         return new DefaultDirectConsoleReporter( reporterConfiguration.getOriginalSystemOut() );
 135  
     }
 136  
 
 137  
     public void setTestRequest( TestRequest testRequest )
 138  
     {
 139  0
         this.testRequest = testRequest;
 140  0
     }
 141  
 
 142  
     public DirectoryScannerParameters getDirectoryScannerParameters()
 143  
     {
 144  0
         return directoryScannerParameters;
 145  
     }
 146  
 
 147  
     public ReporterConfiguration getReporterConfiguration()
 148  
     {
 149  0
         return reporterConfiguration;
 150  
     }
 151  
 
 152  
     public TestRequest getTestRequest()
 153  
     {
 154  0
         return testRequest;
 155  
     }
 156  
 
 157  
     public ClassLoader getTestClassLoader()
 158  
     {
 159  0
         return testClassLoader;
 160  
     }
 161  
 
 162  
     public void setProviderProperties( Properties providerProperties )
 163  
     {
 164  0
         this.providerProperties = providerProperties;
 165  0
     }
 166  
 
 167  
     public Properties getProviderProperties()
 168  
     {
 169  0
         return providerProperties;
 170  
     }
 171  
 
 172  
     public TestArtifactInfo getTestArtifactInfo()
 173  
     {
 174  0
         return testArtifactInfo;
 175  
     }
 176  
 
 177  
     public void setTestArtifactInfo( TestArtifactInfo testArtifactInfo )
 178  
     {
 179  0
         this.testArtifactInfo = testArtifactInfo;
 180  0
     }
 181  
 
 182  
     public void setRunOrderParameters( RunOrderParameters runOrderParameters )
 183  
     {
 184  0
         this.runOrderParameters = runOrderParameters;
 185  0
     }
 186  
 
 187  
 }