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 MessageStoreTestCase method createEnqueueableMessage.
private EnqueueableMessage createEnqueueableMessage(long messageId1) {
final StoredMessage<TestMessageMetaData> message1 = _store.addMessage(new TestMessageMetaData(messageId1, 0)).allContentAdded();
EnqueueableMessage enqueueableMessage1 = createMockEnqueueableMessage(messageId1, message1);
return enqueueableMessage1;
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreTestCase method testRollbackTransactionAfterCommit.
public void testRollbackTransactionAfterCommit() throws Exception {
final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
TransactionLogResource mockQueue = createTransactionLogResource(mockQueueId);
long messageId1 = 30L;
long messageId2 = 31L;
long messageId3 = 32L;
final EnqueueableMessage enqueueableMessage1 = createEnqueueableMessage(messageId1);
final EnqueueableMessage enqueueableMessage2 = createEnqueueableMessage(messageId2);
final EnqueueableMessage enqueueableMessage3 = createEnqueueableMessage(messageId3);
Transaction txn = getStore().newTransaction();
txn.enqueueMessage(mockQueue, enqueueableMessage1);
txn.commitTran();
txn = getStore().newTransaction();
txn.enqueueMessage(mockQueue, enqueueableMessage2);
txn.abortTran();
txn = getStore().newTransaction();
txn.enqueueMessage(mockQueue, enqueueableMessage3);
txn.commitTran();
QueueFilteringMessageInstanceHandler filter = new QueueFilteringMessageInstanceHandler(mockQueueId);
_storeReader.visitMessageInstances(filter);
Set<Long> enqueuedIds = filter.getEnqueuedIds();
assertEquals("Number of enqueued messages is incorrect", 2, enqueuedIds.size());
assertTrue("Message with id " + messageId1 + " is not found", enqueuedIds.contains(messageId1));
assertTrue("Message with id " + messageId3 + " is not found", enqueuedIds.contains(messageId3));
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreTestCase method testRollbackTransactionBeforeCommit.
public void testRollbackTransactionBeforeCommit() throws Exception {
final UUID mockQueueId = UUIDGenerator.generateRandomUUID();
TransactionLogResource mockQueue = createTransactionLogResource(mockQueueId);
long messageId1 = 21L;
long messageId2 = 22L;
long messageId3 = 23L;
final EnqueueableMessage enqueueableMessage1 = createEnqueueableMessage(messageId1);
final EnqueueableMessage enqueueableMessage2 = createEnqueueableMessage(messageId2);
final EnqueueableMessage enqueueableMessage3 = createEnqueueableMessage(messageId3);
Transaction txn = getStore().newTransaction();
txn.enqueueMessage(mockQueue, enqueueableMessage1);
txn.abortTran();
txn = getStore().newTransaction();
txn.enqueueMessage(mockQueue, enqueueableMessage2);
txn.enqueueMessage(mockQueue, enqueueableMessage3);
txn.commitTran();
QueueFilteringMessageInstanceHandler filter = new QueueFilteringMessageInstanceHandler(mockQueueId);
_storeReader.visitMessageInstances(filter);
Set<Long> enqueuedIds = filter.getEnqueuedIds();
assertEquals("Number of enqueued messages is incorrect", 2, enqueuedIds.size());
assertTrue("Message with id " + messageId2 + " is not found", enqueuedIds.contains(messageId2));
assertTrue("Message with id " + messageId3 + " is not found", enqueuedIds.contains(messageId3));
}
use of org.apache.qpid.server.message.EnqueueableMessage in project qpid-broker-j by apache.
the class MessageStoreTestCase method createMockEnqueueableMessage.
private EnqueueableMessage createMockEnqueueableMessage(long messageId, final StoredMessage<TestMessageMetaData> message) {
EnqueueableMessage enqueueableMessage = mock(EnqueueableMessage.class);
when(enqueueableMessage.isPersistent()).thenReturn(true);
when(enqueueableMessage.getMessageNumber()).thenReturn(messageId);
when(enqueueableMessage.getStoredMessage()).thenReturn(message);
return enqueueableMessage;
}
Aggregations