use of org.apache.activemq.state.CommandVisitor in project activemq-artemis by apache.
the class ActiveMQMessageTest method testConvertProperties.
public void testConvertProperties() throws Exception {
org.apache.activemq.command.Message msg = new org.apache.activemq.command.Message() {
@Override
public org.apache.activemq.command.Message copy() {
return null;
}
@Override
public void beforeMarshall(WireFormat wireFormat) throws IOException {
super.beforeMarshall(wireFormat);
}
@Override
public byte getDataStructureType() {
return 0;
}
@Override
public Response visit(CommandVisitor visitor) throws Exception {
return null;
}
@Override
public void clearBody() throws JMSException {
}
@Override
public void storeContent() {
}
@Override
public void storeContentAndClear() {
}
};
msg.setProperty("stringProperty", "string");
msg.setProperty("byteProperty", Byte.valueOf("1"));
msg.setProperty("shortProperty", Short.valueOf("1"));
msg.setProperty("intProperty", Integer.valueOf("1"));
msg.setProperty("longProperty", Long.valueOf("1"));
msg.setProperty("floatProperty", Float.valueOf("1.1f"));
msg.setProperty("doubleProperty", Double.valueOf("1.1"));
msg.setProperty("booleanProperty", Boolean.TRUE);
msg.setProperty("nullProperty", null);
msg.beforeMarshall(new OpenWireFormat());
Map<String, Object> properties = msg.getProperties();
assertEquals(properties.get("stringProperty"), "string");
assertEquals(((Byte) properties.get("byteProperty")).byteValue(), 1);
assertEquals(((Short) properties.get("shortProperty")).shortValue(), 1);
assertEquals(((Integer) properties.get("intProperty")).intValue(), 1);
assertEquals(((Long) properties.get("longProperty")).longValue(), 1);
assertEquals(((Float) properties.get("floatProperty")).floatValue(), 1.1f, 0);
assertEquals(((Double) properties.get("doubleProperty")).doubleValue(), 1.1, 0);
assertEquals(((Boolean) properties.get("booleanProperty")).booleanValue(), true);
assertNull(properties.get("nullProperty"));
}
Aggregations