@Test
    public void shouldInterruptWhile() throws Exception {
        final Map<String, Map<String,Object>> config = new HashMap<>();
        final Map<String, Object> scriptPluginConfig = new HashMap<>();
        scriptPluginConfig.put("files", Collections.singletonList(PATHS.get("GremlinExecutorInit.groovy")));
        config.put(ScriptFileGremlinPlugin.class.getName(), scriptPluginConfig);

        final Map<String, Object> groovyPluginConfig = new HashMap<>();
        groovyPluginConfig.put("enableThreadInterrupt", true);
        config.put(GroovyCompilerGremlinPlugin.class.getName(), groovyPluginConfig);

        final GremlinExecutor gremlinExecutor = GremlinExecutor.build()
                .addPlugins("gremlin-groovy", config)
                .create();
        final AtomicBoolean asserted = new AtomicBoolean(false);

        final Thread t = new Thread(() -> {
            try {
                gremlinExecutor.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 10000) {}").get();
            } catch (Exception se) {
                asserted.set(se instanceof InterruptedException);
            }
        });

        t.start();
        Thread.sleep(100);
        t.interrupt();
        while(t.isAlive()) {}

        assertTrue(asserted.get());
    }
Temporary "useless" plugin definition to force GremlinExecutor to use GremlinScriptEngineManager - will be
removed when the old functionality of ScriptEngines is removed.
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/engine/GremlinExecutorTest.java