Search in sources :

Example 6 with Command

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());
}
Also used : ConfigTestUtils.getCommand(org.apache.qpid.disttest.controller.config.ConfigTestUtils.getCommand) CreateConsumerCommand(org.apache.qpid.disttest.message.CreateConsumerCommand) CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Command(org.apache.qpid.disttest.message.Command) CreateSessionCommand(org.apache.qpid.disttest.message.CreateSessionCommand) CreateSessionCommand(org.apache.qpid.disttest.message.CreateSessionCommand) Test(org.junit.Test)

Example 7 with Command

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));
}
Also used : Response(org.apache.qpid.disttest.message.Response) StopClientCommand(org.apache.qpid.disttest.message.StopClientCommand) Command(org.apache.qpid.disttest.message.Command) StopClientCommand(org.apache.qpid.disttest.message.StopClientCommand) Test(org.junit.Test)

Example 8 with Command

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;
}
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 9 with Command

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);
}
Also used : DistributedTestException(org.apache.qpid.disttest.DistributedTestException) RegisterClientCommand(org.apache.qpid.disttest.message.RegisterClientCommand) CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) RegisterClientCommand(org.apache.qpid.disttest.message.RegisterClientCommand) CreateSessionCommand(org.apache.qpid.disttest.message.CreateSessionCommand) CreateConsumerCommand(org.apache.qpid.disttest.message.CreateConsumerCommand) CreateMessageProviderCommand(org.apache.qpid.disttest.message.CreateMessageProviderCommand) Command(org.apache.qpid.disttest.message.Command) CreateConnectionCommand(org.apache.qpid.disttest.message.CreateConnectionCommand) JMSException(javax.jms.JMSException)

Example 10 with 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);
    }
}
Also used : StartDataCollectionCommand(org.apache.qpid.disttest.message.StartDataCollectionCommand) Command(org.apache.qpid.disttest.message.Command) StartTestCommand(org.apache.qpid.disttest.message.StartTestCommand) TearDownTestCommand(org.apache.qpid.disttest.message.TearDownTestCommand) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Command (org.apache.qpid.disttest.message.Command)11 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)3 CommandForClient (org.apache.qpid.disttest.controller.CommandForClient)3 ConfigTestUtils.getCommand (org.apache.qpid.disttest.controller.config.ConfigTestUtils.getCommand)3 CreateConnectionCommand (org.apache.qpid.disttest.message.CreateConnectionCommand)3 CreateProducerCommand (org.apache.qpid.disttest.message.CreateProducerCommand)3 RegisterClientCommand (org.apache.qpid.disttest.message.RegisterClientCommand)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 JMSException (javax.jms.JMSException)2 CreateConsumerCommand (org.apache.qpid.disttest.message.CreateConsumerCommand)2 CreateSessionCommand (org.apache.qpid.disttest.message.CreateSessionCommand)2 NoOpCommand (org.apache.qpid.disttest.message.NoOpCommand)2 Response (org.apache.qpid.disttest.message.Response)2 StopClientCommand (org.apache.qpid.disttest.message.StopClientCommand)2 HashMap (java.util.HashMap)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Message (javax.jms.Message)1 MessageConsumer (javax.jms.MessageConsumer)1 MessageListener (javax.jms.MessageListener)1