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 2015/09/30 16:46:20 UTC
[4/5] incubator-tinkerpop git commit: Add tests to validate all IO
options work for TinkerGraph persistence.
Add tests to validate all IO options work for TinkerGraph persistence.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/550509fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/550509fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/550509fc
Branch: refs/heads/tp30
Commit: 550509fc742be9bed8911a992a4034df61afe7a6
Parents: fb6d006
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 30 09:47:38 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 30 09:47:38 2015 -0400
----------------------------------------------------------------------
.../tinkergraph/structure/TinkerGraphTest.java | 71 ++++++++++++++++++++
1 file changed, 71 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/550509fc/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 3d763b7..627cd0f 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -18,11 +18,16 @@
*/
package org.apache.tinkerpop.gremlin.tinkergraph.structure;
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.tinkerpop.gremlin.TestHelper;
import org.apache.tinkerpop.gremlin.process.traversal.P;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.io.IoTest;
import org.junit.Test;
+import java.io.File;
import java.util.Set;
import static org.junit.Assert.assertEquals;
@@ -256,5 +261,71 @@ public class TinkerGraphTest {
}, 0.5)).has("oid", "1").count().next());
}
+ @Test(expected = IllegalStateException.class)
+ public void shouldRequireGraphLocationIfFormatIsSet() {
+ final Configuration conf = new BaseConfiguration();
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "graphml");
+ TinkerGraph.open(conf);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void shouldRequireGraphFormatIfLocationIsSet() {
+ final Configuration conf = new BaseConfiguration();
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, "/tmp");
+ TinkerGraph.open(conf);
+ }
+
+ @Test
+ public void shouldPersistToGraphML() {
+ final String graphLocation = TestHelper.makeTestDataPath(TinkerGraphTest.class, "temp").getAbsolutePath() + "shouldPersistToGraphML.xml";
+ final File f = new File(graphLocation);
+ if (f.exists() && f.isFile()) f.delete();
+
+ final Configuration conf = new BaseConfiguration();
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "graphml");
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, graphLocation);
+ final TinkerGraph graph = TinkerGraph.open(conf);
+ TinkerFactory.generateModern(graph);
+ graph.close();
+
+ final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+ IoTest.assertModernGraph(reloadedGraph, true, true);
+ reloadedGraph.close();
+ }
+ @Test
+ public void shouldPersistToGraphSON() {
+ final String graphLocation = TestHelper.makeTestDataPath(TinkerGraphTest.class, "temp").getAbsolutePath() + "shouldPersistToGraphSON.json";
+ final File f = new File(graphLocation);
+ if (f.exists() && f.isFile()) f.delete();
+
+ final Configuration conf = new BaseConfiguration();
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "graphson");
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, graphLocation);
+ final TinkerGraph graph = TinkerGraph.open(conf);
+ TinkerFactory.generateModern(graph);
+ graph.close();
+
+ final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+ IoTest.assertModernGraph(reloadedGraph, true, false);
+ reloadedGraph.close();
+ }
+
+ @Test
+ public void shouldPersistToGryo() {
+ final String graphLocation = TestHelper.makeTestDataPath(TinkerGraphTest.class, "temp").getAbsolutePath() + "shouldPersistToGryo.kryo";
+ final File f = new File(graphLocation);
+ if (f.exists() && f.isFile()) f.delete();
+
+ final Configuration conf = new BaseConfiguration();
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_FORMAT, "gryo");
+ conf.setProperty(TinkerGraph.CONFIG_GRAPH_LOCATION, graphLocation);
+ final TinkerGraph graph = TinkerGraph.open(conf);
+ TinkerFactory.generateModern(graph);
+ graph.close();
+
+ final TinkerGraph reloadedGraph = TinkerGraph.open(conf);
+ IoTest.assertModernGraph(reloadedGraph, true, false);
+ reloadedGraph.close();
+ }
}