use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class ResultsXmlWriter method writeResultsToOutputFile.
private void writeResultsToOutputFile(final ResultsForAllTests resultsForAllTests, final String inputFile, final String outputFile) {
try {
DocumentBuilder docBuilder = _docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
doc.setXmlStandalone(true);
Element root = doc.createElement("testsuite");
root.setAttribute("tests", Integer.toString(resultsForAllTests.getTestResults().size()));
doc.appendChild(root);
for (ITestResult testResult : resultsForAllTests.getTestResults()) {
Element testcase = doc.createElement("testcase");
testcase.setAttribute("classname", inputFile);
testcase.setAttribute("name", testResult.getName());
long timeTaken = getTimeTaken(testResult);
if (timeTaken > 0) {
testcase.setAttribute("time", String.valueOf(timeTaken / 1000));
}
if (testResult.hasErrors()) {
for (ParticipantResult result : testResult.getParticipantResults()) {
if (result.hasError()) {
Element error = doc.createElement("error");
error.setAttribute("message", result.getErrorMessage());
testcase.appendChild(error);
}
}
}
root.appendChild(testcase);
}
Transformer transformer = _transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
DOMSource source = new DOMSource(doc);
StreamResult result = new StreamResult(new File(outputFile));
transformer.transform(source, result);
} catch (ParserConfigurationException | TransformerException e) {
throw new DistributedTestException("Failed to create xml file : " + outputFile, e);
}
}
use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class CSVFormatter method format.
public String format(List<ITestResult> results) {
StringBuilder builder = new StringBuilder();
builder.append(header());
for (ITestResult testResult : results) {
List<ParticipantResult> participantResults = new ArrayList<ParticipantResult>(testResult.getParticipantResults());
Collections.sort(participantResults, new CSVOrderParticipantResultComparator());
for (ParticipantResult participantResult : participantResults) {
Map<ParticipantAttribute, Object> attributes = participantResult.getAttributes();
builder.append(row(attributes));
}
}
return builder.toString();
}
use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class ResultsTestFixture method getFirstParticipantResult.
public ParticipantResult getFirstParticipantResult(ResultsForAllTests results) {
List<ITestResult> testResults = results.getTestResults();
ITestResult testResult = testResults.iterator().next();
List<ParticipantResult> participantResults = testResult.getParticipantResults();
return participantResults.iterator().next();
}
Aggregations