Search in sources :

Example 6 with ResultsForAllTests

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;
}
Also used : ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests)

Example 7 with ResultsForAllTests

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;
}
Also used : Config(org.apache.qpid.disttest.controller.config.Config) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests)

Example 8 with 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));
}
Also used : ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) List(java.util.List) File(java.io.File) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Example 9 with ResultsForAllTests

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));
}
Also used : ParticipantResult(org.apache.qpid.disttest.message.ParticipantResult) ITestResult(org.apache.qpid.disttest.results.aggregation.ITestResult) File(java.io.File) ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Example 10 with ResultsForAllTests

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);
}
Also used : ResultsForAllTests(org.apache.qpid.disttest.controller.ResultsForAllTests) Test(org.junit.Test)

Aggregations

ResultsForAllTests (org.apache.qpid.disttest.controller.ResultsForAllTests)11 Test (org.junit.Test)7 File (java.io.File)4 ITestResult (org.apache.qpid.disttest.results.aggregation.ITestResult)4 ParticipantResult (org.apache.qpid.disttest.message.ParticipantResult)3 Config (org.apache.qpid.disttest.controller.config.Config)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Context (javax.naming.Context)1 TestResult (org.apache.qpid.disttest.controller.TestResult)1 ParticipantAttribute (org.apache.qpid.disttest.message.ParticipantAttribute)1 ResultsTestFixture (org.apache.qpid.disttest.results.ResultsTestFixture)1