commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: svn commit: r1441241 - /commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
Date Fri, 01 Feb 2013 00:16:25 GMT
On 1 February 2013 00:06, Gary Gregory <garydgregory@gmail.com> wrote:
> On Thu, Jan 31, 2013 at 6:12 PM, sebb <sebbaz@gmail.com> wrote:
>
>> On 31 January 2013 23:06, Gary Gregory <garydgregory@gmail.com> wrote:
>> > You a finally clause to ensure the stream is closed when a failure takes
>> place.
>>
>> A lot of extra work, and not necessary for unit test code.
>>
>> If an exception occurs before the end of the test method, then the
>> test has failed.
>>
>> There may perhaps be some tests where it is necessary to ensure that
>> the stream is closed regardless, but that would show up as other test
>> failures...
>>
>
> For me, tests should be independent, so cascading failures are misleading
> of the overall health of the project.

In that case, raise a JIRA so it can be fixed at some point.

> Gary
>
>
>>
>> > Gary
>> >
>> > On Jan 31, 2013, at 17:48, "sebb@apache.org" <sebb@apache.org> wrote:
>> >
>> >> Author: sebb
>> >> Date: Thu Jan 31 22:47:39 2013
>> >> New Revision: 1441241
>> >>
>> >> URL: http://svn.apache.org/viewvc?rev=1441241&view=rev
>> >> Log:
>> >> Ensure stream is closed
>> >>
>> >> Modified:
>> >>
>>  commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
>> >>
>> >> Modified:
>> commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
>> >> URL:
>> http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java?rev=1441241&r1=1441240&r2=1441241&view=diff
>> >>
>> ==============================================================================
>> >> ---
>> commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
>> (original)
>> >> +++
>> commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
>> Thu Jan 31 22:47:39 2013
>> >> @@ -195,6 +195,7 @@ public class BOMInputStreamTest {
>> >>         final byte[] data = new byte[] { 'A', 'B', 'C', 'D' };
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, true));
>> >>         assertEquals(7, in.available());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -202,6 +203,7 @@ public class BOMInputStreamTest {
>> >>         final byte[] data = new byte[] { 'A', 'B', 'C', 'D' };
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, false));
>> >>         assertEquals(4, in.available());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -220,6 +222,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, true));
>> >>         final byte[] buf = new byte[1024];
>> >>         assertEquals(-1, in.read(buf));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -228,6 +231,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, false));
>> >>         final byte[] buf = new byte[1024];
>> >>         assertEquals(-1, in.read(buf));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -241,6 +245,7 @@ public class BOMInputStreamTest {
>> >>         assertEquals('B', in.read());
>> >>         assertEquals('C', in.read());
>> >>         assertEquals(-1, in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -257,6 +262,7 @@ public class BOMInputStreamTest {
>> >>         assertEquals('B', in.read());
>> >>         assertEquals('C', in.read());
>> >>         assertEquals(-1, in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -265,6 +271,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, true));
>> >>         final byte[] buf = new byte[1024];
>> >>         assertData(data, buf, in.read(buf));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -273,6 +280,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, false));
>> >>         final byte[] buf = new byte[1024];
>> >>         assertData(data, buf, in.read(buf));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -281,6 +289,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, false));
>> >>         final byte[] buf = new byte[1024];
>> >>         assertData(data, buf, in.read(buf));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -291,6 +300,7 @@ public class BOMInputStreamTest {
>> >>         assertEquals(0xAB, in.read());
>> >>         assertEquals(0xCD, in.read());
>> >>         assertEquals(-1, in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -306,6 +316,7 @@ public class BOMInputStreamTest {
>> >>         in.read();
>> >>         in.reset();
>> >>         assertEquals('B', in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -321,6 +332,7 @@ public class BOMInputStreamTest {
>> >>         in.read();
>> >>         in.reset();
>> >>         assertEquals('B', in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -335,6 +347,7 @@ public class BOMInputStreamTest {
>> >>         in.read();
>> >>         in.reset();
>> >>         assertEquals('A', in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -349,6 +362,7 @@ public class BOMInputStreamTest {
>> >>         in.read();
>> >>         in.reset();
>> >>         assertEquals('A', in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -376,6 +390,7 @@ public class BOMInputStreamTest {
>> >>         assertFalse("hasBOM()", in.hasBOM());
>> >>         assertFalse("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8));
>> >>         assertNull("getBOM", in.getBOM());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -388,6 +403,7 @@ public class BOMInputStreamTest {
>> >>         assertFalse("hasBOM()", in.hasBOM());
>> >>         assertFalse("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8));
>> >>         assertNull("getBOM", in.getBOM());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -414,6 +430,7 @@ public class BOMInputStreamTest {
>> >>         assertTrue("hasBOM()", in.hasBOM());
>> >>         assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8));
>> >>         assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -436,6 +453,7 @@ public class BOMInputStreamTest {
>> >>         } catch (final IllegalArgumentException e) {
>> >>             // expected - not configured for UTF-16LE
>> >>         }
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -458,6 +476,7 @@ public class BOMInputStreamTest {
>> >>         } catch (final IllegalArgumentException e) {
>> >>             // expected - not configured for UTF-16BE
>> >>         }
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -487,6 +506,7 @@ public class BOMInputStreamTest {
>> >>         } catch (final IllegalArgumentException e) {
>> >>             // expected - not configured for UTF-32LE
>> >>         }
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -516,6 +536,7 @@ public class BOMInputStreamTest {
>> >>         } catch (final IllegalArgumentException e) {
>> >>             // expected - not configured for UTF-32BE
>> >>         }
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -535,6 +556,7 @@ public class BOMInputStreamTest {
>> >>         } catch (final IllegalArgumentException e) {
>> >>             // expected - not configured for UTF-16BE
>> >>         }
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -550,6 +572,7 @@ public class BOMInputStreamTest {
>> >>         assertTrue("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8));
>> >>         assertFalse("hasBOM(UTF-16BE)",
>> in.hasBOM(ByteOrderMark.UTF_16BE));
>> >>         assertEquals("getBOM", ByteOrderMark.UTF_8, in.getBOM());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -563,6 +586,7 @@ public class BOMInputStreamTest {
>> >>         assertFalse("hasBOM()", in.hasBOM());
>> >>         assertFalse("hasBOM(UTF-8)", in.hasBOM(ByteOrderMark.UTF_8));
>> >>         assertNull("getBOM", in.getBOM());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -647,6 +671,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, true));
>> >>         in.skip(2L);
>> >>         assertEquals('C', in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -655,6 +680,7 @@ public class BOMInputStreamTest {
>> >>         final InputStream in = new
>> BOMInputStream(createUtf8DataStream(data, false));
>> >>         in.skip(2L);
>> >>         assertEquals('C', in.read());
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -664,6 +690,7 @@ public class BOMInputStreamTest {
>> >>         final byte[] buf = new byte[1024];
>> >>         assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2));
>> >>         assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >> @@ -673,6 +700,7 @@ public class BOMInputStreamTest {
>> >>         final byte[] buf = new byte[1024];
>> >>         assertData(new byte[] { 'A', 'B' }, buf, in.read(buf, 0, 2));
>> >>         assertData(new byte[] { 'C' }, buf, in.read(buf, 0, 2));
>> >> +        in.close();
>> >>     }
>> >>
>> >>     @Test
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> > For additional commands, e-mail: dev-help@commons.apache.org
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message