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 import static org.apache.maven.surefire.booter.BooterConstants.*;
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 public class BooterDeserializer
49 {
50
51
52 private final PropertiesWrapper properties;
53
54 public BooterDeserializer( InputStream inputStream )
55 throws IOException
56 {
57 properties = SystemPropertyManager.loadProperties( inputStream );
58 }
59
60 public ProviderConfiguration deserialize()
61 {
62 final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) );
63 final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION );
64 final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER );
65
66 final TypeEncodedValue typeEncodedTestForFork = properties.getTypeEncodedValue( FORKTESTSET );
67 final boolean preferTestsFromInStream =
68 properties.getBooleanProperty( FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM );
69
70 final String requestedTest = properties.getProperty( REQUESTEDTEST );
71 final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD );
72 final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY );
73
74 final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
75 final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
76 final List specificTestsList = properties.getStringList( SPECIFIC_TEST_PROPERTY_PREFIX );
77
78 final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
79 final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY );
80 final String runOrder = properties.getProperty( RUN_ORDER );
81 final String runStatisticsFile = properties.getProperty( RUN_STATISTICS_FILE );
82
83 final int rerunFailingTestsCount = properties.getIntProperty( RERUN_FAILING_TESTS_COUNT );
84
85 DirectoryScannerParameters dirScannerParams =
86 new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList, specificTestsList,
87 properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder );
88
89 RunOrderParameters runOrderParameters = new RunOrderParameters( runOrder, runStatisticsFile );
90
91 TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier );
92 TestRequest testSuiteDefinition =
93 new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod,
94 rerunFailingTestsCount );
95
96 ReporterConfiguration reporterConfiguration =
97 new ReporterConfiguration( reportsDirectory, properties.getBooleanObjectProperty( ISTRIMSTACKTRACE ) );
98
99 return new ProviderConfiguration( dirScannerParams, runOrderParameters,
100 properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg,
101 testSuiteDefinition, properties.getProperties(), typeEncodedTestForFork,
102 preferTestsFromInStream );
103 }
104
105 public StartupConfiguration getProviderConfiguration()
106 {
107 boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
108 boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
109 String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
110
111 ClassLoaderConfiguration classLoaderConfiguration =
112 new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar );
113
114 ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties );
115
116 return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration,
117 classLoaderConfiguration );
118 }
119 }