1 | |
package org.apache.maven.surefire.junitcore; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import java.util.Properties; |
23 | |
import org.apache.maven.surefire.booter.ProviderParameterNames; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
class JUnitCoreParameters |
29 | |
{ |
30 | |
private final String parallel; |
31 | |
|
32 | |
private final Boolean perCoreThreadCount; |
33 | |
|
34 | |
private final int threadCount; |
35 | |
|
36 | |
private final Boolean useUnlimitedThreads; |
37 | |
|
38 | |
private final boolean reuseForks; |
39 | |
|
40 | |
public static final String PARALLEL_KEY = ProviderParameterNames.PARALLEL_PROP; |
41 | |
|
42 | |
public static final String PERCORETHREADCOUNT_KEY = "perCoreThreadCount"; |
43 | |
|
44 | |
public static final String THREADCOUNT_KEY = ProviderParameterNames.THREADCOUNT_PROP; |
45 | |
|
46 | |
public static final String USEUNLIMITEDTHREADS_KEY = "useUnlimitedThreads"; |
47 | |
|
48 | |
public static final String REUSEFORKS_KEY = "reuseForks"; |
49 | |
|
50 | |
public JUnitCoreParameters( Properties properties ) |
51 | 25 | { |
52 | 25 | this.parallel = properties.getProperty( PARALLEL_KEY, "none" ).toLowerCase(); |
53 | 25 | this.perCoreThreadCount = Boolean.valueOf( properties.getProperty( PERCORETHREADCOUNT_KEY, "true" ) ); |
54 | 25 | this.threadCount = Integer.valueOf( properties.getProperty( THREADCOUNT_KEY, "2" ) ); |
55 | 25 | this.useUnlimitedThreads = Boolean.valueOf( properties.getProperty( USEUNLIMITEDTHREADS_KEY, "false" ) ); |
56 | 25 | this.reuseForks = Boolean.valueOf( properties.getProperty( REUSEFORKS_KEY, "false" ) ); |
57 | 25 | } |
58 | |
|
59 | |
public boolean isParallelMethod() |
60 | |
{ |
61 | 7 | return "methods".equals( parallel ); |
62 | |
} |
63 | |
|
64 | |
public boolean isParallelClasses() |
65 | |
{ |
66 | 9 | return "classes".equals( parallel ); |
67 | |
} |
68 | |
|
69 | |
public boolean isParallelBoth() |
70 | |
{ |
71 | 5 | return "both".equals( parallel ); |
72 | |
} |
73 | |
|
74 | |
public Boolean isPerCoreThreadCount() |
75 | |
{ |
76 | 6 | return perCoreThreadCount; |
77 | |
} |
78 | |
|
79 | |
public int getThreadCount() |
80 | |
{ |
81 | 0 | return threadCount; |
82 | |
} |
83 | |
|
84 | |
public Boolean isUseUnlimitedThreads() |
85 | |
{ |
86 | 3 | return useUnlimitedThreads; |
87 | |
} |
88 | |
|
89 | |
public boolean isNoThreading() |
90 | |
{ |
91 | 6 | return !( isParallelClasses() || isParallelMethod() || isParallelBoth() ); |
92 | |
} |
93 | |
|
94 | |
public boolean isAnyParallelitySelected() |
95 | |
{ |
96 | 3 | return !isNoThreading(); |
97 | |
} |
98 | |
|
99 | |
public boolean isReuseForks() |
100 | |
{ |
101 | 0 | return reuseForks; |
102 | |
} |
103 | |
|
104 | |
@Override |
105 | |
public String toString() |
106 | |
{ |
107 | 1 | return "parallel='" + parallel + '\'' + ", perCoreThreadCount=" + perCoreThreadCount + ", threadCount=" |
108 | |
+ threadCount + ", useUnlimitedThreads=" + useUnlimitedThreads; |
109 | |
} |
110 | |
} |