use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_0_10Test method testMapMessageWithMimeType.
public void testMapMessageWithMimeType() throws Exception {
HashMap<Object, Object> content = new HashMap<>();
content.put("key1", 37);
content.put("key2", "foo");
final String mimeType = "foo/bar";
final MapToJmsMapMessage mapToJmsMapMessage = new MapToJmsMapMessage();
final byte[] expectedContent = mapToJmsMapMessage.toMimeContent(content);
doTest(content, mimeType, expectedContent, mapToJmsMapMessage.getMimeType());
}
use of org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_0_8Test 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());
}
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 testAmqpValueWithNullWithMapMessageAnnotation.
public void testAmqpValueWithNullWithMapMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(MAP_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
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));
}
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 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 MessageTransferMessage 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));
}
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 testAmqpValueWithNullWithMapMessageAnnotation.
public void testAmqpValueWithNullWithMapMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(MAP_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
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));
}
Aggregations