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 | |
|
46 | |
public class BooterDeserializer |
47 | |
implements BooterConstants |
48 | |
{ |
49 | |
|
50 | |
|
51 | |
private final PropertiesWrapper properties; |
52 | |
|
53 | |
public BooterDeserializer( InputStream inputStream ) |
54 | |
throws IOException |
55 | 0 | { |
56 | 0 | properties = SystemPropertyManager.loadProperties( inputStream ); |
57 | 0 | } |
58 | |
|
59 | |
public ProviderConfiguration deserialize() |
60 | |
{ |
61 | 0 | final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) ); |
62 | 0 | final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION ); |
63 | 0 | final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER ); |
64 | 0 | final TypeEncodedValue typeEncodedTestForFork = properties.getTypeEncodedValue( FORKTESTSET ); |
65 | 0 | final String requestedTest = properties.getProperty( REQUESTEDTEST ); |
66 | 0 | final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD ); |
67 | 0 | final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY ); |
68 | |
|
69 | 0 | final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX ); |
70 | 0 | final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX ); |
71 | |
|
72 | 0 | final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES ); |
73 | 0 | final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY ); |
74 | 0 | final String runOrder = properties.getProperty( RUN_ORDER ); |
75 | 0 | final String runStatisticsFile = properties.getProperty( RUN_STATISTICS_FILE ); |
76 | |
|
77 | 0 | DirectoryScannerParameters dirScannerParams = |
78 | |
new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList, |
79 | |
properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder ); |
80 | |
|
81 | 0 | RunOrderParameters runOrderParameters = new RunOrderParameters( runOrder, runStatisticsFile ); |
82 | |
|
83 | 0 | TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier ); |
84 | 0 | TestRequest testSuiteDefinition = |
85 | |
new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod ); |
86 | |
|
87 | 0 | ReporterConfiguration reporterConfiguration = |
88 | |
new ReporterConfiguration( reportsDirectory, properties.getBooleanObjectProperty( ISTRIMSTACKTRACE ) ); |
89 | |
|
90 | 0 | return new ProviderConfiguration( dirScannerParams, runOrderParameters, |
91 | |
properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg, |
92 | |
testSuiteDefinition, properties.getProperties(), typeEncodedTestForFork ); |
93 | |
} |
94 | |
|
95 | |
public StartupConfiguration getProviderConfiguration() |
96 | |
{ |
97 | 0 | boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER ); |
98 | 0 | boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR ); |
99 | 0 | String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION ); |
100 | 0 | String forkMode = properties.getProperty( FORKMODE ); |
101 | |
|
102 | 0 | ClassLoaderConfiguration classLoaderConfiguration = |
103 | |
new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar ); |
104 | |
|
105 | 0 | ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties ); |
106 | |
|
107 | 0 | return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration, |
108 | |
forkMode ); |
109 | |
} |
110 | |
} |