use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldCloseBoltChannelWhenClosed.
@Test
void shouldCloseBoltChannelWhenClosed() {
BoltStateMachineSPIImpl spi = mock(BoltStateMachineSPIImpl.class);
BoltChannel boltChannel = mock(BoltChannel.class);
var memoryTracker = mock(MemoryTracker.class);
BoltStateMachine machine = new BoltStateMachineV4(spi, boltChannel, Clock.systemUTC(), mock(DefaultDatabaseResolver.class), MapValue.EMPTY, memoryTracker);
machine.close();
verify(boltChannel).close();
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldResetWithOpenTransactionAndOpenResult.
@Test
void shouldResetWithOpenTransactionAndOpenResult() throws Throwable {
// Given a ready machine with an open transaction...
final BoltStateMachine machine = newMachineWithTransaction();
// ...and an open result
machine.process(BoltV4Messages.run(), nullResponseHandler());
// Then
assertThat(machine).satisfies(canReset());
assertThat(machine).satisfies(hasNoTransaction());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldResetWithOpenResult.
@Test
void shouldResetWithOpenResult() throws Throwable {
// Given a ready machine...
final BoltStateMachine machine = init(newMachine());
// ...and an open result
machine.process(BoltV4Messages.run(), nullResponseHandler());
// Then
assertThat(machine).satisfies(canReset());
assertThat(machine).satisfies(hasNoTransaction());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method testRollbackError.
@Test
void testRollbackError() throws Throwable {
// Given
BoltStateMachine machine = init(newMachine());
// Given there is a running transaction
machine.process(BoltV4Messages.begin(), nullResponseHandler());
// And given that transaction will fail to roll back
TransactionStateMachine txMachine = txStateMachine(machine);
doThrow(new TransactionFailureException("No Mr. Bond, I expect you to die.")).when(txMachine.ctx.currentTransaction).rollback();
// When
machine.process(BoltV4Messages.rollback(), nullResponseHandler());
// Then
assertThat(machine).satisfies(inState(FailedState.class));
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldFailWhenOutOfOrderRollback.
@Test
void shouldFailWhenOutOfOrderRollback() throws Throwable {
// Given a failed machine
final BoltStateMachine machine = newMachine();
machine.markFailed(Neo4jError.from(new RuntimeException()));
// When
machine.process(BoltV4Messages.rollback(), nullResponseHandler());
// Then
assertThat(machine).satisfies(inState(FailedState.class));
}
Aggregations