@Test
    public void shouldTypeCheckWithExtension() throws Exception {
        // with no type checking extension this should pass
        final TypeCheckedGroovyCustomizer providerNoExtension = new TypeCheckedGroovyCustomizer();
        GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(providerNoExtension);
        assertEquals(255, scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red"));

        final TypeCheckedGroovyCustomizer providerWithExtension = new TypeCheckedGroovyCustomizer(
                PrecompiledExtensions.PreventColorUsageExtension.class.getName());
        scriptEngine = new GremlinGroovyScriptEngine(providerWithExtension);
        try {
            scriptEngine.eval("def c = new java.awt.Color(255, 255, 255); c.red");
            fail("Should have failed type checking");
        } catch (ScriptException se) {
            assertEquals(MultipleCompilationErrorsException.class, se.getCause().getClass());
            assertThat(se.getMessage(), containsString("Method call is not allowed!"));
        }
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTypeCheckedTest.java