public File serialize( KeyValueSource sourceProperties, ProviderConfiguration booterConfiguration,
StartupConfiguration providerConfiguration, Object testSet, boolean readTestsFromInStream )
throws IOException
{
SurefireProperties properties = new SurefireProperties( sourceProperties );
ClasspathConfiguration cp = providerConfiguration.getClasspathConfiguration();
properties.setClasspath( ClasspathConfiguration.CLASSPATH, cp.getTestClasspath() );
properties.setClasspath( ClasspathConfiguration.SUREFIRE_CLASSPATH, cp.getProviderClasspath() );
properties.setProperty( ClasspathConfiguration.ENABLE_ASSERTIONS, String.valueOf( cp.isEnableAssertions() ) );
properties.setProperty( ClasspathConfiguration.CHILD_DELEGATION, String.valueOf( cp.isChildDelegation() ) );
TestArtifactInfo testNg = booterConfiguration.getTestArtifact();
if ( testNg != null )
{
properties.setProperty( BooterConstants.TESTARTIFACT_VERSION, testNg.getVersion() );
properties.setNullableProperty( BooterConstants.TESTARTIFACT_CLASSIFIER, testNg.getClassifier() );
}
properties.setProperty( BooterConstants.FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM, readTestsFromInStream );
properties.setNullableProperty( 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.setNullableProperty( BooterConstants.REQUESTEDTEST, testSuiteDefinition.getRequestedTest() );
properties.setNullableProperty( BooterConstants.REQUESTEDTESTMETHOD,
testSuiteDefinition.getRequestedTestMethod() );
properties.setNullableProperty( BooterConstants.RERUN_FAILING_TESTS_COUNT,
String.valueOf( testSuiteDefinition.getRerunFailingTestsCount() ) );
}
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,
forkConfiguration.getTempDirectory(), "surefire",
forkConfiguration.isDebug() );
}