use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testReplyToConversionWhenReplyToCannotBeResolved.
public void testReplyToConversionWhenReplyToCannotBeResolved() throws IOException {
final AMQMessageHeader header = mock(AMQMessageHeader.class);
final String replyTo = "direct://amq.direct//test?routingkey='test'";
when(header.getReplyTo()).thenReturn(replyTo);
InternalMessage originalMessage = createTestMessage(header);
MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
final ReplyTo convertedReplyTo = convertedMessage.getHeader().getMessageProperties().getReplyTo();
assertEquals("Unexpected exchange", "", convertedReplyTo.getExchange());
assertEquals("Unexpected routing key", replyTo, convertedReplyTo.getRoutingKey());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testMessageIdStringConversion.
public void testMessageIdStringConversion() throws IOException {
final String messageId = "testMessageId";
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getMessageId()).thenReturn(messageId);
InternalMessage originalMessage = createTestMessage(header);
MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertNull("Unexpected messageId", convertedMessage.getHeader().getMessageProperties().getMessageId());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testHeadersConversionWhenKeyLengthExceeds255.
public void testHeadersConversionWhenKeyLengthExceeds255() throws IOException {
final Map<String, Object> properties = Collections.singletonMap(generateLongString(), "test");
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getHeaderNames()).thenReturn(properties.keySet());
doAnswer(invocation -> {
final String originalArgument = (String) (invocation.getArguments())[0];
return properties.get(originalArgument);
}).when(header).getHeader(any(String.class));
InternalMessage originalMessage = createTestMessage(header);
try {
_messageConverter.convert(originalMessage, _addressSpace);
fail("Expected exception not thrown");
} catch (MessageConversionException e) {
// pass
}
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testToConversionWhenDestinationIsSpecifiedButDoesNotExists.
public void testToConversionWhenDestinationIsSpecifiedButDoesNotExists() throws IOException {
final String testDestination = "testDestination";
InternalMessage message = createTestMessage(testDestination);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _addressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected exchange", "", deliveryProperties.getExchange());
assertEquals("Unexpected routing key", testDestination, deliveryProperties.getRoutingKey());
}
use of org.apache.qpid.server.message.internal.InternalMessage in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method createTestMessage.
private InternalMessage createTestMessage(String to) throws IOException {
final InternalMessageHeader internalMessageHeader = new InternalMessageHeader(mock(AMQMessageHeader.class));
final StoredMessage<InternalMessageMetaData> handle = createInternalStoredMessage(null, false, internalMessageHeader);
return new InternalMessage(handle, internalMessageHeader, null, to);
}
Aggregations