Package org.zeroturnaround.exec

Examples of org.zeroturnaround.exec.ProcessExecutor


        add("-cp");
        add("target/test-classes");
        add(HelloWorld.class.getName());
      }
    };
    ProcessExecutor exec = new ProcessExecutor();
    exec.command(args);
    ProcessResult result = exec.readOutput(true).execute();
    Assert.assertEquals("Hello world!", result.outputUTF8());
  }
View Full Code Here


        add("-cp");
        add("test-classes");
        add(HelloWorld.class.getName());
      }
    };
    ProcessExecutor exec = new ProcessExecutor().directory(new File("target"));
    exec.command(args);
    ProcessResult result = exec.readOutput(true).execute();
    Assert.assertEquals("Hello world!", result.outputUTF8());
  }
View Full Code Here

  public void testWithInputAndRedirectOutput() throws Exception {
    String str = "Tere Minu Uus vihik";
    ByteArrayInputStream bais = new ByteArrayInputStream(str.getBytes());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes",
        PrintInputToOutput.class.getName());
    exec.redirectInput(bais).redirectOutput(baos);

    exec.execute();
    Assert.assertEquals(str, baos.toString());
  }
View Full Code Here

    Assert.assertEquals(repeat("-"), new String(err.toByteArray()));
  }

  private ProcessExecutor bigOutput() {
    // Use timeout in case we get stuck
    return new ProcessExecutor("java", "-cp", "target/test-classes", BigOutput.class.getName()).timeout(10, TimeUnit.SECONDS);
  }
View Full Code Here

            }
            LOG.info(output.toString());

            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            ByteArrayOutputStream errStream = new ByteArrayOutputStream();
            ProcessExecutor executor = new ProcessExecutor().command(command)
                                                            .readOutput(true)
                                                            .redirectOutput(outStream)
                                                            .redirectError(errStream);
            ProcessResult result = executor.execute();
            if (result.getExitValue() != 0) {
                LOG.error(result.getOutput().getString());
                throw new RuntimeException(String.format("mongoimport failed with exit code %d: %s", result.getExitValue(),
                                                         result.getOutput().getString()));
            }
View Full Code Here

            }
            output.append("\n");
        }

        LOG.info(output.toString());
        new ProcessExecutor().command(cmd)
                             .environment(env)
                             .redirectError(System.out)
                             .execute();

    }
View Full Code Here

                }
                output.append("\n");
            }

            LOG.info(output);
            new ProcessExecutor().command(cmd)
                                 .environment(env)
                                 .redirectError(System.out)
                                 .execute();

        } catch (final IOException e) {
View Full Code Here

        LOG.info(output.toString());
        final Map<String, String> env = new HashMap<String, String>();
        String path = System.getenv("PATH");
        env.put("HADOOP_HOME", HADOOP_HOME);
        env.put("path", HADOOP_HOME + "/bin" + File.pathSeparator + path);
        new ProcessExecutor().command(cmd)
                             .environment(env)
                             .redirectError(System.out)
                             .execute();

    }
View Full Code Here

        return getMongoClient().getDB("mongo_hadoop").getCollection(collection);
    }

    protected void loadIntoHDFS(final String localPath, final String hdfsPath) {
        try {
            new ProcessExecutor(HADOOP_HOME + "/bin/hadoop", "fs", "-mkdir", "-p", hdfsPath)
                .redirectOutput(System.out)
                .execute();
            new ProcessExecutor(HADOOP_HOME + "/bin/hadoop", "fs", "-put", localPath, hdfsPath)
                .directory(PROJECT_HOME)
                .redirectOutput(System.out)
                .execute();
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
View Full Code Here

    public void produceMobi(Path currentPath,String kindlegenDir) {

        try {
            indikatorService.startCycle();
            ProcessExecutor processExecutor = new ProcessExecutor();
            processExecutor.readOutput(true);
            processExecutor.directory(new File(kindlegenDir));
            String message = processExecutor
                    .command("kindlegen", currentPath.resolve("book.epub").toString())
                    .execute()
                    .outputUTF8();
            logger.debug(message);
            indikatorService.completeCycle();
View Full Code Here

TOP

Related Classes of org.zeroturnaround.exec.ProcessExecutor

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.