Loading ...
Sorry, an error occurred while loading the content.
 

JUnit4: Why can't TextListener take a PrintWriter?

Expand Messages
  • Jon Skeet
    I ve just been writing some tests for my parameterisation classes, and I m trying to verify that the right things are being logged. For a quick and dirty
    Message 1 of 1 , Dec 1 6:22 AM
      I've just been writing some tests for my parameterisation classes, and
      I'm trying to verify that the right things are being logged. For a quick
      and dirty start, I thought I'd use TextListener, creating a StringWriter
      to get the results into. Unfortunately, TextListener only takes a
      PrintStream - it can't take a PrintWriter.

      Is there any reason for this? I'd personally prefer the constructors to
      be:

      public TextListener() {
      this(System.out);
      }

      public TextListener(Writer writer) {
      this.fWriter = new PrintWriter(writer);
      }

      public TextListener(OutputStream stream) {
      this.fWriter = new PrintWriter (stream);
      }

      (where fWriter becomes a PrintWriter instead of a PrintStream).

      The listener is conceptually only dealing with text, so in my view a
      writer is more appropriate than a stream anyway.

      (As it happens, I think I'll rewrite the tests to use EasyMock, but the
      above is still worthwhile, IMO.)

      Jon Skeet
      Senior Software Engineer
      CLEARSWIFT
      The MIMEsweeper Company

      DDI: +44 (0) 1189 038 109
      Mobile: +44 (0) 7970 158 865
      Switchboard: +44 (0) 1189 038 903
      Fax: +44 (0) 1189 039 000
      Web: www.clearswift.com


      Clearswift monitors, controls and protects all its messaging traffic in compliance with its corporate email policy using Clearswift products.
      Find out more about Clearswift, its solutions and services at http://www.clearswift.com

      This communication is confidential and may contain privileged information intended solely for the named addressee(s). It may not be used or disclosed except for the purpose for which it has been sent. If you are not the intended recipient, you must not copy, distribute or take any action in reliance on it. Unless expressly stated, opinions in this message are those of the individual sender and not of Clearswift. If you have received this communication in error, please notify Clearswift by emailing support@... quoting the sender and delete the message and any attached documents. Clearswift accepts no liability or responsibility for any onward transmission or use of emails and attachments having left the Clearswift domain.

      This footnote confirms that this email message has been swept by MIMEsweeper for Content Security threats, including computer viruses.
    Your message has been successfully submitted and would be delivered to recipients shortly.