Search in sources :

Example 1 with BoltResponseMessageWriter

use of org.neo4j.bolt.v1.messaging.BoltResponseMessageWriter in project neo4j by neo4j.

the class MessageMatchers method serialize.

public static byte[] serialize(ResponseMessage... messages) throws IOException {
    final RecordingByteChannel rawData = new RecordingByteChannel();
    final BoltResponseMessageWriter packer = new BoltResponseMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(rawData)), NO_BOUNDARY_HOOK);
    for (ResponseMessage message : messages) {
        message.dispatch(packer);
    }
    packer.flush();
    return rawData.getBytes();
}
Also used : BoltResponseMessageWriter(org.neo4j.bolt.v1.messaging.BoltResponseMessageWriter) RecordingByteChannel(org.neo4j.bolt.v1.messaging.RecordingByteChannel) ResponseMessage(org.neo4j.bolt.v1.messaging.message.ResponseMessage) Neo4jPack(org.neo4j.bolt.v1.messaging.Neo4jPack) BufferedChannelOutput(org.neo4j.bolt.v1.packstream.BufferedChannelOutput)

Example 2 with BoltResponseMessageWriter

use of org.neo4j.bolt.v1.messaging.BoltResponseMessageWriter in project neo4j by neo4j.

the class BoltResponseMessageTest method serializeAndDeserialize.

private <T extends ResponseMessage> T serializeAndDeserialize(T msg) throws IOException {
    RecordingByteChannel channel = new RecordingByteChannel();
    BoltResponseMessageReader reader = new BoltResponseMessageReader(new Neo4jPack.Unpacker(new BufferedChannelInput(16).reset(channel)));
    BoltResponseMessageWriter writer = new BoltResponseMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(channel)), NO_BOUNDARY_HOOK);
    msg.dispatch(writer);
    writer.flush();
    channel.eof();
    return unpack(reader, channel);
}
Also used : BufferedChannelInput(org.neo4j.bolt.v1.packstream.BufferedChannelInput) BufferedChannelOutput(org.neo4j.bolt.v1.packstream.BufferedChannelOutput)

Aggregations

BufferedChannelOutput (org.neo4j.bolt.v1.packstream.BufferedChannelOutput)2 BoltResponseMessageWriter (org.neo4j.bolt.v1.messaging.BoltResponseMessageWriter)1 Neo4jPack (org.neo4j.bolt.v1.messaging.Neo4jPack)1 RecordingByteChannel (org.neo4j.bolt.v1.messaging.RecordingByteChannel)1 ResponseMessage (org.neo4j.bolt.v1.messaging.message.ResponseMessage)1 BufferedChannelInput (org.neo4j.bolt.v1.packstream.BufferedChannelInput)1