Package org.apache.commons.io.output

Examples of org.apache.commons.io.output.WriterOutputStream


      if (lastRequest instanceof HttpEntityEnclosingRequest) {
        HttpEntityEnclosingRequest lastEERequest = (HttpEntityEnclosingRequest) lastRequest;
        HttpEntity lastEE = lastEERequest.getEntity();
        if (lastEE.isRepeatable()) {
          StringWriter requestCapture = new StringWriter();
          lastEE.writeTo(new WriterOutputStream(requestCapture, "UTF-8"));
          requestBody = requestCapture.toString();
          ContentType ct = ContentType.get(lastEE);
          String mimeType = ct.getMimeType();
          EncodingEnum ctEnum = EncodingEnum.forContentType(mimeType);
          if (ctEnum == null) {
View Full Code Here


   * into a character streams. If both {@link Writer} arguments are the same object
   * the streams will be combined. 
   */
  public void decodeStreams(List<IEvent> events, Writer sysout, Writer syserr) throws IOException {
    int lineBuffer = 160;
    WriterOutputStream stdout = new WriterOutputStream(sysout, getCharset(), lineBuffer, true);
    WriterOutputStream stderr = new WriterOutputStream(syserr, getCharset(), lineBuffer, true);
    for (IEvent evt : events) {
      switch (evt.getType()) {
        case APPEND_STDOUT:
          if (sysout != null) {
            ((IStreamEvent) evt).copyTo(stdout);
          }
          break;

        case APPEND_STDERR:
          if (syserr != null) {
            ((IStreamEvent) evt).copyTo(stderr);
          }
          break;
      }
    }

    stdout.flush();
    stderr.flush();
  }
View Full Code Here

  }

  @Subscribe
  public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException {
    final Charset charset = e.getSlave().getCharset();
    outStream = new WriterOutputStream(outWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);
    errStream = new WriterOutputStream(errWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);

    if (showSuiteSummary && isPassthrough()) {
      SuiteStartedEvent evt = e.getSuiteStartedEvent();
      emitSuiteStart(evt.getDescription(), evt.getStartTimestamp());
    }
View Full Code Here

    final JsonArray output = new JsonArray();
    final SlaveInfo slave = e.getSlave();
    int lineBuffer = 160;
    final StringWriter out = new StringWriter();
    final StringWriter err = new StringWriter();
    WriterOutputStream stdout = new WriterOutputStream(out, slave.getCharset(), lineBuffer, false);
    WriterOutputStream stderr = new WriterOutputStream(err, slave.getCharset(), lineBuffer, false);
    for (IEvent evt : e.getEventStream()) {
      try {
        JsonObject marker;
        switch (evt.getType()) {
          case SUITE_FAILURE:
View Full Code Here

    final JsonArray output = new JsonArray();
    final SlaveInfo slave = e.getSlave();
    int lineBuffer = 160;
    final StringWriter out = new StringWriter();
    final StringWriter err = new StringWriter();
    WriterOutputStream stdout = new WriterOutputStream(out, slave.getCharset(), lineBuffer, false);
    WriterOutputStream stderr = new WriterOutputStream(err, slave.getCharset(), lineBuffer, false);
    for (IEvent evt : e.getEventStream()) {
      try {
        JsonObject marker;
        switch (evt.getType()) {
          case SUITE_FAILURE:
          case TEST_IGNORED_ASSUMPTION:
          case TEST_IGNORED:
          case TEST_STARTED:
          case TEST_FINISHED:
          case TEST_FAILURE:
            flushBoth(output, out, err, stdout, stderr);
            marker = new JsonObject();
            marker.addProperty("event", evt.getType().toString());
            marker.add("description", context.serialize(((IDescribable) evt).getDescription()));
            if (evt instanceof FailureEvent) {
              marker.add("failure", context.serialize(((FailureEvent) evt).getFailure()));
            }
            output.add(marker);
            break;

          // Flush streams only if there's interwoven output between them.

          case APPEND_STDOUT:
            flush(APPEND_STDERR, output, stderr, err);
            stdout.write(((IStreamEvent) evt).getChunk());
            break;

          case APPEND_STDERR:
            flush(APPEND_STDOUT, output, stdout, out);
            stderr.write(((IStreamEvent) evt).getChunk());
            break;
        }
      } catch (IOException ex) {
        // Ignore.
      }
View Full Code Here

   * into a character streams. If both {@link Writer} arguments are the same object
   * the streams will be combined. 
   */
  public void decodeStreams(List<IEvent> events, Writer sysout, Writer syserr) throws IOException {
    int lineBuffer = 160;
    WriterOutputStream stdout = new WriterOutputStream(sysout, getCharset(), lineBuffer, true);
    WriterOutputStream stderr = new WriterOutputStream(syserr, getCharset(), lineBuffer, true);
    for (IEvent evt : events) {
      switch (evt.getType()) {
        case APPEND_STDOUT:
          if (sysout != null) {
            ((IStreamEvent) evt).copyTo(stdout);
          }
          break;

        case APPEND_STDERR:
          if (syserr != null) {
            ((IStreamEvent) evt).copyTo(stderr);
          }
          break;

        default:
          break;
    }
    }

    stdout.flush();
    stderr.flush();
  }
View Full Code Here

  }

  @Subscribe
  public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException {
    final Charset charset = e.getSlave().getCharset();
    outStream = new WriterOutputStream(outWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);
    errStream = new WriterOutputStream(errWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);

    if (showSuiteSummary && isPassthrough()) {
      SuiteStartedEvent evt = e.getSuiteStartedEvent();
      emitSuiteStart(evt.getDescription(), evt.getStartTimestamp());
    }
View Full Code Here

    final JsonArray output = new JsonArray();
    final ForkedJvmInfo slave = e.getSlave();
    int lineBuffer = 160;
    final StringWriter out = new StringWriter();
    final StringWriter err = new StringWriter();
    WriterOutputStream stdout = new WriterOutputStream(out, slave.getCharset(), lineBuffer, false);
    WriterOutputStream stderr = new WriterOutputStream(err, slave.getCharset(), lineBuffer, false);
    for (IEvent evt : e.getEventStream()) {
      try {
        JsonObject marker;
        switch (evt.getType()) {
          case SUITE_FAILURE:
View Full Code Here

   * into a character streams. If both {@link Writer} arguments are the same object
   * the streams will be combined. 
   */
  public void decodeStreams(List<IEvent> events, Writer sysout, Writer syserr) {
    int lineBuffer = 160;
    WriterOutputStream stdout = new WriterOutputStream(sysout, getCharset(), lineBuffer, true);
    WriterOutputStream stderr = new WriterOutputStream(syserr, getCharset(), lineBuffer, true);
    for (IEvent evt : events) {
      try {
        switch (evt.getType()) {
          case APPEND_STDOUT:
            if (sysout != null) {
              stdout.write(((AppendStdOutEvent) evt).getChunk());
            }
            break;

          case APPEND_STDERR:
            if (syserr != null) {
              stderr.write(((AppendStdErrEvent) evt).getChunk());
            }
            break;
        }
      } catch (IOException e) {
        // Ignore.
      }
    }

    try {
      stdout.flush();
      stderr.flush();
    } catch (IOException e) {
      // Ignore.
    }
  }
View Full Code Here

  }

  @Subscribe
  public void onSuiteStart(AggregatedSuiteStartedEvent e) throws IOException {
    final Charset charset = e.getSlave().getCharset();
    outStream = new WriterOutputStream(outWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);
    errStream = new WriterOutputStream(errWriter, charset, DEFAULT_MAX_LINE_WIDTH, true);

    if (showSuiteSummary && isPassthrough()) {
      SuiteStartedEvent evt = e.getSuiteStartedEvent();
      emitSuiteStart(evt.getDescription(), evt.getStartTimestamp());
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.io.output.WriterOutputStream

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.