use of org.neo4j.bolt.messaging.RecordingByteChannel in project neo4j by neo4j.
the class BoltProtocolV4ComponentFactory method encode.
public static byte[] encode(Neo4jPack neo4jPack, RequestMessage... messages) throws IOException {
RecordingByteChannel rawData = new RecordingByteChannel();
Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(rawData));
BoltRequestMessageWriter writer = requestMessageWriter(packer);
for (RequestMessage message : messages) {
writer.write(message);
}
writer.flush();
return rawData.getBytes();
}
use of org.neo4j.bolt.messaging.RecordingByteChannel in project neo4j by neo4j.
the class BoltProtocolV3ComponentFactory method encode.
public static byte[] encode(Neo4jPack neo4jPack, RequestMessage... messages) throws IOException {
RecordingByteChannel rawData = new RecordingByteChannel();
Neo4jPack.Packer packer = neo4jPack.newPacker(new BufferedChannelOutput(rawData));
BoltRequestMessageWriter writer = requestMessageWriter(packer);
for (RequestMessage message : messages) {
writer.write(message);
}
writer.flush();
return rawData.getBytes();
}
use of org.neo4j.bolt.messaging.RecordingByteChannel 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 BoltRequestMessageWriterV4(new Neo4jPackV2().newPacker(new BufferedChannelOutput(channel)));
writer.write(msgs[i]).flush();
serialized[i] = channel.getBytes();
}
return Chunker.chunk(chunkSize, serialized);
}
use of org.neo4j.bolt.messaging.RecordingByteChannel 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();
}
use of org.neo4j.bolt.messaging.RecordingByteChannel in project neo4j by neo4j.
the class TransportErrorIT method shouldHandleUnknownMarkerBytes.
@ParameterizedTest(name = "{displayName} {2}")
@MethodSource("argumentsProvider")
public void shouldHandleUnknownMarkerBytes(Class<? extends TransportConnection> connectionClass, Neo4jPack neo4jPack, String name) throws Exception {
initParameters(connectionClass, neo4jPack, name);
// Given I send a message with an invalid type
final RecordingByteChannel rawData = new RecordingByteChannel();
final BufferedChannelOutput out = new BufferedChannelOutput(rawData);
final PackStream.Packer packer = new PackStream.Packer(out);
packer.packStructHeader(2, RunMessage.SIGNATURE);
// Invalid marker byte
out.writeByte(PackStream.RESERVED_C7);
out.flush();
byte[] invalidMessage = rawData.getBytes();
// When
connection.connect(address).send(util.defaultAcceptedVersions()).send(util.chunk(32, invalidMessage));
// Then
assertThat(connection).satisfies(util.eventuallyReceivesSelectedProtocolVersion());
assertThat(connection).satisfies(eventuallyDisconnects());
}
Aggregations