[03/18] tinkerpop git commit: Added test to verify the paths in HADOOP_GREMLIN_LIBS are handled properly handled, with and without a file system scheme prefix.

2016-06-15 Thread okram
Added test to verify the paths in HADOOP_GREMLIN_LIBS are handled properly 
handled, with and without a file system scheme prefix.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6352bab2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6352bab2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6352bab2

Branch: refs/heads/TINKERPOP-1278
Commit: 6352bab23e14745588d519634d97471132a68ec9
Parents: fe98cf0
Author: Daniel Kuppitz 
Authored: Mon Jun 13 06:55:22 2016 +0200
Committer: Daniel Kuppitz 
Committed: Mon Jun 13 09:08:09 2016 +0200

--
 .../groovy/plugin/HadoopGremlinPluginCheck.java | 142 +++
 1 file changed, 142 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6352bab2/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
--
diff --git 
a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
 
b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
index 8e4ff25..f7b702a 100644
--- 
a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
+++ 
b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
@@ -29,13 +29,30 @@ import 
org.apache.tinkerpop.gremlin.groovy.util.TestableConsolePluginAcceptor;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
 import org.apache.tinkerpop.gremlin.hadoop.HadoopGremlinSuite;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.util.Gremlin;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Before;
 import org.junit.Test;
 
+import javax.tools.JavaCompiler;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -166,4 +183,129 @@ public class HadoopGremlinPluginCheck extends 
AbstractGremlinTest {
 assertEquals(6, IteratorUtils.count(traversal));
 assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT));
 }
+
+@Test
+@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+public void shouldSupportVariousFileSystemsInGremlinHadoopLibs() throws 
Exception {
+
+// The whole point of this test is to verify that HADOOP_GREMLIN_LIBS 
may contain paths with or without
+// a file system scheme prefix and that either path is properly 
handled. If all jar files, that were specified
+// in HADOOP_GREMLIN_LIBS, are found in the GraphComputers temporary 
directory after using the GraphComputer
+// (by submitting a traversal), the test is considered to be 
successful.
+//
+// The traversal will likely never fail, since both - Spark and Giraph 
- run in the same JVM during tests. This
+// is unfortunate as it doesn't allow us to verify that GraphComputers 
load jars properly in a distributed
+// environment. The test would fail in a distributed environment, IF 
loading the jars specified in
+// HADOOP_GREMLIN_LIBS wouldn't work. That is because we generate new 
jar files on the fly that are definitely
+// not part of any existing directory or the current classpath.
+
+final String testDataDirectory = 
TestHelper.makeTestDataDirectory(HadoopGremlinPluginCheck.class, 
"shouldHandleLocalGremlinHadoopLibs");
+final File jarFile1 = createJarFile(testDataDirectory + File.separator 
+ "1", "Greeter1");
+final File jarFile2 = createJarFile(testDataDirectory + File.separator 
+ "2", "Greeter2");
+final String graphComputerJarTargetBasePath = 
System.getProperty("java.io.tmpdir") + File.separator +
+"hadoop-gremlin-" + Gremlin.version() + "-libs" + 
File.separator;
+final File graphComputerJarTargetPath1 = new 
File(graphComputerJarTargetBasePath + "1" + File.separator + "Greeter1.jar");
+final File graphComputerJarTargetPath2 = new 
File(graphComputerJarTargetBasePath + 

[5/6] tinkerpop git commit: Added test to verify the paths in HADOOP_GREMLIN_LIBS are handled properly handled, with and without a file system scheme prefix.

2016-06-13 Thread dkuppitz
Added test to verify the paths in HADOOP_GREMLIN_LIBS are handled properly 
handled, with and without a file system scheme prefix.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/6352bab2
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/6352bab2
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/6352bab2

Branch: refs/heads/TINKERPOP-1331
Commit: 6352bab23e14745588d519634d97471132a68ec9
Parents: fe98cf0
Author: Daniel Kuppitz 
Authored: Mon Jun 13 06:55:22 2016 +0200
Committer: Daniel Kuppitz 
Committed: Mon Jun 13 09:08:09 2016 +0200

--
 .../groovy/plugin/HadoopGremlinPluginCheck.java | 142 +++
 1 file changed, 142 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6352bab2/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
--
diff --git 
a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
 
b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
index 8e4ff25..f7b702a 100644
--- 
a/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
+++ 
b/hadoop-gremlin/src/test/java/org/apache/tinkerpop/gremlin/hadoop/groovy/plugin/HadoopGremlinPluginCheck.java
@@ -29,13 +29,30 @@ import 
org.apache.tinkerpop.gremlin.groovy.util.TestableConsolePluginAcceptor;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
 import org.apache.tinkerpop.gremlin.hadoop.HadoopGremlinSuite;
 import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.util.Gremlin;
 import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils;
 import org.junit.Before;
 import org.junit.Test;
 
+import javax.tools.JavaCompiler;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URI;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -166,4 +183,129 @@ public class HadoopGremlinPluginCheck extends 
AbstractGremlinTest {
 assertEquals(6, IteratorUtils.count(traversal));
 assertNotNull(this.console.getBindings().get(RemoteAcceptor.RESULT));
 }
+
+@Test
+@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+public void shouldSupportVariousFileSystemsInGremlinHadoopLibs() throws 
Exception {
+
+// The whole point of this test is to verify that HADOOP_GREMLIN_LIBS 
may contain paths with or without
+// a file system scheme prefix and that either path is properly 
handled. If all jar files, that were specified
+// in HADOOP_GREMLIN_LIBS, are found in the GraphComputers temporary 
directory after using the GraphComputer
+// (by submitting a traversal), the test is considered to be 
successful.
+//
+// The traversal will likely never fail, since both - Spark and Giraph 
- run in the same JVM during tests. This
+// is unfortunate as it doesn't allow us to verify that GraphComputers 
load jars properly in a distributed
+// environment. The test would fail in a distributed environment, IF 
loading the jars specified in
+// HADOOP_GREMLIN_LIBS wouldn't work. That is because we generate new 
jar files on the fly that are definitely
+// not part of any existing directory or the current classpath.
+
+final String testDataDirectory = 
TestHelper.makeTestDataDirectory(HadoopGremlinPluginCheck.class, 
"shouldHandleLocalGremlinHadoopLibs");
+final File jarFile1 = createJarFile(testDataDirectory + File.separator 
+ "1", "Greeter1");
+final File jarFile2 = createJarFile(testDataDirectory + File.separator 
+ "2", "Greeter2");
+final String graphComputerJarTargetBasePath = 
System.getProperty("java.io.tmpdir") + File.separator +
+"hadoop-gremlin-" + Gremlin.version() + "-libs" + 
File.separator;
+final File graphComputerJarTargetPath1 = new 
File(graphComputerJarTargetBasePath + "1" + File.separator + "Greeter1.jar");
+final File graphComputerJarTargetPath2 = new 
File(graphComputerJarTargetBasePath +