use of org.neo4j.bolt.v1.runtime.BoltResponseHandler in project neo4j by neo4j.
the class BoltConnectionIT method shouldHandleFailureDuringResultPublishing.
@Test
public void shouldHandleFailureDuringResultPublishing() throws Throwable {
// Given
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
machine.init(USER_AGENT, emptyMap(), null);
final CountDownLatch pullAllCallbackCalled = new CountDownLatch(1);
final AtomicReference<Neo4jError> error = new AtomicReference<>();
// When something fails while publishing the result stream
machine.run("RETURN 1", EMPTY_PARAMS, nullResponseHandler());
machine.pullAll(new BoltResponseHandler() {
@Override
public void onStart() {
}
@Override
public void onRecords(BoltResult result, boolean pull) throws Exception {
throw new RuntimeException("Ooopsies!");
}
@Override
public void onMetadata(String key, Object value) {
}
@Override
public void markFailed(Neo4jError err) {
error.set(err);
pullAllCallbackCalled.countDown();
}
@Override
public void markIgnored() {
}
@Override
public void onFinish() {
}
});
// Then
assertTrue(pullAllCallbackCalled.await(30, TimeUnit.SECONDS));
final Neo4jError err = error.get();
assertThat(err.status(), equalTo((Status) Status.General.UnknownError));
assertThat(err.message(), CoreMatchers.containsString("Ooopsies!"));
}
Aggregations