use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltStateMachineTest method testPublishingError.
@Test
public void testPublishingError() throws Throwable {
// Given a new ready machine...
BoltStateMachine machine = newMachine(READY);
// ...and a result ready to be retrieved...
machine.run("RETURN 1", null, nullResponseHandler());
// ...and a handler guaranteed to break
BoltResponseRecorder recorder = new BoltResponseRecorder() {
@Override
public void onRecords(BoltResult result, boolean pull) throws Exception {
throw new RuntimeException("I've been expecting you, Mr Bond.");
}
};
// When we pull using that handler
machine.pullAll(recorder);
// Then the breakage should surface as a FAILURE
assertThat(recorder.nextResponse(), failedWithStatus(Status.General.UnknownError));
// ...and the machine should have entered a FAILED state
assertThat(machine, inState(FAILED));
}
use of org.neo4j.bolt.testing.BoltResponseRecorder 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.testing.BoltResponseRecorder 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());
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionIT method shouldCloseConnectionOnPullAllBeforeInit.
@Test
public void shouldCloseConnectionOnPullAllBeforeInit() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.pullAll(recorder));
// then
assertThat(recorder.nextResponse(), failedWithStatus(Status.Request.Invalid));
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionIT method shouldCloseConnectionAckFailureBeforeInit.
@Test
public void shouldCloseConnectionAckFailureBeforeInit() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
// when
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.ackFailure(recorder));
// then
assertThat(recorder.nextResponse(), failedWithStatus(Status.Request.Invalid));
}
Aggregations