use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testPriorityConversion.
public void testPriorityConversion() throws IOException {
final AMQMessageHeader header = mock(AMQMessageHeader.class);
byte priority = (byte) 7;
when(header.getPriority()).thenReturn(priority);
InternalMessage originalMessage = createTestMessage(header);
MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected priority", priority, convertedMessage.getHeader().getDeliveryProperties().getPriority().getValue());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_v0_8_to_InternalTest method testReplyToNonBurl.
public void testReplyToNonBurl() {
final String replyTo = "test/routing";
BasicContentHeaderProperties header = new BasicContentHeaderProperties();
header.setReplyTo(replyTo);
final AMQMessage originalMessage = createTestMessage(header);
InternalMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected replyTo", replyTo, convertedMessage.getMessageHeader().getReplyTo());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_1_0Test method doTest.
private void doTest(final Serializable messageBytes, final String mimeType, final Class<? extends EncodingRetainingSection<?>> expectedBodySection, final Object expectedContent, final Symbol expectedContentType, final Byte expectedJmsTypeAnnotation) throws Exception {
final InternalMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
final Message_1_0 convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
final QpidByteBuffer content = convertedMessage.getContent();
List<EncodingRetainingSection<?>> sections = getEncodingRetainingSections(content, 1);
EncodingRetainingSection<?> encodingRetainingSection = sections.get(0);
assertEquals("Unexpected section type", expectedBodySection, encodingRetainingSection.getClass());
if (expectedContent instanceof byte[]) {
assertArrayEquals("Unexpected content", ((byte[]) expectedContent), ((Binary) encodingRetainingSection.getValue()).getArray());
} else {
assertEquals("Unexpected content", expectedContent, encodingRetainingSection.getValue());
}
Symbol contentType = getContentType(convertedMessage);
if (expectedContentType == null) {
assertNull("Content type should be null", contentType);
} else {
assertEquals("Unexpected content type", expectedContentType, contentType);
}
Byte jmsMessageTypeAnnotation = getJmsMessageTypeAnnotation(convertedMessage);
if (expectedJmsTypeAnnotation == null) {
assertEquals("Unexpected annotation 'x-opt-jms-msg-type'", null, jmsMessageTypeAnnotation);
} else {
assertEquals("Unexpected annotation 'x-opt-jms-msg-type'", expectedJmsTypeAnnotation, jmsMessageTypeAnnotation);
}
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method testNoBody.
public void testNoBody() throws Exception {
final Message_1_0 sourceMessage = createTestMessage(null);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
assertEquals("Unexpected content", null, convertedMessage.getMessageBody());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_v1_0_to_InternalTest method doTestDataWithAnnotation.
private void doTestDataWithAnnotation(final byte[] data, final MessageAnnotations messageAnnotations, final String mimeType, final String expectedMimeType) {
final Data value = new Data(new Binary(data));
Message_1_0 sourceMessage;
if (mimeType != null) {
Properties properties = new Properties();
properties.setContentType(Symbol.valueOf(mimeType));
sourceMessage = createTestMessage(properties, messageAnnotations, value.createEncodingRetainingSection());
} else {
sourceMessage = createTestMessage(messageAnnotations, value.createEncodingRetainingSection());
}
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
assertEquals("Unexpected mime type", expectedMimeType, convertedMessage.getMessageHeader().getMimeType());
assertArrayEquals("Unexpected content", data, ((byte[]) convertedMessage.getMessageBody()));
}
Aggregations