use of org.apache.qpid.disttest.controller.CommandForClient in project qpid-broker-j by apache.
the class ClientConfig method createCommands.
public List<CommandForClient> createCommands() {
List<CommandForClient> commandsForClient = new ArrayList<CommandForClient>();
for (MessageProviderConfig messageProvider : _messageProviders) {
Command command = messageProvider.createCommand();
commandsForClient.add(new CommandForClient(_name, command));
}
for (ConnectionConfig connection : _connections) {
List<Command> commands = connection.createCommands();
for (Command command : commands) {
commandsForClient.add(new CommandForClient(_name, command));
}
}
return commandsForClient;
}
use of org.apache.qpid.disttest.controller.CommandForClient in project qpid-broker-j by apache.
the class TestConfigTest method createClientConfigReturningCommands.
private ClientConfig createClientConfigReturningCommands(final String clientName, int numberOfCommands) {
ClientConfig clientConfig = mock(ClientConfig.class);
List<CommandForClient> commandList = new ArrayList<CommandForClient>();
for (int i = 1; i <= numberOfCommands; i++) {
commandList.add(new CommandForClient(clientName, new NoOpCommand()));
}
when(clientConfig.createCommands()).thenReturn(commandList);
return clientConfig;
}
use of org.apache.qpid.disttest.controller.CommandForClient in project qpid-broker-j by apache.
the class TestInstanceTest method createTestConfig.
private TestConfig createTestConfig() {
CommandForClient commandForClient1 = new CommandForClient(CLIENT_NAME, _noOpCommand);
CommandForClient commandForClient2 = new CommandForClient(CLIENT_NAME, _createProducerCommand);
CommandForClient commandForClient3 = new CommandForClient(CLIENT_NAME, _createConsumerCommand);
TestConfig config = mock(TestConfig.class);
when(config.createCommands()).thenReturn(Arrays.asList(commandForClient1, commandForClient2, commandForClient3));
return config;
}
use of org.apache.qpid.disttest.controller.CommandForClient 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.controller.CommandForClient in project qpid-broker-j by apache.
the class ConfigTestUtils method assertCommandForClient.
public static <C extends Command> void assertCommandForClient(final List<CommandForClient> commandsForClients, final int index, final String expectedRegisteredClientName, final Class<C> expectedCommandClass) {
final CommandForClient commandForClient = commandsForClients.get(index);
assertEquals(expectedRegisteredClientName, commandForClient.getClientName());
final Command command = commandForClient.getCommand();
assertTrue("Command " + index + " is of class " + command.getClass() + " but expecting " + expectedCommandClass, expectedCommandClass.isAssignableFrom(command.getClass()));
}
Aggregations