Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.NodeScript


    {
        NodeEnvironment localEnv = new NodeEnvironment();
        Sandbox sb = new Sandbox();
        sb.setSubprocessPolicy(new NoEchoPolicy());
        localEnv.setSandbox(sb);
        NodeScript script = localEnv.createScript("spawntest.js",
                                             new File("./target/test-classes/tests/spawntest.js"),
                                             new String[] { "fail" });
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
    }
View Full Code Here


    @Test
    public void testAddEnvironment()
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeEnvironment localEnv = new NodeEnvironment();
        NodeScript script = localEnv.createScript("environmenttest.js",
                                                  new File("./target/test-classes/tests/environmenttest.js"),
                                                  new String[] { "foo", "bar" });

        script.addEnvironment("foo", "bar");

        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
    }
View Full Code Here

    @Test
    public void testSetEnvironment()
        throws InterruptedException, ExecutionException, NodeException
    {

        NodeScript script = env.createScript("environmenttest.js",
                                             new File("./target/test-classes/tests/environmenttest.js"),
                                             new String[] { "foo", "bar", "baz", "foo" });

        HashMap<String, String> env = new HashMap<String, String>();
        env.put("foo", "bar");
        env.put("baz", "foo");
        script.setEnvironment(env);

        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
    }
View Full Code Here

    @Test
    public void testGlobalModule()
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        HashMap<String, String> env = new HashMap<String, String>();
        env.put("NODE_PATH", "./target/test-classes/global");
        script.setEnvironment(env);

        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

    public void testChrootGlobalModule()
        throws InterruptedException, ExecutionException, NodeException
    {
        Sandbox sb = new Sandbox();
        sb.setFilesystemRoot("./target/test-classes");
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        HashMap<String, String> env = new HashMap<String, String>();
        env.put("NODE_PATH", "./global");
        script.setEnvironment(env);
        script.setSandbox(sb);

        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

            System.out.println("Mount is currently not supported on Windows");
            return;
        }

        Sandbox sb = new Sandbox();
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        sb.mount("/usr/lib/node_modules", "./target/test-classes/global");
        HashMap<String, String> env = new HashMap<String, String>();
        env.put("NODE_PATH", "/usr/lib/node_modules");
        script.setEnvironment(env);
        script.setSandbox(sb);

        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

        }

        Sandbox sb = new Sandbox();
        sb.setFilesystemRoot("./target/test-classes");
        sb.mount("/node_modules", "./target/test-classes/global");
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        HashMap<String, String> env = new HashMap<String, String>();
        // TODO we can't seem to do this for nested paths unless we have every subdirectory there.
        env.put("NODE_PATH", "/node_modules");
        script.setEnvironment(env);
        script.setSandbox(sb);

        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

    @Test
    public void testRunModule()
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("testmodue.js",
                                             new File("./target/test-classes/tests/testmodule"),
                                             null);
        ScriptFuture future = script.executeModule();
        Scriptable module = future.getModuleResult();
        assertNotNull(module);
        assertTrue(module.has("modulename", module));
        assertEquals("testmodule", module.get("modulename", module));
        future.cancel(true);
View Full Code Here

    @Test
    public void testArgv()
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("argvtest.js",
                                             new File("target/test-classes/tests/argvtest.js"),
                                             new String[] { "One", "Two", "Three" });
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

          return;
        }
        NodeEnvironment testEnv = new NodeEnvironment();
        Sandbox sb = new Sandbox().setHideOSDetails(true);
        testEnv.setSandbox(sb);
        NodeScript script = testEnv.createScript("hiddenostest.js",
                                             new File("target/test-classes/tests/hiddenostest.js"),
                                             null);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
        testEnv.close();
    }
View Full Code Here

TOP

Related Classes of io.apigee.trireme.core.NodeScript

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.