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/07/15 23:21:26 UTC

[18/46] incubator-tinkerpop git commit: Add test for multiple extensions on TypeChecking

Add test for multiple extensions on TypeChecking


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

Branch: refs/heads/master
Commit: f93330870fad731c9a4af4eb06e0bb27c78171f3
Parents: 8665a0f
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 9 09:51:22 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 9 09:51:22 2015 -0400

----------------------------------------------------------------------
 ...remlinGroovyScriptEngineTypeCheckedTest.java | 26 ++++++++++++++++++++
 1 file changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/f9333087/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
index 0a7639e..b298750 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java
@@ -63,4 +63,30 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
             assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
         }
     }
+
+    @Test
+    public void shouldTypeCheckWithMultipleExtension() throws Exception {
+        // with no type checking extension this should pass
+        final TypeCheckedCustomizerProvider providerNoExtension = new TypeCheckedCustomizerProvider();
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension)) {
+            assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));
+            assertEquals(1l, scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count"));
+        }
+
+        final TypeCheckedCustomizerProvider providerWithExtension = new TypeCheckedCustomizerProvider(
+                "PreventColorUsageExtension.groovy,PreventCountDownLatchUsageExtension.groovy");
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
+            scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+        }
+
+        try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension)) {
+            scriptEngine.eval("def c = new java.util.concurrent.CountDownLatch(1); c.count");
+            fail("Should have failed type checking");
+        } catch (ScriptException se) {
+            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+        }
+    }
 }