Search in sources :

Example 26 with BoltResponseRecorder

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));
}
Also used : BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.Test)

Example 27 with BoltResponseRecorder

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));
}
Also used : BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.Test)

Example 28 with BoltResponseRecorder

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());
}
Also used : BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.Test)

Example 29 with BoltResponseRecorder

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));
}
Also used : BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.Test)

Example 30 with BoltResponseRecorder

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));
}
Also used : BoltStateMachine(org.neo4j.bolt.v1.runtime.BoltStateMachine) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.Test)

Aggregations

BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)36 Test (org.junit.Test)34 BoltStateMachine (org.neo4j.bolt.v1.runtime.BoltStateMachine)30 InetSocketAddress (java.net.InetSocketAddress)2 RecordedBoltResponse (org.neo4j.bolt.testing.RecordedBoltResponse)2 BoltConnectionDescriptor (org.neo4j.bolt.v1.runtime.BoltConnectionDescriptor)2 HashMap (java.util.HashMap)1 BoltConnectionFatality (org.neo4j.bolt.v1.runtime.BoltConnectionFatality)1 BoltResult (org.neo4j.bolt.v1.runtime.spi.BoltResult)1 BinaryLatch (org.neo4j.concurrent.BinaryLatch)1 Node (org.neo4j.graphdb.Node)1 Transaction (org.neo4j.graphdb.Transaction)1