Search in sources :

Example 16 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor in project neo4j by neo4j.

the class BoltStateMachineContextImplTest method shouldAllowToSetNewStatementProcessor.

@Test
void shouldAllowToSetNewStatementProcessor() throws Throwable {
    // Given
    StatementProcessor txStateMachine = mock(StatementProcessor.class);
    // Then we can set tx state machine on a context.
    boltStateMachineContextWithStatementProcessor(txStateMachine, DB_NAME);
}
Also used : StatementProcessor(org.neo4j.bolt.runtime.statemachine.StatementProcessor) Test(org.junit.jupiter.api.Test)

Example 17 with StatementProcessor

use of org.neo4j.bolt.runtime.statemachine.StatementProcessor 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

StatementProcessor (org.neo4j.bolt.runtime.statemachine.StatementProcessor)17 Test (org.junit.jupiter.api.Test)7 StatementMetadata (org.neo4j.bolt.runtime.statemachine.StatementMetadata)3 Bookmark (org.neo4j.bolt.runtime.Bookmark)2 BoltProtocolBreachFatality (org.neo4j.bolt.runtime.BoltProtocolBreachFatality)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 BoltStateMachineSPI (org.neo4j.bolt.runtime.statemachine.BoltStateMachineSPI)1 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)1