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 2018/09/04 13:32:23 UTC
tinkerpop git commit: Added a different sort of assert for
scriptconfig testing CTR
Repository: tinkerpop
Updated Branches:
refs/heads/master df928cde0 -> a215a52ba
Added a different sort of assert for scriptconfig testing CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/a215a52b
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/a215a52b
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/a215a52b
Branch: refs/heads/master
Commit: a215a52ba020b2915bff2c446869cb7976101597
Parents: df928cd
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Sep 4 09:31:46 2018 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Sep 4 09:31:46 2018 -0400
----------------------------------------------------------------------
.../gremlin/groovy/jsr223/BaseScriptForTesting.java | 6 ++++++
.../jsr223/GremlinGroovyScriptEngineConfigTest.java | 12 ++++++++++++
2 files changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a215a52b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/BaseScriptForTesting.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/BaseScriptForTesting.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/BaseScriptForTesting.java
index 98c8e8c..0ebc32e 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/BaseScriptForTesting.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/BaseScriptForTesting.java
@@ -20,6 +20,8 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223;
import groovy.lang.Script;
+import java.util.Map;
+
/**
* @author Stephen Mallette (http://stephen.genoprime.com)
*/
@@ -27,4 +29,8 @@ public abstract class BaseScriptForTesting extends Script {
public String hello(final String name) {
return "hello, " + name;
}
+
+ public String typeOf(final String name) {
+ return ((Map<String,Object>) getBinding().getVariable("registry")).get(name).getClass().getSimpleName();
+ }
}
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/a215a52b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
index 8414274..11d0d1f 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineConfigTest.java
@@ -20,7 +20,11 @@ package org.apache.tinkerpop.gremlin.groovy.jsr223;
import org.junit.Test;
+import javax.script.Bindings;
import javax.script.ScriptEngine;
+import javax.script.SimpleBindings;
+
+import java.util.HashMap;
import static org.junit.Assert.assertEquals;
@@ -35,5 +39,13 @@ public class GremlinGroovyScriptEngineConfigTest {
new ConfigurationGroovyCustomizer("ScriptBaseClass", BaseScriptForTesting.class.getName()));
assertEquals("hello, stephen", engine.eval("hello('stephen')"));
+
+ final Bindings b = new SimpleBindings();
+ b.put("registry", new HashMap<String,Object>(){{
+ put("xxx", String.class.getSimpleName());
+ }});
+
+ assertEquals(String.class.getSimpleName(), engine.eval("typeOf('xxx')", b));
}
+
}