commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1441248 - in /commons/proper/io/trunk/src/test/java/org/apache/commons/io: input/ output/
Date Thu, 31 Jan 2013 23:02:04 GMT
Author: sebb
Date: Thu Jan 31 23:02:03 2013
New Revision: 1441248

URL: http://svn.apache.org/viewvc?rev=1441248&view=rev
Log:
Ensure stream is closed

Modified:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullReaderTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CharSequenceReaderTest.java
Thu Jan 31 23:02:03 2013
@@ -43,9 +43,10 @@ public class CharSequenceReaderTest {
 
     /** Test {@link Reader#markSupported()}. */
     @Test
-    public void testMarkSupported() {
+    public void testMarkSupported() throws Exception {
         final Reader reader = new CharSequenceReader("FooBar");
         assertTrue(reader.markSupported());
+        reader.close();
     }
 
     /** Test {@link Reader#mark(int)}. */
@@ -88,6 +89,7 @@ public class CharSequenceReaderTest {
         assertEquals('o', reader.read());
         assertEquals(-1, reader.read());
         assertEquals(-1, reader.read());
+        reader.close();
     }
 
     /** Test {@link Reader#read(char[])}. */
@@ -104,6 +106,7 @@ public class CharSequenceReaderTest {
         assertEquals(1, reader.read(chars));
         checkArray(new char[] {'r', NONE, NONE}, chars);
         assertEquals(-1, reader.read(chars));
+        reader.close();
     }
 
     /** Test {@link Reader#read(char[], int, int)}. */
@@ -116,6 +119,7 @@ public class CharSequenceReaderTest {
         assertEquals(3, reader.read(chars, 0, 3));
         checkArray(new char[] {'B', 'a', 'r', 'F', 'o', 'o', NONE}, chars);
         assertEquals(-1, reader.read(chars));
+        reader.close();
     }
 
     private void checkRead(final Reader reader, final String expected) throws IOException
{

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
Thu Jan 31 23:02:03 2013
@@ -66,6 +66,7 @@ public class CountingInputStreamTest ext
         // trim to get rid of the 6 empty values
         final String textResult = new String(result).trim();
         assertEquals(textResult, text);
+        cis.close();
     }
 
 
@@ -115,6 +116,7 @@ public class CountingInputStreamTest ext
         final int count = cis.resetCount();
         found = cis.read(result, 6, 5);
         assertEquals( found, count );
+        cis.close();
     }
     
     public void testZeroLength1() throws Exception {
@@ -124,6 +126,7 @@ public class CountingInputStreamTest ext
         final int found = cis.read();
         assertEquals(-1, found);
         assertEquals(0, cis.getCount());
+        cis.close();
     }
 
     public void testZeroLength2() throws Exception {
@@ -135,6 +138,7 @@ public class CountingInputStreamTest ext
         final int found = cis.read(result);
         assertEquals(-1, found);
         assertEquals(0, cis.getCount());
+        cis.close();
     }
 
     public void testZeroLength3() throws Exception {
@@ -146,6 +150,7 @@ public class CountingInputStreamTest ext
         final int found = cis.read(result, 0, 5);
         assertEquals(-1, found);
         assertEquals(0, cis.getCount());
+        cis.close();
     }
 
     public void testEOF1() throws Exception {
@@ -161,6 +166,7 @@ public class CountingInputStreamTest ext
         found = cis.read();
         assertEquals(-1, found);
         assertEquals(2, cis.getCount());
+        cis.close();
     }
 
     public void testEOF2() throws Exception {
@@ -172,6 +178,7 @@ public class CountingInputStreamTest ext
         final int found = cis.read(result);
         assertEquals(2, found);
         assertEquals(2, cis.getCount());
+        cis.close();
     }
 
     public void testEOF3() throws Exception {
@@ -183,6 +190,7 @@ public class CountingInputStreamTest ext
         final int found = cis.read(result, 0, 5);
         assertEquals(2, found);
         assertEquals(2, cis.getCount());
+        cis.close();
     }
     
     public void testSkipping() throws IOException {
@@ -198,6 +206,7 @@ public class CountingInputStreamTest ext
         
         assertEquals("World!",new String(result));
         assertEquals(12,cis.getCount());
+        cis.close();
     }
 
 }

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullInputStreamTest.java
Thu Jan 31 23:02:03 2013
@@ -135,6 +135,7 @@ public class NullInputStreamTest extends
         } catch (final EOFException e) {
             // expected
         }
+        input.close();
     }
 
     /**
@@ -188,6 +189,7 @@ public class NullInputStreamTest extends
                          + readlimit + "]",
                          e.getMessage());
         }
+        input.close();
     }
 
     /**
@@ -210,6 +212,7 @@ public class NullInputStreamTest extends
         } catch (final UnsupportedOperationException e) {
             assertEquals("reset() error message",  "Mark not supported", e.getMessage());
         }
+        input.close();
     }
 
     /**
@@ -231,6 +234,7 @@ public class NullInputStreamTest extends
                     "Skip after end of file",
                     e.getMessage());
         }
+        input.close();
     }
 
 

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullReaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullReaderTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullReaderTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/NullReaderTest.java
Thu Jan 31 23:02:03 2013
@@ -132,6 +132,7 @@ public class NullReaderTest extends Test
         } catch (final EOFException e) {
             // expected
         }
+        reader.close();
     }
 
     /**
@@ -185,6 +186,7 @@ public class NullReaderTest extends Test
                          + readlimit + "]",
                          e.getMessage());
         }
+        reader.close();
     }
 
     /**
@@ -207,6 +209,7 @@ public class NullReaderTest extends Test
         } catch (final UnsupportedOperationException e) {
             assertEquals("reset() error message",  "Mark not supported", e.getMessage());
         }
+        reader.close();
     }
 
     /**
@@ -228,6 +231,7 @@ public class NullReaderTest extends Test
                     "Skip after end of file",
                     e.getMessage());
         }
+        reader.close();
     }
 
 

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ProxyReaderTest.java
Thu Jan 31 23:02:03 2013
@@ -34,7 +34,7 @@ public class ProxyReaderTest extends Tes
     }
 
     /** Test writing Null Char Array */
-    public void testNullCharArray() {
+    public void testNullCharArray() throws Exception {
 
         final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0));
 
@@ -49,10 +49,11 @@ public class ProxyReaderTest extends Tes
         } catch(final Exception e) {
             fail("Writing null String threw " + e);
         }
+        proxy.close();
     }
 
     /** Test writing Null CharBuffer */
-    public void testNullCharBuffer() {
+    public void testNullCharBuffer() throws Exception {
 
         final ProxyReader proxy = new ProxyReaderImpl(new CustomNullReader(0));
 
@@ -61,6 +62,7 @@ public class ProxyReaderTest extends Tes
         } catch(final Exception e) {
             fail("Writing null String threw " + e);
         }
+        proxy.close();
     }
 
     /** ProxyReader implementation */

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/ReaderInputStreamTest.java
Thu Jan 31 23:02:03 2013
@@ -51,6 +51,7 @@ public class ReaderInputStreamTest {
             assertEquals(b, (byte)read);
         }
         assertEquals(-1, in.read());
+        in.close();
     }
     
     private void testWithBufferedRead(final String testString, final String charsetName)
throws IOException {
@@ -76,6 +77,7 @@ public class ReaderInputStreamTest {
                 }
             }
         }
+        in.close();
     }
     
     @Test
@@ -112,6 +114,7 @@ public class ReaderInputStreamTest {
         assertEquals(inStr.length(), r.read(bytes, 0, inStr.length()+1));
         // Should always return 0 for length == 0
         assertEquals(0, r.read(bytes, 0, 0));
+        r.close();
     }
     
     @Test
@@ -123,6 +126,7 @@ public class ReaderInputStreamTest {
         assertEquals(-1, r.read(bytes, 0, 1));
         assertEquals(0, r.read(bytes, 0, 0));
         assertEquals(-1, r.read(bytes, 0, 1));
+        r.close();
     }
     
     /**

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/TaggedInputStreamTest.java
Thu Jan 31 23:02:03 2013
@@ -109,7 +109,7 @@ public class TaggedInputStreamTest exten
         }
     }
 
-    public void testOtherException() {
+    public void testOtherException() throws Exception {
         final IOException exception = new IOException("test exception");
         final InputStream closed = new ClosedInputStream();
         final TaggedInputStream stream = new TaggedInputStream(closed);
@@ -130,6 +130,7 @@ public class TaggedInputStreamTest exten
         } catch (final IOException e) {
             fail("Unexpected exception thrown");
         }
+        stream.close();
     }
 
 }

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java?rev=1441248&r1=1441247&r2=1441248&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/output/ProxyWriterTest.java
Thu Jan 31 23:02:03 2013
@@ -30,7 +30,7 @@ public class ProxyWriterTest extends Tes
     }
 
     /** Test Appending a CharSequence */
-    public void testAppendCharSequence() {
+    public void testAppendCharSequence() throws Exception {
         final StringBuilderWriter writer = new StringBuilderWriter();
         final ProxyWriter proxy = new ProxyWriter(writer);
         try {
@@ -39,11 +39,11 @@ public class ProxyWriterTest extends Tes
             fail("Appending CharSequence threw " + e);
         }
         assertEquals("ABC", writer.toString());
-        
+        proxy.close();        
     }
 
     /** Test Writing a String */
-    public void testWriteString() {
+    public void testWriteString() throws Exception {
         final StringBuilderWriter writer = new StringBuilderWriter();
         final ProxyWriter proxy = new ProxyWriter(writer);
         try {
@@ -52,11 +52,11 @@ public class ProxyWriterTest extends Tes
             fail("Writing String threw " + e);
         }
         assertEquals("ABC", writer.toString());
-        
+        proxy.close();
     }
 
     /** Test Writing a Partial String */
-    public void testWriteStringPartial() {
+    public void testWriteStringPartial() throws Exception {
         final StringBuilderWriter writer = new StringBuilderWriter();
         final ProxyWriter proxy = new ProxyWriter(writer);
         try {
@@ -65,11 +65,11 @@ public class ProxyWriterTest extends Tes
             fail("Writing String threw " + e);
         }
         assertEquals("BC", writer.toString());
-        
+        proxy.close();
     }
 
     /** Test Writing a Char array */
-    public void testWriteCharArray() {
+    public void testWriteCharArray() throws Exception {
         final StringBuilderWriter writer = new StringBuilderWriter();
         final ProxyWriter proxy = new ProxyWriter(writer);
         try {
@@ -78,11 +78,11 @@ public class ProxyWriterTest extends Tes
             fail("Writing char[] threw " + e);
         }
         assertEquals("ABC", writer.toString());
-        
+        proxy.close();
     }
 
     /** Test Writing a Partial Char array */
-    public void testWriteCharArrayPartial() {
+    public void testWriteCharArrayPartial() throws Exception {
         final StringBuilderWriter writer = new StringBuilderWriter();
         final ProxyWriter proxy = new ProxyWriter(writer);
         try {
@@ -91,11 +91,11 @@ public class ProxyWriterTest extends Tes
             fail("Writing char[] threw " + e);
         }
         assertEquals("BC", writer.toString());
-        
+        proxy.close();
     }
     
     /** Test writing Null String */
-    public void testNullString() {
+    public void testNullString() throws Exception {
 
         final ProxyWriter proxy = new ProxyWriter(new NullWriter());
 
@@ -110,10 +110,11 @@ public class ProxyWriterTest extends Tes
         } catch(final Exception e) {
             fail("Writing null String threw " + e);
         }
+        proxy.close();
     }
 
     /** Test writing Null Char array */
-    public void testNullCharArray() {
+    public void testNullCharArray() throws Exception {
 
         final ProxyWriter proxy = new ProxyWriter(new NullWriter());
 
@@ -128,10 +129,11 @@ public class ProxyWriterTest extends Tes
         } catch(final Exception e) {
             fail("Writing null char[] threw " + e);
         }
+        proxy.close();
     }
 
     /** Test appending Null CharSequence */
-    public void testNullCharSequencec() {
+    public void testNullCharSequencec() throws Exception {
 
         final ProxyWriter proxy = new ProxyWriter(new NullWriter());
 
@@ -140,6 +142,7 @@ public class ProxyWriterTest extends Tes
         } catch(final Exception e) {
             fail("Appending null CharSequence threw " + e);
         }
+        proxy.close();
     }
 
 }



Mime
View raw message