use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineFactoryImplTest method shouldCreateBoltStateMachinesV41.
@Test
void shouldCreateBoltStateMachinesV41() {
BoltStateMachineFactoryImpl factory = newBoltFactory();
var memoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
BoltStateMachine boltStateMachine = factory.newStateMachine(new BoltProtocolVersion(4, 1), CHANNEL, MapValue.EMPTY, memoryTracker);
assertNotNull(boltStateMachine);
assertThat(boltStateMachine).isInstanceOf(BoltStateMachineV41.class);
verify(memoryTracker).getScopedMemoryTracker();
verify(memoryTracker, times(3)).allocateHeap(anyLong());
verifyNoMoreInteractions(memoryTracker);
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineFactoryImplTest method shouldCreateBoltStateMachinesV4.
@Test
void shouldCreateBoltStateMachinesV4() {
BoltStateMachineFactoryImpl factory = newBoltFactory();
var memoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
BoltStateMachine boltStateMachine = factory.newStateMachine(new BoltProtocolVersion(4, 0), CHANNEL, MapValue.EMPTY, memoryTracker);
assertNotNull(boltStateMachine);
assertThat(boltStateMachine).isInstanceOf(BoltStateMachineV4.class);
verify(memoryTracker).getScopedMemoryTracker();
verify(memoryTracker, times(3)).allocateHeap(anyLong());
verifyNoMoreInteractions(memoryTracker);
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineFactoryImplTest method shouldCreateBoltStateMachinesV43.
@Test
void shouldCreateBoltStateMachinesV43() {
BoltStateMachineFactoryImpl factory = newBoltFactory();
var memoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
BoltStateMachine boltStateMachine = factory.newStateMachine(new BoltProtocolVersion(4, 3), CHANNEL, MapValue.EMPTY, memoryTracker);
assertNotNull(boltStateMachine);
assertThat(boltStateMachine).isInstanceOf(BoltStateMachineV43.class);
verify(memoryTracker).getScopedMemoryTracker();
verify(memoryTracker, times(3)).allocateHeap(anyLong());
verifyNoMoreInteractions(memoryTracker);
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine 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.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method testPublishingError.
@Test
void testPublishingError() throws Throwable {
// Given a new ready machine...
BoltStateMachine machine = init(newMachine());
// ...and a result ready to be retrieved...
machine.process(BoltV4Messages.run(), nullResponseHandler());
// ...and a handler guaranteed to break
BoltResponseRecorder recorder = new BoltResponseRecorder() {
@Override
public boolean onPullRecords(BoltResult result, long size) {
throw new RuntimeException("I've been expecting you, Mr Bond.");
}
};
// When we pull using that handler
machine.process(BoltV4Messages.pullAll(), recorder);
// Then the breakage should surface as a FAILURE
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.General.UnknownError));
// ...and the machine should have entered a FAILED state
assertThat(machine).satisfies(inState(FailedState.class));
}
Aggregations