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 org.apache.maven.surefire.report.ReporterConfiguration; |
23 | |
import org.apache.maven.surefire.testset.DirectoryScannerParameters; |
24 | |
import org.apache.maven.surefire.testset.TestArtifactInfo; |
25 | |
import org.apache.maven.surefire.testset.TestRequest; |
26 | |
|
27 | |
import java.io.File; |
28 | |
import java.io.IOException; |
29 | |
import java.io.InputStream; |
30 | |
import java.util.List; |
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 | |
throws IOException |
61 | |
{ |
62 | |
|
63 | 0 | final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) ); |
64 | 0 | Integer timeout = properties.getIntegerObjectProperty( FORKTIMEOUT ); |
65 | 0 | final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION ); |
66 | 0 | final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER ); |
67 | 0 | final Object testForFork = properties.getTypeDecoded( FORKTESTSET ); |
68 | 0 | final String requestedTest = properties.getProperty( REQUESTEDTEST ); |
69 | 0 | final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD ); |
70 | 0 | final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY ); |
71 | |
|
72 | 0 | final List reports = properties.getStringList( REPORT_PROPERTY_PREFIX ); |
73 | 0 | final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX ); |
74 | 0 | final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX ); |
75 | |
|
76 | 0 | final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES ); |
77 | 0 | final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY ); |
78 | 0 | final String runOrder = properties.getProperty( RUN_ORDER ); |
79 | |
|
80 | 0 | DirectoryScannerParameters dirScannerParams = |
81 | |
new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList, |
82 | |
properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder ); |
83 | |
|
84 | 0 | TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier ); |
85 | 0 | TestRequest testSuiteDefinition = new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod ); |
86 | |
|
87 | 0 | ReporterConfiguration reporterConfiguration = new ReporterConfiguration( reports, reportsDirectory, |
88 | |
properties.getBooleanObjectProperty( |
89 | |
ISTRIMSTACKTRACE ), timeout ); |
90 | |
|
91 | 0 | return new ProviderConfiguration( dirScannerParams, properties.getBooleanProperty( FAILIFNOTESTS ), |
92 | |
reporterConfiguration, testNg, testSuiteDefinition, |
93 | |
properties.getProperties(), testForFork ); |
94 | |
} |
95 | |
|
96 | |
public StartupConfiguration getProviderConfiguration() |
97 | |
throws IOException |
98 | |
{ |
99 | 0 | boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER ); |
100 | 0 | boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR ); |
101 | 0 | String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION ); |
102 | |
|
103 | 0 | ClassLoaderConfiguration classLoaderConfiguration = |
104 | |
new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar ); |
105 | |
|
106 | 0 | ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties ); |
107 | |
|
108 | 0 | return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, |
109 | |
classLoaderConfiguration ); |
110 | |
} |
111 | |
} |