Search in sources :

Example 1 with PropertyValue

use of org.apache.qpid.disttest.client.property.PropertyValue in project qpid-broker-j by apache.

the class ClientConfigTest method createClientConfigWithMessageProviderConfigReturningCommands.

private ClientConfig createClientConfigWithMessageProviderConfigReturningCommands() {
    Map<String, PropertyValue> messageProperties = new HashMap<String, PropertyValue>();
    messageProperties.put("test", new SimplePropertyValue("testValue"));
    MessageProviderConfig config = new MessageProviderConfig("test", messageProperties);
    List<MessageProviderConfig> providerConfigs = new ArrayList<MessageProviderConfig>();
    providerConfigs.add(config);
    return new ClientConfig(CLIENT1, new ArrayList<ConnectionConfig>(), providerConfigs);
}
Also used : SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PropertyValue(org.apache.qpid.disttest.client.property.PropertyValue) SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue)

Example 2 with PropertyValue

use of org.apache.qpid.disttest.client.property.PropertyValue in project qpid-broker-j by apache.

the class MessageProviderConfigTest method testCreateCommandsForMessageProvider.

@Test
public void testCreateCommandsForMessageProvider() {
    Map<String, PropertyValue> messageProperties = new HashMap<String, PropertyValue>();
    messageProperties.put("test", new SimplePropertyValue("testValue"));
    MessageProviderConfig config = new MessageProviderConfig("test", messageProperties);
    CreateMessageProviderCommand command = config.createCommand();
    assertNotNull("Command should not be null", command);
    assertNotNull("Unexpected name", command.getProviderName());
    assertEquals("Unexpected properties", messageProperties, command.getMessageProperties());
}
Also used : SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) HashMap(java.util.HashMap) PropertyValue(org.apache.qpid.disttest.client.property.PropertyValue) SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) CreateMessageProviderCommand(org.apache.qpid.disttest.message.CreateMessageProviderCommand) Test(org.junit.Test)

Example 3 with PropertyValue

use of org.apache.qpid.disttest.client.property.PropertyValue in project qpid-broker-j by apache.

the class JsonHandlerTest method testGeneratorDesrialization.

@Test
public void testGeneratorDesrialization() throws Exception {
    String json = "{'_messageProperties': {'test': 1, 'generator': {'@def': 'list',  '_cyclic': false, '_items': ['first', " + "{'@def': 'range', '_upper':10, '_type':'int'}]}}}";
    final TestCommand unmarshalledCommand = _jsonHandler.unmarshall(json, TestCommand.class);
    Map<String, PropertyValue> properties = unmarshalledCommand.getMessageProperties();
    assertNotNull("Properties should not be null", properties);
    assertFalse("Properties should not be empty", properties.isEmpty());
    assertEquals("Unexpected properties size", (long) 2, (long) properties.size());
    PropertyValue testProperty = properties.get("test");
    assertNotNull("Unexpected property test", testProperty);
    final boolean condition1 = testProperty.getValue() instanceof Number;
    assertTrue("Unexpected property test", condition1);
    assertEquals("Unexpected property value", (long) 1, (long) ((Number) testProperty.getValue()).intValue());
    Object generatorObject = properties.get("generator");
    final boolean condition = generatorObject instanceof ListPropertyValue;
    assertTrue("Unexpected generator object : " + generatorObject, condition);
    PropertyValue generator = (PropertyValue) generatorObject;
    assertEquals("Unexpected generator value", "first", generator.getValue());
    for (int i = 0; i < 10; i++) {
        assertEquals("Unexpected generator value", Integer.valueOf(i), generator.getValue());
    }
    String newJson = _jsonHandler.marshall(unmarshalledCommand);
    final TestCommand newUnmarshalledCommand = _jsonHandler.unmarshall(newJson, TestCommand.class);
    assertEquals("Unmarshalled command should be equal to the original object", unmarshalledCommand, newUnmarshalledCommand);
}
Also used : PropertyValue(org.apache.qpid.disttest.client.property.PropertyValue) ListPropertyValue(org.apache.qpid.disttest.client.property.ListPropertyValue) ListPropertyValue(org.apache.qpid.disttest.client.property.ListPropertyValue) Test(org.junit.Test)

Example 4 with PropertyValue

use of org.apache.qpid.disttest.client.property.PropertyValue 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 5 with PropertyValue

use of org.apache.qpid.disttest.client.property.PropertyValue in project qpid-broker-j by apache.

the class MessageProviderConfigTest method testMessageProviderConfig.

@Test
public void testMessageProviderConfig() {
    Map<String, PropertyValue> messageProperties = new HashMap<String, PropertyValue>();
    messageProperties.put("test", new SimplePropertyValue("testValue"));
    MessageProviderConfig config = new MessageProviderConfig("test", messageProperties);
    assertEquals("Unexpected name", "test", config.getName());
    assertEquals("Unexpected properties", messageProperties, config.getMessageProperties());
}
Also used : SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) HashMap(java.util.HashMap) PropertyValue(org.apache.qpid.disttest.client.property.PropertyValue) SimplePropertyValue(org.apache.qpid.disttest.client.property.SimplePropertyValue) Test(org.junit.Test)

Aggregations

PropertyValue (org.apache.qpid.disttest.client.property.PropertyValue)6 Test (org.junit.Test)5 HashMap (java.util.HashMap)4 SimplePropertyValue (org.apache.qpid.disttest.client.property.SimplePropertyValue)4 ListPropertyValue (org.apache.qpid.disttest.client.property.ListPropertyValue)3 ArrayList (java.util.ArrayList)2 Message (javax.jms.Message)1 TextMessage (javax.jms.TextMessage)1 CreateMessageProviderCommand (org.apache.qpid.disttest.message.CreateMessageProviderCommand)1 CreateProducerCommand (org.apache.qpid.disttest.message.CreateProducerCommand)1