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 2016/01/26 21:47:05 UTC

incubator-tinkerpop git commit: Alter asserts in some commits around type checking ScriptEngine tests.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master 3af6ef12e -> cebe3c917


Alter asserts in some commits around type checking ScriptEngine tests.


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

Branch: refs/heads/master
Commit: cebe3c9179619cebe4cb06838a12bd60959dd18a
Parents: 3af6ef1
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jan 26 15:46:33 2016 -0500
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jan 26 15:46:33 2016 -0500

----------------------------------------------------------------------
 .../jsr223/GremlinGroovyScriptEngineCompileStaticTest.java  | 9 ++++++---
 .../jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java    | 9 ++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/cebe3c91/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
index 1f46f58..3ba3e0b 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineCompileStaticTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.groovy.jsr223;
 
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider;
 import org.codehaus.groovy.control.MultipleCompilationErrorsException;
 import org.junit.Test;
@@ -37,15 +38,17 @@ public class GremlinGroovyScriptEngineCompileStaticTest {
     public void shouldCompileStatic() throws Exception {
         // with no type checking this should pass
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
-            assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).red"));
+            assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
         }
 
         final CompileStaticCustomizerProvider provider = new CompileStaticCustomizerProvider();
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) {
-            scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).red");
+            scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
             fail("Should have failed type checking");
         } catch (ScriptException se) {
-            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            final Throwable root = ExceptionUtils.getRootCause(se);
+            assertEquals(MultipleCompilationErrorsException.class, root.getClass());
+            assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists."));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/cebe3c91/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 d1a0dca..a9062a8 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
@@ -18,6 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.groovy.jsr223;
 
+import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.CompileStaticCustomizerProvider;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.customizer.TypeCheckedCustomizerProvider;
 import org.codehaus.groovy.control.MultipleCompilationErrorsException;
@@ -38,15 +39,17 @@ public class GremlinGroovyScriptEngineTypeCheckedTest {
     public void shouldTypeCheck() throws Exception {
         // with no type checking this should pass
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine()) {
-            assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).red"));
+            assertEquals(255, scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()"));
         }
 
         final TypeCheckedCustomizerProvider provider = new TypeCheckedCustomizerProvider();
         try (GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(provider)) {
-            scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).red");
+            scriptEngine.eval("((Object) new java.awt.Color(255, 255, 255)).getRed()");
             fail("Should have failed type checking");
         } catch (ScriptException se) {
-            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
+            final Throwable root = ExceptionUtils.getRootCause(se);
+            assertEquals(MultipleCompilationErrorsException.class, root.getClass());
+            assertThat(se.getMessage(), containsString("[Static type checking] - Cannot find matching method java.lang.Object#getRed(). Please check if the declared type is right and if the method exists."));
         }
     }