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.");
}
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);
}
}
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);
}
Aggregations