Package io.apigee.trireme.core

Examples of io.apigee.trireme.core.Sandbox


    @Test
    public void testChrootGlobalModule()
        throws InterruptedException, ExecutionException, NodeException
    {
        Sandbox sb = new Sandbox();
        sb.setFilesystemRoot("./target/test-classes");
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        HashMap<String, String> env = new HashMap<String, String>();
        env.put("NODE_PATH", "./global");
        script.setEnvironment(env);
View Full Code Here


        if (Platform.get().isWindows()) {
            System.out.println("Mount is currently not supported on Windows");
            return;
        }

        Sandbox sb = new Sandbox();
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        sb.mount("/usr/lib/node_modules", "./target/test-classes/global");
        HashMap<String, String> env = new HashMap<String, String>();
        env.put("NODE_PATH", "/usr/lib/node_modules");
        script.setEnvironment(env);
        script.setSandbox(sb);
View Full Code Here

        if (Platform.get().isWindows()) {
            System.out.println("Mount is currently not supported on Windows");
            return;
        }

        Sandbox sb = new Sandbox();
        sb.setFilesystemRoot("./target/test-classes");
        sb.mount("/node_modules", "./target/test-classes/global");
        NodeScript script = env.createScript("globalmoduletest.js",
                                             new File("./target/test-classes/tests/globalmoduletest.js"), null);
        HashMap<String, String> env = new HashMap<String, String>();
        // TODO we can't seem to do this for nested paths unless we have every subdirectory there.
        env.put("NODE_PATH", "/node_modules");
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();
View Full Code Here

    public void testRedirectStdout()
        throws NodeException, InterruptedException, ExecutionException, TimeoutException
    {
        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 });
View Full Code Here

    public void testRedirectStderr()
        throws NodeException, InterruptedException, ExecutionException, TimeoutException
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        NodeEnvironment env = new NodeEnvironment();
        Sandbox sb = new Sandbox();
        sb.setStderr(out);
        env.setSandbox(sb);

        String msg = "Hello, World!";
        NodeScript ns =
            env.createScript("consolelogtest.js", new File("./target/test-classes/tests/consolelogtest.js"),
View Full Code Here

        String msg1 = "This is script number 1";
        NodeScript ns1 =
            env.createScript("consolelogtest.js", new File("./target/test-classes/tests/consolelogtest.js"),
                             new String[] { "stdout", msg1 });
        ns1.setSandbox(new Sandbox().setStdout(out1));

        String msg2 = "This is script number two";
        NodeScript ns2 =
            env.createScript("consolelogtest.js", new File("./target/test-classes/tests/consolelogtest.js"),
                             new String[] { "stdout", msg2 });
        ns2.setSandbox(new Sandbox().setStdout(out2));

        try {
            ScriptFuture f1 = ns1.execute();
            ScriptFuture f2 = ns2.execute();
View Full Code Here

    public void testStdoutSharing()
        throws NodeException, InterruptedException, ExecutionException, TimeoutException
    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        NodeEnvironment env = new NodeEnvironment();
        env.setSandbox(new Sandbox().setStdout(out));

        String msg1 = "This is script number 1";
        NodeScript ns1 =
            env.createScript("consolelogtest.js", new File("./target/test-classes/tests/consolelogtest.js"),
                             new String[] { "stdout", msg1 });
View Full Code Here

    public void testExtraClassShutter()
            throws NodeException, ExecutionException, InterruptedException, IOException
    {
        NodeEnvironment env = new NodeEnvironment();

        env.setSandbox(new Sandbox().setExtraClassShutter(new ClassShutter() {
            @Override
            public boolean visibleToScripts(String fullClassName) {
                return true;
            }
        }));
View Full Code Here

TOP

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

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.