use of org.neo4j.bolt.v1.messaging.BoltRequestMessageWriter in project neo4j by neo4j.
the class FragmentedMessageDeliveryTest method serialize.
private byte[] serialize(int chunkSize, RequestMessage... msgs) throws IOException {
byte[][] serialized = new byte[msgs.length][];
for (int i = 0; i < msgs.length; i++) {
RecordingByteChannel channel = new RecordingByteChannel();
BoltRequestMessageWriter writer = new BoltRequestMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(channel)), NO_BOUNDARY_HOOK);
writer.write(msgs[i]).flush();
serialized[i] = channel.getBytes();
}
return Chunker.chunk(chunkSize, serialized);
}
use of org.neo4j.bolt.v1.messaging.BoltRequestMessageWriter in project neo4j by neo4j.
the class MessageMatchers method serialize.
public static byte[] serialize(RequestMessage... messages) throws IOException {
final RecordingByteChannel rawData = new RecordingByteChannel();
final BoltRequestMessageWriter packer = new BoltRequestMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(rawData)), NO_BOUNDARY_HOOK);
for (RequestMessage message : messages) {
packer.write(message);
}
packer.flush();
return rawData.getBytes();
}
use of org.neo4j.bolt.v1.messaging.BoltRequestMessageWriter in project neo4j by neo4j.
the class BoltRequestMessageTest method serializeAndDeserialize.
private <T extends RequestMessage> T serializeAndDeserialize(T msg) throws IOException {
RecordingByteChannel channel = new RecordingByteChannel();
BoltRequestMessageReader reader = new BoltRequestMessageReader(new Neo4jPack.Unpacker(new BufferedChannelInput(16).reset(channel)));
BoltRequestMessageWriter writer = new BoltRequestMessageWriter(new Neo4jPack.Packer(new BufferedChannelOutput(channel)), NO_BOUNDARY_HOOK);
writer.write(msg).flush();
channel.eof();
return unpack(reader, channel);
}
Aggregations