Index: src/test/it/com/xpn/xwiki/it/xmlrpc/XhtmlValidityTest.java
===================================================================
--- src/test/it/com/xpn/xwiki/it/xmlrpc/XhtmlValidityTest.java (revision 5192)
+++ src/test/it/com/xpn/xwiki/it/xmlrpc/XhtmlValidityTest.java (working copy)
@@ -19,10 +19,12 @@
*/
package com.xpn.xwiki.it.xmlrpc;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.util.ArrayList;
@@ -78,6 +80,10 @@
private int errors = 0;
+ private PrintStream stdout = System.out;
+
+ private PrintStream stderr = System.err;
+
public XhtmlValidityTest(String fullPageName)
{
super("testValidityOfDocument");
@@ -138,6 +144,13 @@
// TODO Until we find a way to incrementally display the result of tests this stays
System.out.println(getName());
+ // we redirect the stdout and the stderr in order to detect (server-side) error/warning
+ // messages like the ones generated by the velocity parser
+ ByteArrayOutputStream newOut = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(newOut));
+ ByteArrayOutputStream newErr = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(newErr));
+
Page page = rpc.getPage(fullPageName);
String renderedContent = rpc.renderContent(page);
assertNotNull(renderedContent);
@@ -159,7 +172,22 @@
}
errors += assertCssValid(page.getUrl());
}
+
+ System.setOut(stdout);
+ String output = newOut.toString();
+ System.out.print(output);
+
+ System.setErr(stderr);
+ String errput = newErr.toString();
+ System.err.print(errput);
+
assertTrue(errors == 0);
+ // detect server-side error/warning messages from the stdout
+ assertTrue(output.indexOf("ERROR") < 0);
+ assertTrue(output.indexOf("WARNING") < 0);
+ // detect server-side error/warning messages from the stderr
+ assertTrue(errput.indexOf("ERROR") < 0);
+ assertTrue(errput.indexOf("WARNING") < 0);
}
private static List readXarContents(String fileName) throws Exception