use of org.neo4j.bolt.v4.messaging.BeginMessage in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToInTransactionOnBegin_succ.
@Test
void shouldMoveToInTransactionOnBegin_succ() throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
machine.process(new BeginMessage(), recorder);
// Then
RecordedBoltResponse response = recorder.nextResponse();
assertThat(response).satisfies(succeeded());
assertThat(machine.state()).isInstanceOf(InTransactionState.class);
}
use of org.neo4j.bolt.v4.messaging.BeginMessage in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToFailedStateOnBegin_fail.
@Test
void shouldMoveToFailedStateOnBegin_fail() throws Throwable {
// Given
BoltStateMachineV4 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
BeginMessage beginMessage = mock(BeginMessage.class);
when(beginMessage.databaseName()).thenReturn(ABSENT_DB_NAME);
when(beginMessage.bookmarks()).thenThrow(new RuntimeException("Fail"));
machine.process(beginMessage, recorder);
// Then
assertThat(recorder.nextResponse()).satisfies(failedWithStatus(Status.General.UnknownError));
assertThat(machine.state()).isInstanceOf(FailedState.class);
}
use of org.neo4j.bolt.v4.messaging.BeginMessage in project neo4j by neo4j.
the class BoltV41TransportIT method shouldReturnUpdatedBookmarkAfterExplicitTransaction.
@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterExplicitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
init(connectionClass);
negotiateBoltV41();
// bookmark is expected to advance once the auto-commit transaction is committed
var lastClosedTransactionId = getLastClosedTransactionId();
var expectedBookmark = new BookmarkWithDatabaseId(lastClosedTransactionId + 1, getDatabaseId()).toString();
connection.send(util.chunk(new BeginMessage()));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
connection.send(util.chunk(new RunMessage("CREATE ()"), new PullMessage(asMapValue(map("n", -1L)))));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).doesNotContainEntry("bookmark", expectedBookmark))));
connection.send(util.chunk(CommitMessage.COMMIT_MESSAGE));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
use of org.neo4j.bolt.v4.messaging.BeginMessage in project neo4j by neo4j.
the class BoltV42TransportIT method shouldReturnUpdatedBookmarkAfterExplicitTransaction.
@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterExplicitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
init(connectionClass);
negotiateBoltV42();
// bookmark is expected to advance once the auto-commit transaction is committed
var lastClosedTransactionId = getLastClosedTransactionId();
var expectedBookmark = new BookmarkWithDatabaseId(lastClosedTransactionId + 1, getDatabaseId()).toString();
connection.send(util.chunk(new BeginMessage()));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
connection.send(util.chunk(new RunMessage("CREATE ()"), new PullMessage(asMapValue(map("n", -1L)))));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).doesNotContainEntry("bookmark", expectedBookmark))));
connection.send(util.chunk(CommitMessage.COMMIT_MESSAGE));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
use of org.neo4j.bolt.v4.messaging.BeginMessage in project neo4j by neo4j.
the class BoltV4TransportIT method shouldReturnUpdatedBookmarkAfterExplicitTransaction.
@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterExplicitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
init(connectionClass);
negotiateBoltV4();
// bookmark is expected to advance once the auto-commit transaction is committed
var lastClosedTransactionId = getLastClosedTransactionId();
var expectedBookmark = new BookmarkWithDatabaseId(lastClosedTransactionId + 1, getDatabaseId()).toString();
connection.send(util.chunk(new BeginMessage()));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
connection.send(util.chunk(new RunMessage("CREATE ()"), new PullMessage(asMapValue(map("n", -1L)))));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).doesNotContainEntry("bookmark", expectedBookmark))));
connection.send(util.chunk(CommitMessage.COMMIT_MESSAGE));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
Aggregations