use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToFailedStateOnRun_fail.
@Test
void shouldMoveToFailedStateOnRun_fail() throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
RunMessage runMessage = mock(RunMessage.class);
when(runMessage.statement()).thenThrow(new RuntimeException("Fail"));
machine.process(runMessage, recorder);
// Then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.General.UnknownError));
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class ReadyStateIT method shouldCloseConnectionOnIllegalMessages.
private void shouldCloseConnectionOnIllegalMessages(RequestMessage message) throws InterruptedException, BoltConnectionFatality {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.process(message, recorder));
// then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
assertNull(machine.state());
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToTransactionReadyOnBegin_succ.
@Test
void shouldMoveToTransactionReadyOnBegin_succ() throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(new BeginMessage(), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertThat(machine.state()).isInstanceOf(TransactionReadyState.class);
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionReadyStateIT method shouldCloseConnectionOnIllegalMessages.
private void shouldCloseConnectionOnIllegalMessages(RequestMessage message) throws Throwable {
// Given
BoltStateMachineV3 machine = getBoltStateMachineInTxReadyState();
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.process(message, recorder));
// then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
assertNull(machine.state());
}
use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.
the class TransactionReadyStateIT method shouldMoveToInterruptedOnInterrupt.
@Test
void shouldMoveToInterruptedOnInterrupt() throws Throwable {
// Given
BoltStateMachineV3 machine = getBoltStateMachineInTxReadyState();
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(InterruptSignal.INSTANCE, recorder);
// Then
assertThat(machine.state()).isInstanceOf(InterruptedState.class);
}
Aggregations