1
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
package org.testng.internal;
import java.util.Map;
import java.util.Properties;
import org.testng.ITestResult;
import org.testng.collections.Maps;
/**
* Constants used by TestNG
*
* @author Cedric Beust, May 2, 2004
*
*/
public class Constants {
private static final String NAMESPACE = "testng";
//////// //
// Properties
//
public static final String PROP_OUTPUT_DIR = NAMESPACE + "." + "outputDir";
// public static final String PROP_NAME = NAMESPACE + "." + "name";
// public static final String PROP_INCLUDED_GROUPS = NAMESPACE + "." + "includedGroups";
// public static final String PROP_EXCLUDED_GROUPS = NAMESPACE + "." + "excludedGroups";
// public static final String PROP_CLASS_NAMES = NAMESPACE + "." + "classNames";
// public static final String PROP_VERBOSE = NAMESPACE + "." + "verbose";
// public static final String PROP_JUNIT= NAMESPACE + "." + "junit";
// public static final String PROP_QUIET= NAMESPACE + "." + "quiet";
// public static final String PROP_GROUP= NAMESPACE + "." + "group";
private static final TestNGProperty[] COMMAND_LINE_PARAMETERS = {
new TestNGProperty("-d", PROP_OUTPUT_DIR, "Directory where the result files will be created.", "test-output"),
};
private static final Map<String, TestNGProperty> m_propertiesByName = Maps.newHashMap();
static {
// for (int i = 0; i < PROPERTIES.length; i++) {
// m_propertiesByName.put(PROPERTIES[i].getName(), PROPERTIES[i]);
// }
for (TestNGProperty element : COMMAND_LINE_PARAMETERS) {
m_propertiesByName.put(element.getName(), element);
}
}
private static TestNGProperty getProperty(String propertyName) {
TestNGProperty result = m_propertiesByName.get(propertyName);
assert null != result : "Unknown property : " + propertyName;
return result;
}
public static String getPropertyValue(Properties p, String propertyName) {
TestNGProperty r= getProperty(propertyName);
assert null != r : "Unknown property : " + propertyName;
String result = p.getProperty(r.getName());
return result;
}
public static boolean getBooleanPropertyValue(Properties properties, String propertyName) {
TestNGProperty p = getProperty(propertyName);
String r = properties.getProperty(propertyName, p.getDefault());
boolean result = "true".equalsIgnoreCase(r);
return Boolean.valueOf(result);
}
public static int getIntegerPropertyValue(Properties properties, String propertyName) {
TestNGProperty p = getProperty(propertyName);
String r = properties.getProperty(propertyName, p.getDefault());
int result = Integer.parseInt(r);
return result;
}
public static String getDefaultValueFor(String propertyName) {
TestNGProperty p = getProperty(propertyName);
return p.getDefault();
}
public static String displayStatus(int status) {
if (ITestResult.SKIP == status) {
return "SKIP";
} else if (ITestResult.SUCCESS == status) {
return "SUCCESS";
} else if (ITestResult.FAILURE == status) {
return "FAILURE";
} else {
return "UNKNOWN_STATUS";
}
}
}
|