use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_0_8_to_InternalTest method doTest.
private void doTest(final byte[] messageBytes, final String mimeType, final Object expectedContent, final String expectedMimeType) throws Exception {
final AMQMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
if (expectedContent instanceof byte[]) {
assertArrayEquals("Unexpected content", ((byte[]) expectedContent), ((byte[]) convertedMessage.getMessageBody()));
} else if (expectedContent instanceof List) {
assertEquals("Unexpected content", new ArrayList((Collection) expectedContent), new ArrayList((Collection) convertedMessage.getMessageBody()));
} else if (expectedContent instanceof Map) {
assertEquals("Unexpected content", new HashMap((Map) expectedContent), new HashMap((Map) convertedMessage.getMessageBody()));
} else {
assertEquals("Unexpected content", expectedContent, convertedMessage.getMessageBody());
}
String convertedMimeType = convertedMessage.getMessageHeader().getMimeType();
assertEquals("Unexpected content type", expectedMimeType, convertedMimeType);
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class MessageConverter_Internal_to_0_8Test method doTest.
private void doTest(final Serializable messageBytes, final String mimeType, final byte[] expectedContent, final String expectedContentType) throws Exception {
final InternalMessage sourceMessage = getAmqMessage(messageBytes, mimeType);
final AMQMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
final QpidByteBuffer content = convertedMessage.getContent();
assertArrayEquals("Unexpected content", expectedContent != null ? expectedContent : new byte[0], getBytes(content));
assertEquals("Unexpected content type", expectedContentType, convertedMessage.getMessageHeader().getMimeType());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testUserIdConversion.
public void testUserIdConversion() {
final String userId = "testUserId";
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getUserId()).thenReturn(userId);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected userId", userId, convertedMessage.getContentHeaderBody().getProperties().getUserIdAsString());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testReplyToConversionWhenNonExistingExchangeAndRoutingKeyAreSpecified.
public void testReplyToConversionWhenNonExistingExchangeAndRoutingKeyAreSpecified() {
final String exchangeName = "testExchange";
final String routingKey = "testKey";
final String replyTo = String.format("%s/%s", exchangeName, routingKey);
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getReplyTo()).thenReturn(replyTo);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected reply-to", "direct:////?routingkey='" + replyTo + "'", convertedMessage.getContentHeaderBody().getProperties().getReplyToAsString());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testToConversionWhenGlobalAddressIsKnown.
public void testToConversionWhenGlobalAddressIsKnown() {
final String globalPrefix = "/testPrefix";
final String queueName = "testQueue";
final String globalAddress = globalPrefix + "/" + queueName;
InternalMessage message = createTestMessage(globalAddress);
Queue<?> queue = mock(Queue.class);
when(queue.getName()).thenReturn(queueName);
when(_addressSpace.getAttainedMessageDestination(queueName)).thenReturn(queue);
when(_addressSpace.getLocalAddress(globalAddress)).thenReturn(queueName);
final AMQMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
final MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected exchange", "", messagePublishInfo.getExchange().toString());
assertEquals("Unexpected routing key", queueName, messagePublishInfo.getRoutingKey().toString());
}
Aggregations