use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.
the class Aggregator method aggregateResults.
public ResultsForAllTests aggregateResults(ResultsForAllTests rawResultsForAllTests) {
ResultsForAllTests aggregatedResultsForAllTests = new ResultsForAllTests();
for (ITestResult testResult : rawResultsForAllTests.getTestResults()) {
AggregatedTestResult aggregateTestResult = _testResultAggregator.aggregateTestResult(testResult);
aggregatedResultsForAllTests.add(aggregateTestResult);
}
return aggregatedResultsForAllTests;
}
use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.
the class ControllerRunner method runTest.
private ResultsForAllTests runTest(Controller controller, String testConfigFile) {
final Config testConfig = buildTestConfigFrom(testConfigFile);
controller.setConfig(testConfig);
ResultsForAllTests rawResultsForAllTests = controller.runAllTests();
ResultsForAllTests resultsForAllTests = _aggregator.aggregateResults(rawResultsForAllTests);
_resultsWriter.writeResults(resultsForAllTests, testConfigFile);
return resultsForAllTests;
}
use of org.apache.qpid.disttest.controller.ResultsForAllTests 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.controller.ResultsForAllTests 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));
}
use of org.apache.qpid.disttest.controller.ResultsForAllTests in project qpid-broker-j by apache.
the class AggregatorTest method testAggregrateManyTestResults.
@Test
public void testAggregrateManyTestResults() throws Exception {
ResultsForAllTests resultsForAllTests = mock(ResultsForAllTests.class);
ITestResult testResult1 = mock(ITestResult.class);
ITestResult testResult2 = mock(ITestResult.class);
when(resultsForAllTests.getTestResults()).thenReturn(Arrays.asList(testResult1, testResult2));
when(_testResultAggregator.aggregateTestResult(testResult1)).thenReturn(mock(AggregatedTestResult.class));
when(_testResultAggregator.aggregateTestResult(testResult2)).thenReturn(mock(AggregatedTestResult.class));
ResultsForAllTests aggregatedResultsForAllTests = _aggregator.aggregateResults(resultsForAllTests);
assertEquals((long) 2, (long) aggregatedResultsForAllTests.getTestResults().size());
verify(_testResultAggregator).aggregateTestResult(testResult1);
verify(_testResultAggregator).aggregateTestResult(testResult2);
}
Aggregations