* @param element
* @param extendedForm
* @return
*/
private Testsuite loadTestSuite(Element element, boolean extendedForm) {
Testsuite o = JunitresultFactory.eINSTANCE.createTestsuite();
// super class part
loadAbstractAggregatedPart(o, element);
// attributes
o.setSystem_err(getTagValue(element, "system-err"));
o.setSystem_out(getTagValue(element, "system-out"));
o.setHostname(element.getAttribute("hostname"));
o.setTime(getTime(element, "time"));
o.setTimestamp(getTimestamp(element, "timestamp"));
// JUnit 4 - (?)
o.setDisabled(getIntAttributeWith0Default(element, "disabled"));
o.setSkipped(getIntAttributeWith0Default(element, "skipped"));
// when embedded in a junitreport result where <testsuites> is the document root these two
// attributes are present in each nested testsuite.
//
if(extendedForm) {
o.setId(getIntAttributeWith0Default(element, "id"));
o.setPackage(element.getAttribute("package"));
}
// child test suites (nested) & test cases
NodeList children = element.getChildNodes();
for(int i = 0; i < children.getLength(); i++) {
Node n = children.item(i);
if(n.getNodeType() == Node.ELEMENT_NODE)
if("testsuite".equalsIgnoreCase(n.getNodeName()))
o.getTestsuites().add(loadTestSuite((Element) n, extendedForm));
else if("testcase".equalsIgnoreCase(n.getNodeName()))
o.getTestcases().add(loadTestCase((Element) n));
else if("properties".equalsIgnoreCase(n.getNodeName())) {
NodeList properties = ((Element) n).getElementsByTagName("property");
for(int j = 0; j < properties.getLength(); j++) {
Node pn = properties.item(j);
if(pn.getNodeType() == Node.ELEMENT_NODE) {
Element propertyElement = (Element) pn;
Property p = JunitresultFactory.eINSTANCE.createProperty();
p.setName(propertyElement.getAttribute("name"));
p.setValue(propertyElement.getAttribute("value"));
o.getProperties().add(p);
}
}
}
}