use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_0_8Test method createTestMessage.
private MessageTransferMessage createTestMessage(final DeliveryProperties deliveryProperties, final MessageProperties messageProperties, final byte[] content, final long arrivalTime) {
int bodySize = content == null ? 0 : content.length;
final org.apache.qpid.server.protocol.v0_10.transport.Header header = new org.apache.qpid.server.protocol.v0_10.transport.Header(deliveryProperties, messageProperties);
final MessageMetaData_0_10 metaData = new MessageMetaData_0_10(header, bodySize, arrivalTime);
final StoredMessage<MessageMetaData_0_10> storedMessage = mock(StoredMessage.class);
when(storedMessage.getMetaData()).thenReturn(metaData);
if (content != null) {
when(storedMessage.getContentSize()).thenReturn(content.length);
when(storedMessage.getContent(0, content.length)).thenReturn(QpidByteBuffer.wrap(content));
} else {
when(storedMessage.getContentSize()).thenReturn(0);
when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
}
return new MessageTransferMessage(storedMessage, null);
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenExchangeAndRoutingKeySpecified.
public void testReplyToConversionWhenExchangeAndRoutingKeySpecified() {
final String exchangeName = "amq.direct";
final String routingKey = "test_routing_key";
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyTo(new ReplyTo(exchangeName, routingKey));
MessageTransferMessage message = createTestMessage(messageProperties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
BasicContentHeaderProperties properties = convertedMessage.getContentHeaderBody().getProperties();
String expectedReplyTo = String.format("direct://%s//?routingkey='%s'", exchangeName, routingKey);
assertEquals("Unexpected reply-to", expectedReplyTo, properties.getReplyTo().toString());
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_0_8Test method testDiscardUnroutableTrueConversion.
public void testDiscardUnroutableTrueConversion() {
final boolean discardUnroutable = true;
final DeliveryProperties deliveryProperties = new DeliveryProperties();
deliveryProperties.setDiscardUnroutable(discardUnroutable);
MessageTransferMessage message = createTestMessage(deliveryProperties);
final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
MessagePublishInfo messagePublishInfo = convertedMessage.getMessagePublishInfo();
assertEquals("Unexpected mandatory flag", !discardUnroutable, messagePublishInfo.isMandatory());
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_10_to_0_8Test method testReplyToConversionWhenResultExceeds255.
public void testReplyToConversionWhenResultExceeds255() {
final MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyTo(new ReplyTo(generateLongString(255), generateLongString(255)));
MessageTransferMessage message = createTestMessage(messageProperties);
try {
_messageConverter.convert(message, _namedAddressSpace);
fail("expected exception not thrown");
} catch (MessageConversionException e) {
// pass
}
}
use of org.apache.qpid.server.protocol.v0_10.MessageTransferMessage in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_0_10Test method testPublishInfoRoutingKeyConversion.
public void testPublishInfoRoutingKeyConversion() {
final String testRoutingKey = "testRoutingKey";
AMQMessage message = createTestMessage(new BasicContentHeaderProperties());
message.getMessagePublishInfo().setRoutingKey(AMQShortString.valueOf(testRoutingKey));
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
assertEquals("Unexpected routing-key", testRoutingKey, deliveryProperties.getRoutingKey());
}
Aggregations