Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.NodeEnvironment


    @Test
    public void testHttpPolicyConnect()
        throws InterruptedException, ExecutionException, NodeException, IOException
    {
        NodeEnvironment localEnv = new NodeEnvironment();
        Sandbox sb = new Sandbox();
        sb.setNetworkPolicy(new RejectOutPolicy());
        localEnv.setSandbox(sb);
        NodeScript script = localEnv.createScript("httppolicyconnect.js",
                                             new File("./target/test-classes/tests/httppolicyconnect.js"),
                                             null);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
    }
View Full Code Here


    @Test
    public void testSpawnBlocked()
        throws InterruptedException, ExecutionException, NodeException
    {
        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");
View Full Code Here

    {
        if (System.getProperty("os.name").matches(".*Windows.*")) {
          // Fails on Windows because hidden OS causes path module to not work
          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

    @BeforeClass
    public static void start()
        throws NodeException, IOException, InterruptedException
    {
        NodeEnvironment env = new NodeEnvironment();
        env.setHttpContainer(new NettyHttpContainer());
        NodeScript script = env.createScript("server.js", new File("./target/test-classes/dogs/server.js"), null);
        scriptFuture = script.execute();
        Utils.awaitPortOpen(PORT);
    }
View Full Code Here

        // TODO --no-deprecation, --trace-deprecation
    }

    private static void printVersion()
    {
        NodeEnvironment env = new NodeEnvironment();
        System.err.println("Trireme " + Version.TRIREME_VERSION +
                           " node v" + env.getDefaultNodeVersion());
    }
View Full Code Here

        return true;
    }

    private int run()
    {
        NodeEnvironment env = new NodeEnvironment();

        try {
            NodeScript ns;
            if (scriptSource != null) {
                // Force an "eval"
                ns = env.createScript("[eval]", scriptSource, scriptArgs);
                ns.setPrintEval(printEval);
            } else {
                ns = env.createScript(scriptArgs, runRepl);
            }

            ScriptStatus status;
            try {
                Future<ScriptStatus> future = ns.execute();
                status = future.get();
            } finally {
                ns.close();
            }

            if (status.hasCause()) {
                printException(status.getCause());
            }

            return status.getExitCode();
        } catch (NodeException ne) {
            ne.printStackTrace(System.err);
            return 99;
        } catch (InterruptedException ie) {
            return 99;
        } catch (ExecutionException ee) {
            printException(ee.getCause());
            return 99;
        } finally {
            env.close();
        }
    }
View Full Code Here

    @BeforeClass
    public static void init()
    {
        launcher = new ShellLauncher();
        env = new NodeEnvironment();
    }
View Full Code Here

    private static NodeEnvironment env;

    @BeforeClass
    public static void init()
    {
        env = new NodeEnvironment();
    }
View Full Code Here

    private static NodeEnvironment env;

    @BeforeClass
    public static void init()
    {
        env = new NodeEnvironment();
    }
View Full Code Here

TOP

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

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.