juergen 2004/02/09 09:08:30
Modified:
testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor
TProcessors.java
testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tutil
TProcessorTask.java
Log:
improved output of TProcessorTask
Revision Changes Path
1.76 +26 -27
jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java
Index: TProcessors.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tprocessor/TProcessors.java,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- TProcessors.java 6 Feb 2004 16:15:34 -0000 1.75
+++ TProcessors.java 9 Feb 2004 17:08:30 -0000 1.76
@@ -362,7 +362,7 @@
// System.out.println("Can get the name of this file: "+
testName.getName());
- if (!tp.executeTestCase( new File (stestName), xmlresult )) {
+ if (!tp.executeTestCaseVerbose( new File (stestName), xmlresult, System.out
)) {
result = false;
}
@@ -451,24 +451,37 @@
}
// -------------------------------------------------------- Private Methods
+ public boolean executeTestCaseVerbose(File testfile, PrintStream xmlresultPar,
PrintStream verbose) {
+ boolean result;
+
+ verbose.println("");
+ verbose.println(new Date() + " Starting test case: " +
testfile.getAbsolutePath());
+
+ try {
+ result = executeTestCase(testfile, xmlresultPar);
+ } catch (Exception e) {
+ e.printStackTrace(verbose);
+ result = false;
+ }
+ if (!result) {
+ verbose.println(new Date() + " FAILED test case: " +
testfile.getAbsolutePath());
+ }
+ return result;
+ }
+
/**
* Construct a document (tree) out of given XML file. Execute testStep given in
the
* file
* @param WeddavClient client, File
*/
- public boolean executeTestCase( File testfile, PrintStream xmlresultPar ){
- boolean result= true; // TODO: not used
+ public boolean executeTestCase(File testfile, PrintStream xmlresultPar) throws
Exception {
long time = System.currentTimeMillis();
if (xmlresultPar != null){
this.xmlresult = new XMLOutput(xmlresultPar);
}
-
- System.out.println("");
- System.out.println(new Date() + " Starting test case: " +
testfile.getAbsolutePath());
-
xmlresult.writeRootElementStart("testCase");
xmlresult.writeElement("fileName", testfile.getAbsolutePath());
@@ -476,16 +489,11 @@
globalTestFileName = testfile.getName();
globalAbsolutePath = testfile.getParent();
// globalAbsolutePath = testfile.;
- result = exceuteStepOrRepeater(new
SAXBuilder(true).build(testfile).getRootElement().getChildren().iterator());
+ exceuteStepOrRepeater(new
SAXBuilder(true).build(testfile).getRootElement().getChildren().iterator());
} catch (JDOMException e){
- result = false;
xmlresult.writeElement("domException", e.toString());
- e.printStackTrace();
- } catch( Exception e ) {
- e.printStackTrace();
+ throw e;
}
-
-
xmlresult.writeElement("result",
((testElementsExecutedWithError!=0)?"ERROR":"Success"));
xmlresult.writeElement("time", ((System.currentTimeMillis() - time)));
xmlresult.writeElement("testElementCount", testElementsExecuted);
@@ -493,16 +501,7 @@
xmlresult.writeRootElementEnd("testCase");
xmlresult.flush();
-
- if (testElementsExecutedWithError!=0) System.out.println(new Date() + "
FAILED test case: " + testfile.getAbsolutePath());
- // System.out.println("Ending test case: " +
testfile.getAbsolutePath());
- // System.out.println("");
- // try {System.in.read();} catch (Exception e) {}
-
-
-
return testElementsExecutedWithError==0;
-
}
1.2 +20 -12
jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tutil/TProcessorTask.java
Index: TProcessorTask.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/testsuite/testsuite/junit/src/org/apache/slide/testsuite/testtools/tutil/TProcessorTask.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TProcessorTask.java 6 Feb 2004 15:55:15 -0000 1.1
+++ TProcessorTask.java 9 Feb 2004 17:08:30 -0000 1.2
@@ -68,17 +68,18 @@
}
public void execute() throws BuildException {
int i;
+ int max;
List lst;
TProcessors tp;
- Iterator iter;
File file;
PrintStream out;
- int ok;
+ int okCount;
String host;
String port;
String user;
String password;
-
+ boolean ok;
+
host = getProperty("host");
port = getProperty("port");
user = getProperty("user");
@@ -96,28 +97,35 @@
for (i = 0; i < filesets.size(); i++) {
addFileset(lst, (FileSet) filesets.get(i));
}
- System.out.println("selected " + lst.size() + " tests");
- System.out.println("writing results to " + result);
- iter = lst.iterator();
+ log("selected " + lst.size() + " tests, writing results to " + result);
try {
out = new PrintStream(new FileOutputStream(result));
} catch (IOException e) {
throw new BuildException("cannot create result file " + result, e);
}
- ok = 0;
+ okCount = 0;
+ max = lst.size();
try {
- while (iter.hasNext()) {
- file = (File) iter.next();
+ for (i = 0; i < max; i++) {
+ file = (File) lst.get(i);
tp = new TProcessors(config, host, port, user, password,
urlEncoding, tracingRequest, createProperties());
- if (tp.executeTestCase(file, out)) {
- ok++;
+ log((i + 1) + "/" + max + ": " + file.getPath());
+ try {
+ ok = tp.executeTestCase(file, out);
+ } catch (Exception e) {
+ throw new BuildException("execution failed: " + file, e);
+ }
+ if (ok) {
+ okCount++;
+ } else {
+ log(" FAILED");
}
}
} finally {
out.close();
}
- System.out.println("result: " + ok + "/" + lst.size() + " ok");
+ log("result: " + okCount + "/" + lst.size() + " ok");
}
private static final String PREFIX = "xdav.";
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]