hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1444640 - in /httpcomponents/httpcore/trunk: httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/ httpcore/src/test/java/org/apache/http/impl/io/
Date Mon, 11 Feb 2013 00:32:55 GMT
Author: sebb
Date: Mon Feb 11 00:32:55 2013
New Revision: 1444640

URL: http://svn.apache.org/r1444640
Log:
Close resources at end of test

Modified:
    httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java

Modified: httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java?rev=1444640&r1=1444639&r2=1444640&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore-nio/src/test/java/org/apache/http/impl/nio/codecs/TestIdentityDecoder.java
Mon Feb 11 00:32:55 2013
@@ -183,6 +183,7 @@ public class TestIdentityDecoder {
         Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
 
         deleteWithCheck(fileHandle);
+        testfile.close();
     }
 
     private void deleteWithCheck(final File handle){
@@ -224,6 +225,7 @@ public class TestIdentityDecoder {
         Assert.assertEquals("stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
 
         deleteWithCheck(fileHandle);
+        testfile.close();
     }
 
     @Test
@@ -267,6 +269,7 @@ public class TestIdentityDecoder {
         Assert.assertEquals("beginning; stuff; more stuff; a lot more stuff!", readFromFile(fileHandle));
 
         deleteWithCheck(fileHandle);
+        testfile.close();
     }
 
     @Test

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java?rev=1444640&r1=1444639&r2=1444640&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestChunkCoding.java
Mon Feb 11 00:32:55 2013
@@ -35,6 +35,7 @@ import java.io.OutputStream;
 
 import org.apache.http.Header;
 import org.apache.http.MalformedChunkCodingException;
+import org.apache.http.TruncatedChunkException;
 import org.apache.http.impl.SessionInputBufferMock;
 import org.apache.http.impl.SessionOutputBufferMock;
 import org.apache.http.io.SessionInputBuffer;
@@ -149,6 +150,7 @@ public class TestChunkCoding {
         Assert.assertEquals(0, in.available());
         in.read();
         Assert.assertEquals(4, in.available());
+        in.close();
     }
 
     @Test
@@ -210,7 +212,8 @@ public class TestChunkCoding {
         final byte[] tmp = new byte[5];
         Assert.assertEquals(5, in.read(tmp));
         Assert.assertEquals(-1, in.read());
-    }
+        in.close();
+}
 
     // Missing \r\n at the end of the first chunk
     @Test
@@ -245,7 +248,8 @@ public class TestChunkCoding {
         } catch(final MalformedChunkCodingException e) {
             /* expected exception */
         }
-    }
+        in.close();
+}
 
     // Invalid chunk size
     @Test
@@ -260,7 +264,11 @@ public class TestChunkCoding {
         } catch(final MalformedChunkCodingException e) {
             /* expected exception */
         }
-    }
+        try {
+            in.close();
+        } catch (TruncatedChunkException expected) {
+        }
+}
 
     // Negative chunk size
     @Test
@@ -275,7 +283,11 @@ public class TestChunkCoding {
         } catch(final MalformedChunkCodingException e) {
             /* expected exception */
         }
-    }
+        try {
+            in.close();
+        } catch (TruncatedChunkException expected) {
+        }
+}
 
     // Truncated chunk
     @Test
@@ -292,7 +304,8 @@ public class TestChunkCoding {
         } catch(final MalformedChunkCodingException e) {
             /* expected exception */
         }
-    }
+        in.close();
+}
 
     // Invalid footer
     @Test
@@ -308,7 +321,8 @@ public class TestChunkCoding {
         } catch(final MalformedChunkCodingException e) {
             /* expected exception */
         }
-    }
+        in.close();
+}
 
     @Test
     public void testEmptyChunkedInputStream() throws IOException {
@@ -323,7 +337,8 @@ public class TestChunkCoding {
             out.write(buffer, 0, len);
         }
         Assert.assertEquals(0, out.size());
-    }
+        in.close();
+}
 
     @Test
     public void testChunkedConsistence() throws IOException {
@@ -348,7 +363,8 @@ public class TestChunkCoding {
 
         final String output = EncodingUtils.getString(result.toByteArray(), CONTENT_CHARSET);
         Assert.assertEquals(input, output);
-    }
+        in.close();
+}
 
     @Test
     public void testChunkedOutputStream() throws IOException {
@@ -461,7 +477,8 @@ public class TestChunkCoding {
         }
         Assert.assertEquals(20, bytesRead);
         Assert.assertEquals(2, timeouts);
-    }
+        in.close();
+}
 
     @Test
     public void testResumeOnSocketTimeoutInChunk() throws IOException {
@@ -488,7 +505,8 @@ public class TestChunkCoding {
         }
         Assert.assertEquals(20, bytesRead);
         Assert.assertEquals(5, timeouts);
-    }
+        in.close();
+}
 
 }
 

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java?rev=1444640&r1=1444639&r2=1444640&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthInputStream.java
Mon Feb 11 00:32:55 2013
@@ -74,6 +74,7 @@ public class TestContentLengthInputStrea
 
         final String result = EncodingUtils.getString(out.toByteArray(), CONTENT_CHARSET);
         Assert.assertEquals(result, "1234567890");
+        in.close();
     }
 
     @Test
@@ -86,6 +87,7 @@ public class TestContentLengthInputStrea
         in.read();
         Assert.assertEquals(9, in.skip(10));
         Assert.assertTrue(in.read() == -1);
+        in.close();
 
         in = new ContentLengthInputStream(new SessionInputBufferMock(new byte[20]), 2L);
         in.read();
@@ -93,10 +95,12 @@ public class TestContentLengthInputStrea
         Assert.assertTrue(in.skip(10) <= 0);
         Assert.assertTrue(in.skip(-1) == 0);
         Assert.assertTrue(in.read() == -1);
+        in.close();
 
         in = new ContentLengthInputStream(new SessionInputBufferMock(new byte[20]), 10L);
         Assert.assertEquals(5,in.skip(5));
         Assert.assertEquals(5, in.read(new byte[20]));
+        in.close();
     }
 
     @Test

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java?rev=1444640&r1=1444639&r2=1444640&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java
Mon Feb 11 00:32:55 2013
@@ -64,6 +64,7 @@ public class TestIdentityInputStream {
         Assert.assertEquals(-1, instream.read());
         Assert.assertEquals(-1, instream.read(tmp, 0, tmp.length));
         Assert.assertEquals(-1, instream.read());
+        instream.close();
     }
 
     @Test
@@ -90,6 +91,7 @@ public class TestIdentityInputStream {
         final IdentityInputStream instream = new IdentityInputStream(receiver);
         instream.read();
         Assert.assertEquals(2, instream.available());
+        instream.close();
     }
 
 }



Mime
View raw message