Search in sources :

Example 1 with ResponseMessage

use of org.neo4j.bolt.messaging.ResponseMessage 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);
}
Also used : BoltResponseMessageRecorder(org.neo4j.bolt.messaging.BoltResponseMessageRecorder) BoltConnection(org.neo4j.bolt.runtime.BoltConnection) AnyValue(org.neo4j.values.AnyValue) Value(org.neo4j.values.storable.Value) ResponseMessage(org.neo4j.bolt.messaging.ResponseMessage) RecordMessage(org.neo4j.bolt.v3.messaging.response.RecordMessage) BoltResult(org.neo4j.bolt.runtime.BoltResult) Test(org.junit.jupiter.api.Test)

Example 2 with ResponseMessage

use of org.neo4j.bolt.messaging.ResponseMessage in project neo4j by neo4j.

the class ResultHandlerTest method shouldDiscardTheResult.

@Test
void shouldDiscardTheResult() 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.onDiscardRecords(result, STREAM_LIMIT_UNLIMITED);
    handler.onFinish();
    List<ResponseMessage> messages = messageWriter.asList();
    assertThat(messages.size()).isEqualTo(1);
    assertThat(messages.get(0)).isInstanceOf(SuccessMessage.class);
}
Also used : BoltResponseMessageRecorder(org.neo4j.bolt.messaging.BoltResponseMessageRecorder) BoltConnection(org.neo4j.bolt.runtime.BoltConnection) AnyValue(org.neo4j.values.AnyValue) Value(org.neo4j.values.storable.Value) ResponseMessage(org.neo4j.bolt.messaging.ResponseMessage) BoltResult(org.neo4j.bolt.runtime.BoltResult) Test(org.junit.jupiter.api.Test)

Example 3 with ResponseMessage

use of org.neo4j.bolt.messaging.ResponseMessage in project neo4j by neo4j.

the class MessageConditions method serialize.

public static byte[] serialize(Neo4jPack neo4jPack, ResponseMessage... messages) throws IOException {
    RecordingByteChannel rawData = new RecordingByteChannel();
    BufferedChannelOutput output = new BufferedChannelOutput(rawData);
    BoltResponseMessageWriter writer = new BoltResponseMessageWriterV3(neo4jPack::newPacker, output, NullLogService.getInstance());
    for (ResponseMessage message : messages) {
        writer.write(message);
    }
    writer.flush();
    return rawData.getBytes();
}
Also used : BoltResponseMessageWriter(org.neo4j.bolt.messaging.BoltResponseMessageWriter) BoltResponseMessageWriterV3(org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3) RecordingByteChannel(org.neo4j.bolt.messaging.RecordingByteChannel) ResponseMessage(org.neo4j.bolt.messaging.ResponseMessage) BufferedChannelOutput(org.neo4j.bolt.packstream.BufferedChannelOutput)

Aggregations

ResponseMessage (org.neo4j.bolt.messaging.ResponseMessage)3 Test (org.junit.jupiter.api.Test)2 BoltResponseMessageRecorder (org.neo4j.bolt.messaging.BoltResponseMessageRecorder)2 BoltConnection (org.neo4j.bolt.runtime.BoltConnection)2 BoltResult (org.neo4j.bolt.runtime.BoltResult)2 AnyValue (org.neo4j.values.AnyValue)2 Value (org.neo4j.values.storable.Value)2 BoltResponseMessageWriter (org.neo4j.bolt.messaging.BoltResponseMessageWriter)1 RecordingByteChannel (org.neo4j.bolt.messaging.RecordingByteChannel)1 BufferedChannelOutput (org.neo4j.bolt.packstream.BufferedChannelOutput)1 BoltResponseMessageWriterV3 (org.neo4j.bolt.v3.messaging.BoltResponseMessageWriterV3)1 RecordMessage (org.neo4j.bolt.v3.messaging.response.RecordMessage)1