Search in sources :

Example 1 with AmqpMapToMapConverter

use of org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.AmqpMapToMapConverter in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testAmqpValueWithMapContainingMap.

public void testAmqpValueWithMapContainingMap() throws Exception {
    final Map<String, Object> originalMap = Collections.singletonMap("testMap", Collections.singletonMap("innerKey", "testValue"));
    final AmqpValue amqpValue = new AmqpValue(originalMap);
    Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "amqp/map", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    Map<String, Object> convertedMap = new AmqpMapToMapConverter().toObject(getBytes(content));
    assertEquals("Unexpected size", originalMap.size(), convertedMap.size());
    assertEquals("Unexpected binary entry", new HashMap((Map<String, Object>) originalMap.get("testMap")), new HashMap((Map<String, Object>) convertedMap.get("testMap")));
}
Also used : MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpMapToMapConverter(org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.AmqpMapToMapConverter) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) HashMap(java.util.HashMap) JmsMapMessageToMap(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 2 with AmqpMapToMapConverter

use of org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.AmqpMapToMapConverter in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method testAmqpValueWithMapContainingMap.

public void testAmqpValueWithMapContainingMap() throws Exception {
    final Map<String, Object> originalMap = Collections.singletonMap("testMap", Collections.singletonMap("innerKey", "testValue"));
    final AmqpValue amqpValue = new AmqpValue(originalMap);
    Message_1_0 sourceMessage = createTestMessage(amqpValue.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "amqp/map", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    Map<String, Object> convertedMap = new AmqpMapToMapConverter().toObject(getBytes(content));
    assertEquals("Unexpected size", originalMap.size(), convertedMap.size());
    assertEquals("Unexpected binary entry", new HashMap((Map<String, Object>) originalMap.get("testMap")), new HashMap((Map<String, Object>) convertedMap.get("testMap")));
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) AmqpMapToMapConverter(org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.AmqpMapToMapConverter) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) HashMap(java.util.HashMap) JmsMapMessageToMap(org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)2 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)2 AmqpMapToMapConverter (org.apache.qpid.server.protocol.v0_10.transport.mimecontentconverter.AmqpMapToMapConverter)2 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)2 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)2 JmsMapMessageToMap (org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap)2 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)1 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)1