use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelTransactionImplementationTest method shouldRollbackOnClosingTerminatedTransaction.
@Test
public void shouldRollbackOnClosingTerminatedTransaction() throws Exception {
// GIVEN
KernelTransaction transaction = newTransaction(securityContext());
transactionInitializer.accept(transaction);
transaction.success();
transaction.markForTermination(Status.General.UnknownError);
try {
// WHEN
transaction.close();
fail("Exception expected");
} catch (Exception e) {
assertThat(e, instanceOf(TransactionTerminatedException.class));
}
// THEN
verify(transactionMonitor, times(1)).transactionFinished(false, isWriteTx);
verify(transactionMonitor, times(1)).transactionTerminated(isWriteTx);
verifyExtraInteractionWithTheMonitor(transactionMonitor, isWriteTx);
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelTransactionImplementationTest method shouldRollbackAndThrowOnFailedAndSuccess.
@Test
public void shouldRollbackAndThrowOnFailedAndSuccess() throws Exception {
// GIVEN
boolean exceptionReceived = false;
try (KernelTransaction transaction = newTransaction(securityContext())) {
// WHEN
transactionInitializer.accept(transaction);
transaction.failure();
transaction.success();
} catch (TransactionFailureException e) {
// Expected.
exceptionReceived = true;
}
// THEN
assertTrue(exceptionReceived);
verify(transactionMonitor, times(1)).transactionFinished(false, isWriteTx);
verifyExtraInteractionWithTheMonitor(transactionMonitor, isWriteTx);
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelTransactionImplementationTest method shouldRollbackOnClosingSuccessfulButTerminatedTransaction.
@Test
public void shouldRollbackOnClosingSuccessfulButTerminatedTransaction() throws Exception {
try (KernelTransaction transaction = newTransaction(securityContext())) {
// WHEN
transactionInitializer.accept(transaction);
transaction.markForTermination(Status.General.UnknownError);
assertEquals(Status.General.UnknownError, transaction.getReasonIfTerminated().get());
}
// THEN
verify(transactionMonitor, times(1)).transactionFinished(false, isWriteTx);
verify(transactionMonitor, times(1)).transactionTerminated(isWriteTx);
verifyExtraInteractionWithTheMonitor(transactionMonitor, isWriteTx);
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelTransactionImplementationTest method shouldRollbackUnsuccessfulTransaction.
@Test
public void shouldRollbackUnsuccessfulTransaction() throws Exception {
// GIVEN
try (KernelTransaction transaction = newTransaction(securityContext())) {
// WHEN
transactionInitializer.accept(transaction);
}
// THEN
verify(transactionMonitor, times(1)).transactionFinished(false, isWriteTx);
verifyExtraInteractionWithTheMonitor(transactionMonitor, isWriteTx);
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class KernelSchemaStateFlushingTest method dropConstraint.
private void dropConstraint(ConstraintDescriptor descriptor) throws KernelException {
try (KernelTransaction transaction = kernel.newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
Statement statement = transaction.acquireStatement()) {
statement.schemaWriteOperations().constraintDrop(descriptor);
transaction.success();
}
}
Aggregations