commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting (JIRA)" <>
Subject [jira] Created: (IO-193) Broken input and output streams
Date Thu, 05 Feb 2009 16:25:59 GMT
Broken input and output streams

                 Key: IO-193
             Project: Commons IO
          Issue Type: New Feature
          Components: Streams/Writers
            Reporter: Jukka Zitting
            Priority: Minor
             Fix For: 1.5

When testing error handling in code that uses streams one needs a way to simulate an IOException
being thrown by a stream. Typically this means using a custom stream class that throws the
desired exception. To avoid having to implement such custom classes over and over again for
multiple projects, I'd like to introduce such classes in Commons IO.

The proposed BrokenInputStream and BrokenOutputStream always throw a given IOException from
all InputStream and OutputStream methods that declare such exceptions.

For example, the following fictional test code:

Result result = processStream(new InputStream() {
        public int read() throws IOException {
            throw new IOException("test");
assertEquals(PROCESSING_FAILED, result);

could be replaced with:

Result result = processStream(new BrokenInputStream());
assertEquals(PROCESSING_FAILED, result);

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message