Search in sources :

Example 1 with CommandForClient

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;
}
Also used : Command(org.apache.qpid.disttest.message.Command) ArrayList(java.util.ArrayList) CommandForClient(org.apache.qpid.disttest.controller.CommandForClient)

Example 2 with CommandForClient

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;
}
Also used : ArrayList(java.util.ArrayList) ConfigTestUtils.assertCommandForClient(org.apache.qpid.disttest.controller.config.ConfigTestUtils.assertCommandForClient) CommandForClient(org.apache.qpid.disttest.controller.CommandForClient) NoOpCommand(org.apache.qpid.disttest.message.NoOpCommand)

Example 3 with CommandForClient

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

Example 4 with CommandForClient

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;
}
Also used : DistributedTestException(org.apache.qpid.disttest.DistributedTestException) CreateParticipantCommand(org.apache.qpid.disttest.message.CreateParticipantCommand) CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Command(org.apache.qpid.disttest.message.Command) CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) ArrayList(java.util.ArrayList) CommandForClient(org.apache.qpid.disttest.controller.CommandForClient) CreateParticipantCommand(org.apache.qpid.disttest.message.CreateParticipantCommand)

Example 5 with CommandForClient

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

Aggregations

CommandForClient (org.apache.qpid.disttest.controller.CommandForClient)5 ArrayList (java.util.ArrayList)3 Command (org.apache.qpid.disttest.message.Command)3 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)1 ConfigTestUtils.assertCommandForClient (org.apache.qpid.disttest.controller.config.ConfigTestUtils.assertCommandForClient)1 CreateParticipantCommand (org.apache.qpid.disttest.message.CreateParticipantCommand)1 CreateProducerCommand (org.apache.qpid.disttest.message.CreateProducerCommand)1 NoOpCommand (org.apache.qpid.disttest.message.NoOpCommand)1