use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class FlowToDiskTransactionObserverTest method createMessage.
private EnqueueableMessage<?> createMessage(int size) {
EnqueueableMessage message = mock(EnqueueableMessage.class);
StoredMessage handle = mock(StoredMessage.class);
when(message.getStoredMessage()).thenReturn(handle);
when(handle.getContentSize()).thenReturn(size);
final StorableMessageMetaData metadata = mock(StorableMessageMetaData.class);
when(metadata.getStorableSize()).thenReturn(0);
when(metadata.getContentSize()).thenReturn(size);
when(handle.getMetaData()).thenReturn(metadata);
return message;
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreQuotaEventsTestBase method testOverflow.
@Test
public void testOverflow() throws Exception {
Transaction transaction = _store.newTransaction();
List<EnqueueableMessage> messages = new ArrayList<EnqueueableMessage>();
for (int i = 0; i < getNumberOfMessagesToFillStore(); i++) {
EnqueueableMessage m = addMessage(i);
messages.add(m);
transaction.enqueueMessage(this, m);
}
transaction.commitTran();
assertEvent(1, Event.PERSISTENT_MESSAGE_SIZE_OVERFULL);
for (EnqueueableMessage m : messages) {
m.getStoredMessage().remove();
}
assertEvent(2, Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL);
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreTestCase method enqueueMessage.
private void enqueueMessage(final StoredMessage<TestMessageMetaData> message, final String queueName) {
Transaction txn = _store.newTransaction();
txn.enqueueMessage(new TransactionLogResource() {
private final UUID _id = UUID.nameUUIDFromBytes(queueName.getBytes());
@Override
public String getName() {
return queueName;
}
@Override
public UUID getId() {
return _id;
}
@Override
public MessageDurability getMessageDurability() {
return MessageDurability.DEFAULT;
}
}, new EnqueueableMessage() {
@Override
public long getMessageNumber() {
return message.getMessageNumber();
}
@Override
public boolean isPersistent() {
return true;
}
@Override
public StoredMessage getStoredMessage() {
return message;
}
});
txn.commitTran();
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreTestCase method getTestRecord.
private TestRecord getTestRecord(long messageNumber) {
UUID queueId1 = UUIDGenerator.generateRandomUUID();
TransactionLogResource queue1 = mock(TransactionLogResource.class);
when(queue1.getId()).thenReturn(queueId1);
EnqueueableMessage message1 = mock(EnqueueableMessage.class);
when(message1.isPersistent()).thenReturn(true);
when(message1.getMessageNumber()).thenReturn(messageNumber);
final StoredMessage<?> storedMessage = mock(StoredMessage.class);
when(storedMessage.getMessageNumber()).thenReturn(messageNumber);
when(message1.getStoredMessage()).thenReturn(storedMessage);
TestRecord enqueueRecord = new TestRecord(queue1, message1);
return enqueueRecord;
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreTestCase method testVisitMessageInstances.
@Test
public void testVisitMessageInstances() throws Exception {
long messageId = 1;
int contentSize = 0;
final StoredMessage<TestMessageMetaData> message = _store.addMessage(new TestMessageMetaData(messageId, contentSize)).allContentAdded();
EnqueueableMessage enqueueableMessage = createMockEnqueueableMessage(messageId, message);
UUID queueId = UUID.randomUUID();
TransactionLogResource queue = createTransactionLogResource(queueId);
Transaction transaction = _store.newTransaction();
transaction.enqueueMessage(queue, enqueueableMessage);
transaction.commitTran();
MessageInstanceHandler handler = mock(MessageInstanceHandler.class);
_storeReader.visitMessageInstances(handler);
verify(handler, times(1)).handle(argThat(new EnqueueRecordMatcher(queueId, messageId)));
}
Aggregations