Skip to content

Commit 7f47b32

Browse files
authored
Merge pull request #486 from tenzap/autotest
Improvements to autotest (run towards jar, other server, print outcome to console...)
2 parents cb34945 + a06dc4d commit 7f47b32

File tree

5 files changed

+376
-37
lines changed

5 files changed

+376
-37
lines changed

autotest/AutoTest.java

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@
3232
public class AutoTest {
3333

3434
XMLReader saxReader;
35+
AutoTestContentHandler autoTestContentHandler;
3536

3637
/**
3738
* Constructor.
3839
*
3940
* @throws SAXException
4041
*/
41-
public AutoTest() throws SAXException {
42+
public AutoTest(String testInstance) throws SAXException {
4243
saxReader = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
43-
saxReader.setContentHandler(new AutoTestContentHandler());
44+
autoTestContentHandler = new AutoTestContentHandler(testInstance);
45+
saxReader.setContentHandler(autoTestContentHandler);
4446
}
4547

4648
/**
@@ -62,18 +64,54 @@ public void parse(String uri) throws IOException, SAXException {
6264
* list of arguments of the program: uri [options]
6365
*/
6466
public static void main(String[] args) {
65-
if (args.length != 1) {
66-
System.out.println("Usage : AutoTest uri");
67+
if (args.length == 0) {
68+
System.out.println("Usage : AutoTest uri [instance]");
6769
System.exit(1);
6870
}
6971

70-
String uri = args[0];
72+
String uri = null;
73+
String instance = null;
7174

75+
if (args.length >= 1) {
76+
uri = args[0];
77+
}
78+
79+
if (args.length >= 2) {
80+
instance = args[1];
81+
}
82+
83+
System.out.println("Processing: " + uri);
7284
try {
73-
AutoTest parser = new AutoTest();
85+
AutoTest parser = new AutoTest(instance);
7486
parser.parse(uri);
87+
if (parser.autoTestContentHandler.hasErrors()) {
88+
System.err.println("\tTests outcome:" +
89+
" " +
90+
parser.autoTestContentHandler.getTestSuccessCount() +
91+
" success(es)." +
92+
" " +
93+
parser.autoTestContentHandler.getTestFailCount() +
94+
" failure(s)." +
95+
" " +
96+
parser.autoTestContentHandler.getTestErrorCount() +
97+
" error(s)."
98+
);
99+
System.exit(1);
100+
} else {
101+
System.out.println("\tTests outcome:" +
102+
" " +
103+
parser.autoTestContentHandler.getTestSuccessCount() +
104+
" success(es)." +
105+
" " +
106+
parser.autoTestContentHandler.getTestFailCount() +
107+
" failure(s)." +
108+
" " +
109+
parser.autoTestContentHandler.getTestErrorCount() +
110+
" error(s)."
111+
);
112+
}
75113
} catch (Throwable t) {
76114
t.printStackTrace();
77115
}
78116
}
79-
}
117+
}

0 commit comments

Comments
 (0)