You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/01/12 22:10:51 UTC
[04/15] incubator-tinkerpop git commit: Add gryo,
graphML tests to IoTest
Add gryo, graphML tests to IoTest
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/11b90090
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/11b90090
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/11b90090
Branch: refs/heads/master
Commit: 11b9009043c2be8171754dac98fd00e41678aa20
Parents: 38ad2a0
Author: Benjamin Han <be...@siftsec.com>
Authored: Wed Dec 9 17:01:31 2015 -0800
Committer: Benjamin Han <be...@siftsec.com>
Committed: Wed Dec 9 17:01:31 2015 -0800
----------------------------------------------------------------------
.../tinkerpop/gremlin/structure/io/IoTest.java | 64 +++++++++++++++++++-
1 file changed, 63 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/11b90090/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
index 192fd26..6848f6c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/IoTest.java
@@ -250,6 +250,65 @@ public class IoTest {
// need to manually close the "g2" instance
graphProvider.clear(g2, configuration);
}
+
+ @Test
+ @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+ @FeatureRequirement(featureClass = EdgePropertyFeatures.class, feature = FEATURE_STRING_VALUES)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+ public void shouldReadWriteSelfLoopingEdges() throws Exception {
+ final Configuration sourceConf = graphProvider.newGraphConfiguration("source", this.getClass(), name.getMethodName(), null);
+ final Graph source = GraphFactory.open(sourceConf);
+ final Vertex v1 = source.addVertex();
+ final Vertex v2 = source.addVertex();
+ v1.addEdge("CONTROL", v2);
+ v1.addEdge("SELF-LOOP", v1);
+
+ final GraphMLWriter w = GraphMLWriter.build().create();
+ final File f = TestHelper.generateTempFile(this.getClass(), "test", ".txt");
+ try (final OutputStream out = new FileOutputStream(f)) {
+ w.writeGraph(out, graph);
+ }
+
+ final Configuration targetConf = graphProvider.newGraphConfiguration("target", this.getClass(), name.getMethodName(), null);
+ final Graph target = GraphFactory.open(targetConf);
+ final GraphMLReader r = GraphMLReader.build().create();
+ try (final InputStream in = new FileInputStream(f)) {
+ r.readGraph(in, target);
+ }
+
+ assertEquals(source.traversal().V().count(), target.traversal().V().count());
+ assertEquals(source.traversal().E().count(), target.traversal().E().count());
+ }
+ }
+
+ public static final class GryoTest extends AbstractGremlinTest {
+
+ @Test
+ @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+ @FeatureRequirement(featureClass = EdgePropertyFeatures.class, feature = FEATURE_STRING_VALUES)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+ public void shouldReadWriteSelfLoopingEdges() {
+ final Configuration sourceConf = graphProvider.newGraphConfiguration("source", this.getClass(), name.getMethodName(), null);
+ final Graph source = GraphFactory.open(sourceConf);
+ final Vertex v1 = source.addVertex();
+ final Vertex v2 = source.addVertex();
+ v1.addEdge("CONTROL", v2);
+ v1.addEdge("SELF-LOOP", v1);
+
+ final Configuration targetConf = graphProvider.newGraphConfiguration("target", this.getClass(), name.getMethodName(), null);
+ final Graph target = GraphFactory.open(targetConf);
+ try (ByteArrayOutputStream os = new ByteArrayOutputStream()) {
+ source.io(IoCore.gryo()).writer().create().writeGraph(os, source);
+ try (ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray())) {
+ target.io(IoCore.gryo()).reader().create().readGraph(is, target);
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+
+ assertEquals(source.traversal().V().count(), target.traversal().V().count());
+ assertEquals(source.traversal().E().count(), target.traversal().E().count());
+ }
}
public static final class GraphSONTest extends AbstractGremlinTest {
@@ -371,7 +430,10 @@ public class IoTest {
}
@Test
- public void shouldReadWriteSelfLoopingEdges() {
+ @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES)
+ @FeatureRequirement(featureClass = EdgePropertyFeatures.class, feature = FEATURE_STRING_VALUES)
+ @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES)
+ public void shouldReadWriteSelfLoopingEdges() throws Exception {
final Configuration sourceConf = graphProvider.newGraphConfiguration("source", this.getClass(), name.getMethodName(), null);
final Graph source = GraphFactory.open(sourceConf);
final Vertex v1 = source.addVertex();