Search in sources :

Example 6 with BoltResponseHandler

use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.

the class BoltStateMachineV4Test method testMarkFailedShouldYieldIgnoredIfAlreadyFailed.

private static void testMarkFailedShouldYieldIgnoredIfAlreadyFailed(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
    // Given
    BoltStateMachine machine = init(newMachine());
    machine.markFailed(Neo4jError.from(new RuntimeException()));
    BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
    Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
    machine.markFailed(error);
    // When
    action.accept(machine, responseHandler);
    // Expect
    assertNull(pendingError(machine));
    assertFalse(pendingIgnore(machine));
    assertThat(machine).satisfies(inState(FailedState.class));
    verify(responseHandler).markIgnored();
}
Also used : Neo4jError(org.neo4j.bolt.runtime.Neo4jError) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltResponseHandler(org.neo4j.bolt.runtime.BoltResponseHandler) FailedState(org.neo4j.bolt.v4.runtime.FailedState)

Example 7 with BoltResponseHandler

use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.

the class BoltStateMachineV4Test method testMarkFailedOnNextMessage.

private static void testMarkFailedOnNextMessage(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
    // Given
    BoltStateMachine machine = init(newMachine());
    BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
    Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
    machine.markFailed(error);
    // When
    action.accept(machine, responseHandler);
    // Expect
    assertNull(pendingError(machine));
    assertFalse(pendingIgnore(machine));
    assertThat(machine).satisfies(inState(FailedState.class));
    verify(responseHandler).markFailed(error);
}
Also used : Neo4jError(org.neo4j.bolt.runtime.Neo4jError) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltResponseHandler(org.neo4j.bolt.runtime.BoltResponseHandler) FailedState(org.neo4j.bolt.v4.runtime.FailedState)

Example 8 with BoltResponseHandler

use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.

the class BoltStateMachineV4Test method shouldInvokeResponseHandlerOnMarkFailedIfThereIsHandler.

@Test
void shouldInvokeResponseHandlerOnMarkFailedIfThereIsHandler() throws Exception {
    BoltStateMachine machine = init(newMachine());
    Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
    BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
    ((AbstractBoltStateMachine) machine).connectionState().setResponseHandler(responseHandler);
    machine.markFailed(error);
    assertNull(pendingError(machine));
    assertFalse(pendingIgnore(machine));
    assertThat(machine).satisfies(inState(FailedState.class));
    verify(responseHandler).markFailed(error);
}
Also used : Neo4jError(org.neo4j.bolt.runtime.Neo4jError) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) BoltResponseHandler(org.neo4j.bolt.runtime.BoltResponseHandler) FailedState(org.neo4j.bolt.v4.runtime.FailedState) Test(org.junit.jupiter.api.Test)

Example 9 with BoltResponseHandler

use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.

the class BoltStateMachineV4Test method testReadyStateAfterMarkFailedOnNextMessage.

private static void testReadyStateAfterMarkFailedOnNextMessage(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
    // Given
    BoltStateMachine machine = init(newMachine());
    BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
    Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
    machine.markFailed(error);
    // When
    action.accept(machine, responseHandler);
    // Expect
    assertNull(pendingError(machine));
    assertFalse(pendingIgnore(machine));
    assertThat(machine).satisfies(inState(ReadyState.class));
    verify(responseHandler, never()).markFailed(any());
    verify(responseHandler, never()).markIgnored();
}
Also used : Neo4jError(org.neo4j.bolt.runtime.Neo4jError) BoltStateMachine(org.neo4j.bolt.runtime.statemachine.BoltStateMachine) ReadyState(org.neo4j.bolt.v4.runtime.ReadyState) BoltResponseHandler(org.neo4j.bolt.runtime.BoltResponseHandler)

Example 10 with BoltResponseHandler

use of org.neo4j.bolt.runtime.BoltResponseHandler in project neo4j by neo4j.

the class BoltRequestMessageReaderV41 method buildDecoders.

private static List<RequestMessageDecoder> buildDecoders(BoltConnection connection, BoltResponseMessageWriter responseMessageWriter, BookmarksParser bookmarksParser, LogService logService) {
    BoltResponseHandler resultHandler = new ResultHandler(responseMessageWriter, connection, internalLog(logService));
    BoltResponseHandler defaultHandler = newSimpleResponseHandler(responseMessageWriter, connection, logService);
    return Arrays.asList(// NEW
    new HelloMessageDecoder(defaultHandler), new RunMessageDecoder(defaultHandler, bookmarksParser), new DiscardMessageDecoder(resultHandler), new PullMessageDecoder(resultHandler), new BeginMessageDecoder(defaultHandler, bookmarksParser), new CommitMessageDecoder(resultHandler), new RollbackMessageDecoder(resultHandler), new ResetMessageDecoder(connection, defaultHandler), new GoodbyeMessageDecoder(connection, defaultHandler));
}
Also used : DiscardMessageDecoder(org.neo4j.bolt.v4.messaging.DiscardMessageDecoder) RollbackMessageDecoder(org.neo4j.bolt.v3.messaging.decoder.RollbackMessageDecoder) HelloMessageDecoder(org.neo4j.bolt.v41.messaging.decoder.HelloMessageDecoder) GoodbyeMessageDecoder(org.neo4j.bolt.v3.messaging.decoder.GoodbyeMessageDecoder) BoltResponseHandler(org.neo4j.bolt.runtime.BoltResponseHandler) ResetMessageDecoder(org.neo4j.bolt.v3.messaging.decoder.ResetMessageDecoder) ResultHandler(org.neo4j.bolt.v3.messaging.ResultHandler) CommitMessageDecoder(org.neo4j.bolt.v3.messaging.decoder.CommitMessageDecoder) PullMessageDecoder(org.neo4j.bolt.v4.messaging.PullMessageDecoder) BeginMessageDecoder(org.neo4j.bolt.v4.messaging.BeginMessageDecoder) RunMessageDecoder(org.neo4j.bolt.v4.messaging.RunMessageDecoder)

Aggregations

BoltResponseHandler (org.neo4j.bolt.runtime.BoltResponseHandler)20 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)10 Test (org.junit.jupiter.api.Test)8 Neo4jError (org.neo4j.bolt.runtime.Neo4jError)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 CommitMessageDecoder (org.neo4j.bolt.v3.messaging.decoder.CommitMessageDecoder)4 GoodbyeMessageDecoder (org.neo4j.bolt.v3.messaging.decoder.GoodbyeMessageDecoder)4 ResetMessageDecoder (org.neo4j.bolt.v3.messaging.decoder.ResetMessageDecoder)4 RollbackMessageDecoder (org.neo4j.bolt.v3.messaging.decoder.RollbackMessageDecoder)4 FailedState (org.neo4j.bolt.v4.runtime.FailedState)4 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 StatementOutcome (org.neo4j.bolt.runtime.statemachine.impl.TransactionStateMachine.StatementOutcome)3 BoltStateMachineV3 (org.neo4j.bolt.v3.BoltStateMachineV3)3 ResultHandler (org.neo4j.bolt.v3.messaging.ResultHandler)3 Unpacker (org.neo4j.bolt.packstream.Neo4jPack.Unpacker)2 BoltConnection (org.neo4j.bolt.runtime.BoltConnection)2 BoltConnectionAuthFatality (org.neo4j.bolt.runtime.BoltConnectionAuthFatality)2 SynchronousBoltConnection (org.neo4j.bolt.runtime.SynchronousBoltConnection)2 ChannelProtector (org.neo4j.bolt.transport.pipeline.ChannelProtector)2 HelloMessageDecoder (org.neo4j.bolt.v3.messaging.decoder.HelloMessageDecoder)2