use of org.apache.qpid.server.store.TransactionLogResource in project qpid-broker-j by apache.
the class JDBCMessageStoreTest method mockTransactionLogResource.
private TransactionLogResource mockTransactionLogResource(final UUID transactionalLogId, final String transactionalLogName) {
final TransactionLogResource transactionalLog = mock(TransactionLogResource.class);
when(transactionalLog.getId()).thenReturn(transactionalLogId);
when(transactionalLog.getName()).thenReturn(transactionalLogName);
when(transactionalLog.getMessageDurability()).thenReturn(MessageDurability.ALWAYS);
return transactionalLog;
}
use of org.apache.qpid.server.store.TransactionLogResource in project qpid-broker-j by apache.
the class AbstractServerMessageTest method createQueue.
private TransactionLogResource createQueue(String name) {
TransactionLogResource queue = mock(TransactionLogResource.class);
when(queue.getId()).thenReturn(UUID.randomUUID());
when(queue.getName()).thenReturn(name);
return queue;
}
use of org.apache.qpid.server.store.TransactionLogResource in project qpid-broker-j by apache.
the class AbstractConsumerTargetTest method testConversionExceptionPolicyWhenOwningResourceIsNotMessageSource.
public void testConversionExceptionPolicyWhenOwningResourceIsNotMessageSource() throws Exception {
final TransactionLogResource owningResource = mock(TransactionLogResource.class);
when(_messageInstance.getOwningResource()).thenReturn(owningResource);
try {
_consumerTarget.sendNextMessage();
fail("exception not thrown");
} catch (ConnectionScopedRuntimeException e) {
assertTrue(String.format("ConnectionScopedRuntimeException has unexpected cause '%s'", e.getCause().getClass().getSimpleName()), e.getCause() instanceof MessageConversionException);
}
assertTrue("message credit was not restored", _consumerTarget.isCreditRestored());
verify(_messageInstance, never()).routeToAlternate(any(Action.class), any(ServerTransaction.class));
}
use of org.apache.qpid.server.store.TransactionLogResource in project qpid-broker-j by apache.
the class AutoCommitTransactionTest method createTestQueueEntries.
private Collection<MessageInstance> createTestQueueEntries(boolean[] queueDurableFlags, boolean[] messagePersistentFlags) {
Collection<MessageInstance> queueEntries = new ArrayList<MessageInstance>();
assertTrue("Boolean arrays must be the same length", queueDurableFlags.length == messagePersistentFlags.length);
for (int i = 0; i < queueDurableFlags.length; i++) {
final BaseQueue queue = createTestAMQQueue(queueDurableFlags[i]);
final ServerMessage message = createTestMessage(messagePersistentFlags[i]);
final boolean hasRecord = queueDurableFlags[i] && messagePersistentFlags[i];
queueEntries.add(new MockMessageInstance() {
@Override
public ServerMessage getMessage() {
return message;
}
@Override
public TransactionLogResource getOwningResource() {
return queue;
}
@Override
public MessageEnqueueRecord getEnqueueRecord() {
if (hasRecord) {
return mock(MessageEnqueueRecord.class);
} else {
return null;
}
}
});
}
return queueEntries;
}
use of org.apache.qpid.server.store.TransactionLogResource 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);
}
Aggregations