use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class BoltV4MachineRoom method newMachineWithTransactionSPI.
public static BoltStateMachine newMachineWithTransactionSPI(TransactionStateMachineSPI transactionSPI) throws BoltConnectionFatality, BoltIOException {
BoltStateMachineSPI spi = mock(BoltStateMachineSPI.class, RETURNS_MOCKS);
TransactionStateMachineSPIProvider transactionSPIProvider = mock(TransactionStateMachineSPIProvider.class);
var memoryTracker = mock(MemoryTracker.class);
when(transactionSPIProvider.getTransactionStateMachineSPI(any(String.class), any(StatementProcessorReleaseManager.class))).thenReturn(transactionSPI);
when(spi.transactionStateMachineSPIProvider()).thenReturn(transactionSPIProvider);
BoltChannel boltChannel = BoltTestUtil.newTestBoltChannel();
BoltStateMachine machine = new BoltStateMachineV4(spi, boltChannel, Clock.systemUTC(), mock(DefaultDatabaseResolver.class), MapValue.EMPTY, memoryTracker);
init(machine);
return machine;
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldCloseBoltChannelWhenClosed.
@Test
void shouldCloseBoltChannelWhenClosed() {
BoltStateMachineSPIImpl spi = mock(BoltStateMachineSPIImpl.class);
BoltChannel boltChannel = mock(BoltChannel.class);
var memoryTracker = mock(MemoryTracker.class);
BoltStateMachine machine = new BoltStateMachineV4(spi, boltChannel, Clock.systemUTC(), mock(DefaultDatabaseResolver.class), MapValue.EMPTY, memoryTracker);
machine.close();
verify(boltChannel).close();
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class FailedStateIT method shouldCloseConnectionOnIllegalMessages.
private void shouldCloseConnectionOnIllegalMessages(RequestMessage message) throws InterruptedException, BoltConnectionFatality {
// Given
BoltStateMachineV4 machine = getBoltStateMachineInFailedState();
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.process(message, recorder));
// then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
assertNull(machine.state());
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class FailedStateIT method getBoltStateMachineInFailedState.
private BoltStateMachineV4 getBoltStateMachineInFailedState() throws BoltConnectionFatality, InterruptedException {
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
RunMessage runMessage = mock(RunMessage.class);
when(runMessage.databaseName()).thenReturn(ABSENT_DB_NAME);
when(runMessage.statement()).thenThrow(new RuntimeException("error here"));
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(runMessage, recorder);
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.General.UnknownError));
assertThat(machine.state()).isInstanceOf(FailedState.class);
return machine;
}
use of org.neo4j.bolt.v4.BoltStateMachineV4 in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToFailedStateOnRun_fail.
@Test
void shouldMoveToFailedStateOnRun_fail() throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
RunMessage runMessage = mock(RunMessage.class);
when(runMessage.databaseName()).thenReturn(ABSENT_DB_NAME);
when(runMessage.statement()).thenThrow(new RuntimeException("Fail"));
machine.process(runMessage, recorder);
// Then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.General.UnknownError));
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
Aggregations