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.TestArtifactInfo;
29 import org.apache.maven.surefire.testset.TestRequest;
30
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 final TypeEncodedValue typeEncodedTestForFork = properties.getTypeEncodedValue( FORKTESTSET );
64 final String requestedTest = properties.getProperty( REQUESTEDTEST );
65 final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD );
66 final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY );
67
68 final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
69 final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
70
71 final List testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES );
72 final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY );
73 final String runOrder = properties.getProperty( RUN_ORDER );
74
75 DirectoryScannerParameters dirScannerParams =
76 new DirectoryScannerParameters( testClassesDirectory, includesList, excludesList,
77 properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder );
78
79 TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier );
80 TestRequest testSuiteDefinition =
81 new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod );
82
83 ReporterConfiguration reporterConfiguration =
84 new ReporterConfiguration( reportsDirectory, properties.getBooleanObjectProperty( ISTRIMSTACKTRACE ) );
85
86 return new ProviderConfiguration( dirScannerParams, properties.getBooleanProperty( FAILIFNOTESTS ),
87 reporterConfiguration, testNg, testSuiteDefinition,
88 properties.getProperties(), typeEncodedTestForFork );
89 }
90
91 public StartupConfiguration getProviderConfiguration()
92 {
93 boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
94 boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
95 String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
96 String forkMode = properties.getProperty( FORKMODE );
97
98 ClassLoaderConfiguration classLoaderConfiguration =
99 new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar );
100
101 ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties );
102
103 return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration,
104 forkMode );
105 }
106 }