forked from w3c/css-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoTest.java
More file actions
117 lines (106 loc) · 2.96 KB
/
AutoTest.java
File metadata and controls
117 lines (106 loc) · 2.96 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
package autotest;
import java.io.IOException;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;
/**
* AutoTest<br />
* Created: Jul 28, 2005 5:36:18 PM<br />
* Entry point of the software.<br/>
* This soft allows to run a battery of CSSs test cases to check the the
* CSS Validator.<br/>
* To run the AutoTest, use this command:<br/>
* java AutoTest uri [options]<br/>
* where uri is the uri of the xml file containing the list of test cases,
* and options a String containing the options for the validator, written in the
* "URI" style (e.g. &usermedium=all&profile=css2).
* There are some limitations in the options you can use:
* <ul>
* <li> The options list must begin with &</li>
* <li> Do not put text option nor uri one, they will be appended automatically
* from the xml file</li>
* <li> Do not put output option, it MUST be soap12 for the soft to work well,
* so it is appended automatically to the options</li>
* </ul>
*/
/**
*
*/
public class AutoTest {
XMLReader saxReader;
AutoTestContentHandler autoTestContentHandler;
/**
* Constructor.
*
* @throws SAXException
*/
public AutoTest(String testInstance) throws SAXException {
saxReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
autoTestContentHandler = new AutoTestContentHandler(testInstance);
saxReader.setContentHandler(autoTestContentHandler);
}
/**
* Parse an xml file
*
* @param uri
* the uri of the file to parse
* @throws IOException
* @throws SAXException
*/
public void parse(String uri) throws IOException, SAXException {
saxReader.parse(uri);
}
/**
* Entry point of the program
*
* @param args
* list of arguments of the program: uri [options]
*/
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("Usage : AutoTest uri [instance]");
System.exit(1);
}
String uri = null;
String instance = null;
if (args.length >= 1) {
uri = args[0];
}
if (args.length >= 2) {
instance = args[1];
}
System.out.println("Processing: " + uri);
try {
AutoTest parser = new AutoTest(instance);
parser.parse(uri);
if (parser.autoTestContentHandler.hasErrors()) {
System.err.println("\tTests outcome:" +
" " +
parser.autoTestContentHandler.getTestSuccessCount() +
" success(es)." +
" " +
parser.autoTestContentHandler.getTestFailCount() +
" failure(s)." +
" " +
parser.autoTestContentHandler.getTestErrorCount() +
" error(s)."
);
System.exit(1);
} else {
System.out.println("\tTests outcome:" +
" " +
parser.autoTestContentHandler.getTestSuccessCount() +
" success(es)." +
" " +
parser.autoTestContentHandler.getTestFailCount() +
" failure(s)." +
" " +
parser.autoTestContentHandler.getTestErrorCount() +
" error(s)."
);
}
} catch (Throwable t) {
t.printStackTrace();
}
}
}