use of org.neo4j.bolt.dbapi.BoltTransaction in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldResetInExplicitTransactionUponTxBeginWhenValidated.
@Test
void shouldResetInExplicitTransactionUponTxBeginWhenValidated() throws Exception {
BoltTransaction transaction = newTimedOutTransaction();
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
// start an explicit transaction
beginTx(stateMachine);
assertThat(stateMachine.state).isEqualTo(TransactionStateMachine.State.EXPLICIT_TRANSACTION);
assertNotNull(stateMachine.ctx.currentTransaction);
// verify transaction, which is timed out
stateMachine.validateTransaction();
assertThat(stateMachine.state).isEqualTo(TransactionStateMachine.State.AUTO_COMMIT);
assertNull(stateMachine.ctx.currentTransaction);
assertThat(stateMachine.ctx.statementOutcomes.entrySet()).hasSize(0);
verify(transaction).getReasonIfTerminated();
verify(transaction).rollback();
}
use of org.neo4j.bolt.dbapi.BoltTransaction in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldUnbindTxAfterStreamResult.
@Test
void shouldUnbindTxAfterStreamResult() throws Throwable {
BoltTransaction transaction = newTimedOutTransaction();
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
stateMachine.run("SOME STATEMENT", null);
stateMachine.streamResult(StatementMetadata.ABSENT_QUERY_ID, EMPTY);
}
use of org.neo4j.bolt.dbapi.BoltTransaction in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldUnbindTxAfterRun.
@Test
void shouldUnbindTxAfterRun() throws Exception {
BoltTransaction transaction = newTimedOutTransaction();
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
stateMachine.run("SOME STATEMENT", null);
}
use of org.neo4j.bolt.dbapi.BoltTransaction in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldResetInAutoCommitTransactionWhileStatementIsRunningWhenValidated.
@Test
void shouldResetInAutoCommitTransactionWhileStatementIsRunningWhenValidated() throws Exception {
BoltTransaction transaction = newTimedOutTransaction();
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
// We're in auto-commit state
assertThat(stateMachine.state).isEqualTo(TransactionStateMachine.State.AUTO_COMMIT);
assertNull(stateMachine.ctx.currentTransaction);
stateMachine.run("RETURN 1", null);
// We're in auto-commit state
assertThat(stateMachine.state).isEqualTo(TransactionStateMachine.State.AUTO_COMMIT);
assertNotNull(stateMachine.ctx.currentTransaction);
// call validate transaction
stateMachine.validateTransaction();
assertThat(stateMachine.state).isEqualTo(TransactionStateMachine.State.AUTO_COMMIT);
assertNull(stateMachine.ctx.currentTransaction);
assertThat(stateMachine.ctx.statementOutcomes.entrySet()).hasSize(0);
verify(transaction).getReasonIfTerminated();
verify(transaction).rollback();
}
use of org.neo4j.bolt.dbapi.BoltTransaction in project neo4j by neo4j.
the class TransactionStateMachineTest method shouldNotMarkForTerminationWhenNoTransaction.
@Test
void shouldNotMarkForTerminationWhenNoTransaction() throws Exception {
BoltTransaction transaction = newTransaction();
TransactionStateMachineSPI stateMachineSPI = newTransactionStateMachineSPI(transaction);
TransactionStateMachine stateMachine = newTransactionStateMachine(stateMachineSPI);
stateMachine.markCurrentTransactionForTermination();
verify(transaction, never()).markForTermination(any());
}
Aggregations