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 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class ClasspathConfiguration |
31 | |
{ |
32 | |
public static final String CHILD_DELEGATION = "childDelegation"; |
33 | |
|
34 | |
public static final String ENABLE_ASSERTIONS = "enableAssertions"; |
35 | |
|
36 | |
public static final String CLASSPATH = "classPathUrl."; |
37 | |
|
38 | |
public static final String SUREFIRE_CLASSPATH = "surefireClassPathUrl."; |
39 | |
|
40 | |
private final Classpath classpathUrls; |
41 | |
|
42 | |
private final Classpath surefireClasspathUrls; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
private final Classpath inprocClasspath; |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
private final boolean enableAssertions; |
54 | |
|
55 | |
|
56 | |
private final boolean childDelegation; |
57 | |
|
58 | |
public ClasspathConfiguration( boolean enableAssertions, boolean childDelegation ) |
59 | |
{ |
60 | 0 | this( Classpath.emptyClasspath(), Classpath.emptyClasspath(), Classpath.emptyClasspath(), enableAssertions, childDelegation ); |
61 | 0 | } |
62 | |
|
63 | |
ClasspathConfiguration( PropertiesWrapper properties ) |
64 | |
{ |
65 | 0 | this( properties.getClasspath( CLASSPATH ), properties.getClasspath( SUREFIRE_CLASSPATH ), |
66 | |
Classpath.emptyClasspath(), |
67 | |
properties.getBooleanProperty( ENABLE_ASSERTIONS ), properties.getBooleanProperty( CHILD_DELEGATION ) ); |
68 | 0 | } |
69 | |
|
70 | |
public ClasspathConfiguration( Classpath testClasspath, Classpath surefireClassPathUrls, Classpath inprocClasspath, |
71 | |
boolean enableAssertions, boolean childDelegation ) |
72 | 0 | { |
73 | 0 | this.enableAssertions = enableAssertions; |
74 | 0 | this.childDelegation = childDelegation; |
75 | 0 | this.inprocClasspath = inprocClasspath; |
76 | 0 | this.classpathUrls = testClasspath; |
77 | 0 | this.surefireClasspathUrls = surefireClassPathUrls; |
78 | 0 | } |
79 | |
|
80 | |
public ClassLoader createMergedClassLoader() |
81 | |
throws SurefireExecutionException |
82 | |
{ |
83 | 0 | return Classpath.join( inprocClasspath, classpathUrls) |
84 | |
.createClassLoader( null, this.childDelegation, enableAssertions, "test" ); |
85 | |
} |
86 | |
|
87 | |
public Classpath getProviderClasspath() |
88 | |
{ |
89 | 0 | return surefireClasspathUrls; |
90 | |
} |
91 | |
|
92 | |
|
93 | |
public Classpath getTestClasspath() |
94 | |
{ |
95 | 0 | return classpathUrls; |
96 | |
} |
97 | |
|
98 | |
public void trickClassPathWhenManifestOnlyClasspath() |
99 | |
throws SurefireExecutionException |
100 | |
{ |
101 | 0 | System.setProperty( "surefire.real.class.path", System.getProperty( "java.class.path" ) ); |
102 | 0 | getTestClasspath().writeToSystemProperty( "java.class.path" ); |
103 | 0 | } |
104 | |
|
105 | |
public boolean isEnableAssertions() |
106 | |
{ |
107 | 0 | return enableAssertions; |
108 | |
} |
109 | |
|
110 | |
public boolean isChildDelegation() |
111 | |
{ |
112 | 0 | return childDelegation; |
113 | |
} |
114 | |
} |