use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class SortedQueueEntryListTest method testInsertBefore.
public void testInsertBefore() throws Exception {
_sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
ServerMessage msg = generateTestMessage(1, "B");
_sqel.add(msg, null);
SortedQueueEntry entry = _sqel.next(_sqel.getHead());
validateEntry(entry, "B", 1);
msg = generateTestMessage(2, "A");
_sqel.add(msg, null);
entry = _sqel.next(_sqel.getHead());
validateEntry(entry, "A", 2);
entry = _sqel.next(entry);
validateEntry(entry, "B", 1);
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class SortedQueueEntryListTest method testNonUniqueSortKeys.
public void testNonUniqueSortKeys() throws Exception {
_sqel = new SelfValidatingSortedQueueEntryList(_testQueue);
// Build test list
long messageId = 0L;
while (messageId < 200) {
final ServerMessage msg = generateTestMessage(messageId++, "samekey");
_sqel.add(msg, null);
}
final QueueEntryIterator iter = getTestList().iterator();
int count = 0;
while (iter.advance()) {
assertEquals("Sorted queue entry value is not as expected", "samekey", getSortedKeyValue(iter));
assertEquals("Message id not as expected", Long.valueOf(count++), getMessageId(iter));
}
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class SortedQueueEntryTest method getQueueEntryImpl.
@Override
public QueueEntryImpl getQueueEntryImpl(int msgId) {
final ServerMessage message = mock(ServerMessage.class);
AMQMessageHeader hdr = mock(AMQMessageHeader.class);
when(message.getMessageHeader()).thenReturn(hdr);
when(hdr.getHeader(eq("KEY"))).thenReturn(keys[msgId - 1]);
when(hdr.containsHeader(eq("KEY"))).thenReturn(true);
when(hdr.getHeaderNames()).thenReturn(Collections.singleton("KEY"));
final MessageReference reference = mock(MessageReference.class);
when(reference.getMessage()).thenReturn(message);
when(message.newReference()).thenReturn(reference);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(reference);
return _queueEntryList.add(message, null);
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class StandardQueueEntryListTest method createServerMessage.
private ServerMessage createServerMessage(final long id) {
ServerMessage message = mock(ServerMessage.class);
when(message.getMessageNumber()).thenReturn(id);
final MessageReference reference = mock(MessageReference.class);
when(reference.getMessage()).thenReturn(message);
when(message.newReference()).thenReturn(reference);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(reference);
return message;
}
use of org.apache.qpid.server.message.ServerMessage in project qpid-broker-j by apache.
the class StandardQueueTest method testAutoDeleteQueue.
public void testAutoDeleteQueue() throws Exception {
getQueue().close();
getQueue().delete();
Map<String, Object> queueAttributes = new HashMap<>();
queueAttributes.put(Queue.NAME, getQname());
queueAttributes.put(Queue.LIFETIME_POLICY, LifetimePolicy.DELETE_ON_NO_OUTBOUND_LINKS);
final StandardQueueImpl queue = new StandardQueueImpl(queueAttributes, getVirtualHost());
queue.open();
setQueue(queue);
ServerMessage message = createMessage(25l);
QueueConsumer consumer = (QueueConsumer) getQueue().addConsumer(getConsumerTarget(), null, message.getClass(), "test", EnumSet.of(ConsumerOption.ACQUIRES, ConsumerOption.SEES_REQUEUES), 0);
getQueue().enqueue(message, null, null);
consumer.close();
assertTrue("Queue was not deleted when consumer was removed", getQueue().isDeleted());
}
Aggregations