org.apache.maven.surefire.booter
Class SurefireBooter

java.lang.Object
  extended by org.apache.maven.surefire.booter.SurefireBooter

public class SurefireBooter
extends java.lang.Object

Version:
$Id: SurefireBooter.java 510866 2007-02-23 08:13:49Z brett $
Author:
Jason van Zyl, Emmanuel Venisse

Field Summary
private static java.lang.reflect.Method assertionStatusMethod
           
private  boolean childDelegation
          Deprecated. because the IsolatedClassLoader is really isolated - no parent.
private  java.util.List classPathUrls
           
private  ForkConfiguration forkConfiguration
           
private  boolean redirectTestOutputToFile
           
private  java.util.List reports
           
private  java.io.File reportsDirectory
           
private  java.util.List surefireBootClassPathUrls
           
private  java.util.List surefireClassPathUrls
           
private static int TESTS_FAILED_EXIT_CODE
           
private static int TESTS_SUCCEEDED_EXIT_CODE
           
private  java.util.List testSuites
           
private  boolean useSystemClassLoader
           
 
Constructor Summary
SurefireBooter()
           
 
Method Summary
 void addClassPathUrl(java.lang.String path)
           
private  void addPropertiesForTypeHolder(java.util.List typeHolderList, java.util.Properties properties, java.lang.String propertyPrefix)
           
 void addReport(java.lang.String report)
           
 void addReport(java.lang.String report, java.lang.Object[] constructorParams)
           
 void addSurefireBootClassPathUrl(java.lang.String path)
           
 void addSurefireClassPathUrl(java.lang.String path)
           
 void addTestSuite(java.lang.String suiteClassName, java.lang.Object[] constructorParams)
           
private static java.lang.Object[] constructParamObjects(java.lang.String paramProperty, java.lang.String typeProperty)
           
private static java.lang.ClassLoader createClassLoader(java.util.List classPathUrls, java.lang.ClassLoader parent, boolean assertionsEnabled)
           
private static java.lang.ClassLoader createClassLoader(java.util.List classPathUrls, java.lang.ClassLoader parent, boolean childDelegation, boolean assertionsEnabled)
           
private  boolean fork(java.util.Properties properties, boolean showHeading, boolean showFooter)
           
private  boolean forkSuite(java.lang.Object[] testSuite, java.lang.String testSet, boolean showHeading, boolean showFooter, java.util.Properties properties)
           
private  boolean forkSuites(java.util.List testSuites, boolean showHeading, boolean showFooter)
           
private  org.codehaus.plexus.util.cli.StreamConsumer getForkingStreamConsumer(boolean showHeading, boolean showFooter, boolean redirectTestOutputToFile)
           
 java.io.File getReportsDirectory()
          Get the directory where reports will be saved
private  java.util.Map getTestSets(java.lang.Object[] testSuite, java.lang.ClassLoader testsClassLoader, java.lang.ClassLoader surefireClassLoader)
           
private static java.util.Properties loadProperties(java.io.File file)
           
static void main(java.lang.String[] args)
          This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and then calls the Surefire class' run method.
private static java.util.List processStringList(java.lang.String stringList)
           
 boolean run()
           
private  boolean runSuitesForkOnce()
           
private  boolean runSuitesForkPerTestSet()
           
private  boolean runSuitesInProcess()
           
private  boolean runSuitesInProcess(java.lang.String testSet, java.util.Properties results)
           
 void setChildDelegation(boolean childDelegation)
           
 void setForkConfiguration(ForkConfiguration forkConfiguration)
           
private  void setForkProperties(java.util.List testSuites, java.util.Properties properties)
           
 void setRedirectTestOutputToFile(boolean redirectTestOutputToFile)
          When forking, setting this to true will make the test output to be saved in a file instead of showing it on the standard output
 void setReportsDirectory(java.io.File reportsDirectory)
          Set the directory where reports will be saved
private static void setSystemProperties(java.io.File file)
           
 void setUseSystemClassLoader(boolean useSystemClassLoader)
           
private  void writePropertiesFile(java.io.File file, java.lang.String name, java.util.Properties properties)
           
private  java.io.File writePropertiesFile(java.lang.String name, java.util.Properties properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reports

private java.util.List reports

classPathUrls

private java.util.List classPathUrls

surefireClassPathUrls

private java.util.List surefireClassPathUrls

surefireBootClassPathUrls

private java.util.List surefireBootClassPathUrls

testSuites

private java.util.List testSuites

redirectTestOutputToFile

private boolean redirectTestOutputToFile

useSystemClassLoader

private boolean useSystemClassLoader

forkConfiguration

private ForkConfiguration forkConfiguration

TESTS_SUCCEEDED_EXIT_CODE

private static final int TESTS_SUCCEEDED_EXIT_CODE
See Also:
Constant Field Values

TESTS_FAILED_EXIT_CODE

private static final int TESTS_FAILED_EXIT_CODE
See Also:
Constant Field Values

assertionStatusMethod

private static java.lang.reflect.Method assertionStatusMethod

childDelegation

private boolean childDelegation
Deprecated. because the IsolatedClassLoader is really isolated - no parent.

reportsDirectory

private java.io.File reportsDirectory
Constructor Detail

SurefireBooter

public SurefireBooter()
Method Detail

addReport

public void addReport(java.lang.String report)

addReport

public void addReport(java.lang.String report,
                      java.lang.Object[] constructorParams)

addTestSuite

public void addTestSuite(java.lang.String suiteClassName,
                         java.lang.Object[] constructorParams)

addClassPathUrl

public void addClassPathUrl(java.lang.String path)

addSurefireClassPathUrl

public void addSurefireClassPathUrl(java.lang.String path)

addSurefireBootClassPathUrl

public void addSurefireBootClassPathUrl(java.lang.String path)

setRedirectTestOutputToFile

public void setRedirectTestOutputToFile(boolean redirectTestOutputToFile)
When forking, setting this to true will make the test output to be saved in a file instead of showing it on the standard output

Parameters:
redirectTestOutputToFile -

setReportsDirectory

public void setReportsDirectory(java.io.File reportsDirectory)
Set the directory where reports will be saved

Parameters:
reportsDirectory - the directory

getReportsDirectory

public java.io.File getReportsDirectory()
Get the directory where reports will be saved


setForkConfiguration

public void setForkConfiguration(ForkConfiguration forkConfiguration)

setUseSystemClassLoader

public void setUseSystemClassLoader(boolean useSystemClassLoader)

run

public boolean run()
            throws SurefireBooterForkException,
                   SurefireExecutionException
Throws:
SurefireBooterForkException
SurefireExecutionException

runSuitesInProcess

private boolean runSuitesInProcess(java.lang.String testSet,
                                   java.util.Properties results)
                            throws SurefireExecutionException
Throws:
SurefireExecutionException

runSuitesInProcess

private boolean runSuitesInProcess()
                            throws SurefireExecutionException
Throws:
SurefireExecutionException

runSuitesForkOnce

private boolean runSuitesForkOnce()
                           throws SurefireBooterForkException
Throws:
SurefireBooterForkException

runSuitesForkPerTestSet

private boolean runSuitesForkPerTestSet()
                                 throws SurefireBooterForkException
Throws:
SurefireBooterForkException

getTestSets

private java.util.Map getTestSets(java.lang.Object[] testSuite,
                                  java.lang.ClassLoader testsClassLoader,
                                  java.lang.ClassLoader surefireClassLoader)
                           throws SurefireBooterForkException
Throws:
SurefireBooterForkException

forkSuites

private boolean forkSuites(java.util.List testSuites,
                           boolean showHeading,
                           boolean showFooter)
                    throws SurefireBooterForkException
Throws:
SurefireBooterForkException

forkSuite

private boolean forkSuite(java.lang.Object[] testSuite,
                          java.lang.String testSet,
                          boolean showHeading,
                          boolean showFooter,
                          java.util.Properties properties)
                   throws SurefireBooterForkException
Throws:
SurefireBooterForkException

setForkProperties

private void setForkProperties(java.util.List testSuites,
                               java.util.Properties properties)

writePropertiesFile

private java.io.File writePropertiesFile(java.lang.String name,
                                         java.util.Properties properties)
                                  throws java.io.IOException
Throws:
java.io.IOException

writePropertiesFile

private void writePropertiesFile(java.io.File file,
                                 java.lang.String name,
                                 java.util.Properties properties)
                          throws java.io.IOException
Throws:
java.io.IOException

addPropertiesForTypeHolder

private void addPropertiesForTypeHolder(java.util.List typeHolderList,
                                        java.util.Properties properties,
                                        java.lang.String propertyPrefix)

fork

private boolean fork(java.util.Properties properties,
                     boolean showHeading,
                     boolean showFooter)
              throws SurefireBooterForkException
Throws:
SurefireBooterForkException

createClassLoader

private static java.lang.ClassLoader createClassLoader(java.util.List classPathUrls,
                                                       java.lang.ClassLoader parent,
                                                       boolean assertionsEnabled)
                                                throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

createClassLoader

private static java.lang.ClassLoader createClassLoader(java.util.List classPathUrls,
                                                       java.lang.ClassLoader parent,
                                                       boolean childDelegation,
                                                       boolean assertionsEnabled)
                                                throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

processStringList

private static java.util.List processStringList(java.lang.String stringList)

loadProperties

private static java.util.Properties loadProperties(java.io.File file)
                                            throws java.io.IOException
Throws:
java.io.IOException

setSystemProperties

private static void setSystemProperties(java.io.File file)
                                 throws java.io.IOException
Throws:
java.io.IOException

constructParamObjects

private static java.lang.Object[] constructParamObjects(java.lang.String paramProperty,
                                                        java.lang.String typeProperty)

main

public static void main(java.lang.String[] args)
                 throws java.lang.Throwable
This method is invoked when Surefire is forked - this method parses and organizes the arguments passed to it and then calls the Surefire class' run method.

The system exit code will be 1 if an exception is thrown.

Parameters:
args -
Throws:
java.lang.Throwable

setChildDelegation

public void setChildDelegation(boolean childDelegation)

getForkingStreamConsumer

private org.codehaus.plexus.util.cli.StreamConsumer getForkingStreamConsumer(boolean showHeading,
                                                                             boolean showFooter,
                                                                             boolean redirectTestOutputToFile)