Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.NodeEnvironment


    private static final String ATTACHMENT_VAL = "basichttptest";

    @BeforeClass
    public static void init()
    {
        env = new NodeEnvironment();
        env.setHttpContainer(new NettyHttpContainer());
        env.setScriptTimeLimit(TIME_LIMIT, TimeUnit.SECONDS);
    }
View Full Code Here


    private static NodeEnvironment env;

    @BeforeClass
    public static void init()
    {
        env = new NodeEnvironment();
        System.setProperty("TriremeHttpTimeout", "2");
        env.setHttpContainer(new NettyHttpContainer());
    }
View Full Code Here

        if ((args.length < 1) || (args.length > 4)) {
            System.exit(10);
        }

        File fileName = new File(args[0]);
        NodeEnvironment env = new NodeEnvironment();
        int exitCode = 101;
        int timeout = TEST_TIMEOUT_SECS;
        String version = NodeEnvironment.DEFAULT_NODE_VERSION;

        if ((args.length >= 2) && args[1].equals("netty")) {
            env.setHttpContainer(new NettyHttpContainer());
        }
        if (args.length >= 3) {
            timeout = Integer.parseInt(args[2]);
        }
        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) {
            exitCode = 103;
        } catch (ExecutionException ee) {
            Throwable cause = ee.getCause();
            if (cause instanceof JavaScriptException) {
                Object value = ((JavaScriptException)cause).getValue();
                Context.enter();
                System.err.println(Context.toString(value));
                System.err.println(((JavaScriptException)cause).getScriptStackTrace());
                Context.exit();
            } else if (cause instanceof RhinoException) {
                RhinoException re = (RhinoException)cause;
                System.err.println(re.details());
                System.err.println(re.getScriptStackTrace());
            } else {
                System.err.println(cause.getMessage());
            }
            cause.printStackTrace(System.err);
            exitCode = 104;
        } catch (NodeException ne) {
            ne.printStackTrace(System.err);
            exitCode = 105;
        } finally {
            env.close();
        }

        System.exit(exitCode);
    }
View Full Code Here

    protected Scriptable module;
    protected NodeEnvironment env;

    public HadoopBase()
    {
        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.