use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class AbstractTestRunner method awaitTestResults.
private void awaitTestResults() {
long timeout = _testResultTimeout;
DistributedTestException lastException = null;
boolean waitForever = _testResultTimeout == WAIT_FOREVER;
final long interval = waitForever ? PARTICIPANT_RESULTS_LOG_INTERVAL : Math.min(PARTICIPANT_RESULTS_LOG_INTERVAL, _testResultTimeout);
while (_testResultsLatch.getCount() > 0 && (waitForever || timeout > 0)) {
try {
awaitLatch(_testResultsLatch, interval, "still waiting for participant results");
} catch (DistributedTestException e) {
lastException = e;
LOGGER.info(e.getMessage());
}
if (!waitForever) {
timeout = -interval;
}
}
if (_testResultsLatch.getCount() > 0) {
throw lastException;
}
}
use of org.apache.qpid.disttest.DistributedTestException 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.DistributedTestException in project qpid-broker-j by apache.
the class JmsMessageAdaptor method commandToMessage.
public static Message commandToMessage(final Session session, final Command command) {
Message jmsMessage = null;
try {
jmsMessage = session.createMessage();
jmsMessage.setStringProperty(DistributedTestConstants.MSG_COMMAND_PROPERTY, command.getType().name());
final JsonHandler jsonHandler = new JsonHandler();
jmsMessage.setStringProperty(DistributedTestConstants.MSG_JSON_PROPERTY, jsonHandler.marshall(command));
} catch (final JMSException | IOException e) {
throw new DistributedTestException("Unable to convert command " + command + " to JMS Message", e);
}
return jmsMessage;
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ControllerTest method testControllerRejectsEmptyConfiguration.
@Test
public void testControllerRejectsEmptyConfiguration() {
Config configWithZeroClients = createMockConfig(0);
try {
_controller.setConfig(configWithZeroClients);
fail("Exception not thrown");
} catch (DistributedTestException e) {
// PASS
}
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class OrdinaryTestRunnerTest method testClientRespondingWithErrorResponseStopsTest.
@Test
public void testClientRespondingWithErrorResponseStopsTest() {
Response errorResponse = new Response(CLIENT1_REGISTERED_NAME, CommandType.CREATE_CONNECTION, "error occurred");
configureMockToReturnResponseTo(CreateConnectionCommand.class, errorResponse, null);
_testInstance = createTestInstanceWithConnection();
_testRunner = new OrdinaryTestRunner(_participatingClients, _testInstance, _respondingJmsDelegate, COMMAND_RESPONSE_TIMEOUT, TEST_RESULT_TIMEOUT);
try {
_testRunner.run();
fail("Exception not thrown");
} catch (DistributedTestException e) {
assertEquals("One or more clients were unable to successfully process commands. " + "1 command(s) generated an error response.", e.getMessage());
}
}
Aggregations