Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.NodeScript


    }

    private void runTest(String name)
        throws InterruptedException, NodeException
    {
        NodeScript script = env.createScript(name,
                                             new File("./target/test-classes/testscripts/" + name),
                                             null);
        try {
            ScriptStatus status = script.execute().get();
            assertEquals(0, status.getExitCode());
        } catch (ExecutionException ee) {
            if (ee.getCause() instanceof RhinoException) {
                System.err.println(((RhinoException)ee.getCause()).getScriptStackTrace());
            }
            ee.getCause().printStackTrace(System.err);
            assertTrue(false);
        } finally {
            script.close();
        }
    }
View Full Code Here


    @Test
    public void testHello()
        throws NodeException, InterruptedException, ExecutionException
    {
        NodeScript script = env.createScript("hellotest.js",
                                             new File("target/test-classes/hellotest.js"),
                                             null);
        ScriptStatus status = script.execute().get();
        assertEquals(0, status.getExitCode());
        script.close();
    }
View Full Code Here

        throws NodeException, InterruptedException, ExecutionException
    {
        File npmTests = new File("./target/test-classes/npm");
        String cacheDir = new File(npmTests, "cache").getAbsolutePath();
        String npmTestsDir = new File("./target/test-classes/argo").getAbsolutePath();
        NodeScript script = env.createScript("npmoutdated.js",
                                             new File(npmTests, "npmoutdated.js"),
                                             new String[] { npmTestsDir, cacheDir });
        ScriptFuture future = script.execute();
        ScriptStatus status = future.get();
        assertTrue(status.isOk());
    }
View Full Code Here

        throws NodeException, InterruptedException, ExecutionException
    {
        File npmTests = new File("./target/test-classes/npm");
        String cacheDir = new File(npmTests, "cache").getAbsolutePath();
        String npmTestsDir = new File(npmTests, "apitest").getAbsolutePath();
        NodeScript script = env.createScript("npmupdate.js",
                                             new File(npmTests, "npmupdate.js"),
                                             new String[] { npmTestsDir, cacheDir });
        ScriptFuture future = script.execute();
        ScriptStatus status = future.get();
        assertTrue(status.isOk());
    }
View Full Code Here

        throws NodeException, InterruptedException, ExecutionException
    {
        File npmTests = new File("./target/test-classes/npm");
        String cacheDir = new File(npmTests, "cache").getAbsolutePath();
        String npmTestsDir = new File(npmTests, "apitest").getAbsolutePath();
        NodeScript script = env.createScript("npmupdate.js",
                                             new File(npmTests, "npmupdate.js"),
                                             new String[] { npmTestsDir, cacheDir });
        ScriptFuture future = script.execute();
        ScriptStatus status = future.get();
        assertTrue(status.isOk());
    }
View Full Code Here

    public void testAppMemory()
        throws NodeException, InterruptedException, IOException
    {
        long before = getMemoryUsed();
        NodeEnvironment env = new NodeEnvironment();
        NodeScript script = env.createScript("server.js", new File("./target/test-classes/dogs/server.js"), null);
        ScriptFuture scriptFuture = script.execute();
        Utils.awaitPortOpen(PORT);
        long after = getMemoryUsed();
        System.out.println("Added " + (after - before) + " bytes after starting one script");
        scriptFuture.cancel(true);
    }
View Full Code Here

        ArrayList<ScriptFuture> futures = new ArrayList<ScriptFuture>();

        System.out.print("Starting...");
        int p = PORT + 1;
        for (int i = 0; i < NUMSCRIPTS; i++) {
            NodeScript script = env.createScript("server.js", new File("./target/test-classes/dogs/server.js"),
                                                 new String[] { String.valueOf(p) });
            futures.add(script.execute());
            p++;
            System.out.print(i + " ");
            System.out.flush();
        }
        System.out.println();
View Full Code Here

        ArrayList<ScriptFuture> futures = new ArrayList<ScriptFuture>();

        System.out.print("Starting with cache...");
        int p = PORT + 1;
        for (int i = 0; i < NUMSCRIPTS; i++) {
            NodeScript script = env.createScript("server.js", new File("./target/test-classes/dogs/server.js"),
                                                 new String[] { String.valueOf(p) });
            futures.add(script.execute());
            p++;
            System.out.print(i + " ");
            System.out.flush();
        }
        System.out.println();
View Full Code Here

        if (useNetty) {
            env.setHttpContainer(new NettyHttpContainer());
        }
        // Use separate ports between netty and non-netty because netty might take a while to close them
        int port = PORT + (useNetty ? 1 : 0);
        NodeScript script = env.createScript("server.js", new File("./target/test-classes/argo/server.js"),
                                             new String[] { String.valueOf(port) });
        ScriptFuture scriptFuture = script.execute();
        System.out.println("Waiting for the port to open. useNetty = " + useNetty);
        Utils.awaitPortOpen(port);

        System.out.println("Port " + port + " is open");
        Utils.getString(BASEURL + port + "/forecastrss?p=08904", 200);
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        NodeEnvironment env = new NodeEnvironment();
        env.setSandbox(new Sandbox().setStdout(out));

        String msg = "Hello, World!";
        NodeScript ns =
            env.createScript("consolelogtest.js", new File("./target/test-classes/tests/consolelogtest.js"),
                             new String[] { "stdout", msg });

        try {
            ScriptFuture f = ns.execute();
            ScriptStatus result = f.get(SCRIPT_TIMEOUT_SECS, TimeUnit.SECONDS);
            assertEquals(0, result.getExitCode());

            String stream = new String(out.toByteArray(), UTF8);
            assertEquals(msg + '\n', stream);
        } finally {
            ns.close();
            env.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.