use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineFactoryImplTest method shouldCreateBoltStateMachinesV3.
@Test
void shouldCreateBoltStateMachinesV3() {
BoltStateMachineFactoryImpl factory = newBoltFactory();
var memoryTracker = mock(MemoryTracker.class, RETURNS_MOCKS);
BoltStateMachine boltStateMachine = factory.newStateMachine(new BoltProtocolVersion(3, 0), CHANNEL, MapValue.EMPTY, memoryTracker);
assertNotNull(boltStateMachine);
assertThat(boltStateMachine).isInstanceOf(BoltStateMachineV3.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 newMachineWithTransaction.
public static BoltStateMachine newMachineWithTransaction() throws BoltConnectionFatality, BoltIOException {
BoltStateMachine machine = newMachine();
init(machine);
runBegin(machine);
return machine;
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltConnectionAuthIT method shouldGiveCredentialsExpiredStatusOnExpiredCredentials.
@Test
void shouldGiveCredentialsExpiredStatusOnExpiredCredentials() throws Throwable {
// Given it is important for client applications to programmatically
// identify expired credentials as the cause of not being authenticated
BoltStateMachine machine = newStateMachine();
BoltResponseRecorder recorder = new BoltResponseRecorder();
// When
var hello = BoltV4Messages.hello(newBasicAuthToken("neo4j", "neo4j"));
machine.process(hello, recorder);
machine.process(BoltV4Messages.run("CREATE ()"), recorder);
// Then
assertThat(recorder.nextResponse()).satisfies(succeededWithMetadata("credentials_expired", TRUE));
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Security.CredentialsExpired));
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method testMarkFailedShouldYieldSuccessIfAlreadyFailed.
private static void testMarkFailedShouldYieldSuccessIfAlreadyFailed(ThrowingBiConsumer<BoltStateMachine, BoltResponseHandler, BoltConnectionFatality> action) throws Exception {
// Given
BoltStateMachine machine = init(newMachine());
machine.markFailed(Neo4jError.from(new RuntimeException()));
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
Neo4jError error = Neo4jError.from(Status.Request.NoThreadsAvailable, "no threads");
machine.markFailed(error);
// When
action.accept(machine, responseHandler);
// Expect
assertNull(pendingError(machine));
assertFalse(pendingIgnore(machine));
assertThat(machine).satisfies(inState(ReadyState.class));
verify(responseHandler, never()).markIgnored();
verify(responseHandler, never()).markFailed(any());
}
use of org.neo4j.bolt.runtime.statemachine.BoltStateMachine in project neo4j by neo4j.
the class BoltStateMachineV4Test method shouldNotFailWhenMarkedForTerminationAndPullAll.
@Test
void shouldNotFailWhenMarkedForTerminationAndPullAll() throws Exception {
BoltStateMachineSPIImpl spi = mock(BoltStateMachineSPIImpl.class, RETURNS_MOCKS);
BoltStateMachine machine = init(newMachine(spi));
// move to streaming state
machine.process(BoltV4Messages.run(), nullResponseHandler());
txStateMachine(machine).ctx.statementOutcomes.put(StatementMetadata.ABSENT_QUERY_ID, new StatementOutcome(BoltResult.EMPTY));
BoltResponseHandler responseHandler = mock(BoltResponseHandler.class);
machine.markForTermination();
machine.process(BoltV4Messages.pullAll(), responseHandler);
verify(spi, never()).reportError(any());
assertThat(machine).isNotEqualTo(inState(FailedState.class));
}
Aggregations