use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class SessionConfigTest method testCreateCommandsForSessionAndChildren.
@Test
public void testCreateCommandsForSessionAndChildren() {
SessionConfig sessionConfig = createSessionConfigWithChildCommands();
List<Command> commands = sessionConfig.createCommands(CONNECTION_NAME);
assertEquals((long) 3, (long) commands.size());
assertCommandEquals(commands, 0, CreateSessionCommand.class);
assertCommandEquals(commands, 1, CreateProducerCommand.class);
assertCommandEquals(commands, 2, CreateConsumerCommand.class);
CreateSessionCommand createSessionCommand = getCommand(commands, 0);
assertEquals((long) Session.AUTO_ACKNOWLEDGE, (long) createSessionCommand.getAcknowledgeMode());
assertEquals(SESSION, createSessionCommand.getSessionName());
assertEquals(CONNECTION_NAME, createSessionCommand.getConnectionName());
}
use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class ClientTest method testProcessInstructionVisitsCommandAndResponds.
@Test
public void testProcessInstructionVisitsCommandAndResponds() throws Exception {
// has to be declared to be of supertype Command otherwise Mockito verify()
// refers to wrong method
final Command command = new StopClientCommand();
_client.processInstruction(command);
verify(_visitor).visit(command);
verify(_delegate).sendResponseMessage(isA(Response.class));
}
use of org.apache.qpid.disttest.message.Command 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.message.Command in project qpid-broker-j by apache.
the class ClientJmsDelegate method sendRegistrationMessage.
public void sendRegistrationMessage() {
Command command;
try {
command = new RegisterClientCommand(_clientName, _instructionQueue.getQueueName());
} catch (final JMSException e) {
throw new DistributedTestException(e);
}
sendCommand(command);
}
use of org.apache.qpid.disttest.message.Command in project qpid-broker-j by apache.
the class AbstractTestRunner method sendTestSetupCommands.
private void sendTestSetupCommands() {
List<CommandForClient> commandsForAllClients = _testInstance.createCommands();
validateCommands(commandsForAllClients);
final int numberOfCommandsToSend = commandsForAllClients.size();
_commandResponseLatch = new CountDownLatch(numberOfCommandsToSend);
LOGGER.debug("About to send {} command(s)", numberOfCommandsToSend);
for (CommandForClient commandForClient : commandsForAllClients) {
String configuredClientName = commandForClient.getClientName();
String registeredClientName = _participatingClients.getRegisteredNameFromConfiguredName(configuredClientName);
Command command = commandForClient.getCommand();
LOGGER.debug("Sending command : {} ", command);
sendCommandInternal(registeredClientName, command);
}
}
Aggregations