use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class LastValueQueueListTest method createTestServerMessage.
private ServerMessage createTestServerMessage(String conflationKeyValue) {
ServerMessage mockMessage = mock(ServerMessage.class);
AMQMessageHeader messageHeader = mock(AMQMessageHeader.class);
when(messageHeader.getHeader(CONFLATION_KEY)).thenReturn(conflationKeyValue);
when(mockMessage.getMessageHeader()).thenReturn(messageHeader);
MessageReference messageReference = mock(MessageReference.class);
when(mockMessage.newReference()).thenReturn(messageReference);
when(mockMessage.newReference(any(TransactionLogResource.class))).thenReturn(messageReference);
when(messageReference.getMessage()).thenReturn(mockMessage);
return mockMessage;
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PriorityQueueListTest method testGetLeastSignificantOldestEntry.
public void testGetLeastSignificantOldestEntry() {
assertEquals("Unexpected last entry", _priority4message1, _list.getLeastSignificantOldestEntry());
ServerMessage<?> message = mock(ServerMessage.class);
AMQMessageHeader header = mock(AMQMessageHeader.class);
@SuppressWarnings({ "rawtypes", "unchecked" }) MessageReference<ServerMessage> ref = mock(MessageReference.class);
when(message.getMessageHeader()).thenReturn(header);
when(message.newReference()).thenReturn(ref);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(ref.getMessage()).thenReturn(message);
when(header.getPriority()).thenReturn((byte) 3);
QueueEntry newEntry = _list.add(message, null);
assertEquals("Unexpected last entry", newEntry, _list.getLeastSignificantOldestEntry());
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PriorityQueueListTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
BrokerTestHelper.setUp();
QueueEntry[] entries = new QueueEntry[PRIORITIES.length];
Map<String, Object> queueAttributes = new HashMap<String, Object>();
queueAttributes.put(Queue.ID, UUID.randomUUID());
queueAttributes.put(Queue.NAME, getName());
queueAttributes.put(PriorityQueue.PRIORITIES, 10);
final QueueManagingVirtualHost<?> virtualHost = BrokerTestHelper.createVirtualHost("testVH");
PriorityQueueImpl queue = new PriorityQueueImpl(queueAttributes, virtualHost);
queue.open();
_list = queue.getEntries();
for (int i = 0; i < PRIORITIES.length; i++) {
ServerMessage<?> message = mock(ServerMessage.class);
AMQMessageHeader header = mock(AMQMessageHeader.class);
@SuppressWarnings({ "rawtypes", "unchecked" }) MessageReference<ServerMessage> ref = mock(MessageReference.class);
when(message.getMessageHeader()).thenReturn(header);
when(message.newReference()).thenReturn(ref);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(ref.getMessage()).thenReturn(message);
when(header.getPriority()).thenReturn(PRIORITIES[i]);
entries[i] = _list.add(message, null);
}
_priority4message1 = entries[0];
_priority4message2 = entries[3];
_priority5message1 = entries[1];
_priority5message2 = entries[2];
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class PriorityQueueTest method createMessage.
protected ServerMessage createMessage(Long id, byte i) {
ServerMessage msg = super.createMessage(id);
AMQMessageHeader hdr = msg.getMessageHeader();
when(hdr.getPriority()).thenReturn(i);
return msg;
}
use of org.apache.qpid.server.message.AMQMessageHeader in project qpid-broker-j by apache.
the class QueueEntryListTestBase method createServerMessage.
private ServerMessage createServerMessage(long number) {
final ServerMessage message = mock(ServerMessage.class);
when(message.getMessageNumber()).thenReturn(number);
MessageReference ref = mock(MessageReference.class);
AMQMessageHeader hdr = mock(AMQMessageHeader.class);
when(ref.getMessage()).thenReturn(message);
when(message.newReference()).thenReturn(ref);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(message.getMessageHeader()).thenReturn(hdr);
return message;
}
Aggregations