use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class BoltConnectionIT method shouldFailOn__discardAll__discardAll.
@Test
public void shouldFailOn__discardAll__discardAll() 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.discardAll(nullResponseHandler());
// When I attempt to pull more items from the stream
BoltResponseRecorder recorder = new BoltResponseRecorder();
verifyKillsConnection(() -> machine.discardAll(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 shouldFailOn__discardAll__pullAll.
@Test
public void shouldFailOn__discardAll__pullAll() 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.discardAll(nullResponseHandler());
// When I attempt to pull more items from the stream
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 shouldSucceedOn__run__discardAll__run.
@Test
public void shouldSucceedOn__run__discardAll__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.discardAll(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 TransactionIT method shouldReceiveBookmarkOnCommitAndDiscardAll.
@Test
public void shouldReceiveBookmarkOnCommitAndDiscardAll() throws Throwable {
// Given
BoltResponseRecorder recorder = new BoltResponseRecorder();
BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
machine.init(USER_AGENT, emptyMap(), null);
// When
machine.run("BEGIN", emptyMap(), recorder);
machine.discardAll(recorder);
machine.run("CREATE (a:Person)", emptyMap(), recorder);
machine.discardAll(recorder);
machine.run("COMMIT", emptyMap(), recorder);
machine.discardAll(recorder);
// Then
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeeded());
assertThat(recorder.nextResponse(), succeededWithMetadata("bookmark", BOOKMARK_PATTERN));
}
use of org.neo4j.bolt.testing.BoltResponseRecorder in project neo4j by neo4j.
the class TransactionIT method beginShouldNotOverwriteLastStatement.
@Test
public void beginShouldNotOverwriteLastStatement() throws Throwable {
// Given
final BoltStateMachine machine = env.newMachine(CONNECTION_DESCRIPTOR);
machine.init(USER_AGENT, emptyMap(), null);
BoltResponseRecorder recorder = new BoltResponseRecorder();
// When
machine.run("RETURN 1", emptyMap(), nullResponseHandler());
machine.pullAll(recorder);
machine.run("BEGIN", emptyMap(), nullResponseHandler());
machine.discardAll(nullResponseHandler());
machine.run("", emptyMap(), nullResponseHandler());
machine.pullAll(recorder);
machine.run("COMMIT", emptyMap(), nullResponseHandler());
machine.discardAll(nullResponseHandler());
// Then
assertThat(recorder.nextResponse(), succeededWithRecord(1L));
assertThat(recorder.nextResponse(), succeededWithRecord(1L));
}
Aggregations