You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by pl...@apache.org on 2016/06/15 12:49:49 UTC

tinkerpop git commit: fix GremlinGroovyScriptEngineFileSandboxTest resource loading

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1320 [created] 11491010f


fix GremlinGroovyScriptEngineFileSandboxTest resource loading


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

Branch: refs/heads/TINKERPOP-1320
Commit: 11491010f151d32ce80d7b9fdb88f17f57181fd8
Parents: 9c8c655
Author: Jason Plurad <pl...@us.ibm.com>
Authored: Wed Jun 15 08:49:17 2016 -0400
Committer: Jason Plurad <pl...@us.ibm.com>
Committed: Wed Jun 15 08:49:17 2016 -0400

----------------------------------------------------------------------
 .../gremlin/structure/io/gryo/GryoWriter.java          |  2 +-
 .../GremlinGroovyScriptEngineFileSandboxTest.java      | 13 ++++++++-----
 .../java/org/apache/tinkerpop/gremlin/TestHelper.java  | 10 +++++++++-
 3 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11491010/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
index b3a25fa..7ef7ec5 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoWriter.java
@@ -131,7 +131,7 @@ public final class GryoWriter implements GraphWriter {
     public void writeProperty(final OutputStream outputStream, final Property p) throws IOException {
         final Output output = new Output(outputStream);
         writeHeader(output);
-        kryo.writeObject(output, DetachedFactory.detach(p, true));
+        kryo.writeObject(output, DetachedFactory.detach(p));
         output.flush();
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11491010/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java
index 89aba64..3ee1306 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFileSandboxTest.java
@@ -27,7 +27,7 @@ import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.FileSandboxExtensio
 import org.codehaus.groovy.control.MultipleCompilationErrorsException;
 import org.hamcrest.MatcherAssert;
 import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.Before;
 import org.junit.Test;
 
 import javax.script.Bindings;
@@ -46,10 +46,13 @@ import static org.junit.Assert.fail;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class GremlinGroovyScriptEngineFileSandboxTest extends AbstractGremlinTest {
-    @BeforeClass
-    public static void init() throws Exception {
-        final File f = TestHelper.generateTempFileFromResource(GremlinGroovyScriptEngineFileSandboxTest.class, "sandbox.yaml", ".yaml");
-        System.setProperty(FileSandboxExtension.GREMLIN_SERVER_SANDBOX, f.getAbsolutePath());
+    @Before
+    public void setup() throws Exception {
+        super.setup();
+        if (System.getProperty(FileSandboxExtension.GREMLIN_SERVER_SANDBOX) == null) {
+            final File f = TestHelper.generateTempFileFromResource(graph.getClass(), GremlinGroovyScriptEngineFileSandboxTest.class, "sandbox.yaml", ".yaml");
+            System.setProperty(FileSandboxExtension.GREMLIN_SERVER_SANDBOX, f.getAbsolutePath());
+        }
     }
 
     @AfterClass

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/11491010/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
index f824ade..1432b7d 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/TestHelper.java
@@ -134,7 +134,15 @@ public final class TestHelper {
      * {@link TestHelper#makeTestDataPath} in a subdirectory called {@code temp/resources}.
      */
     public static File generateTempFileFromResource(final Class resourceClass, final String resourceName, final String extension) throws IOException {
-        final File temp = makeTestDataPath(resourceClass, "resources");
+        return generateTempFileFromResource(resourceClass, resourceClass, resourceName, extension);
+    }
+
+    /**
+     * Copies a file stored as part of a resource to the file system in the path returned from
+     * {@link TestHelper#makeTestDataPath} in a subdirectory called {@code temp/resources}.
+     */
+    public static File generateTempFileFromResource(final Class graphClass, final Class resourceClass, final String resourceName, final String extension) throws IOException {
+        final File temp = makeTestDataPath(graphClass, "resources");
         if (!temp.exists()) temp.mkdirs();
         final File tempFile = new File(temp, resourceName + extension);
         final FileOutputStream outputStream = new FileOutputStream(tempFile);