X-Git-Url: http://git.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/reporthandling/XMLReportHandler.java b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/reporthandling/XMLReportHandler.java
index 27ddbc3..4638cfe 100644
--- a/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/reporthandling/XMLReportHandler.java
+++ b/net.sourceforge.phpeclipse.phpunit/src/net/sourceforge/phpeclipse/phpunit/reporthandling/XMLReportHandler.java
@@ -6,7 +6,6 @@
*
*************************************************************************/
-
package net.sourceforge.phpeclipse.phpunit.reporthandling;
import java.io.File;
@@ -27,36 +26,42 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class XMLReportHandler extends DefaultHandler {
-
+
private String currentVerdict;
- private PHPUnitView view;
+
+ private PHPUnitView view;
+
private String currentCommand;
+
private String currentTestCount;
+
private String currentTestID;
+
private String currentTestName;
+
private String currentTestParentTestSuiteName;
-
+
private void doAsyncRunnable(Runnable runnable) {
-
+
view.getSite().getShell().getDisplay().asyncExec(runnable);
}
-
+
public void handle(String report, PHPUnitView view) {
- //TODO : how to parse directly a string?
+ // TODO : how to parse directly a string?
// now doing it with a stream.
this.view = view;
SAXParser parser;
-
+
System.out.println("handling: " + report);
-
+
try {
-
+
File file = new File("tmp3.xml");
FileOutputStream out = null;
FileInputStream in = null;
out = new FileOutputStream(file);
- //OutputStreamWriter outS = new OutputStreamWriter(out, UTF8);
+ // OutputStreamWriter outS = new OutputStreamWriter(out, UTF8);
report += "\n \r";
out.write(report.getBytes("UTF8"));
out.close();
@@ -65,7 +70,7 @@ public class XMLReportHandler extends DefaultHandler {
parser.parse(in, this);
in.close();
file.delete();
-
+
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -75,7 +80,7 @@ public class XMLReportHandler extends DefaultHandler {
} catch (FactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
- } catch (FileNotFoundException e1) {
+ } catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (IOException e) {
@@ -83,102 +88,104 @@ public class XMLReportHandler extends DefaultHandler {
e.printStackTrace();
}
-
-
}
-
- /* (non-Javadoc)
- * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ContentHandler#endElement(java.lang.String,
+ * java.lang.String, java.lang.String)
*/
public void endElement(String arg0, String arg1, String elementName)
- throws SAXException {
-
- // send this current command to view
+ throws SAXException {
+
+ // send this current command to view
}
- /* (non-Javadoc)
- * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.xml.sax.ContentHandler#startElement(java.lang.String,
+ * java.lang.String, java.lang.String, org.xml.sax.Attributes)
*/
- public void startElement(
- String arg0,
- String arg1,
- String elementName,
- Attributes attributes)
- throws SAXException {
-
- System.out.println(arg0 + " - " + arg1 + " - " + elementName);
-
-
- if(elementName.equals("report")) {
-
+ public void startElement(String arg0, String arg1, String elementName,
+ Attributes attributes) throws SAXException {
+
+ System.out.println(arg0 + " - " + arg1 + " - " + elementName);
+
+ if (elementName.equals("report")) {
+
currentCommand = attributes.getValue("command");
currentTestCount = attributes.getValue("testCount");
currentTestID = attributes.getValue("testID");
currentTestName = attributes.getValue("testName");
- currentTestParentTestSuiteName = attributes.getValue("parentTestSuiteName");
-
+ currentTestParentTestSuiteName = attributes
+ .getValue("parentTestSuiteName");
+
doAsyncRunnable(new Runnable() {
-
+
public void run() {
-
- //view.handleCommand(currentCommand, currentTestCount, currentTestID, );
- view.handleCommand(currentCommand, new String[] {currentTestID, currentTestCount, currentTestName, currentTestParentTestSuiteName});
-
- }
+
+ // view.handleCommand(currentCommand, currentTestCount,
+ // currentTestID, );
+ view.handleCommand(currentCommand, new String[] {
+ currentTestID, currentTestCount, currentTestName,
+ currentTestParentTestSuiteName });
+
+ }
});
} else if (elementName.equals("verdict")) {
-
- currentVerdict = attributes.getValue("desc");
- //view.setTestVerdict(currentTestID, currentVerdict);
-
+
+ currentVerdict = attributes.getValue("desc");
+ // view.setTestVerdict(currentTestID, currentVerdict);
+
doAsyncRunnable(new Runnable() {
-
+
public void run() {
-
- view.setTestVerdict(currentTestID, currentVerdict);
+
+ view.setTestVerdict(currentTestID, currentVerdict);
}
-
- });
+
+ });
} else if (elementName.equals("exceptions")) {
-
- //do nothing
-
+
+ // do nothing
+
} else if (elementName.equals("exception")) {
-
+
final String exception = attributes.getValue("desc");
-
+
doAsyncRunnable(new Runnable() {
-
+
public void run() {
-
- view.addTestException(currentTestID, exception);
+
+ view.addTestException(currentTestID, exception);
}
-
- });
-
+
+ });
+
}
-
-
+
}
public static void main(String[] args) {
-
+
XMLReportHandler handler = new XMLReportHandler();
String xml = "";
xml = " ";
- handler.handle(xml, null);
-
+ handler.handle(xml, null);
+
xml = " ";
handler.handle(xml, null);
-
+
xml = " ";
handler.handle(xml, null);
-
+
xml = " ";
- handler.handle(xml, null);
+ handler.handle(xml, null);
}
}
\ No newline at end of file