Search in sources :

Example 1 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class BoltV3TransportIT method shouldReturnUpdatedBookmarkAfterAutoCommitTransaction.

@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterAutoCommitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
    init(connectionClass);
    negotiateBoltV3();
    // bookmark is expected to advance once the auto-commit transaction is committed
    long lastClosedTransactionId = getLastClosedTransactionId();
    String expectedBookmark = new BookmarkWithPrefix(lastClosedTransactionId + 1).toString();
    connection.send(util.chunk(new RunMessage("CREATE ()"), PullAllMessage.INSTANCE));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
Also used : BookmarkWithPrefix(org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class StreamingStateIT method shouldThrowExceptionOnIllegalMessagesInStreamingState.

private void shouldThrowExceptionOnIllegalMessagesInStreamingState(RequestMessage message) throws Throwable {
    // Given
    BoltStateMachineV3 machine = newStateMachine();
    machine.process(newHelloMessage(), nullResponseHandler());
    machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), nullResponseHandler());
    assertThat(machine.state()).isInstanceOf(StreamingState.class);
    // when
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    verifyKillsConnection(() -> machine.process(message, recorder));
    // then
    assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
    assertNull(machine.state());
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage)

Example 3 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class StreamingStateIT method getBoltStateMachineInStreamingState.

private BoltStateMachineV3 getBoltStateMachineInStreamingState() throws BoltConnectionFatality {
    BoltStateMachineV3 machine = newStateMachine();
    machine.process(newHelloMessage(), nullResponseHandler());
    machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k", EMPTY_PARAMS), nullResponseHandler());
    assertThat(machine.state()).isInstanceOf(StreamingState.class);
    return machine;
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage)

Example 4 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class TransactionStreamingStateIT method getBoltStateMachineInTxStreamingState.

private BoltStateMachineV3 getBoltStateMachineInTxStreamingState() throws BoltConnectionFatality {
    BoltStateMachineV3 machine = newStateMachine();
    machine.process(newHelloMessage(), nullResponseHandler());
    machine.process(new BeginMessage(), nullResponseHandler());
    assertThat(machine.state()).isInstanceOf(TransactionReadyState.class);
    machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k"), nullResponseHandler());
    // tx streaming state
    assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
    return machine;
}
Also used : BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage)

Example 5 with RunMessage

use of org.neo4j.bolt.v3.messaging.request.RunMessage in project neo4j by neo4j.

the class TransactionStreamingStateIT method shouldThrowExceptionOnIllegalMessagesInTxStreamingState.

private void shouldThrowExceptionOnIllegalMessagesInTxStreamingState(RequestMessage message) throws Throwable {
    // Given
    BoltStateMachineV3 machine = newStateMachine();
    machine.process(newHelloMessage(), nullResponseHandler());
    machine.process(new BeginMessage(), nullResponseHandler());
    machine.process(new RunMessage("CREATE (n {k:'k'}) RETURN n.k"), nullResponseHandler());
    assertThat(machine.state()).isInstanceOf(TransactionStreamingState.class);
    // when
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    verifyKillsConnection(() -> machine.process(message, recorder));
    // then
    assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.Request.Invalid));
    assertNull(machine.state());
}
Also used : BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage)

Aggregations

RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)15 BoltStateMachineV3 (org.neo4j.bolt.v3.BoltStateMachineV3)9 Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)6 BeginMessage (org.neo4j.bolt.v3.messaging.request.BeginMessage)4 MapValue (org.neo4j.values.virtual.MapValue)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 RecordedBoltResponse (org.neo4j.bolt.testing.RecordedBoltResponse)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 BoltResponseHandler (org.neo4j.bolt.runtime.BoltResponseHandler)1 SynchronousBoltConnection (org.neo4j.bolt.runtime.SynchronousBoltConnection)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 HelloMessage (org.neo4j.bolt.v3.messaging.request.HelloMessage)1 BookmarkWithPrefix (org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix)1 KernelTransactionHandle (org.neo4j.kernel.api.KernelTransactionHandle)1 KernelTransactions (org.neo4j.kernel.impl.api.KernelTransactions)1 ValueUtils.asMapValue (org.neo4j.kernel.impl.util.ValueUtils.asMapValue)1 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)1