Search in sources :

Example 6 with CreateProducerCommand

use of org.apache.qpid.disttest.message.CreateProducerCommand in project qpid-broker-j by apache.

the class ProducerConfigTest method testCreateProducerCommand.

@Test
public void testCreateProducerCommand() {
    String destination = "url:/destination";
    int messageSize = 1000;
    int numberOfMessages = 10;
    int priority = 4;
    long timeToLive = 10000;
    int batchSize = 5;
    long interval = 60;
    long maximumDuration = 70;
    long startDelay = 80;
    String providerName = "testProvider1";
    ProducerConfig producerConfig = new ProducerConfig("producer1", destination, numberOfMessages, batchSize, maximumDuration, DeliveryMode.NON_PERSISTENT, messageSize, priority, timeToLive, interval, providerName);
    CreateProducerCommand command = producerConfig.createCommand("session1");
    assertEquals("session1", command.getSessionName());
    assertEquals("producer1", command.getParticipantName());
    assertEquals(destination, command.getDestinationName());
    assertEquals((long) numberOfMessages, command.getNumberOfMessages());
    assertEquals((long) batchSize, (long) command.getBatchSize());
    assertEquals(maximumDuration, command.getMaximumDuration());
    assertEquals((long) DeliveryMode.NON_PERSISTENT, (long) command.getDeliveryMode());
    assertEquals((long) messageSize, (long) command.getMessageSize());
    assertEquals((long) priority, (long) command.getPriority());
    assertEquals(timeToLive, command.getTimeToLive());
    assertEquals(interval, command.getInterval());
    assertEquals(providerName, command.getMessageProviderName());
}
Also used : CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Test(org.junit.Test)

Example 7 with CreateProducerCommand

use of org.apache.qpid.disttest.message.CreateProducerCommand in project qpid-broker-j by apache.

the class ProducerConfigTest method testCreateProducerCommandAppliesDurationOverride.

@Test
public void testCreateProducerCommandAppliesDurationOverride() {
    long overriddenDuration = 123;
    setTestSystemProperty(ParticipantConfig.DURATION_OVERRIDE_SYSTEM_PROPERTY, String.valueOf(overriddenDuration));
    ProducerConfig producerConfig = new ProducerConfig("", "", 0, 0, 1, 0, 0, 0, 0, 0, "");
    CreateProducerCommand command = producerConfig.createCommand("name");
    assertEquals((long) 123, command.getMaximumDuration());
}
Also used : CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Test(org.junit.Test)

Example 8 with CreateProducerCommand

use of org.apache.qpid.disttest.message.CreateProducerCommand in project qpid-broker-j by apache.

the class ProducerConfig method createCommand.

public CreateProducerCommand createCommand(String sessionName) {
    CreateProducerCommand command = new CreateProducerCommand();
    setParticipantProperties(command);
    command.setSessionName(sessionName);
    command.setDeliveryMode(_deliveryMode);
    final Integer overriddenMessageSize = getOverriddenMessageSize();
    Integer messageSize = overriddenMessageSize == null ? _messageSize : overriddenMessageSize;
    command.setMessageSize(messageSize);
    command.setPriority(_priority);
    command.setTimeToLive(_timeToLive);
    command.setInterval(_interval);
    command.setMessageProviderName(_messageProviderName);
    return command;
}
Also used : CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand)

Example 9 with CreateProducerCommand

use of org.apache.qpid.disttest.message.CreateProducerCommand 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 10 with CreateProducerCommand

use of org.apache.qpid.disttest.message.CreateProducerCommand in project qpid-broker-j by apache.

the class MessageProviderTest method testGetMessagePayload.

@Test
public void testGetMessagePayload() throws Exception {
    MessageProvider messageProvider = new MessageProvider(null) {

        @Override
        public String getMessagePayload(CreateProducerCommand command) {
            return super.getMessagePayload(command);
        }
    };
    CreateProducerCommand command = new CreateProducerCommand();
    command.setMessageSize(100);
    String payloadValue = messageProvider.getMessagePayload(command);
    assertNotNull("Mesage payload should not be null", payloadValue);
    assertEquals("Unexpected payload size", (long) 100, (long) payloadValue.length());
}
Also used : CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Test(org.junit.Test)

Aggregations

CreateProducerCommand (org.apache.qpid.disttest.message.CreateProducerCommand)12 Test (org.junit.Test)10 ArrayList (java.util.ArrayList)2 Message (javax.jms.Message)2 TextMessage (javax.jms.TextMessage)2 HashMap (java.util.HashMap)1 DistributedTestException (org.apache.qpid.disttest.DistributedTestException)1 ListPropertyValue (org.apache.qpid.disttest.client.property.ListPropertyValue)1 PropertyValue (org.apache.qpid.disttest.client.property.PropertyValue)1 SimplePropertyValue (org.apache.qpid.disttest.client.property.SimplePropertyValue)1 CommandForClient (org.apache.qpid.disttest.controller.CommandForClient)1 Command (org.apache.qpid.disttest.message.Command)1 CreateParticipantCommand (org.apache.qpid.disttest.message.CreateParticipantCommand)1 ProducerParticipantResult (org.apache.qpid.disttest.message.ProducerParticipantResult)1