use of org.apache.qpid.server.store.MessageStore in project qpid-broker-j by apache.
the class SynchronousMessageStoreRecovererTest method testRecoveryDeletesOrphanMessages.
public void testRecoveryDeletesOrphanMessages() {
final long messageId = 1;
final StoredMessage<StorableMessageMetaData> storedMessage = createMockStoredMessage(messageId);
MessageStore store = new NullMessageStore() {
@Override
public void visitMessages(MessageHandler handler) throws StoreException {
handler.handle(storedMessage);
}
@Override
public void visitMessageInstances(MessageInstanceHandler handler) throws StoreException {
// No messages instances
}
};
when(_virtualHost.getMessageStore()).thenReturn(store);
SynchronousMessageStoreRecoverer recoverer = new SynchronousMessageStoreRecoverer();
recoverer.recover(_virtualHost);
verify(storedMessage, times(1)).remove();
}
use of org.apache.qpid.server.store.MessageStore in project qpid-broker-j by apache.
the class AbstractVirtualHostTest method testStartInErrorStateAfterOpen.
public void testStartInErrorStateAfterOpen() throws Exception {
Map<String, Object> attributes = Collections.<String, Object>singletonMap(AbstractVirtualHost.NAME, getTestName());
final MessageStore store = mock(MessageStore.class);
doThrow(new RuntimeException("Cannot open store")).when(store).openMessageStore(any(ConfiguredObject.class));
AbstractVirtualHost host = new AbstractVirtualHost(attributes, _node) {
@Override
protected MessageStore createMessageStore() {
return store;
}
};
host.open();
assertEquals("Unexpected state", State.ERRORED, host.getState());
doNothing().when(store).openMessageStore(any(ConfiguredObject.class));
when(store.newMessageStoreReader()).thenReturn(mock(MessageStore.MessageStoreReader.class));
host.start();
assertEquals("Unexpected state", State.ACTIVE, host.getState());
host.close();
}
use of org.apache.qpid.server.store.MessageStore in project qpid-broker-j by apache.
the class AbstractVirtualHostTest method testValidateMessageStoreCreationSucceeds.
public void testValidateMessageStoreCreationSucceeds() {
Map<String, Object> attributes = Collections.<String, Object>singletonMap(AbstractVirtualHost.NAME, getTestName());
final MessageStore store = mock(MessageStore.class);
AbstractVirtualHost host = new AbstractVirtualHost(attributes, _node) {
@Override
protected MessageStore createMessageStore() {
return store;
}
};
host.validateMessageStoreCreation();
verify(store).openMessageStore(host);
verify(store).closeMessageStore();
host.close();
}
use of org.apache.qpid.server.store.MessageStore in project qpid-broker-j by apache.
the class JDBCMessageStoreTest method testEnqueueTransactionCommitAsync.
public void testEnqueueTransactionCommitAsync() throws Exception {
final String queueName = getTestName();
final UUID transactionalLogId = UUID.randomUUID();
final MessageStore store = getStore();
final TransactionLogResource transactionalLog = mockTransactionLogResource(transactionalLogId, queueName);
final InternalMessage message = addTestMessage(store, queueName, "test");
final Transaction transaction = store.newTransaction();
final MessageEnqueueRecord record = transaction.enqueueMessage(transactionalLog, message);
assertNotNull("Message enqueue record should not be null", record);
assertEquals("Unexpected queue id", transactionalLogId, record.getQueueId());
assertEquals("Unexpected message number", message.getMessageNumber(), record.getMessageNumber());
final ListenableFuture<Void> future = transaction.commitTranAsync(null);
future.get(1000, TimeUnit.MILLISECONDS);
}
use of org.apache.qpid.server.store.MessageStore in project qpid-broker-j by apache.
the class JDBCMessageStoreTest method testDequeueTransactionCommitAsync.
public void testDequeueTransactionCommitAsync() throws Exception {
final String queueName = getTestName();
final UUID transactionalLogId = UUID.randomUUID();
final MessageStore store = getStore();
final TransactionLogResource transactionalLog = mockTransactionLogResource(transactionalLogId, queueName);
final InternalMessage message = addTestMessage(store, queueName, "test2");
final Transaction enqueueTransaction = store.newTransaction();
MessageEnqueueRecord record = enqueueTransaction.enqueueMessage(transactionalLog, message);
enqueueTransaction.commitTran();
final Transaction dequeueTransaction = store.newTransaction();
dequeueTransaction.dequeueMessage(record);
final ListenableFuture<Void> future = dequeueTransaction.commitTranAsync(null);
future.get(1000, TimeUnit.MILLISECONDS);
}
Aggregations