Examples of RhinoScript


Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

        Object x = ri.invoke("echo", new Object[] { "petra" }, null);
        assertEquals("petra", x);
    }

    public void testCopy() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        Object x = ri.invoke("echo", new Object[] { "petra" }, null);
        assertEquals("petra", x);

        ri = ri.copy();
        x = ri.invoke("echo", new Object[] { "sue" }, null);
        assertEquals("sue", x);

    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

        assertEquals("sue", x);

    }

    public void testContexts1() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        Map<String, Object> contexts = new HashMap<String, Object>();
        contexts.put("a", "petra");
        Object x = ri.invoke("getA", null, contexts);
        assertEquals("petra", x);
    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

    /**
     * Tests context not accessable across invocations
     */
    public void testContexts2() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        Map<String, Object> contexts = new HashMap<String, Object>();
        contexts.put("a", "petra");
        Object x = ri.invoke("getA", null, contexts);
        assertEquals("petra", x);

        try {
            x = ri.invoke("getA", null, null);
            assertTrue("expected ReferenceError", false);
        } catch (EcmaError e) {
            assertEquals("ReferenceError", e.getName());
        }
    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

    /**
     * Tests shared scope is accessable across invocations
     */
    public void testScopes1() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        ri.invoke("setGlobalVarY", new Object[] { "petra" }, null);

        Object x = ri.invoke("getGlobalVarY", null, null);
        assertEquals("petra", x);
    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

    /**
     * Tests local vars are NOT accessable across invocations
     */
    public void testScopes2() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        ri.invoke("setLocalVarY", new Object[] { "petra" }, null);

        try {
            ri.invoke("getGlobalVarY", null, null);
            assertTrue("expected ReferenceError", false);
        } catch (EcmaError e) {
            assertEquals("ReferenceError", e.getName());
        }
    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

    /**
     * Tests shared scope is accessable when using contexts (ie an wire scope)
     */
    public void testScopes3() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        ri.invoke("setGlobalVarY", new Object[] { "petra" }, null);

        Map<String, Object> contexts = new HashMap<String, Object>();
        contexts.put("a", "sue");
        Object x = ri.invoke("getGlobalVarY", null, contexts);
        assertEquals("petra", x);

        x = ri.invoke("getA", null, contexts);
        assertEquals("sue", x);

    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

    /**
     * Tests a copy only retains the script scope not the shared scope
     */
    public void testScopes4() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        ri.invoke("setGlobalVarY", new Object[] { "petra" }, null);

        ri = ri.copy();
        try {
            ri.invoke("getGlobalVarY", null, null);
            assertTrue("expected ReferenceError", false);
        } catch (EcmaError e) {
            assertEquals("ReferenceError", e.getName());
        }
        try {
            ri.invoke("getA", null, null);
            assertTrue("expected ReferenceError", false);
        } catch (EcmaError e) {
            assertEquals("ReferenceError", e.getName());
        }

View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

        }

    }

    public void testGetInt() {
        RhinoScript ri = new RhinoScript(scriptName, script);
        Object x = ri.invoke("getInt", null, Integer.TYPE, null);
        assertEquals(Integer.class, x.getClass());
    }
View Full Code Here

Examples of org.apache.tuscany.container.rhino.rhino.RhinoScript

        }

        String script = jsImplementation.getScript();
        ClassLoader cl = jsImplementation.getResourceLoader().getClassLoader();

        RhinoScript invoker;
        if (isE4XStyle(componentName, jsImplementation.getComponentType().getServices())) {
            E4XDataBinding dataBinding = createDataBinding(jsImplementation);
            invoker = new RhinoE4XScript(componentName, script, defaultProperties, cl, dataBinding);
        } else {
            invoker = new RhinoScript(componentName, script, defaultProperties, cl);
        }

        Map<String, Object> properties = new HashMap<String, Object>();
        JavaScriptContextFactory contextFactory = new JavaScriptContextFactory(componentName, scope, services, properties, invoker);
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.