use of org.neo4j.bolt.v1.runtime.BoltStateMachine in project neo4j by neo4j.
the class ThreadedWorkerFactory method newWorker.
@Override
public BoltWorker newWorker(BoltConnectionDescriptor connectionDescriptor, Runnable onClose) {
BoltStateMachine machine = connector.newMachine(connectionDescriptor, onClose, clock);
RunnableBoltWorker worker = new RunnableBoltWorker(machine, logging);
scheduler.schedule(sessionWorker, worker, stringMap(THREAD_ID, machine.key()));
return worker;
}
use of org.neo4j.bolt.v1.runtime.BoltStateMachine in project neo4j by neo4j.
the class BoltMatchers method hasTransaction.
public static Matcher<BoltStateMachine> hasTransaction() {
return new BaseMatcher<BoltStateMachine>() {
@Override
public boolean matches(final Object item) {
final BoltStateMachine machine = (BoltStateMachine) item;
final StatementProcessor statementProcessor = machine.statementProcessor();
return statementProcessor != null && statementProcessor.hasTransaction();
}
@Override
public void describeTo(Description description) {
description.appendText("no transaction");
}
};
}
use of org.neo4j.bolt.v1.runtime.BoltStateMachine in project neo4j by neo4j.
the class BoltMatchers method verifyOneResponse.
public static void verifyOneResponse(BoltStateMachine.State initialState, ThrowingBiConsumer<BoltStateMachine, BoltResponseRecorder, BoltConnectionFatality> transition) throws AuthenticationException, BoltConnectionFatality {
BoltStateMachine machine = newMachine(initialState);
BoltResponseRecorder recorder = new BoltResponseRecorder();
try {
transition.accept(machine, recorder);
} catch (BoltConnectionFatality connectionFatality) {
// acceptable for invalid transitions
}
assertEquals(1, recorder.responseCount());
}
use of org.neo4j.bolt.v1.runtime.BoltStateMachine in project neo4j by neo4j.
the class BoltConnectionAuthIT method shouldCloseConnectionAfterAuthenticationFailure.
@Test
public void shouldCloseConnectionAfterAuthenticationFailure() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
// When... then
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.init(USER_AGENT, map("scheme", "basic", "principal", "neo4j", "credentials", "j4oen"), recorder));
// ...and
assertThat(recorder.nextResponse(), failedWithStatus(Status.Security.Unauthorized));
}
use of org.neo4j.bolt.v1.runtime.BoltStateMachine in project neo4j by neo4j.
the class BoltConnectionIT method shouldSucceedOn__run__pullAll__run.
@Test
public void shouldSucceedOn__run__pullAll__run() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
machine.init(USER_AGENT, emptyMap(), null);
// And Given that I've ran and pulled one stream
machine.run("RETURN 1", EMPTY_PARAMS, nullResponseHandler());
machine.pullAll(nullResponseHandler());
// When I run a new statement
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.run("RETURN 1", EMPTY_PARAMS, recorder);
// Then
assertThat(recorder.nextResponse(), succeeded());
}
Aggregations