Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.ScriptFuture


        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


        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

        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, 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

        }
        // 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);
        scriptFuture.cancel(true);

        try {
            scriptFuture.get();
        } catch (CancellationException ok) {
        }
        System.out.println("Server has stopped");
    }
View Full Code Here

        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

        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("endless.js",
                                             new File("./target/test-classes/tests/endless.js"),
                                             null);
        final ScriptFuture status = script.execute();
        status.setListener(new ScriptStatusListener()
        {
            @Override
            public void onComplete(NodeScript script, ScriptStatus s)
            {
                assertTrue(status.isCancelled());
            }
        });
        Thread.sleep(50L);
        status.cancel(false);
        try {
            status.get();
            assertFalse("Script should return an cancellation exception", true);
        } catch (CancellationException ce) {
            // Expected result
        }
        assertTrue(status.isDone());
    }
View Full Code Here

        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("endless.js",
                                             new File("./target/test-classes/tests/endless.js"),
                                             null);
        final ScriptFuture status = script.execute();
        status.setListener(new ScriptStatusListener()
        {
            @Override
            public void onComplete(NodeScript script, ScriptStatus s)
            {
                assertTrue(status.isCancelled());
            }
        });
        Thread.sleep(50L);
        try {
            status.get(250L, TimeUnit.MILLISECONDS);
            assertTrue("Wait should have timed out", false);
        } catch (TimeoutException ok) {
        }
        status.cancel(true);
    }
View Full Code Here

        throws InterruptedException, ExecutionException, NodeException
    {
        NodeScript script = env.createScript("endless.js",
                                             new File("./target/test-classes/tests/endless.js"),
                                             null);
        final ScriptFuture status = script.execute();
        status.setListener(new ScriptStatusListener()
        {
            @Override
            public void onComplete(NodeScript script, ScriptStatus s)
            {
                assertTrue(status.isCancelled());
            }
        });
        Thread.sleep(50L);
        status.cancel(true);
        try {
            status.get();
            assertFalse("Script should return an cancellation exception", true);
        } catch (CancellationException ce) {
            // Expected result
        }
        assertTrue(status.isDone());
    }
View Full Code Here

        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 {
View Full Code Here

TOP

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

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.