Search in sources :

Example 1 with BoltResponseMessageRecorder

use of org.neo4j.bolt.messaging.BoltResponseMessageRecorder 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 BoltResponseMessageRecorder

use of org.neo4j.bolt.messaging.BoltResponseMessageRecorder 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 BoltResponseMessageRecorder

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

the class MessageConditions method responseMessage.

public static ResponseMessage responseMessage(Neo4jPack neo4jPack, byte[] bytes) throws IOException {
    BoltResponseMessageReader unpacker = responseReader(neo4jPack, bytes);
    BoltResponseMessageRecorder consumer = new BoltResponseMessageRecorder();
    try {
        unpacker.read(consumer);
        return consumer.asList().get(0);
    } catch (Throwable e) {
        throw new IOException("Failed to deserialize response, '" + e.getMessage() + "'.\n" + "Raw data: \n" + HexPrinter.hex(bytes), e);
    }
}
Also used : BoltResponseMessageRecorder(org.neo4j.bolt.messaging.BoltResponseMessageRecorder) BoltResponseMessageReader(org.neo4j.bolt.messaging.BoltResponseMessageReader) IOException(java.io.IOException)

Aggregations

BoltResponseMessageRecorder (org.neo4j.bolt.messaging.BoltResponseMessageRecorder)3 Test (org.junit.jupiter.api.Test)2 ResponseMessage (org.neo4j.bolt.messaging.ResponseMessage)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 IOException (java.io.IOException)1 BoltResponseMessageReader (org.neo4j.bolt.messaging.BoltResponseMessageReader)1 RecordMessage (org.neo4j.bolt.v3.messaging.response.RecordMessage)1