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/07/14 20:51:37 UTC

tinkerpop git commit: Made some adjustments to interfaces for the GremlinScriptEngine.

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1278 eb91f42db -> 6399ec494


Made some adjustments to interfaces for the GremlinScriptEngine.


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

Branch: refs/heads/TINKERPOP-1278
Commit: 6399ec4943f7113bcf33f4572d47359629f5eb2a
Parents: eb91f42
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Jul 14 16:21:30 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Jul 14 16:51:27 2016 -0400

----------------------------------------------------------------------
 .../gremlin/jsr223/CoreGremlinModule.java       | 45 +++++++++++++++
 .../gremlin/jsr223/CustomizerManager.java       | 34 -----------
 .../DefaultGremlinScriptEngineManager.java      | 25 +++++++-
 .../tinkerpop/gremlin/jsr223/GremlinModule.java | 61 ++++++++++++++++++++
 .../jsr223/GremlinScriptEngineFactory.java      |  4 +-
 .../jsr223/GremlinScriptEngineManager.java      | 14 ++++-
 .../gremlin/groovy/engine/ScriptEngines.java    |  1 -
 .../GremlinGroovyScriptEngineFactory.java       | 12 ++--
 .../GremlinJythonScriptEngineFactory.java       |  6 +-
 .../jsr223/GremlinEnabledScriptEngineTest.java  | 57 ++++++++++++++++++
 .../jsr223/GremlinScriptEngineSuite.java        |  1 +
 11 files changed, 211 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
new file mode 100644
index 0000000..dfe9f93
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CoreGremlinModule.java
@@ -0,0 +1,45 @@
+/*
+ * 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.jsr223;
+
+import java.util.Optional;
+
+/**
+ * This module is required for a {@code ScriptEngine} to be Gremlin-enabled.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class CoreGremlinModule implements GremlinModule {
+
+    private static final Optional<Customizer[]> CUSTOMIZERS = Optional.of(new Customizer[] { ImportCustomizer.GREMLIN_CORE });
+
+    public static final CoreGremlinModule INSTANCE = new CoreGremlinModule();
+
+    private CoreGremlinModule() {}
+
+    @Override
+    public Optional<Customizer[]> getCustomizers(final String scriptEngineName) {
+        return CUSTOMIZERS;
+    }
+
+    @Override
+    public String getName() {
+        return "tinkerpop.core";
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CustomizerManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CustomizerManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CustomizerManager.java
deleted file mode 100644
index bcaeee4..0000000
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/CustomizerManager.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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.jsr223;
-
-import java.util.Optional;
-
-/**
- * Holds the list of {@link Customizer} implementations that will be supplied to the {@link GremlinScriptEngine} when
- * it is created.
- *
- * @author Stephen Mallette (http://stephen.genoprime.com)
- */
-public interface CustomizerManager {
-    /**
-     * Gets the list of {@link Customizer} implementations to assign to a new {@link GremlinScriptEngine}.
-     */
-    public Optional<Customizer[]> getCustomizers();
-}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
index 02dac59..25a0612 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/DefaultGremlinScriptEngineManager.java
@@ -34,6 +34,7 @@ import java.util.Optional;
 import java.util.ServiceConfigurationError;
 import java.util.ServiceLoader;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * The {@code ScriptEngineManager} implements a discovery, instantiation and configuration mechanism for
@@ -61,7 +62,7 @@ import java.util.stream.Collectors;
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
-public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineManager, CustomizerManager {
+public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineManager {
 
     private static final boolean DEBUG = false;
 
@@ -91,6 +92,12 @@ public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineMan
     private Bindings globalScope = new ConcurrentBindings();
 
     /**
+     * List of extensions for the {@link GremlinScriptEngineManager} which will be used to supply
+     * {@link Customizer} instances to {@link GremlinScriptEngineFactory} that are instantiated.
+     */
+    private List<GremlinModule> modules = new ArrayList<>();
+
+    /**
      * The effect of calling this constructor is the same as calling
      * {@code DefaultGremlinScriptEngineManager(Thread.currentThread().getContextClassLoader())}.
      */
@@ -110,8 +117,17 @@ public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineMan
     }
 
     @Override
-    public Optional<Customizer[]> getCustomizers() {
-        return Optional.of(new Customizer[] { ImportCustomizer.GREMLIN_CORE });
+    public List<Customizer> getCustomizers(final String scriptEngineName) {
+        return modules.stream().flatMap(module -> {
+            final Optional<Customizer[]> moduleCustomizers = module.getCustomizers(scriptEngineName);
+            return Stream.of(moduleCustomizers.orElse(new Customizer[0]));
+        }).collect(Collectors.toList());
+    }
+
+    @Override
+    public void addModule(final GremlinModule module) {
+        // TODO: should modules be a set based on "name" to ensure uniqueness? not sure what bad stuff can happen with dupes
+        if (module != null) modules.add(module);
     }
 
     /**
@@ -361,6 +377,9 @@ public class DefaultGremlinScriptEngineManager implements GremlinScriptEngineMan
     }
 
     private void initEngines(final ClassLoader loader) {
+        // always need this module for a scriptengine to be "Gremlin-enabled"
+        modules.add(CoreGremlinModule.INSTANCE);
+
         Iterator<GremlinScriptEngineFactory> itty;
         try {
             final ServiceLoader<GremlinScriptEngineFactory> sl = AccessController.doPrivileged(

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java
new file mode 100644
index 0000000..20e9ff8
--- /dev/null
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinModule.java
@@ -0,0 +1,61 @@
+/*
+ * 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.jsr223;
+
+import java.util.Optional;
+
+/**
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public interface GremlinModule {
+    /**
+     * The name of the module.  This name should be unique (use a namespaced approach) as naming clashes will
+     * prevent proper module operations. Modules developed by TinkerPop will be prefixed with "tinkerpop."
+     * For example, TinkerPop's implementation of Giraph would be named "tinkerpop.giraph".  If Facebook were
+     * to do their own implementation the implementation might be called "facebook.giraph".
+     */
+    public String getName();
+
+    /**
+     * Some modules may require a restart of the plugin host for the classloader to pick up the features.  This is
+     * typically true of modules that rely on {@code Class.forName()} to dynamically instantiate classes from the
+     * root classloader (e.g. JDBC drivers that instantiate via @{code DriverManager}).
+     */
+    public default boolean requireRestart() {
+        return false;
+    }
+
+    /**
+     * Gets the list of all {@link Customizer} implementations to assign to a new {@link GremlinScriptEngine}. This is
+     * the same as doing {@code getCustomizers(null)}.
+     */
+    public default Optional<Customizer[]> getCustomizers(){
+        return getCustomizers(null);
+    }
+
+    /**
+     * Gets the list of {@link Customizer} implementations to assign to a new {@link GremlinScriptEngine}. The
+     * implementation should filter the returned {@code Customizers} according to the supplied name of the
+     * Gremlin-enabled {@code ScriptEngine}. By providing a filter, {@code GremlinModule} developers can have the
+     * ability to target specific {@code ScriptEngines}.
+     *
+     * @param scriptEngineName The name of the {@code ScriptEngine} or null to get all the available {@code Customizers}
+     */
+    public Optional<Customizer[]> getCustomizers(final String scriptEngineName);
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineFactory.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineFactory.java
index 9b4919d..b0bdeb6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineFactory.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineFactory.java
@@ -22,7 +22,7 @@ import javax.script.ScriptEngineFactory;
 
 /**
  * Creates a {@link GremlinScriptEngine} implementation and supplies to it any {@link Customizer} implementations to
- * it that are available on the {@link CustomizerManager}.
+ * it that are available on the {@link GremlinScriptEngineManager}.
  *
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
@@ -40,5 +40,5 @@ public interface GremlinScriptEngineFactory extends ScriptEngineFactory {
      * The factory should take the {@link Customizer} implementations made available by the manager and supply them
      * to the {@link GremlinScriptEngine} implementation it creates.
      */
-    void setCustomizerManager(final CustomizerManager manager);
+    void setCustomizerManager(final GremlinScriptEngineManager manager);
 }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java
index 475a0fb..270d136 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineManager.java
@@ -37,7 +37,7 @@ import java.util.List;
  * {@code javax.script} packages, but adds some additional features that are specific to Gremlin and TinkerPop.
  * Unfortunately, it's not easily possible to extend {@code ScriptEngineManager} directly as there certain behaviors
  * don't appear to be be straightforward to implement and member variables are all private. It is important to note
- * that this class is designed to provide support for "Gremlin-enabled" {@code ScriptEngine} instances (i.e. those
+ * that this interface is designed to provide support for "Gremlin-enabled" {@code ScriptEngine} instances (i.e. those
  * that extend from {@link GremlinScriptEngine}) and is not meant to manage just any {@code ScriptEngine} instance
  * that may be on the path.
  *
@@ -96,6 +96,7 @@ public interface GremlinScriptEngineManager {
      * @throws NullPointerException if extension is {@code null}.
      */
     public GremlinScriptEngine getEngineByExtension(final String extension);
+
     /**
      * Look up and create a {@link GremlinScriptEngine} for a given mime type.  The algorithm used by
      * {@link #getEngineByName(String)} is used except that the search starts by looking for a
@@ -107,6 +108,7 @@ public interface GremlinScriptEngineManager {
      * @throws NullPointerException if mime-type is {@code null}.
      */
     public GremlinScriptEngine getEngineByMimeType(final String mimeType);
+
     /**
      * Returns a list whose elements are instances of all the {@link GremlinScriptEngineFactory} classes
      * found by the discovery mechanism.
@@ -116,6 +118,11 @@ public interface GremlinScriptEngineManager {
     public List<GremlinScriptEngineFactory> getEngineFactories();
 
     /**
+     * Add {@link GremlinModule} instances to customize newly created {@link GremlinScriptEngine} instances.
+     */
+    public void addModule(final GremlinModule module);
+
+    /**
      * Registers a {@link GremlinScriptEngineFactory} to handle a language name.  Overrides any such association found
      * using the discovery mechanism.
      *
@@ -144,4 +151,9 @@ public interface GremlinScriptEngineManager {
      * @throws NullPointerException if any of the parameters is null.
      */
     public void registerEngineExtension(final String extension, final GremlinScriptEngineFactory factory);
+
+    /**
+     * Get the list of {@link Customizer} instances filtered by the {@code scriptEngineName}.
+     */
+    public List<Customizer> getCustomizers(final String scriptEngineName);
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
index 7b00df3..ee3de39 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/engine/ScriptEngines.java
@@ -36,7 +36,6 @@ import javax.script.Compilable;
 import javax.script.CompiledScript;
 import javax.script.ScriptContext;
 import javax.script.ScriptEngine;
-import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 import javax.script.SimpleBindings;
 import java.io.Reader;

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFactory.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFactory.java
index b59beb2..8e5defb 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFactory.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineFactory.java
@@ -18,9 +18,10 @@
  */
 package org.apache.tinkerpop.gremlin.groovy.jsr223;
 
-import org.apache.tinkerpop.gremlin.jsr223.CustomizerManager;
+import org.apache.tinkerpop.gremlin.jsr223.Customizer;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager;
 import org.apache.tinkerpop.gremlin.util.Gremlin;
 
 import javax.script.ScriptEngine;
@@ -37,10 +38,10 @@ public class GremlinGroovyScriptEngineFactory implements GremlinScriptEngineFact
     private static final String PLAIN = "plain";
     private static final List<String> EXTENSIONS = Collections.singletonList("groovy");
 
-    private CustomizerManager manager;
+    private GremlinScriptEngineManager manager;
 
     @Override
-    public void setCustomizerManager(final CustomizerManager manager) {
+    public void setCustomizerManager(final GremlinScriptEngineManager manager) {
         this.manager = manager;
     }
 
@@ -118,7 +119,8 @@ public class GremlinGroovyScriptEngineFactory implements GremlinScriptEngineFact
 
     @Override
     public GremlinScriptEngine getScriptEngine() {
-        return manager.getCustomizers().isPresent() ?
-                new GremlinGroovyScriptEngine(manager.getCustomizers().get()) : new GremlinGroovyScriptEngine();
+        final List<Customizer> customizers =  manager.getCustomizers(ENGINE_NAME);
+        return (customizers.isEmpty()) ? new GremlinGroovyScriptEngine() :
+                new GremlinGroovyScriptEngine(customizers.toArray(new Customizer[customizers.size()]));
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
----------------------------------------------------------------------
diff --git a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
index 0554063..8ecbcd4 100644
--- a/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
+++ b/gremlin-python/src/main/java/org/apache/tinkerpop/gremlin/python/jsr223/GremlinJythonScriptEngineFactory.java
@@ -19,9 +19,9 @@
 
 package org.apache.tinkerpop.gremlin.python.jsr223;
 
-import org.apache.tinkerpop.gremlin.jsr223.CustomizerManager;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngine;
 import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineFactory;
+import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineManager;
 import org.apache.tinkerpop.gremlin.util.Gremlin;
 import org.python.jsr223.PyScriptEngineFactory;
 
@@ -39,10 +39,10 @@ public class GremlinJythonScriptEngineFactory extends PyScriptEngineFactory impl
     private static final String PLAIN = "plain";
     private static final List<String> EXTENSIONS = Collections.singletonList("py");
 
-    private CustomizerManager manager;
+    private GremlinScriptEngineManager manager;
 
     @Override
-    public void setCustomizerManager(final CustomizerManager manager) {
+    public void setCustomizerManager(final GremlinScriptEngineManager manager) {
         this.manager = manager;
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
new file mode 100644
index 0000000..76e8f55
--- /dev/null
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinEnabledScriptEngineTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.jsr223;
+
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Graph;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.junit.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.apache.tinkerpop.gremlin.jsr223.GremlinScriptEngineSuite.ENGINE_TO_TEST;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * This is an important test case in that it validates that core features of {@code ScriptEngine} instances that claim
+ * to be "Gremlin-enabled" work in the expected fashion.
+ *
+ * @author Stephen Mallette (http://stephen.genoprime.com)
+ */
+public class GremlinEnabledScriptEngineTest {
+    private static final GremlinScriptEngineManager manager = new DefaultGremlinScriptEngineManager();
+
+    @Test
+    public void shouldGetEngineByName() throws Exception {
+        final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST);
+        assertEquals(ENGINE_TO_TEST, scriptEngine.getFactory().getEngineName());
+    }
+
+    @Test
+    public void shouldHaveCoreImportsInPlace() throws Exception {
+        // TODO: delete this test - other tests will give us confidence on such things as we get further along
+        final GremlinScriptEngine scriptEngine = manager.getEngineByName(ENGINE_TO_TEST);
+        final List<Class> classesToCheck = Arrays.asList(Vertex.class, Edge.class, Graph.class, VertexProperty.class);
+        for (Class clazz : classesToCheck) {
+            assertEquals(clazz, scriptEngine.eval(clazz.getSimpleName()));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6399ec49/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineSuite.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineSuite.java
index 4867909..8ccde91 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineSuite.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/jsr223/GremlinScriptEngineSuite.java
@@ -30,6 +30,7 @@ public class GremlinScriptEngineSuite extends Suite {
 
     private static final Class<?>[] allTests = new Class<?>[]{
             CachedGremlinScriptEngineManagerTest.class,
+            GremlinEnabledScriptEngineTest.class,
             ScriptEngineLambdaTest.class };
 
     public GremlinScriptEngineSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {