Search in sources :

Example 6 with ITestResult

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);
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) DistributedTestException(org.apache.qpid.disttest.DistributedTestException) Transformer(javax.xml.transform.Transformer) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) StreamResult(javax.xml.transform.stream.StreamResult) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) File(java.io.File) TransformerException(javax.xml.transform.TransformerException)

Example 7 with ITestResult

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();
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) ParticipantAttribute(org.apache.qpid.disttest.message.ParticipantAttribute) ArrayList(java.util.ArrayList)

Example 8 with ITestResult

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();
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult)

Aggregations

ITestResult (org.apache.qpid.disttest.results.aggregation.ITestResult)8 ParticipantResult (org.apache.qpid.disttest.message.ParticipantResult)5 File (java.io.File)4 ResultsForAllTests (org.apache.qpid.disttest.controller.ResultsForAllTests)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Transformer (javax.xml.transform.Transformer)1 TransformerException (javax.xml.transform.TransformerException)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)1 TestInstance (org.apache.qpid.disttest.controller.config.TestInstance)1 ParticipantAttribute (org.apache.qpid.disttest.message.ParticipantAttribute)1 Document (org.w3c.dom.Document)1 Element (org.w3c.dom.Element)1