Package javax.script

Examples of javax.script.ScriptEngineManager


        assertEquals("xml", engine.eval("typeof xml", bindings));
        assertEquals("petra", engine.eval("xml.b.toString()", bindings));
    }

    public void setUp() {
        ScriptEngineManager manager = new ScriptEngineManager();
        // The default Rhino implementation provided by Java 1.6 does not support E4X,
        // so use the unique name supported by the 1.6R7 version factory.
        engine = manager.getEngineByName("rhino-nonjdk");
        xmlHelper = XMLHelper.getArgHelper(engine);
    }
View Full Code Here


    }

    protected void setUp() {
        // The default Rhino implementation provided by Java 1.6 does not support E4X,
        // so use the unique name supported by the 1.6R7 version factory.
        engine = new ScriptEngineManager().getEngineByName("rhino-nonjdk");
        assertNotNull("Could not load js engine",engine);
        xmlHelper = XMLHelper.getArgHelper(engine);
    }
View Full Code Here


public class JavaScriptTestcase extends TestCase {

    public void testEval() throws ScriptException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByExtension("js");
        assertNotNull("engine should not be null", engine);
        assertTrue(((Boolean)engine.eval("true;")).booleanValue());
        assertFalse(((Boolean)engine.eval("false;")).booleanValue());
    }
View Full Code Here

        assertTrue(((Boolean)engine.eval("true;")).booleanValue());
        assertFalse(((Boolean)engine.eval("false;")).booleanValue());
    }

    public void testInvokeFunction() throws ScriptException, NoSuchMethodException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByExtension("js");
        assertNotNull("engine should not be null", engine);
        engine.eval("function hello(s) { return 'Hello ' + s; }" );
        assertTrue(engine instanceof Invocable);
        Invocable invocableScript = (Invocable) engine;
        assertEquals("Hello petra", invocableScript.invokeFunction("hello", new Object[]{"petra"}));
View Full Code Here

        Invocable invocableScript = (Invocable) engine;
        assertEquals("Hello petra", invocableScript.invokeFunction("hello", new Object[]{"petra"}));
    }

    public void testInvokeMethod() throws ScriptException, NoSuchMethodException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByExtension("js");
        assertNotNull("engine should not be null", engine);
        engine.eval("function hello(s) { return 'Hello ' + s; }" );
        assertTrue(engine instanceof Invocable);
        Invocable invocableScript = (Invocable) engine;
View Full Code Here

//    }

    public void testE4X() throws ScriptException, XMLStreamException, FactoryConfigurationError {
        // The default Rhino implementation provided by Java 1.6 does not support E4X,
        // so use the unique name supported by the 1.6R7 version factory.
        ScriptEngine engine = new ScriptEngineManager().getEngineByName("rhino-nonjdk");
        assertNotNull("engine should not be null",engine);
        XMLHelper convertor = XMLHelper.getArgHelper(engine);
        Object o = convertor.toScriptXML(createOMElement("<a><b>petra</b></a>"));
        OMElement om = convertor.toOMElement(o);
        assertEquals("<a><b>petra</b></a>", om.toString());
View Full Code Here

* Simple hello testcase to verify basic Jython functionality
*/
public class HelloTestCase extends TestCase {

    public void testInvokeFunction() throws ScriptException, NoSuchMethodException {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByExtension("py");
        assertNotNull("engine should not be null", engine);
        engine.eval("def hello(name):\n return 'Hello ' + name");
        assertTrue("engine should be invocable",engine instanceof Invocable);
        Invocable invocableScript = (Invocable) engine;
        assertEquals("Hello Monty", invocableScript.invokeFunction("hello", new Object[] { "Monty" }));
View Full Code Here

    protected boolean matches(Exchange exchange, Object scriptValue) {
        return ObjectConverter.toBool(scriptValue);
    }

    protected ScriptEngine createScriptEngine() {
        ScriptEngineManager manager = new ScriptEngineManager();
        try {
            engine = manager.getEngineByName(scriptEngineName);
        } catch (NoClassDefFoundError ex) {
            LOG.error("Cannot load the scriptEngine for " + scriptEngineName + ", the exception is " + ex
                      + ", please ensure correct JARs is provided on classpath.");
        }
        if (engine == null) {
View Full Code Here

        mScriptContent = scriptContent;
        mFileName = fileName;
    }
   
    public boolean check() {
        ScriptEngineManager manager = new ScriptEngineManager();
        ScriptEngine engine = manager.getEngineByName("python");
        Compilable compilable = (Compilable) engine;

        try {
      compilable.compile(mScriptContent);
          checkStepsDescriptions();
View Full Code Here

/**
* @version $Revision: 630591 $
*/
public class Jsr223Test extends TestCase {
    public void testLanguageNames() throws Exception {
        ScriptEngineManager manager = new ScriptEngineManager();
        for (ScriptEngineFactory factory : manager.getEngineFactories()) {
            System.out.println("Factory: " + factory.getNames() + " " + factory.getEngineName());
        }
    }
View Full Code Here

TOP

Related Classes of javax.script.ScriptEngineManager

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.