use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testLongContentEncodingConversion.
public void testLongContentEncodingConversion() {
String contentEncoding = generateLongString();
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getEncoding()).thenReturn(contentEncoding);
InternalMessage originalMessage = createTestMessage(header);
try {
_messageConverter.convert(originalMessage, _addressSpace);
fail("Expected exception is not thrown");
} catch (MessageConversionException e) {
// pass
}
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testMessageHoldingDependentOnQueueProperty.
public void testMessageHoldingDependentOnQueueProperty() throws Exception {
_queue.close();
Map<String, Object> attributes = new HashMap<>(_arguments);
attributes.put(Queue.NAME, _qname);
attributes.put(Queue.OWNER, _owner);
attributes.put(Queue.HOLD_ON_PUBLISH_ENABLED, Boolean.FALSE);
_queue = _virtualHost.createChild(Queue.class, attributes);
ServerMessage messageA = createMessage(new Long(24));
AMQMessageHeader messageHeader = messageA.getMessageHeader();
when(messageHeader.getNotValidBefore()).thenReturn(System.currentTimeMillis() + 20000L);
_queue.enqueue(messageA, null, null);
_consumer = (QueueConsumer<?, ?>) _queue.addConsumer(_consumerTarget, null, messageA.getClass(), "test", EnumSet.of(ConsumerOption.ACQUIRES, ConsumerOption.SEES_REQUEUES), 0);
while (_consumerTarget.processPending()) ;
assertEquals("Message was held despite queue not having holding enabled", 1, _consumerTarget.getMessages().size());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testUnheldMessageOvertakesHeld.
public void testUnheldMessageOvertakesHeld() throws Exception {
_queue.close();
Map<String, Object> attributes = new HashMap<>(_arguments);
attributes.put(Queue.NAME, _qname);
attributes.put(Queue.OWNER, _owner);
attributes.put(Queue.HOLD_ON_PUBLISH_ENABLED, Boolean.TRUE);
_queue = _virtualHost.createChild(Queue.class, attributes);
ServerMessage messageA = createMessage(new Long(24));
AMQMessageHeader messageHeader = messageA.getMessageHeader();
when(messageHeader.getNotValidBefore()).thenReturn(System.currentTimeMillis() + 20000L);
_queue.enqueue(messageA, null, null);
ServerMessage messageB = createMessage(new Long(25));
_queue.enqueue(messageB, null, null);
_consumer = (QueueConsumer<?, ?>) _queue.addConsumer(_consumerTarget, null, messageA.getClass(), "test", EnumSet.of(ConsumerOption.ACQUIRES, ConsumerOption.SEES_REQUEUES), 0);
while (_consumerTarget.processPending()) ;
assertEquals("Expect one message (message B)", 1, _consumerTarget.getMessages().size());
assertEquals("Wrong message received", messageB.getMessageHeader().getMessageId(), _consumerTarget.getMessages().get(0).getMessage().getMessageHeader().getMessageId());
when(messageHeader.getNotValidBefore()).thenReturn(System.currentTimeMillis() - 100L);
_queue.checkMessageStatus();
while (_consumerTarget.processPending()) ;
assertEquals("Message which was valid was not received", 2, _consumerTarget.getMessages().size());
assertEquals("Wrong message received", messageA.getMessageHeader().getMessageId(), _consumerTarget.getMessages().get(1).getMessage().getMessageHeader().getMessageId());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class AbstractQueueTestBase method createMessage.
protected ServerMessage createMessage(Long id) {
AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getMessageId()).thenReturn(String.valueOf(id));
ServerMessage message = mock(ServerMessage.class);
when(message.getMessageNumber()).thenReturn(id);
when(message.getMessageHeader()).thenReturn(header);
StoredMessage storedMessage = mock(StoredMessage.class);
when(message.getStoredMessage()).thenReturn(storedMessage);
MessageReference ref = mock(MessageReference.class);
when(ref.getMessage()).thenReturn(message);
when(message.newReference()).thenReturn(ref);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
return message;
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class RingOverflowPolicyHandlerTest method createLastEntry.
private QueueEntry createLastEntry() {
AMQMessageHeader oldestMessageHeader = mock(AMQMessageHeader.class);
ServerMessage oldestMessage = mock(ServerMessage.class);
when(oldestMessage.getMessageHeader()).thenReturn(oldestMessageHeader);
QueueEntry oldestEntry = mock(QueueEntry.class);
when(oldestEntry.getMessage()).thenReturn(oldestMessage);
return oldestEntry;
}
Aggregations