Search in sources :

Example 1 with BoltProtocolBreachFatality

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

the class DefaultDatabaseTransactionStateMachineSPIProviderTest method shouldErrorIfDatabaseNotFound.

@Test
void shouldErrorIfDatabaseNotFound() {
    DatabaseManagementService managementService = managementServiceWithDatabase("database");
    TransactionStateMachineSPIProvider spiProvider = newSpiProvider(managementService);
    BoltProtocolBreachFatality error = assertThrows(BoltProtocolBreachFatality.class, () -> spiProvider.getTransactionStateMachineSPI("database", mock(StatementProcessorReleaseManager.class)));
    assertThat(error.getMessage()).contains("Database selection by name not supported by Bolt protocol version lower than BoltV4.");
}
Also used : DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) TransactionStateMachineSPIProvider(org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider) BoltProtocolBreachFatality(org.neo4j.bolt.runtime.BoltProtocolBreachFatality) Test(org.junit.jupiter.api.Test)

Example 2 with BoltProtocolBreachFatality

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

the class AbstractBoltStateMachine method nextState.

private void nextState(RequestMessage message, StateMachineContext context) throws BoltConnectionFatality {
    BoltStateMachineState preState = state;
    state = state.process(message, context);
    if (state == null) {
        String msg = "Message '" + message + "' cannot be handled by a session in the " + preState.name() + " state.";
        fail(Neo4jError.fatalFrom(Status.Request.Invalid, msg));
        throw new BoltProtocolBreachFatality(msg);
    }
}
Also used : BoltStateMachineState(org.neo4j.bolt.runtime.statemachine.BoltStateMachineState) BoltProtocolBreachFatality(org.neo4j.bolt.runtime.BoltProtocolBreachFatality)

Example 3 with BoltProtocolBreachFatality

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

the class BoltStateMachineContextImplTest method shouldErrorToSetNewStatementProcessorWhilePreviousIsNotReleased.

@Test
void shouldErrorToSetNewStatementProcessorWhilePreviousIsNotReleased() throws Throwable {
    // Given a context that has a active tx state machine set.
    StatementProcessor txStateMachine = mock(StatementProcessor.class);
    BoltStateMachineContextImpl context = boltStateMachineContextWithStatementProcessor(txStateMachine, DB_NAME);
    // When & Then
    BoltProtocolBreachFatality error = assertThrows(BoltProtocolBreachFatality.class, () -> context.setCurrentStatementProcessorForDatabase("Bossi"));
    assertThat(error.getMessage()).contains("Changing database without closing the previous is forbidden.");
    assertThat(context.connectionState().getStatementProcessor()).isEqualTo(txStateMachine);
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) BoltProtocolBreachFatality(org.neo4j.bolt.runtime.BoltProtocolBreachFatality) Test(org.junit.jupiter.api.Test)

Aggregations

BoltProtocolBreachFatality (org.neo4j.bolt.runtime.BoltProtocolBreachFatality)3 Test (org.junit.jupiter.api.Test)2 BoltStateMachineState (org.neo4j.bolt.runtime.statemachine.BoltStateMachineState)1 StatementProcessor (org.neo4j.bolt.runtime.statemachine.StatementProcessor)1 TransactionStateMachineSPIProvider (org.neo4j.bolt.runtime.statemachine.TransactionStateMachineSPIProvider)1 DatabaseManagementService (org.neo4j.dbms.api.DatabaseManagementService)1