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