use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class SortedQueueEntryListTest method generateTestMessage.
private ServerMessage generateTestMessage(final long id, final String keyValue) {
final ServerMessage message = mock(ServerMessage.class);
AMQMessageHeader hdr = mock(AMQMessageHeader.class);
when(message.getMessageHeader()).thenReturn(hdr);
when(hdr.getHeader(eq("KEY"))).thenReturn(keyValue);
when(hdr.containsHeader(eq("KEY"))).thenReturn(true);
when(hdr.getHeaderNames()).thenReturn(Collections.singleton("KEY"));
MessageReference ref = mock(MessageReference.class);
when(ref.getMessage()).thenReturn(message);
when(message.newReference()).thenReturn(ref);
when(message.newReference(any(TransactionLogResource.class))).thenReturn(ref);
when(message.getMessageNumber()).thenReturn(id);
return message;
}
use of org.apache.qpid.server.message.MessageReference 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.MessageReference 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.MessageReference in project qpid-broker-j by apache.
the class ReferenceCountingTest method testMessageGetsRemoved.
/**
* Check that when the reference count is decremented the message removes itself from the store
*/
public void testMessageGetsRemoved() throws QpidException {
ContentHeaderBody chb = createPersistentContentHeader();
MessagePublishInfo info = new MessagePublishInfo(null, false, false, null);
final MessageMetaData mmd = new MessageMetaData(info, chb);
StoredMessage storedMessage = _store.addMessage(mmd).allContentAdded();
Transaction txn = _store.newTransaction();
txn.enqueueMessage(createTransactionLogResource("dummyQ"), createEnqueueableMessage(storedMessage));
txn.commitTran();
AMQMessage message = new AMQMessage(storedMessage);
MessageReference ref = message.newReference();
assertEquals(1, getStoreMessageCount());
ref.release();
assertEquals(0, getStoreMessageCount());
}
use of org.apache.qpid.server.message.MessageReference in project qpid-broker-j by apache.
the class ReferenceCountingTest method testMessageRemains.
public void testMessageRemains() throws QpidException {
MessagePublishInfo info = new MessagePublishInfo(null, false, false, null);
final ContentHeaderBody chb = createPersistentContentHeader();
final MessageMetaData mmd = new MessageMetaData(info, chb);
StoredMessage storedMessage = _store.addMessage(mmd).allContentAdded();
Transaction txn = _store.newTransaction();
txn.enqueueMessage(createTransactionLogResource("dummyQ"), createEnqueueableMessage(storedMessage));
txn.commitTran();
AMQMessage message = new AMQMessage(storedMessage);
MessageReference ref = message.newReference();
assertEquals(1, getStoreMessageCount());
MessageReference ref2 = message.newReference();
ref.release();
assertEquals(1, getStoreMessageCount());
}
Aggregations