use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testDataWithContentTypeJmsStreamMessage.
public void testDataWithContentTypeJmsStreamMessage() throws Exception {
List<Object> originalMap = Collections.singletonList("testValue");
byte[] bytes = new ListToJmsStreamMessage().toMimeContent(originalMap);
final Data value = new Data(new Binary(bytes));
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf("jms/stream-message"));
Message_1_0 sourceMessage = createTestMessage(properties, value.createEncodingRetainingSection());
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "jms/stream-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.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testNoBodyWithObjectMessageContentType.
public void testNoBodyWithObjectMessageContentType() throws Exception {
final Properties properties = new Properties();
properties.setContentType(Symbol.valueOf("application/x-java-serialized-object"));
final Message_1_0 sourceMessage = createTestMessage(properties, null);
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content size", getObjectBytes(null).length, convertedMessage.getSize());
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testAmqpSequenceWithMap.
public void testAmqpSequenceWithMap() throws Exception {
final List<Object> originalList = Collections.singletonList(Collections.singletonMap("testKey", "testValue"));
final AmqpSequence amqpSequence = new AmqpSequence(originalList);
Message_1_0 sourceMessage = createTestMessage(amqpSequence.createEncodingRetainingSection());
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "amqp/list", convertedMessage.getMessageHeader().getMimeType());
final QpidByteBuffer content = convertedMessage.getContent(0, (int) convertedMessage.getSize());
List<Object> convertedList = new AmqpListToListConverter().toObject(getBytes(content));
assertEquals("Unexpected size", originalList.size(), convertedList.size());
assertEquals("Unexpected map item", new HashMap<String, Object>((Map) originalList.get(0)), new HashMap<String, Object>((Map) convertedList.get(0)));
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testNoBodyWithStreamMessageAnnotation.
public void testNoBodyWithStreamMessageAnnotation() throws Exception {
Message_1_0 sourceMessage = createTestMessage(STREAM_MESSAGE_MESSAGE_ANNOTATION, null);
final MessageTransferMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", "jms/stream-message", convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content size", 0, convertedMessage.getSize());
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class MessageConverter_1_0_to_v0_10Test method testAmqpValueWithNullWithObjectMessageAnnotation.
public void testAmqpValueWithNullWithObjectMessageAnnotation() throws Exception {
final Object expected = null;
final AmqpValue amqpValue = new AmqpValue(expected);
Message_1_0 sourceMessage = createTestMessage(OBJECT_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", "application/java-object-stream", convertedMessage.getMessageHeader().getMimeType());
assertArrayEquals("Unexpected content size", getObjectBytes(null), getBytes(content));
}
Aggregations