Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.NodeScript


    @Test
    public void testInvalidNodeVersion()
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("test.js",
                                             "console.log(\'Hello, World!\');process.exit(0);  ",
                                             null);
        script.setNodeVersion("0.0.0");
        try {
            script.execute().get();
            assertFalse(true);
        } catch (NodeException ok) {
        }
    }
View Full Code Here


    @Test
    public void testWildcardNodeVersion()
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("test.js",
                                             "console.log(\'Hello, World!\');process.exit(0);  ",
                                             null);
        script.setNodeVersion("x");
        script.execute().get();
    }
View Full Code Here

    }

    private void runTest(String name)
        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript(name,
                                             new File("target/test-classes/tests/" + name),
                                             null);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

    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

    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());
            }
View Full Code Here

    }

    private void runScript(String name)
        throws NodeException, InterruptedException, ExecutionException
    {
        NodeScript script = env.createScript(name,
                                             new File("target/test-classes/scripts/" + name),
                                             null);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

    private void runTest(String name)
        throws InterruptedException, ExecutionException, NodeException
    {
        System.out.println("Running " + name + "...");
        NodeScript script = env.createScript(name,
                                             new File("./target/test-classes/tests/" + name),
                                             null);
        ScriptStatus status = script.execute().get();
        System.out.println("  " + name + " returned " + status.getExitCode());
        assertEquals(0, status.getExitCode());
    }
View Full Code Here

            scriptEnv.put("NODE_DEBUG", System.getenv("NODE_DEBUG"));
        }
        if (System.getenv("LOGLEVEL") != null) {
            scriptEnv.put("LOGLEVEL", System.getenv("LOGLEVEL"));
        }
        NodeScript script = env.createScript(name,
                                             new File("./target/test-classes/tests/" + name),
                                             null);
        script.setEnvironment(scriptEnv);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
    }
View Full Code Here

            scriptEnv.put("NODE_DEBUG", System.getenv("NODE_DEBUG"));
        }
        if (System.getenv("LOGLEVEL") != null) {
            scriptEnv.put("LOGLEVEL", System.getenv("LOGLEVEL"));
        }
        NodeScript script = env.createScript(name,
                                             new File("./target/test-classes/tests/" + name),
                                             null);
        script.setEnvironment(scriptEnv);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
    }
View Full Code Here

        if (args.length >= 4) {
            version = args[3];
        }

        try {
            NodeScript script = env.createScript(fileName.getName(), fileName, null);
            script.setNodeVersion(version);

            Future<ScriptStatus> exec;
            try {
                exec = script.execute();
                ScriptStatus status = exec.get(timeout, TimeUnit.SECONDS);
                exitCode = status.getExitCode();
                if (status.hasCause()) {
                    Throwable cause = status.getCause();

                    if (cause instanceof JavaScriptException) {
                        Object value = ((JavaScriptException) cause).getValue();
                        Context cx = Context.enter();
                        System.err.println(Context.toString(value));
                        Context.exit();
                    }
                    if (cause instanceof RhinoException) {
                        System.err.println(((RhinoException) cause).getScriptStackTrace());
                    }
                    cause.printStackTrace(System.err);
                }
            } finally {
                script.close();
            }
        } catch (TimeoutException te) {
            System.err.println("Test timeout!");
            exitCode = 102;
        } catch (InterruptedException ie) {
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.