public File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterConfiguration,
StartupConfiguration providerConfiguration, Object testSet, boolean readTestsFromInStream )
throws IOException
{
PropertiesWrapper properties = new PropertiesWrapper( new Properties() );
sourceProperties.copyTo( properties.getProperties() );
providerConfiguration.getClasspathConfiguration().addForkProperties( properties );
TestArtifactInfo testNg = booterConfiguration.getTestArtifact();
if ( testNg != null )
{
properties.setProperty( BooterConstants.TESTARTIFACT_VERSION, testNg.getVersion() );
properties.setProperty( BooterConstants.TESTARTIFACT_CLASSIFIER, testNg.getClassifier() );
}
properties.setProperty( BooterConstants.FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM,
Boolean.valueOf( readTestsFromInStream ) );
properties.setProperty( BooterConstants.FORKTESTSET, getTypeEncoded( testSet ) );
TestRequest testSuiteDefinition = booterConfiguration.getTestSuiteDefinition();
if ( testSuiteDefinition != null )
{
properties.setProperty( BooterConstants.SOURCE_DIRECTORY, testSuiteDefinition.getTestSourceDirectory() );
properties.addList( testSuiteDefinition.getSuiteXmlFiles(), BooterConstants.TEST_SUITE_XML_FILES );
properties.setProperty( BooterConstants.REQUESTEDTEST, testSuiteDefinition.getRequestedTest() );
properties.setProperty( BooterConstants.REQUESTEDTESTMETHOD, testSuiteDefinition.getRequestedTestMethod() );
}
DirectoryScannerParameters directoryScannerParameters = booterConfiguration.getDirScannerParams();
if ( directoryScannerParameters != null )
{
properties.setProperty( BooterConstants.FAILIFNOTESTS,
String.valueOf( directoryScannerParameters.isFailIfNoTests() ) );
properties.addList( directoryScannerParameters.getIncludes(), BooterConstants.INCLUDES_PROPERTY_PREFIX );
properties.addList( directoryScannerParameters.getExcludes(), BooterConstants.EXCLUDES_PROPERTY_PREFIX );
properties.addList( directoryScannerParameters.getSpecificTests(),
BooterConstants.SPECIFIC_TEST_PROPERTY_PREFIX );
properties.setProperty( BooterConstants.TEST_CLASSES_DIRECTORY,
directoryScannerParameters.getTestClassesDirectory() );
}
final RunOrderParameters runOrderParameters = booterConfiguration.getRunOrderParameters();
if ( runOrderParameters != null )
{
properties.setProperty( BooterConstants.RUN_ORDER, RunOrder.asString( runOrderParameters.getRunOrder() ) );
properties.setProperty( BooterConstants.RUN_STATISTICS_FILE, runOrderParameters.getRunStatisticsFile() );
}
ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
Boolean rep = reporterConfiguration.isTrimStackTrace();
properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep );
properties.setProperty( BooterConstants.REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() );
ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration();
properties.setProperty( BooterConstants.USESYSTEMCLASSLOADER,
String.valueOf( classLoaderConfiguration.isUseSystemClassLoader() ) );
properties.setProperty( BooterConstants.USEMANIFESTONLYJAR,
String.valueOf( classLoaderConfiguration.isUseManifestOnlyJar() ) );
properties.setProperty( BooterConstants.FAILIFNOTESTS,
String.valueOf( booterConfiguration.isFailIfNoTests() ) );
properties.setProperty( BooterConstants.PROVIDER_CONFIGURATION, providerConfiguration.getProviderClassName() );
return SystemPropertyManager.writePropertiesFile( properties.getProperties(),
forkConfiguration.getTempDirectory(), "surefire",
forkConfiguration.isDebug() );
}