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 public static final String PARALLEL_KEY = ProviderParameterNames.PARALLEL_PROP;
39
40 public static final String PERCORETHREADCOUNT_KEY = "perCoreThreadCount";
41
42 public static final String THREADCOUNT_KEY = ProviderParameterNames.THREADCOUNT_PROP;
43
44 public static final String USEUNLIMITEDTHREADS_KEY = "useUnlimitedThreads";
45
46 public JUnitCoreParameters( Properties properties )
47 {
48 this.parallel = properties.getProperty( PARALLEL_KEY, "none" ).toLowerCase();
49 this.perCoreThreadCount = Boolean.valueOf( properties.getProperty( PERCORETHREADCOUNT_KEY, "true" ) );
50 this.threadCount = Integer.valueOf( properties.getProperty( THREADCOUNT_KEY, "2" ) );
51 this.useUnlimitedThreads = Boolean.valueOf( properties.getProperty( USEUNLIMITEDTHREADS_KEY, "false" ) );
52 }
53
54 public boolean isParallelMethod()
55 {
56 return "methods".equals( parallel );
57 }
58
59 public boolean isParallelClasses()
60 {
61 return "classes".equals( parallel );
62 }
63
64 public boolean isParallelBoth()
65 {
66 return "both".equals( parallel );
67 }
68
69 public Boolean isPerCoreThreadCount()
70 {
71 return perCoreThreadCount;
72 }
73
74 public int getThreadCount()
75 {
76 return threadCount;
77 }
78
79 public Boolean isUseUnlimitedThreads()
80 {
81 return useUnlimitedThreads;
82 }
83
84 public boolean isNoThreading()
85 {
86 return !( isParallelClasses() || isParallelMethod() || isParallelBoth() );
87 }
88
89 public boolean isAnyParallelitySelected()
90 {
91 return !isNoThreading();
92 }
93
94 @Override
95 public String toString()
96 {
97 return "parallel='" + parallel + '\'' + ", perCoreThreadCount=" + perCoreThreadCount + ", threadCount="
98 + threadCount + ", useUnlimitedThreads=" + useUnlimitedThreads;
99 }
100 }