1 package org.apache.maven.surefire.booter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.util.List;
26 import org.apache.maven.surefire.report.ReporterConfiguration;
27 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
28 import org.apache.maven.surefire.testset.RunOrderParameters;
29 import org.apache.maven.surefire.testset.TestArtifactInfo;
30 import org.apache.maven.surefire.testset.TestRequest;
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 public class BooterDeserializer
46 implements BooterConstants
47 {
48
49
50 private final PropertiesWrapper properties;
51
52 public BooterDeserializer( InputStream inputStream )
53 throws IOException
54 {
55 properties = SystemPropertyManager.loadProperties( inputStream );
56 }
57
58 public ProviderConfiguration deserialize()
59 {
60 final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) );
61 final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION );
62 final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER );
63
64 final TypeEncodedValue typeEncodedTestForFork = properties.getTypeEncodedValue( FORKTESTSET );
65 final boolean preferTestsFromInStream =
66 properties.getBooleanProperty( FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM );
67
68 final String requestedTest = properties.getProperty( REQUESTEDTEST );
69 final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD );
70 final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY );
71
72 final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
73 final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
74 final List specificTestsList = properties.getStringList( SPECIFIC_TEST_PROPERTY_PREFIX );
75
76 final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
77 final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY );
78 final String runOrder = properties.getProperty( RUN_ORDER );
79 final String runStatisticsFile = properties.getProperty( RUN_STATISTICS_FILE );
80
81 DirectoryScannerParameters dirScannerParams =
82 new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList, specificTestsList,
83 properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder );
84
85 RunOrderParameters runOrderParameters = new RunOrderParameters( runOrder, runStatisticsFile );
86
87 TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier );
88 TestRequest testSuiteDefinition =
89 new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod );
90
91 ReporterConfiguration reporterConfiguration =
92 new ReporterConfiguration( reportsDirectory, properties.getBooleanObjectProperty( ISTRIMSTACKTRACE ) );
93
94 return new ProviderConfiguration( dirScannerParams, runOrderParameters,
95 properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg,
96 testSuiteDefinition, properties.getProperties(), typeEncodedTestForFork,
97 preferTestsFromInStream );
98 }
99
100 public StartupConfiguration getProviderConfiguration()
101 {
102 boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
103 boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
104 String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
105
106 ClassLoaderConfiguration classLoaderConfiguration =
107 new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar );
108
109 ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties );
110
111 return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration,
112 classLoaderConfiguration );
113 }
114 }