Package com.tinkerpop.gremlin.groovy

Examples of com.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider


    private Optional<SecurityCustomizerProvider> securityProvider;

    private final Set<Artifact> artifactsToUse = new HashSet<>();

    public GremlinGroovyScriptEngine() {
        this(new DefaultImportCustomizerProvider());
    }
View Full Code Here


            fail("Should have thrown an exception because no imports were supplied");
        } catch (Exception se) {
            assertTrue(se instanceof ScriptException);
        }

        final ScriptEngine engineWithImports = new GremlinGroovyScriptEngine(new DefaultImportCustomizerProvider());
        engineWithImports.put("g", g);
        assertEquals(Vertex.class.getName(), engineWithImports.eval("Vertex.class.getName()"));
        assertEquals(2l, engineWithImports.eval("g.V().has('age',Compare.gt,30).count().next()"));
        assertEquals(Direction.IN, engineWithImports.eval("Direction.IN"));
        assertEquals(Direction.OUT, engineWithImports.eval("Direction.OUT"));
View Full Code Here


    @Test
    @LoadGraphWith(LoadGraphWith.GraphData.CLASSIC)
    public void shouldLoadStandardImportsAndThenAddToThem() throws Exception {
        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine(new DefaultImportCustomizerProvider());
        engine.put("g", g);
        assertEquals(Vertex.class.getName(), engine.eval("Vertex.class.getName()"));
        assertEquals(2l, engine.eval("g.V().has('age',Compare.gt,30).count().next()"));
        assertEquals(Direction.IN, engine.eval("Direction.IN"));
        assertEquals(Direction.OUT, engine.eval("Direction.OUT"));
View Full Code Here

    @Test
    public void shouldSecureAll() throws Exception {
        GroovyInterceptor.getApplicableInterceptors().forEach(GroovyInterceptor::unregister);
        final SecurityCustomizerProvider provider = new SecurityCustomizerProvider(new DenyAll());
        final GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(
                new DefaultImportCustomizerProvider(), provider);
        try {
            scriptEngine.eval("g = new java.awt.Color(255, 255, 255)");
            fail("Should have failed security");
        } catch (ScriptException se) {
            assertEquals(SecurityException.class, se.getCause().getCause().getClass());
View Full Code Here

    @Test
    public void shouldSecureSome() throws Exception {
        GroovyInterceptor.getApplicableInterceptors().forEach(GroovyInterceptor::unregister);
        final SecurityCustomizerProvider provider = new SecurityCustomizerProvider(new AllowSome());
        final GremlinGroovyScriptEngine scriptEngine = new GremlinGroovyScriptEngine(
                new DefaultImportCustomizerProvider(), provider);
        try {
            scriptEngine.eval("g = 'new java.awt.Color(255, 255, 255)'");
            fail("Should have failed security");
        } catch (ScriptException se) {
            assertEquals(SecurityException.class, se.getCause().getCause().getClass());
View Full Code Here

                    securityCustomizerProvider = null;
                }
            }

            return Optional.of((ScriptEngine) new GremlinGroovyScriptEngine(
                    new DefaultImportCustomizerProvider(imports, staticImports), securityCustomizerProvider));
        } else {
            final ScriptEngineManager manager = new ScriptEngineManager();
            return Optional.ofNullable(manager.getEngineByName(language));
        }
    }
View Full Code Here

        SugarLoader.load();
    }

    @Test
    public void shouldReturnDefaultImports() {
        final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider();
        assertImportsInProvider(provider);
    }
View Full Code Here

    @Test
    public void shouldReturnWithExtraStaticImports() {
        final Set<String> statics = new HashSet<>();
        statics.add("com.test.This.*");
        statics.add("com.test.That.OTHER");
        final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(new HashSet<>(), statics);
        assertImportsInProvider(provider);
    }
View Full Code Here

    @Test
    public void shouldReturnWithExtraImports() {
        final Set<String> imports = new HashSet<>();
        imports.add("com.test.that.*");
        imports.add("com.test.that.That");
        final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(imports, new HashSet<>());
        assertImportsInProvider(provider);
    }
View Full Code Here

        final Set<String> statics = new HashSet<>();
        statics.add("com.test.This.*");
        statics.add("com.test.That.OTHER");

        final DefaultImportCustomizerProvider provider = new DefaultImportCustomizerProvider(imports, statics);
        assertImportsInProvider(provider);
    }
View Full Code Here

TOP

Related Classes of com.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.