use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified.
public void testReplyToConversionWhenExchangeAndRoutingKeyAreSpecified() {
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);
Exchange exchange = mock(Exchange.class);
when(exchange.getName()).thenReturn(exchangeName);
when(exchange.getType()).thenReturn(ExchangeDefaults.TOPIC_EXCHANGE_CLASS);
when(_addressSpace.getAttainedMessageDestination(exchangeName)).thenReturn(exchange);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected reply-to", "topic://" + exchangeName + "//?routingkey='" + routingKey + "'", convertedMessage.getContentHeaderBody().getProperties().getReplyToAsString());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testContentEncodingConversion.
public void testContentEncodingConversion() {
String contentEncoding = "my-test-encoding";
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getEncoding()).thenReturn(contentEncoding);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected content encoding", contentEncoding, convertedMessage.getContentHeaderBody().getProperties().getEncodingAsString());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testMessageIdConversion.
public void testMessageIdConversion() {
final String messageId = "testMessageId";
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getMessageId()).thenReturn(messageId);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected messageId", messageId, convertedMessage.getContentHeaderBody().getProperties().getMessageIdAsString());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testHeadersConversion.
public void testHeadersConversion() {
final Map<String, Object> properties = new HashMap<>();
properties.put("testProperty1", "testProperty1Value");
properties.put("intProperty", 1);
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);
final AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
Map<String, Object> convertedHeaders = FieldTable.convertToMap(convertedMessage.getContentHeaderBody().getProperties().getHeaders());
assertEquals("Unexpected application properties", properties, new HashMap<>(convertedHeaders));
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testCorrelationIdConversionWhenLengthExceeds255.
public void testCorrelationIdConversionWhenLengthExceeds255() {
final String correlationId = generateLongString();
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getCorrelationId()).thenReturn(correlationId);
InternalMessage originalMessage = createTestMessage(header);
try {
_messageConverter.convert(originalMessage, _addressSpace);
fail("Expected exception is not thrown");
} catch (MessageConversionException e) {
// pass
}
}
Aggregations