You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2016/08/23 11:35:39 UTC
tinkerpop git commit: Add full round-trip tests for graphson 2.0
Repository: tinkerpop
Updated Branches:
refs/heads/TINKERPOP-1278 b3f3fe433 -> e6f4cfdf9
Add full round-trip tests for graphson 2.0
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/e6f4cfdf
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/e6f4cfdf
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/e6f4cfdf
Branch: refs/heads/TINKERPOP-1278
Commit: e6f4cfdf93b962fae694db7bc9428f7c052acbab
Parents: b3f3fe4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Aug 23 07:35:18 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Aug 23 07:35:18 2016 -0400
----------------------------------------------------------------------
.../structure/io/graphson/GraphSONIo.java | 24 +++++++++++++++++---
.../gremlin/structure/io/IoGraphTest.java | 10 +++++---
2 files changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e6f4cfdf/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
index 89f0f66..f56afb9 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONIo.java
@@ -40,12 +40,14 @@ import java.util.function.Consumer;
public final class GraphSONIo implements Io<GraphSONReader.Builder, GraphSONWriter.Builder, GraphSONMapper.Builder> {
private final IoRegistry registry;
private final Graph graph;
- private Optional<Consumer<Mapper.Builder>> onMapper;
+ private final Optional<Consumer<Mapper.Builder>> onMapper;
+ private final GraphSONVersion version;
private GraphSONIo(final Builder builder) {
this.registry = builder.registry;
this.graph = builder.graph;
this.onMapper = Optional.ofNullable(builder.onMapper);
+ this.version = builder.version;
}
/**
@@ -69,7 +71,8 @@ public final class GraphSONIo implements Io<GraphSONReader.Builder, GraphSONWrit
*/
@Override
public GraphSONMapper.Builder mapper() {
- final GraphSONMapper.Builder builder = (null == this.registry) ? GraphSONMapper.build() : GraphSONMapper.build().addRegistry(this.registry);
+ final GraphSONMapper.Builder builder = (null == this.registry) ?
+ GraphSONMapper.build().version(version) : GraphSONMapper.build().version(version).addRegistry(this.registry);
onMapper.ifPresent(c -> c.accept(builder));
return builder;
}
@@ -94,8 +97,18 @@ public final class GraphSONIo implements Io<GraphSONReader.Builder, GraphSONWrit
}
}
+ /**
+ * Create a new builder using the default version of GraphSON.
+ */
public static Io.Builder<GraphSONIo> build() {
- return new Builder();
+ return build(GraphSONVersion.V1_0);
+ }
+
+ /**
+ * Create a new builder using the specified version of GraphSON.
+ */
+ public static Io.Builder<GraphSONIo> build(final GraphSONVersion version) {
+ return new Builder(version);
}
public final static class Builder implements Io.Builder<GraphSONIo> {
@@ -103,6 +116,11 @@ public final class GraphSONIo implements Io<GraphSONReader.Builder, GraphSONWrit
private IoRegistry registry = null;
private Graph graph;
private Consumer<Mapper.Builder> onMapper = null;
+ private final GraphSONVersion version;
+
+ Builder(final GraphSONVersion version) {
+ this.version = version;
+ }
/**
* @deprecated As of release 3.2.2, replaced by {@link #onMapper(Consumer)}.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/e6f4cfdf/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoGraphTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoGraphTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoGraphTest.java
index 618f62a..040849e 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoGraphTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoGraphTest.java
@@ -24,6 +24,9 @@ import org.apache.tinkerpop.gremlin.FeatureRequirement;
import org.apache.tinkerpop.gremlin.LoadGraphWith;
import org.apache.tinkerpop.gremlin.TestHelper;
import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONIo;
+import org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONVersion;
+import org.apache.tinkerpop.gremlin.structure.util.star.StarGraph;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -48,7 +51,8 @@ public class IoGraphTest extends AbstractGremlinTest {
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
{"graphml", IoCore.graphml(), false, true, ".xml"},
- {"graphson", IoCore.graphson(), true, true, ".json"},
+ {"graphsonv1d0", IoCore.graphson(), true, true, ".json"},
+ {"graphsonv2d0", GraphSONIo.build(GraphSONVersion.V2_0), true, true, ".json"},
{"gryo", IoCore.gryo(), false, false, ".kryo"}
});
}
@@ -202,8 +206,8 @@ public class IoGraphTest extends AbstractGremlinTest {
@LoadGraphWith(LoadGraphWith.GraphData.CREW)
@FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
@FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
- public void shouldReadWriteCrewToGryo() throws Exception {
- assumeThat("GraphML does not suppport multi/metaproperties", ioType, not("graphml"));
+ public void shouldReadWriteCrew() throws Exception {
+ assumeThat("GraphML does not support multi/metaproperties", ioType, not("graphml"));
try (final ByteArrayOutputStream os = new ByteArrayOutputStream()) {
final GraphWriter writer = graph.io(ioBuilderToTest).writer().create();