use of org.neo4j.bolt.v3.messaging.request.BeginMessage 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);
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldWriteFailureMessage.
@Test
void shouldWriteFailureMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
Status.Transaction errorStatus = Status.Transaction.DeadlockDetected;
String errorMessage = "Hi Deadlock!";
writer.write(new FailureMessage(errorStatus, errorMessage));
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(errorStatus.code().serialize());
inOrder.verify(packer).pack(errorMessage);
inOrder.verify(output).messageSucceeded();
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldWriteSuccessMessage.
@Test
void shouldWriteSuccessMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
MapValue metadata = map(new String[] { "a", "b", "c" }, new AnyValue[] { intValue(1), stringValue("2"), date(2010, 02, 02) });
writer.write(new SuccessMessage(metadata));
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(metadata);
inOrder.verify(output).messageSucceeded();
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldNotifyOutputAboutFailedRecordMessage.
@Test
void shouldNotifyOutputAboutFailedRecordMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
IOException error = new IOException("Unable to pack 42");
doThrow(error).when(packer).pack(longValue(42));
var writer = newWriter(output, packer);
var e = assertThrows(IOException.class, () -> writer.write(new RecordMessage(new AnyValue[] { stringValue("42"), longValue(42) })));
assertEquals(error, e);
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(stringValue("42"));
inOrder.verify(packer).pack(longValue(42));
inOrder.verify(output).messageFailed();
}
use of org.neo4j.bolt.v3.messaging.request.BeginMessage in project neo4j by neo4j.
the class ReadyStateIT method shouldMoveToFailedStateOnBegin_fail.
@Test
void shouldMoveToFailedStateOnBegin_fail() throws Throwable {
// Given
BoltStateMachineV3 machine = newStateMachine();
machine.process(newHelloMessage(), nullResponseHandler());
// When
BoltResponseRecorder recorder = new BoltResponseRecorder();
BeginMessage beginMessage = mock(BeginMessage.class);
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);
}
Aggregations