Search in sources :

Example 11 with MapToJmsMapMessage

use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method testNoBodyWithMapMessageAnnotation.

public void testNoBodyWithMapMessageAnnotation() throws Exception {
    Message_1_0 sourceMessage = createTestMessage(MAP_MESSAGE_MESSAGE_ANNOTATION, null);
    final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    assertArrayEquals("Unexpected content size", new MapToJmsMapMessage().toMimeContent(Collections.emptyMap()), getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 12 with MapToJmsMapMessage

use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method testNoBodyWithJmsMapContentType.

public void testNoBodyWithJmsMapContentType() throws Exception {
    final Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("jms/map-message"));
    final Message_1_0 sourceMessage = createTestMessage(properties, null);
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    assertArrayEquals("Unexpected content size", new MapToJmsMapMessage().toMimeContent(Collections.emptyMap()), getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 13 with MapToJmsMapMessage

use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method testDataWithContentTypeJmsMapMessage.

public void testDataWithContentTypeJmsMapMessage() throws Exception {
    Map<String, Object> originalMap = Collections.singletonMap("testKey", "testValue");
    byte[] bytes = new MapToJmsMapMessage().toMimeContent(originalMap);
    final Data value = new Data(new Binary(bytes));
    Properties properties = new Properties();
    properties.setContentType(Symbol.valueOf("jms/map-message"));
    Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertArrayEquals("Unexpected content", bytes, getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Data(org.apache.qpid.server.protocol.v1_0.type.messaging.Data) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 14 with MapToJmsMapMessage

use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8Test method testNoBodyWithMapMessageAnnotation.

public void testNoBodyWithMapMessageAnnotation() throws Exception {
    Message_1_0 sourceMessage = createTestMessage(MAP_MESSAGE_MESSAGE_ANNOTATION, null);
    final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
    assertEquals("Unexpected mime type", "jms/map-message", convertedMessage.getMessageHeader().getMimeType());
    assertArrayEquals("Unexpected content size", new MapToJmsMapMessage().toMimeContent(Collections.emptyMap()), getBytes(content));
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 15 with MapToJmsMapMessage

use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.

the class MessageConverter_Internal_to_0_10Test method testMapMessageWithoutMimeType.

public void testMapMessageWithoutMimeType() throws Exception {
    HashMap<Object, Object> content = new HashMap<>();
    content.put("key1", 37);
    content.put("key2", "foo");
    final MapToJmsMapMessage mapToJmsMapMessage = new MapToJmsMapMessage();
    final byte[] expectedContent = mapToJmsMapMessage.toMimeContent(content);
    doTest(content, null, expectedContent, mapToJmsMapMessage.getMimeType());
}
Also used : MapToJmsMapMessage(org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage) HashMap(java.util.HashMap)

Aggregations

MapToJmsMapMessage (org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage)16 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)12 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)12 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)12 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)8 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)8 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)6 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)6 HashMap (java.util.HashMap)4 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)4 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)4 Data (org.apache.qpid.server.protocol.v1_0.type.messaging.Data)4