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:49 UTC
[02/15] incubator-tinkerpop git commit: Add test case
Add test case
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/19d0a81f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/19d0a81f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/19d0a81f
Branch: refs/heads/master
Commit: 19d0a81f5d78b4f3d00d8f07da15600d80c848f4
Parents: 1892d7c
Author: Benjamin Han <be...@siftsec.com>
Authored: Wed Dec 9 14:22:15 2015 -0800
Committer: Benjamin Han <be...@siftsec.com>
Committed: Wed Dec 9 14:22:15 2015 -0800
----------------------------------------------------------------------
.../io/graphson/GraphSONReaderTest.java | 62 ++++++++++++++++++++
1 file changed, 62 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/19d0a81f/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReaderTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReaderTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReaderTest.java
new file mode 100644
index 0000000..1dbfddb
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReaderTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.structure.io.graphson;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.IoCore;
+import org.apache.tinkerpop.gremlin.structure.util.GraphFactory;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Created by Benjamin Han
+ */
+public class GraphSONReaderTest extends AbstractGremlinTest {
+
+ @Test
+ public void shouldReadWriteSelfLoopingEdges() {
+ final Configuration sourceConf = graphProvider.newGraphConfiguration("source", this.getClass(), name.getMethodName(), null);
+ final Graph source = GraphFactory.open(sourceConf);
+ Vertex v1 = source.addVertex();
+ 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.graphson()).writer().create().writeGraph(os, source);
+ ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
+ target.io(IoCore.graphson()).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());
+ }
+}