Search in sources :

Example 1 with PackedOutputArray

use of org.neo4j.bolt.packstream.PackedOutputArray in project neo4j by neo4j.

the class UnsupportedStructTypesV1V2IT method createRunWithUnknownValue.

private byte[] createRunWithUnknownValue(AnyValue value) throws IOException {
    PackedOutputArray out = new PackedOutputArray();
    Neo4jPack.Packer packer = neo4jPack.newPacker(out);
    packer.packStructHeader(2, RunMessage.SIGNATURE);
    packer.pack("RETURN $x");
    packer.packMapHeader(1);
    packer.pack("x");
    packer.pack(value);
    return out.bytes();
}
Also used : PackedOutputArray(org.neo4j.bolt.packstream.PackedOutputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack)

Example 2 with PackedOutputArray

use of org.neo4j.bolt.packstream.PackedOutputArray in project neo4j by neo4j.

the class BoltV3TransportIT method runMessage.

private byte[] runMessage(Map<String, Object> metadata) throws IOException {
    PackedOutputArray out = new PackedOutputArray();
    Neo4jPack.Packer packer = util.getNeo4jPack().newPacker(out);
    packer.packStructHeader(3, RunMessage.SIGNATURE);
    packer.pack("RETURN 1");
    packer.pack(EMPTY_MAP);
    packer.pack(asMapValue(metadata));
    return out.bytes();
}
Also used : PackedOutputArray(org.neo4j.bolt.packstream.PackedOutputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack)

Example 3 with PackedOutputArray

use of org.neo4j.bolt.packstream.PackedOutputArray in project neo4j by neo4j.

the class MessageDecoderTest method shouldThrowOnUnknownStructType.

@ParameterizedTest
@MethodSource("argumentsProvider")
public void shouldThrowOnUnknownStructType(Neo4jPack packerUnderTest) throws Exception {
    this.packerUnderTest = packerUnderTest;
    PackedOutputArray out = new PackedOutputArray();
    Neo4jPack.Packer packer = packerUnderTest.newPacker(out);
    packer.packStructHeader(2, RunMessage.SIGNATURE);
    packer.pack("RETURN $x");
    packer.packMapHeader(1);
    packer.pack("x");
    packer.packStructHeader(0, (byte) 'A');
    var ex = assertThrows(BoltIOException.class, () -> unpack(out.bytes()));
    assertEquals("Struct types of 0x41 are not recognized.", ex.getMessage());
}
Also used : PackedOutputArray(org.neo4j.bolt.packstream.PackedOutputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with PackedOutputArray

use of org.neo4j.bolt.packstream.PackedOutputArray in project neo4j by neo4j.

the class MessageDecoderTest method packMessageWithSignature.

private byte[] packMessageWithSignature(byte signature) throws IOException {
    PackedOutputArray out = new PackedOutputArray();
    Neo4jPack.Packer packer = packerUnderTest.newPacker(out);
    packer.packStructHeader(2, signature);
    packer.pack("RETURN 'Hello World!'");
    packer.pack(EMPTY_MAP);
    return out.bytes();
}
Also used : PackedOutputArray(org.neo4j.bolt.packstream.PackedOutputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack)

Example 5 with PackedOutputArray

use of org.neo4j.bolt.packstream.PackedOutputArray in project neo4j by neo4j.

the class TransportUnauthenticatedConnectionErrorIT method createHelloWithOversizeDeclaredMap.

private byte[] createHelloWithOversizeDeclaredMap(Neo4jPack neo4jPack) throws IOException {
    PackedOutputArray out = new PackedOutputArray();
    Neo4jPack.Packer packer = neo4jPack.newPacker(out);
    packer.packStructHeader(2, HelloMessage.SIGNATURE);
    // Map claims to be huge when it isn't
    packer.packMapHeader(Integer.MAX_VALUE);
    packer.pack("x");
    packer.pack("Boom!");
    return out.bytes();
}
Also used : PackedOutputArray(org.neo4j.bolt.packstream.PackedOutputArray) Neo4jPack(org.neo4j.bolt.packstream.Neo4jPack)

Aggregations

Neo4jPack (org.neo4j.bolt.packstream.Neo4jPack)11 PackedOutputArray (org.neo4j.bolt.packstream.PackedOutputArray)11 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1 Neo4jPackV2 (org.neo4j.bolt.packstream.Neo4jPackV2)1 TextArray (org.neo4j.values.storable.TextArray)1