Package javax.script

Examples of javax.script.Invocable.invokeMethod()


        Invocable invocableEngine = (Invocable) pythonEngine;

        assertNull(pythonEngine.eval("def f(x): return abs(x)"));
        assertEquals(Integer.valueOf(5), invocableEngine.invokeFunction("f", Integer.valueOf(-5)));
        assertEquals("spam", invocableEngine.invokeMethod(new PyString("  spam  "), "strip"));
        assertEquals("spam", invocableEngine.invokeMethod("  spam  ", "strip"));
    }

    public void testInvokeFunctionNoSuchMethod() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        Invocable invocableEngine = (Invocable) manager.getEngineByName("python");
View Full Code Here


    public void testInvokeMethodNoSuchMethod() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        Invocable invocableEngine = (Invocable) manager.getEngineByName("python");

        try {
            invocableEngine.invokeMethod("eggs", "undefined");
            fail("Expected a NoSuchMethodException");
        } catch (NoSuchMethodException e) {
            assertEquals("undefined", e.getMessage());
        }
    }
View Full Code Here

    public void testInvokeMethodNoSuchArgs() throws ScriptException, NoSuchMethodException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine pythonEngine = manager.getEngineByName("python");
        Invocable invocableEngine = (Invocable) pythonEngine;

        Object newStringCapitalize = invocableEngine.invokeMethod("test", "capitalize");
        assertEquals(newStringCapitalize, "Test");
    }
   
    public void testPdb() {
        ScriptEngineManager manager = new ScriptEngineManager();
View Full Code Here

        } finally {
            Context.exit();
        }
        Object appReturn = null;
        try {
            appReturn = invocable.invokeMethod(exports, "app", jsgiRequest);
        } catch (NoSuchMethodException e) {
            throw new ScriptException(e);
        }
        if (!(appReturn instanceof Scriptable)) {
            throw new ScriptException("bad return from JSGI app");
View Full Code Here

            // As above, scripts must require('geoscript') first for this to
            // work with GeoScript objects.
            geoArgs = args;
        }
        try {
            results = invocable.invokeMethod(exports, "run", geoObject, geoArgs);
            results = GeoObject.jsToJava(results);
        } catch (NoSuchMethodException e) {
            throw new ScriptException(e);
        } finally {
            Context.exit();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.