use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testMessageIdUUIDConversion.
public void testMessageIdUUIDConversion() throws IOException {
UUID messageId = UUID.randomUUID();
final String messageIdAsString = messageId.toString();
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getMessageId()).thenReturn("ID:" + messageIdAsString);
InternalMessage originalMessage = createTestMessage(header);
MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected messageId", messageId, convertedMessage.getHeader().getMessageProperties().getMessageId());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testTimestampConversion.
public void testTimestampConversion() throws IOException {
final long timestamp = System.currentTimeMillis();
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getTimestamp()).thenReturn(timestamp);
InternalMessage originalMessage = createTestMessage(header);
MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected timestamp", timestamp, convertedMessage.getHeader().getDeliveryProperties().getTimestamp());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_10Test method testExpirationConversion.
public void testExpirationConversion() throws InterruptedException, IOException {
long ttl = 10000;
long arrivalTime = System.currentTimeMillis();
long expiryTime = arrivalTime + ttl;
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getExpiration()).thenReturn(expiryTime);
InternalMessage originalMessage = createTestMessage(header, arrivalTime);
MessageTransferMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected expiration time", expiryTime, convertedMessage.getHeader().getDeliveryProperties().getExpiration());
assertEquals("Unexpected TTL", ttl, convertedMessage.getHeader().getDeliveryProperties().getTtl());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class MessageConverter_v0_8_to_Internal method convert.
@Override
public InternalMessage convert(AMQMessage serverMessage, NamedAddressSpace addressSpace) {
final String mimeType = serverMessage.getMessageHeader().getMimeType();
byte[] data = new byte[(int) serverMessage.getSize()];
try (QpidByteBuffer content = serverMessage.getContent()) {
content.get(data);
}
String encoding = serverMessage.getMessageHeader().getEncoding();
byte[] uncompressed;
if (GZIPUtils.GZIP_CONTENT_ENCODING.equals(encoding) && (uncompressed = GZIPUtils.uncompressBufferToArray(ByteBuffer.wrap(data))) != null) {
data = uncompressed;
encoding = null;
}
Object body = convertMessageBody(mimeType, data);
final AMQMessageHeader convertedHeader = convertHeader(serverMessage, addressSpace, body, encoding);
return InternalMessage.convert(serverMessage, convertedHeader, body);
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class MessageConverter_v0_10_to_Internal method convert.
@Override
public InternalMessage convert(MessageTransferMessage serverMessage, NamedAddressSpace addressSpace) {
final String mimeType = serverMessage.getMessageHeader().getMimeType();
byte[] data = new byte[(int) serverMessage.getSize()];
try (QpidByteBuffer content = serverMessage.getContent()) {
content.get(data);
}
String encoding = serverMessage.getMessageHeader().getEncoding();
byte[] uncompressed;
if (GZIPUtils.GZIP_CONTENT_ENCODING.equals(encoding) && (uncompressed = GZIPUtils.uncompressBufferToArray(ByteBuffer.wrap(data))) != null) {
data = uncompressed;
encoding = null;
}
Object body = convertMessageBody(mimeType, data);
final AMQMessageHeader convertedHeader = convertHeader(serverMessage, addressSpace, body, encoding);
return InternalMessage.convert(serverMessage, convertedHeader, body);
}
Aggregations