use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method createConnection.
public void createConnection(final CreateConnectionCommand command) {
try {
final ConnectionFactory connectionFactory = (ConnectionFactory) _context.lookup(command.getConnectionFactoryName());
final Connection newConnection = connectionFactory.createConnection();
addConnection(command.getConnectionName(), newConnection);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Connection " + command.getConnectionName() + " is created " + metaDataToString(newConnection.getMetaData()));
}
} catch (final NamingException ne) {
throw new DistributedTestException("Unable to lookup factoryName: " + command.getConnectionFactoryName(), ne);
} catch (final JMSException jmse) {
throw new DistributedTestException("Unable to create connection: " + command.getConnectionName() + " (using factory name: " + command.getConnectionFactoryName() + ")", jmse);
}
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method tearDownTest.
public void tearDownTest() {
StringBuilder jmsErrorMessages = new StringBuilder();
int failureCounter = 0;
for (String subscription : _testSubscriptions.keySet()) {
Session session = _testSubscriptions.get(subscription);
try {
session.unsubscribe(subscription);
} catch (JMSException e) {
LOGGER.error("Failed to unsubscribe '" + subscription + "' :" + e.getLocalizedMessage(), e);
failureCounter++;
appendErrorMessage(jmsErrorMessages, e);
}
}
for (Map.Entry<String, Connection> entry : _testConnections.entrySet()) {
Connection connection = entry.getValue();
try {
connection.close();
} catch (JMSException e) {
LOGGER.error("Failed to close connection '" + entry.getKey() + "' :" + e.getLocalizedMessage(), e);
failureCounter++;
appendErrorMessage(jmsErrorMessages, e);
}
}
_testConnections.clear();
_testSubscriptions.clear();
_testSessions.clear();
_testProducers.clear();
_testConsumers.clear();
_testSessionToConnections.clear();
if (failureCounter > 0) {
throw new DistributedTestException("Tear down test encountered " + failureCounter + " failures with the following errors: " + jmsErrorMessages.toString());
}
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ResultsCsvWriter method writeResultsToOutputFile.
private void writeResultsToOutputFile(List<ITestResult> resultsForAllTests, String outputFile) {
try (FileWriter writer = new FileWriter(outputFile)) {
final String outputCsv = _csvFormater.format(resultsForAllTests);
writer.write(outputCsv);
LOGGER.info("Wrote {} test result(s) to output file {}", resultsForAllTests.size(), outputFile);
} catch (IOException e) {
throw new DistributedTestException("Unable to write output file " + outputFile, e);
}
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class TestInstance method createCommands.
public List<CommandForClient> createCommands() {
List<CommandForClient> commands = _testConfig.createCommands();
List<CommandForClient> newCommands = new ArrayList<CommandForClient>(commands.size());
double ratePerProducer = calculateRatePerProducer(_producerRate, commands);
for (CommandForClient commandForClient : commands) {
String clientName = commandForClient.getClientName();
Command command = commandForClient.getCommand();
_iterationValue.applyToCommand(command);
if (command instanceof CreateProducerCommand) {
CreateProducerCommand producerCommand = (CreateProducerCommand) command;
producerCommand.setRate(ratePerProducer);
}
if (command instanceof CreateParticipantCommand) {
CreateParticipantCommand participantCommand = (CreateParticipantCommand) command;
if ((participantCommand.getNumberOfMessages() <= 0 && participantCommand.getMaximumDuration() <= 0)) {
throw new DistributedTestException("Test '" + getName() + "' must specify a positive integer value for numberOfMessages or maximumDuration");
}
}
newCommands.add(new CommandForClient(clientName, command));
}
return newCommands;
}
use of org.apache.qpid.disttest.DistributedTestException in project qpid-broker-j by apache.
the class ClientJmsDelegate method sendCommand.
private void sendCommand(final Command command) {
try {
final Message message = JmsMessageAdaptor.commandToMessage(_controllerSession, command);
_controlQueueProducer.send(message);
LOGGER.debug("Sent message for " + command.getType() + ". message id: " + message.getJMSMessageID());
} catch (final JMSException jmse) {
throw new DistributedTestException("Unable to send command: " + command, jmse);
}
}
Aggregations