Search in sources :

Example 1 with ROLLBACK_MESSAGE

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

the class TransactionReadyStateIT method shouldMoveToReadyOnRollback_succ.

@Test
void shouldMoveToReadyOnRollback_succ() throws Throwable {
    BoltStateMachineV3 machine = getBoltStateMachineInTxReadyState();
    // When
    BoltResponseRecorder recorder = new BoltResponseRecorder();
    machine.process(ROLLBACK_MESSAGE, recorder);
    // Then
    assertThat(recorder.nextResponse()).satisfies(succeeded());
    assertThat(machine.state()).isInstanceOf(ReadyState.class);
}
Also used : BoltStateMachineV3(org.neo4j.bolt.v3.BoltStateMachineV3) BoltResponseRecorder(org.neo4j.bolt.testing.BoltResponseRecorder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with ROLLBACK_MESSAGE

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

the class BoltRequestMessageV3Test method shouldHandleCommonMessages.

@Test
void shouldHandleCommonMessages() throws Throwable {
    assertSerializes(new HelloMessage(map("user_agent", "MyClient/1.0", "scheme", "basic")));
    assertSerializes(new RunMessage("CREATE (n) RETURN åäö"));
    assertSerializes(DiscardAllMessage.INSTANCE);
    assertSerializes(PullAllMessage.INSTANCE);
    assertSerializes(new BeginMessage());
    assertSerializes(COMMIT_MESSAGE);
    assertSerializes(ROLLBACK_MESSAGE);
    assertSerializes(ResetMessage.INSTANCE);
    assertSerializes(GOODBYE_MESSAGE);
}
Also used : HelloMessage(org.neo4j.bolt.v3.messaging.request.HelloMessage) BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) Test(org.junit.jupiter.api.Test)

Example 3 with ROLLBACK_MESSAGE

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

the class BoltV3TransportIT method shouldSetTxMetadata.

@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldSetTxMetadata(Class<? extends TransportConnection> connectionClass) throws Exception {
    init(connectionClass);
    // Given
    negotiateBoltV3();
    Map<String, Object> txMetadata = map("who-is-your-boss", "Molly-mostly-white");
    Map<String, Object> msgMetadata = map("tx_metadata", txMetadata);
    MapValue meta = asMapValue(msgMetadata);
    connection.send(util.chunk(new BeginMessage(meta, List.of(), null, AccessMode.WRITE, txMetadata), new RunMessage("RETURN 1"), PullAllMessage.INSTANCE));
    // When
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(), msgRecord(eqRecord(longEquals(1L))), msgSuccess()));
    // Then
    GraphDatabaseAPI gdb = (GraphDatabaseAPI) server.graphDatabaseService();
    Set<KernelTransactionHandle> txHandles = gdb.getDependencyResolver().resolveDependency(KernelTransactions.class).activeTransactions();
    assertThat(txHandles.size()).isEqualTo(1);
    for (KernelTransactionHandle txHandle : txHandles) {
        assertThat(txHandle.getMetaData()).isEqualTo(txMetadata);
    }
    connection.send(util.chunk(ROLLBACK_MESSAGE));
}
Also used : BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) ValueUtils.asMapValue(org.neo4j.kernel.impl.util.ValueUtils.asMapValue) MapValue(org.neo4j.values.virtual.MapValue) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) KernelTransactionHandle(org.neo4j.kernel.api.KernelTransactionHandle) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

Test (org.junit.jupiter.api.Test)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 BeginMessage (org.neo4j.bolt.v3.messaging.request.BeginMessage)2 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)1 BoltStateMachineV3 (org.neo4j.bolt.v3.BoltStateMachineV3)1 HelloMessage (org.neo4j.bolt.v3.messaging.request.HelloMessage)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 MapValue (org.neo4j.values.virtual.MapValue)1