Search in sources :

Example 6 with PropertyValue

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

the class JsonHandlerTest method testSimplePropertyValueMarshallUnmarshall.

@Test
public void testSimplePropertyValueMarshallUnmarshall() throws Exception {
    String json = "{'_messageProperties': {'test': 1}}";
    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) 1, (long) properties.size());
    PropertyValue testProperty = properties.get("test");
    assertNotNull("Unexpected property test", testProperty);
    final boolean condition = testProperty.getValue() instanceof Number;
    assertTrue("Unexpected property test", condition);
    assertEquals("Unexpected property value", (long) 1, (long) ((Number) testProperty.getValue()).intValue());
    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) 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