use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties 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.transport.MessageProperties 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.transport.MessageProperties 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.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_0_10Test method testHeaderConversion.
public void testHeaderConversion() {
Map<String, Object> headers = new HashMap<>();
headers.put("testProperty1", "testProperty1Value");
headers.put("intProperty", 1);
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
basicContentHeaderProperties.setHeaders(FieldTable.convertToFieldTable(headers));
AMQMessage message = createTestMessage(basicContentHeaderProperties);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
Map<String, Object> applicationProperties = messageProperties.getApplicationHeaders();
assertEquals("Unexpected applicationProperties", headers, new HashMap<>(applicationProperties));
}
use of org.apache.qpid.server.protocol.v0_10.transport.MessageProperties in project qpid-broker-j by apache.
the class PropertyConverter_0_8_to_0_10Test method testContentTypeConversion.
public void testContentTypeConversion() {
String contentType = "test-content-type";
BasicContentHeaderProperties basicContentHeaderProperties = new BasicContentHeaderProperties();
basicContentHeaderProperties.setContentType(contentType);
AMQMessage message = createTestMessage(basicContentHeaderProperties);
final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
assertEquals("Unexpected content type", contentType, messageProperties.getContentType());
}
Aggregations