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