use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class QueueMessageRecoveryTest method createMockMessage.
private ServerMessage createMockMessage(final long i) {
ServerMessage msg = mock(ServerMessage.class);
when(msg.getMessageNumber()).thenReturn(i);
MessageReference ref = mock(MessageReference.class);
when(ref.getMessage()).thenReturn(msg);
when(msg.newReference()).thenReturn(ref);
when(msg.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(msg.getStoredMessage()).thenReturn(mock(StoredMessage.class));
return msg;
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class RejectPolicyHandlerTest method testNotOverfullBytes.
public void testNotOverfullBytes() throws Exception {
when(_queue.getMaximumQueueDepthBytes()).thenReturn(9L);
ServerMessage incomingMessage1 = createIncomingMessage(5);
MessageInstance messageInstance1 = mock(MessageInstance.class);
when(messageInstance1.getMessage()).thenReturn(incomingMessage1);
ServerMessage incomingMessage2 = createIncomingMessage(5);
_rejectOverflowPolicyHandler.checkReject(incomingMessage1);
_rejectOverflowPolicyHandler.postEnqueue(messageInstance1);
_rejectOverflowPolicyHandler.checkReject(incomingMessage2);
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class RejectPolicyHandlerTest method createIncomingMessage.
private ServerMessage createIncomingMessage(final long size) {
AMQMessageHeader incomingMessageHeader = mock(AMQMessageHeader.class);
ServerMessage incomingMessage = mock(ServerMessage.class);
when(incomingMessage.getMessageHeader()).thenReturn(incomingMessageHeader);
when(incomingMessage.getSizeIncludingHeader()).thenReturn(size);
when(incomingMessage.getStoredMessage()).thenReturn(mock(StoredMessage.class));
return incomingMessage;
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class RejectPolicyHandlerTest method testNotOverfullMessages.
public void testNotOverfullMessages() throws Exception {
when(_queue.getMaximumQueueDepthMessages()).thenReturn(1L);
ServerMessage incomingMessage1 = createIncomingMessage(2);
MessageInstance messageInstance1 = mock(MessageInstance.class);
when(messageInstance1.getMessage()).thenReturn(incomingMessage1);
ServerMessage incomingMessage2 = createIncomingMessage(2);
_rejectOverflowPolicyHandler.checkReject(incomingMessage1);
_rejectOverflowPolicyHandler.postEnqueue(messageInstance1);
_rejectOverflowPolicyHandler.checkReject(incomingMessage2);
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class SortedQueueEntryListTest method setUp.
@Override
protected void setUp() throws Exception {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(Queue.ID, UUID.randomUUID());
attributes.put(Queue.NAME, getName());
attributes.put(Queue.DURABLE, false);
attributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.PERMANENT);
attributes.put(SortedQueue.SORT_KEY, "KEY");
// Create test list
final QueueManagingVirtualHost virtualHost = BrokerTestHelper.createVirtualHost("testVH");
_testQueue = new SortedQueueImpl(attributes, virtualHost) {
SelfValidatingSortedQueueEntryList _entries;
@Override
protected void onOpen() {
super.onOpen();
_entries = new SelfValidatingSortedQueueEntryList(this);
}
@Override
SelfValidatingSortedQueueEntryList getEntries() {
return _entries;
}
};
_testQueue.open();
_sqel = (SelfValidatingSortedQueueEntryList) _testQueue.getEntries();
super.setUp();
// Create result array
Arrays.sort(keysSorted);
// Build test list
long messageId = 0L;
for (final String key : keys) {
final ServerMessage msg = generateTestMessage(messageId++, key);
_sqel.add(msg, null);
}
}
Aggregations