Package org.apache.commons.io.output

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


                out = new BytesMessageOutputStream(bytesMsg);
                message = bytesMsg;
            } else {
                sw = new StringWriter();
                try {
                    out = new WriterOutputStream(sw, format.getCharSetEncoding());
                } catch (UnsupportedCharsetException ex) {
                    handleException("Unsupported encoding " + format.getCharSetEncoding(), ex);
                    return null;
                }
            }
View Full Code Here


            // This is the old behavior: just set debug to true
            session.setDebug(true);
        }
        if (ParamUtils.getOptionalParamBoolean(params, MailConstants.TRANSPORT_MAIL_DEBUG, false)) {
            // Redirect debug output to where it belongs, namely to the logs!
            session.setDebugOut(new PrintStream(new WriterOutputStream(new LogWriter(log)), true));
            // Only enable debug afterwards since the call to setDebug might already cause debug output
            session.setDebug(true);
        }
    }
View Full Code Here

  @Test
  public void shouldNotFailWhenNoErrorsAreReported() {
    final LintReport<LinterError> lintReport = new LintReport<LinterError>();
    lintReport.addReport(new ResourceLintReport<LinterError>());
    final StringWriter writer = new StringWriter();
    ReportXmlFormatter.createForLinterError(lintReport, ReportXmlFormatter.FormatterType.LINT).write(new WriterOutputStream(writer));
    assertNotNull(writer.toString());
  }
View Full Code Here

      public void process(final Resource resource, final Reader reader, final Writer writer)
          throws IOException {
        final Type type = new TypeToken<LintReport<LinterError>>() {}.getType();
        final LintReport<LinterError> errors = new Gson().fromJson(reader, type);
        ReportXmlFormatter.createForLinterError(errors, formatterType).write(
            new WriterOutputStream(writer));
      }
    });
  }
View Full Code Here

      throws Exception {
    final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    final HttpServletResponse response = Mockito.mock(HttpServletResponse.class);
   
    Mockito.when(response.getOutputStream()).thenReturn(
        new DelegatingServletOutputStream(new WriterOutputStream(new StringWriter())));
    Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer(""));
    Mockito.when(request.getRequestURI()).thenReturn("");
    Mockito.when(request.getServletPath()).thenReturn("");
    Context.unset();
    Context.set(Context.webContext(request, response, Mockito.mock(FilterConfig.class)));
View Full Code Here

      throws Exception {
    final long connectionTimeout = 10000;
    final Properties props = new Properties();
    props.setProperty(ConfigConstants.connectionTimeout.name(), String.valueOf(connectionTimeout));
    final StringWriter propertiesWriter = new StringWriter();
    props.store(new WriterOutputStream(propertiesWriter), "");
    Mockito.when(mockServletContext.getResourceAsStream(Mockito.anyString())).thenReturn(
        new ByteArrayInputStream(propertiesWriter.toString().getBytes()));
    Assert.assertEquals(connectionTimeout, victim.create().getConnectionTimeout());
  }
View Full Code Here

   * {@inheritDoc}
   */
  public void process(final Resource resource, final Reader reader,
    final Writer writer) throws IOException {
      final InputStream is = new ProxyInputStream(new ReaderInputStream(reader, getEncoding())) {};
      final OutputStream os = new ProxyOutputStream(new WriterOutputStream(writer, getEncoding()));
    try {
      new JSMin(is, os).jsmin();
      is.close();
      os.close();
    } catch (final Exception e) {
View Full Code Here

      final HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
      final HttpServletResponse response = Context.get().getResponse();

      Mockito.when(response.getOutputStream()).thenReturn(
          new DelegatingServletOutputStream(new WriterOutputStream(writer)));
      Mockito.when(request.getRequestURI()).thenReturn("");

      final WroConfiguration config = new WroConfiguration();
      // we don't need caching here, otherwise we'll have clashing during unit tests.
      config.setDebug(true);
View Full Code Here

  private String jsmin(final String inputScript)
      throws Exception {
    final StringReader reader = new StringReader(inputScript);
    final InputStream is = new ReaderInputStream(reader, "UTF-8");
    final StringWriter writer = new StringWriter();
    final OutputStream os = new WriterOutputStream(writer, "UTF-8");
    new JSMin(is, os).jsmin();
    return writer.toString();
  }
View Full Code Here

      ReaderInputStream in3 = new ReaderInputStream(reader, Charsets.UTF_8);

      // OutputStream ->Writer
      OutputStreamWriter writer = new OutputStreamWriter(System.out, Charsets.UTF_8);
      // Writer->OutputStream
      WriterOutputStream out2 = new WriterOutputStream(writer, Charsets.UTF_8);

      // ////////////////////
      // 收集Writer的输出内容到String.
      StringWriter sw = new StringWriter();
      sw.write("I am String writer");
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.