use of org.neo4j.kernel.impl.transaction.log.TransactionAppender in project neo4j by neo4j.
the class TransactionRepresentationCommitProcessTest method shouldSuccessfullyCommitTransactionWithNoCommands.
@Test
public void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception {
// GIVEN
long txId = 11;
long commitTimestamp = System.currentTimeMillis();
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
StorageEngine storageEngine = mock(StorageEngine.class);
TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList());
noCommandTx.setHeader(new byte[0], -1, -1, -1, -1, -1, -1);
// WHEN
commitProcess.commit(new TransactionToApply(noCommandTx), commitEvent, INTERNAL);
verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP);
}
use of org.neo4j.kernel.impl.transaction.log.TransactionAppender in project neo4j by neo4j.
the class TransactionRepresentationCommitProcessTest method shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly.
@Test
public void shouldCloseTransactionRegardlessOfWhetherOrNotItAppliedCorrectly() throws Exception {
// GIVEN
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
long txId = 11;
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
IOException rootCause = new IOException("Mock exception");
StorageEngine storageEngine = mock(StorageEngine.class);
doThrow(new IOException(rootCause)).when(storageEngine).apply(any(TransactionToApply.class), any(TransactionApplicationMode.class));
TransactionCommitProcess commitProcess = new TransactionRepresentationCommitProcess(appender, storageEngine);
TransactionToApply transaction = mockedTransaction();
// WHEN
try {
commitProcess.commit(transaction, commitEvent, INTERNAL);
} catch (TransactionFailureException e) {
assertThat(e.getMessage(), containsString("Could not apply the transaction to the store"));
assertTrue(contains(e, rootCause.getMessage(), rootCause.getClass()));
}
// THEN
// we can't verify transactionCommitted since that's part of the TransactionAppender, which we have mocked
verify(transactionIdStore, times(1)).transactionClosed(eq(txId), anyLong(), anyLong());
}
use of org.neo4j.kernel.impl.transaction.log.TransactionAppender in project neo4j by neo4j.
the class InternalTransactionCommitProcessTest method shouldSuccessfullyCommitTransactionWithNoCommands.
@Test
void shouldSuccessfullyCommitTransactionWithNoCommands() throws Exception {
// GIVEN
long txId = 11;
TransactionIdStore transactionIdStore = mock(TransactionIdStore.class);
TransactionAppender appender = new TestableTransactionAppender(transactionIdStore);
when(transactionIdStore.nextCommittingTransactionId()).thenReturn(txId);
StorageEngine storageEngine = mock(StorageEngine.class);
TransactionCommitProcess commitProcess = new InternalTransactionCommitProcess(appender, storageEngine);
PhysicalTransactionRepresentation noCommandTx = new PhysicalTransactionRepresentation(Collections.emptyList());
noCommandTx.setHeader(new byte[0], -1, -1, -1, -1, ANONYMOUS);
// WHEN
commitProcess.commit(new TransactionToApply(noCommandTx, NULL), commitEvent, INTERNAL);
verify(transactionIdStore).transactionCommitted(txId, FakeCommitment.CHECKSUM, FakeCommitment.TIMESTAMP, NULL);
}
Aggregations