* @return
* @throws XMLParseException
* @throws IOException
*/
public RunResult parse(Reader r) throws XMLParseException, IOException {
XMLElement xmlRun = new XMLElement();
BufferedReader reader = null;
try {
reader = new BufferedReader(r);
xmlRun.parseFromReader(reader);
checkTag(xmlRun, RUN_RESULT);
String attr;
RunResult run = new RunResult(getValue(xmlRun, RUN_NAME, ""));
for (Enumeration enumPkg = xmlRun.enumerateChildren(); enumPkg.hasMoreElements(); ) {
XMLElement xmlPkg = (XMLElement) enumPkg.nextElement();
int indexTag = checkTag(xmlPkg, new String[]{PACKAGE_RESULT, PROPERTY});
if (indexTag == 1) {
String name = getValue(xmlPkg, PROPERTY_NAME, "");
String value = getValue(xmlPkg, PROPERTY_VALUE, "");
run.setSystemProperty(name, value);
continue;
}
attr = getValue(xmlPkg, PACKAGE_NAME, "");
PackageResult pkg = new PackageResult(attr);
run.add(pkg);
for (Enumeration enumCls = xmlPkg.enumerateChildren(); enumCls.hasMoreElements(); ) {
XMLElement xmlCls = (XMLElement) enumCls.nextElement();
checkTag(xmlCls, CLASS_RESULT);
attr = getValue(xmlCls, CLASS_NAME, "");
ClassResult cls = new ClassResult(attr);
pkg.add(cls);
for (Enumeration enumTest = xmlCls.enumerateChildren(); enumTest.hasMoreElements(); ) {
XMLElement xmlTest = (XMLElement) enumTest.nextElement();
checkTag(xmlTest, TEST_RESULT);
attr = getValue(xmlTest, TEST_NAME, "");
TestResult test = new TestResult(attr);
cls.add(test);
for (Enumeration enumCheck = xmlTest.enumerateChildren(); enumCheck.hasMoreElements(); ) {
XMLElement xmlCheck = (XMLElement) enumCheck.nextElement();
if (TEST_ERROR.equals(xmlCheck.getName())) {
test.setFailedMessage(xmlCheck.getContent());
} else {
checkTag(xmlCheck, CHECK_RESULT);
test.add(createCheck(xmlCheck));
}