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/06/22 16:05:07 UTC

[2/4] tinkerpop git commit: added GremlinJythonScriptEngineFactory to META-INF and created a test case stub.

added GremlinJythonScriptEngineFactory to META-INF and created a test case stub.


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

Branch: refs/heads/TINKERPOP-1278
Commit: 0ecac548e9ef657d8f17aecc584b5499e6016823
Parents: 7d2a1bf
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Jun 22 10:00:55 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Jun 22 10:00:55 2016 -0600

----------------------------------------------------------------------
 .../jsr223/GremlinJythonScriptEngine.java       |  2 +-
 .../jsr223/GremlinJythonScriptEngineTest.java   | 50 ++++++++++++++++++++
 .../services/javax.script.ScriptEngineFactory   |  1 +
 3 files changed, 52 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0ecac548/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
index f58101c..090fa5c 100644
--- a/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
+++ b/gremlin-variant/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngine.java
@@ -38,7 +38,7 @@ import java.util.Arrays;
  */
 public class GremlinJythonScriptEngine implements ScriptEngine {
 
-    final PyScriptEngine pyScriptEngine;
+    private final PyScriptEngine pyScriptEngine;
 
     public GremlinJythonScriptEngine() {
         this.pyScriptEngine = (PyScriptEngine) new PyScriptEngineFactory().getScriptEngine();

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0ecac548/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
new file mode 100644
index 0000000..7582877
--- /dev/null
+++ b/gremlin-variant/src/test/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineTest.java
@@ -0,0 +1,50 @@
+/*
+ *  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.python.jsr223;
+
+import org.junit.Test;
+
+import javax.script.ScriptEngine;
+import javax.script.ScriptEngineManager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Marko A. Rodriguez (http://markorodriguez.com)
+ */
+public class GremlinJythonScriptEngineTest {
+
+    @Test
+    public void shouldGetEngineByName() throws Exception {
+        final ScriptEngine engine = new ScriptEngineManager().getEngineByName("gremlin-jython");
+        assertNotNull(engine);
+        assertTrue(engine instanceof GremlinJythonScriptEngine);
+        assertTrue(engine.eval("Graph") instanceof Class);
+        assertEquals(3, engine.eval("1+2"));
+    }
+
+    @Test
+    public void shouldHaveStandardImports() throws Exception {
+        final ScriptEngine engine = new ScriptEngineManager().getEngineByName("gremlin-jython");
+        assertTrue(engine.eval("Graph") instanceof Class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0ecac548/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
----------------------------------------------------------------------
diff --git a/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory b/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
index 24c8a75..910facc 100644
--- a/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
+++ b/gremlin-variant/src/test/resources/META-INF/services/javax.script.ScriptEngineFactory
@@ -1 +1,2 @@
 org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineFactory
+org.apache.tinkerpop.gremlin.python.jsr223.GremlinJythonScriptEngineFactory
\ No newline at end of file