Search in sources :

Example 1 with JanusGraphP

use of org.janusgraph.graphdb.tinkerpop.io.JanusGraphP in project janusgraph by JanusGraph.

the class JanusGraphPGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.

@ParameterizedTest
@MethodSource("janusGraphPProvider")
public void readValueAndWriteValueShouldBeSymmetric(final JanusGraphP predicate) throws IOException {
    final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(JanusGraphP.class, new JanusGraphPBinarySerializer()).addCustomType(Geoshape.class, new GeoshapeGraphBinarySerializer()).create();
    final GraphBinaryReader reader = new GraphBinaryReader(registry);
    final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
    for (boolean nullable : new boolean[] { true, false }) {
        final Buffer buffer = bufferFactory.create(allocator.buffer());
        writer.writeValue(predicate, buffer, nullable);
        final JanusGraphP actual = reader.readValue(buffer, JanusGraphP.class, nullable);
        assertEquals(actual.toString(), predicate.toString());
        buffer.release();
    }
}
Also used : Buffer(org.apache.tinkerpop.gremlin.structure.io.Buffer) GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) Geoshape(org.janusgraph.core.attribute.Geoshape) JanusGraphP(org.janusgraph.graphdb.tinkerpop.io.JanusGraphP) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 2 with JanusGraphP

use of org.janusgraph.graphdb.tinkerpop.io.JanusGraphP in project janusgraph by JanusGraph.

the class JanusGraphPGraphBinarySerializerTest method assertJanusGraphP.

private void assertJanusGraphP(final GraphBinaryMessageSerializerV1 serializer, final JanusGraphP predicate) throws IOException {
    final ByteBuf serialized = serializer.serializeResponseAsBinary(ResponseMessage.build(UUID.randomUUID()).result(predicate).create(), allocator);
    final ResponseMessage deserialized = serializer.deserializeResponse(serialized);
    final JanusGraphP actual = (JanusGraphP) deserialized.getResult().getData();
    assertEquals(actual, predicate);
}
Also used : ResponseMessage(org.apache.tinkerpop.gremlin.driver.message.ResponseMessage) ByteBuf(io.netty.buffer.ByteBuf) JanusGraphP(org.janusgraph.graphdb.tinkerpop.io.JanusGraphP)

Example 3 with JanusGraphP

use of org.janusgraph.graphdb.tinkerpop.io.JanusGraphP in project janusgraph by JanusGraph.

the class JanusGraphPGraphBinarySerializerTest method shouldCustomSerialization.

@ParameterizedTest
@MethodSource("janusGraphPProvider")
public void shouldCustomSerialization(final JanusGraphP predicate) throws IOException {
    final GraphBinaryMessageSerializerV1 serializer = new GraphBinaryMessageSerializerV1(TypeSerializerRegistry.build().addCustomType(JanusGraphP.class, new JanusGraphPBinarySerializer()).addCustomType(Geoshape.class, new GeoshapeGraphBinarySerializer()).create());
    assertJanusGraphP(serializer, predicate);
}
Also used : GraphBinaryMessageSerializerV1(org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1) JanusGraphP(org.janusgraph.graphdb.tinkerpop.io.JanusGraphP) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

JanusGraphP (org.janusgraph.graphdb.tinkerpop.io.JanusGraphP)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 ByteBuf (io.netty.buffer.ByteBuf)1 ResponseMessage (org.apache.tinkerpop.gremlin.driver.message.ResponseMessage)1 GraphBinaryMessageSerializerV1 (org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1)1 Buffer (org.apache.tinkerpop.gremlin.structure.io.Buffer)1 GraphBinaryReader (org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader)1 GraphBinaryWriter (org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter)1 TypeSerializerRegistry (org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry)1 Geoshape (org.janusgraph.core.attribute.Geoshape)1