Search in sources :

Example 1 with CreateProducerCommand

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

the class MessageProviderTest method testNextMessage.

@Test
public void testNextMessage() throws Exception {
    MessageProvider messageProvider = new MessageProvider(null);
    CreateProducerCommand command = new CreateProducerCommand();
    command.setMessageSize(100);
    Message message = messageProvider.nextMessage(_session, command);
    assertNotNull("Mesage should be returned", message);
    verify(_message, atLeastOnce()).setText(isA(String.class));
}
Also used : Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Test(org.junit.Test)

Example 2 with CreateProducerCommand

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

the class MessageProviderTest method testNextMessageWithProperties.

@Test
public void testNextMessageWithProperties() throws Exception {
    Map<String, PropertyValue> properties = new HashMap<String, PropertyValue>();
    properties.put("test1", new SimplePropertyValue("testValue1"));
    properties.put("test2", new SimplePropertyValue(Integer.valueOf(1)));
    properties.put("priority", new SimplePropertyValue(Integer.valueOf(2)));
    List<PropertyValue> listItems = new ArrayList<PropertyValue>();
    listItems.add(new SimplePropertyValue(Double.valueOf(2.0)));
    ListPropertyValue list = new ListPropertyValue();
    list.setItems(listItems);
    properties.put("test3", list);
    MessageProvider messageProvider = new MessageProvider(properties);
    CreateProducerCommand command = new CreateProducerCommand();
    command.setMessageSize(100);
    Message message = messageProvider.nextMessage(_session, command);
    assertNotNull("Mesage should be returned", message);
    verify(_message, atLeastOnce()).setText(isA(String.class));
    verify(_message, atLeastOnce()).setJMSPriority(2);
    verify(_message, atLeastOnce()).setStringProperty("test1", "testValue1");
    verify(_message, atLeastOnce()).setIntProperty("test2", 1);
    verify(_message, atLeastOnce()).setDoubleProperty("test3", 2.0);
}
Also used : SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) Message(javax.jms.Message) TextMessage(javax.jms.TextMessage) HashMap(java.util.HashMap) CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) ArrayList(java.util.ArrayList) PropertyValue(org.apache.qpid.disttest.client.property.PropertyValue) SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) ListPropertyValue(org.apache.qpid.disttest.client.property.ListPropertyValue) ListPropertyValue(org.apache.qpid.disttest.client.property.ListPropertyValue) Test(org.junit.Test)

Example 3 with CreateProducerCommand

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

the class ParticipantResultFactoryTest method testCreateForProducer.

@Test
public void testCreateForProducer() {
    CreateProducerCommand command = new CreateProducerCommand();
    setCommonCommandFields(command);
    int deliveryMode = DeliveryMode.PERSISTENT;
    command.setDeliveryMode(deliveryMode);
    int priority = 5;
    command.setPriority(priority);
    long producerInterval = 50;
    command.setInterval(producerInterval);
    long timeToLive = 60;
    command.setTimeToLive(timeToLive);
    int totalNumberOfConsumers = 0;
    int totalNumberOfProducers = 1;
    int acknowledgeMode = 1;
    ProducerParticipantResult result = _participantResultFactory.createForProducer(PARTICIPANT_NAME, REGISTERED_CLIENT_NAME, command, acknowledgeMode, NUMBER_OF_MESSAGES_PROCESSED, PAYLOAD_SIZE, TOTAL_PAYLOAD_PROCESSED, START, END, PROVIDER_VERSION, PROTOCOL_VERSION);
    assertCommonResultProperties(result);
    assertEquals((long) deliveryMode, (long) result.getDeliveryMode());
    assertEquals((long) acknowledgeMode, (long) result.getAcknowledgeMode());
    assertEquals((long) priority, (long) result.getPriority());
    assertEquals(producerInterval, result.getInterval());
    assertEquals(timeToLive, result.getTimeToLive());
    assertEquals((long) totalNumberOfConsumers, (long) result.getTotalNumberOfConsumers());
}
Also used : CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) ProducerParticipantResult(org.apache.qpid.disttest.message.ProducerParticipantResult) Test(org.junit.Test)

Example 4 with CreateProducerCommand

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

the class ProducerConfigTest method testMessageSizeDefault.

@Test
public void testMessageSizeDefault() {
    CreateProducerCommand producer = new ProducerConfig().createCommand("session1");
    assertEquals("Unexpected default message size", (long) 1024, (long) producer.getMessageSize());
}
Also used : CreateProducerCommand(org.apache.qpid.disttest.message.CreateProducerCommand) Test(org.junit.Test)

Example 5 with CreateProducerCommand

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

the class ProducerConfigTest method testConfigProvidesJmsDefaults.

@Test
public void testConfigProvidesJmsDefaults() {
    CreateProducerCommand p = new ProducerConfig().createCommand("session1");
    assertEquals((long) Message.DEFAULT_DELIVERY_MODE, (long) p.getDeliveryMode());
    assertEquals((long) Message.DEFAULT_PRIORITY, (long) p.getPriority());
    assertEquals(Message.DEFAULT_TIME_TO_LIVE, p.getTimeToLive());
}
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