use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.
the class BoltResponseMessageRecorder method endRecord.
@Override
public void endRecord() {
currentOffset = -1;
messages.add(new RecordMessage(fields));
}
use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldNotNotifyOutputWhenOutputItselfFails.
@Test
void shouldNotNotifyOutputWhenOutputItselfFails() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
IOException error = new IOException("Unable to flush");
doThrow(error).when(output).messageSucceeded();
var writer = newWriter(output, packer);
var e = assertThrows(IOException.class, () -> writer.write(new RecordMessage(new AnyValue[] { longValue(1), longValue(2) })));
assertEquals(error, e);
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(longValue(1));
inOrder.verify(packer).pack(longValue(2));
inOrder.verify(output).messageSucceeded();
verify(output, never()).messageFailed();
}
use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldWriteRecordMessage.
@Test
void shouldWriteRecordMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
writer.write(new RecordMessage(new AnyValue[] { longValue(42), stringValue("42") }));
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(longValue(42));
inOrder.verify(packer).pack(stringValue("42"));
inOrder.verify(output).messageSucceeded();
}
use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.
the class ResultHandlerTest method shouldPullTheResult.
@Test
void shouldPullTheResult() throws Throwable {
BoltResponseMessageRecorder messageWriter = new BoltResponseMessageRecorder();
ResultHandler handler = new ResultHandler(messageWriter, mock(BoltConnection.class), NullLog.getInstance());
Value[] record1 = values("a", "b", "c");
Value[] record2 = values("1", "2", "3");
BoltResult result = new TestBoltResult(record1, record2);
handler.onPullRecords(result, STREAM_LIMIT_UNLIMITED);
handler.onFinish();
List<ResponseMessage> messages = messageWriter.asList();
assertThat(messages.size()).isEqualTo(3);
assertThat(messages.get(0)).isEqualTo(new RecordMessage(record1));
assertThat(messages.get(1)).isEqualTo(new RecordMessage(record2));
assertThat(messages.get(2)).isInstanceOf(SuccessMessage.class);
}
use of org.neo4j.bolt.v3.messaging.response.RecordMessage in project neo4j by neo4j.
the class RecordMessageEncoderTest method shouldEncodeRecordMessage.
@Test
void shouldEncodeRecordMessage() throws Throwable {
// Given
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
RecordMessageEncoder encoder = new RecordMessageEncoder();
// When
encoder.encode(packer, new RecordMessage(new AnyValue[0]));
// Then
verify(packer).packStructHeader(anyInt(), eq(RecordMessage.SIGNATURE));
verify(packer).packListHeader(0);
}
Aggregations