use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class ResultsForAllTests method getAllParticipantsResult.
public List<ITestResult> getAllParticipantsResult() {
List<ITestResult> results = new ArrayList<>(_results.size());
for (ITestResult testResult : _results) {
for (ParticipantResult participantResult : testResult.getParticipantResults()) {
if (TestResultAggregator.ALL_PARTICIPANTS_NAME.equals(participantResult.getParticipantName())) {
TestResult summaryTestResult = new TestResult(testResult.getName());
summaryTestResult.addParticipantResult(participantResult);
results.add(summaryTestResult);
}
}
}
return results;
}
use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class Controller method runAllTests.
public ResultsForAllTests runAllTests() {
LOGGER.info("Running all tests");
ResultsForAllTests resultsForAllTests = new ResultsForAllTests();
for (TestInstance testInstance : _config.getTests()) {
ParticipatingClients participatingClients = new ParticipatingClients(_clientRegistry, testInstance.getClientNames());
ITestRunner runner = _testRunnerFactory.createTestRunner(participatingClients, testInstance, _jmsDelegate, _commandResponseTimeout, AbstractTestRunner.WAIT_FOREVER, _options);
LOGGER.info("Running test {}. Participating clients: {}", testInstance, participatingClients.getRegisteredNames());
ITestResult result = runner.run();
if (result != null) {
LOGGER.info("Finished test {}, result {}", testInstance, result);
resultsForAllTests.add(result);
} else {
LOGGER.warn("Finished test {} without producing a result.", testInstance);
}
}
return resultsForAllTests;
}
use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class ResultsXmlWriterTest method testResultForOneTest.
@Test
public void testResultForOneTest() throws Exception {
ITestResult test = mock(ITestResult.class);
when(test.getName()).thenReturn("mytest");
ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
when(resultsForAllTests.getTestResults()).thenReturn(Collections.singletonList(test));
String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<testsuite tests=\"1\">%n" + " <testcase classname=\"config.json\" name=\"mytest\"/>%n" + "</testsuite>%n");
_resultsFileWriter.writeResults(resultsForAllTests, "config.json");
File resultsFile = new File(_outputDir, "config.xml");
assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
}
use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class ResultsCsvWriterTest method testWriteResultsToFile.
@Test
public void testWriteResultsToFile() throws Exception {
List<ITestResult> testResult1 = mock(List.class);
ResultsForAllTests results1 = mock(ResultsForAllTests.class);
when(results1.getTestResults()).thenReturn(testResult1);
List<ITestResult> testResult2 = mock(List.class);
ResultsForAllTests results2 = mock(ResultsForAllTests.class);
when(results2.getTestResults()).thenReturn(testResult2);
String expectedCsvContents1 = "expected-csv-contents1";
String expectedCsvContents2 = "expected-csv-contents2";
String expectedSummaryFileContents = "expected-summary-file";
when(_csvFormater.format(testResult1)).thenReturn(expectedCsvContents1);
when(_csvFormater.format(testResult2)).thenReturn(expectedCsvContents2);
_resultsFileWriter.begin();
_resultsFileWriter.writeResults(results1, "config1.json");
File resultsFile1 = new File(_outputDir, "config1.csv");
assertEquals(expectedCsvContents1, Resources.toString(resultsFile1.toURI().toURL(), StandardCharsets.UTF_8));
_resultsFileWriter.writeResults(results2, "config2.json");
File resultsFile2 = new File(_outputDir, "config2.csv");
assertEquals(expectedCsvContents2, Resources.toString(resultsFile2.toURI().toURL(), StandardCharsets.UTF_8));
when(_csvFormater.format(any(List.class))).thenReturn(expectedSummaryFileContents);
_resultsFileWriter.end();
File summaryFile = new File(_outputDir, ResultsCsvWriter.TEST_SUMMARY_FILE_NAME);
assertEquals(expectedSummaryFileContents, Resources.toString(summaryFile.toURI().toURL(), StandardCharsets.UTF_8));
}
use of org.apache.qpid.disttest.results.aggregation.ITestResult in project qpid-broker-j by apache.
the class ResultsXmlWriterTest method testResultForOneTestWithError.
@Test
public void testResultForOneTestWithError() throws Exception {
ParticipantResult resultWithError = mock(ParticipantResult.class);
when(resultWithError.hasError()).thenReturn(true);
when(resultWithError.getErrorMessage()).thenReturn("something went wrong");
ITestResult test = mock(ITestResult.class);
when(test.getName()).thenReturn("mytest");
when(test.hasErrors()).thenReturn(true);
when(test.getParticipantResults()).thenReturn(Collections.singletonList(resultWithError));
ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
when(resultsForAllTests.getTestResults()).thenReturn(Collections.singletonList(test));
String expectedXmlContent = String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<testsuite tests=\"1\">%n" + " <testcase classname=\"config.json\" name=\"mytest\">%n" + " <error message=\"something went wrong\"/>%n" + " </testcase>%n" + "</testsuite>%n");
_resultsFileWriter.writeResults(resultsForAllTests, "config.json");
File resultsFile = new File(_outputDir, "config.xml");
assertEquals(expectedXmlContent, Resources.toString(resultsFile.toURI().toURL(), StandardCharsets.UTF_8));
}
Aggregations