use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testDurableTrueConversion.
public void testDurableTrueConversion() {
final AMQMessageHeader header = mock(AMQMessageHeader.class);
InternalMessage originalMessage = createTestMessage(header, null, true);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected delivery mode", BasicContentHeaderProperties.PERSISTENT, convertedMessage.getContentHeaderBody().getProperties().getDeliveryMode());
assertTrue("Unexpected persistence of message", convertedMessage.isPersistent());
assertTrue("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testExpirationConversion.
public void testExpirationConversion() throws InterruptedException {
long ttl = 10000;
long expiryTime = System.currentTimeMillis() + ttl;
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getExpiration()).thenReturn(expiryTime);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected expiration time", expiryTime, convertedMessage.getContentHeaderBody().getProperties().getExpiration());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testDurableFalseConversion.
public void testDurableFalseConversion() {
final AMQMessageHeader header = mock(AMQMessageHeader.class);
InternalMessage originalMessage = createTestMessage(header, null, false);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected delivery mode", BasicContentHeaderProperties.NON_PERSISTENT, convertedMessage.getContentHeaderBody().getProperties().getDeliveryMode());
assertFalse("Unexpected persistence of message", convertedMessage.isPersistent());
assertFalse("Unexpected persistence of meta data", convertedMessage.getStoredMessage().getMetaData().isPersistent());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testHeadersConversionWhenKeyLengthExceeds255.
public void testHeadersConversionWhenKeyLengthExceeds255() {
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.AMQMessageHeader in project qpid-broker-j by apache.
the class ReportRunnerTest method createMockMessageForQueue.
protected ServerMessage createMockMessageForQueue() {
final ServerMessage message = mock(ServerMessage.class);
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(message.getMessageHeader()).thenReturn(header);
when(message.getContent()).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
return message;
}
Aggregations