Search in sources :

Example 1 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class FailedStateIT method shouldIgnoreMessages.

@ParameterizedTest
@MethodSource("ignoredMessages")
void shouldIgnoreMessages(RequestMessage message) throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInFailedState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(message, recorder);
    // Then
    assertThat(recorder.nextResponse()).satisfies(wasIgnored());
    assertThat(machine.state()).isInstanceOf(FailedState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class FailedStateIT method shouldCloseConnectionOnIllegalMessages.

private void shouldCloseConnectionOnIllegalMessages(RequestMessage message) throws InterruptedException, BoltConnectionFatality {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInFailedState();
    // when
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    verifyKillsConnection(() -> machine.process(message, recorder));
    // then
    assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
    assertNull(machine.state());
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder)

Example 3 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class InterruptedStateIT method shouldStayInInterruptedOnInterruptedSignal.

@Test
void shouldStayInInterruptedOnInterruptedSignal() throws Throwable {
    // Given
    BoltStateMachineV3 machine = getBoltStateMachineInInterruptedState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(InterruptSignal.INSTANCE, recorder);
    // Then
    assertThat(recorder.nextResponse()).satisfies(succeeded());
    assertThat(machine.state()).isInstanceOf(InterruptedState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class InterruptedStateIT method getBoltStateMachineInInterruptedState.

private BoltStateMachineV3 getBoltStateMachineInInterruptedState() throws BoltConnectionFatality {
    BoltStateMachineV3 machine = newStateMachine();
    machine.process(newHelloMessage(), nullResponseHandler());
    machine.process(InterruptSignal.INSTANCE, nullResponseHandler());
    assertThat(machine.state()).isInstanceOf(InterruptedState.class);
    return machine;
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3)

Example 5 with BoltStateMachineV3

use of org.neo4j.bolt.v3.BoltStateMachineV3 in project neo4j by neo4j.

the class StreamingStateIT method shouldThrowExceptionOnIllegalMessagesInStreamingState.

private void shouldThrowExceptionOnIllegalMessagesInStreamingState(RequestMessage message) throws Throwable {
    // Given
    BoltStateMachineV3 machine = newStateMachine();
    machine.process(newHelloMessage(), nullResponseHandler());
    machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), nullResponseHandler());
    assertThat(machine.state()).isInstanceOf(StreamingState.class);
    // when
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    verifyKillsConnection(() -> machine.process(message, recorder));
    // then
    assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
    assertNull(machine.state());
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage)

Aggregations

BoltStateMachineV3 (org.neo4j.bolt.v3.BoltStateMachineV3)36 BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 Test (org.junit.jupiter.api.Test)21 RecordedBoltResponse (org.neo4j.bolt.testing.RecordedBoltResponse)9 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)9 BeginMessage (org.neo4j.bolt.v3.messaging.request.BeginMessage)5 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 BoltResponseHandler (org.neo4j.bolt.runtime.BoltResponseHandler)3