Package org.zeroturnaround.exec.stream

Examples of org.zeroturnaround.exec.stream.PumpStreamHandler


  @Test
  public void testPumpFromInputToOutput() throws Exception {
    String str = "Tere Minu Uus vihik";
    ByteArrayInputStream bais = new ByteArrayInputStream(str.getBytes());
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PumpStreamHandler handler = new PumpStreamHandler(baos, System.err, bais);

    ProcessExecutor exec = new ProcessExecutor("java", "-cp", "target/test-classes",
        PrintInputToOutput.class.getName()).readOutput(true);
    exec.streams(handler);
View Full Code Here


  }

  private void testSlf4jLoggerName(String fullName, Slf4jStream stream) {
    ProcessExecutor executor = new ProcessExecutor();
    executor.redirectOutput(stream.asInfo());
    PumpStreamHandler pumps = executor.pumps();
    OutputStream out = pumps.getOut();
    Assert.assertTrue("Slf4jInfoOutputStream expected", out instanceof Slf4jInfoOutputStream);
    Assert.assertEquals(fullName, ((Slf4jInfoOutputStream) out).getLogger().getName());
  }
View Full Code Here

   *
   * @param input input stream that will be written to the process input stream (<code>null</code> means nothing will be written to the process input stream).
   * @return This process executor.
   */
  public ProcessExecutor redirectInput(InputStream input) {
    PumpStreamHandler pumps = pumps();
    // Only set the input stream handler, preserve the same output and error stream handler
    return streams(new PumpStreamHandler(pumps == null ? null : pumps.getOut(), pumps == null ? null : pumps.getErr(), input));
  }
View Full Code Here

   * @return This process executor.
   */
  public ProcessExecutor redirectOutput(OutputStream output) {
    if (output == null)
      output = NullOutputStream.NULL_OUTPUT_STREAM;
    PumpStreamHandler pumps = pumps();
    // Only set the output stream handler, preserve the same error stream handler
    return streams(new PumpStreamHandler(output, pumps == null ? null : pumps.getErr(), pumps == null ? null : pumps.getInput()));
  }
View Full Code Here

   * @return This process executor.
   */
  public ProcessExecutor redirectError(OutputStream output) {
    if (output == null)
      output = NullOutputStream.NULL_OUTPUT_STREAM;
    PumpStreamHandler pumps = pumps();
    // Only set the error stream handler, preserve the same output stream handler
    streams(new PumpStreamHandler(pumps == null ? null : pumps.getOut(), output, pumps == null ? null : pumps.getInput()));
    redirectErrorStream(false);
    return this;
  }
View Full Code Here

      throw new IllegalArgumentException("OutputStream must be provided.");
    OutputStream current = pumps.getOut();
    if (current != null && !(current instanceof NullOutputStream)) {
      output = new TeeOutputStream(current, output);
    }
    return new PumpStreamHandler(output, pumps.getErr(), pumps.getInput());
  }
View Full Code Here

      throw new IllegalArgumentException("OutputStream must be provided.");
    OutputStream current = pumps.getErr();
    if (current != null && !(current instanceof NullOutputStream)) {
      output = new TeeOutputStream(current, output);
    }
    return new PumpStreamHandler(pumps.getOut(), output, pumps.getInput());
  }
View Full Code Here

        builder.directory(),
        new LinkedHashMap<String, String>(environment),
        allowedExitValues == null ? null : new HashSet<Integer>(allowedExitValues));

    if (readOutput) {
      PumpStreamHandler pumps = (PumpStreamHandler) streams;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      return startInternal(process, attributes, redirectOutputAlsoTo(pumps, out), out);
    }
    else {
      return startInternal(process, attributes, streams, null);
View Full Code Here

TOP

Related Classes of org.zeroturnaround.exec.stream.PumpStreamHandler

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.