예제 #1
0
 private void execute(Path image, String moduleName) throws Throwable {
   String cmd = image.resolve("bin").resolve(moduleName).toString();
   OutputAnalyzer analyzer;
   if (System.getProperty("os.name").startsWith("Windows")) {
     analyzer = ProcessTools.executeProcess("sh.exe", cmd, "1", "2", "3");
   } else {
     analyzer = ProcessTools.executeProcess(cmd, "1", "2", "3");
   }
   if (analyzer.getExitValue() != 0) {
     throw new AssertionError("Image invocation failed: rc=" + analyzer.getExitValue());
   }
 }
예제 #2
0
 /**
  * Executes a process, waits for it to finish, prints the process output to stdout and returns the
  * process output.
  *
  * <p>The process will have exited before this method returns.
  *
  * @param pb The ProcessBuilder to execute.
  * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
  */
 public static OutputAnalyzer executeCommand(ProcessBuilder pb) throws Throwable {
   String cmdLine = pb.command().stream().collect(Collectors.joining(" "));
   System.out.println("Command line: [" + cmdLine + "]");
   OutputAnalyzer analyzer = ProcessTools.executeProcess(pb);
   System.out.println(analyzer.getOutput());
   return analyzer;
 }
예제 #3
0
 /**
  * Executes a process, waits for it to finish, prints the process output to stdout, and returns
  * the process output.
  *
  * <p>The process will have exited before this method returns.
  *
  * @param cmds The command line to execute.
  * @return The {@linkplain OutputAnalyzer} instance wrapping the process.
  */
 public static OutputAnalyzer executeCommand(String... cmds) throws Throwable {
   String cmdLine = Arrays.stream(cmds).collect(Collectors.joining(" "));
   System.out.println("Command line: [" + cmdLine + "]");
   OutputAnalyzer analyzer = ProcessTools.executeProcess(cmds);
   System.out.println(analyzer.getOutput());
   return analyzer;
 }