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());
}
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());
}
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;
}
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;
}
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());
}
Aggregations