@Test
    public void shouldContinueToEvalScriptsEvenWithTimedInterrupt() throws Exception {
        final ScriptEngine engine = new GremlinGroovyScriptEngine(
                new TimedInterruptGroovyCustomizer(1000));

        for (int ix = 0; ix < 5; ix++) {
            try {
                // this script takes 1000 ms longer than the interruptionTimeout
                engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 2000) {}");
                fail("This should have timed out");
            } catch (ScriptException se) {
                assertEquals(org.apache.tinkerpop.gremlin.groovy.jsr223.TimedInterruptTimeoutException.class, se.getCause().getCause().getClass());
            }

            // this script takes 500 ms less than the interruptionTimeout
            assertEquals("test", engine.eval("s = System.currentTimeMillis();\nwhile((System.currentTimeMillis() - s) < 500) {};'test'"));
        }

        assertEquals(2, engine.eval("1+1"));
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTimedInterruptTest.java