hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1480299 - in /httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io: TestContentLengthInputStream.java TestContentLengthOutputStream.java TestIdentityInputStream.java
Date Wed, 08 May 2013 14:35:44 GMT
Author: olegk
Date: Wed May  8 14:35:43 2013
New Revision: 1480299

URL: http://svn.apache.org/r1480299
Log:
Fixed resource leak warnings in test cases

Modified:
    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/TestContentLengthOutputStream.java
    httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestIdentityInputStream.java

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=1480299&r1=1480298&r2=1480299&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
Wed May  8 14:35:43 2013
@@ -44,7 +44,9 @@ public class TestContentLengthInputStrea
 
     @Test
     public void testConstructors() throws Exception {
-        new ContentLengthInputStream(new SessionInputBufferMock(new byte[] {}), 10);
+        final ContentLengthInputStream in = new ContentLengthInputStream(
+                new SessionInputBufferMock(new byte[] {}), 0);
+        in.close();
         try {
             new ContentLengthInputStream(null, 10);
             Assert.fail("IllegalArgumentException should have been thrown");
@@ -106,10 +108,11 @@ public class TestContentLengthInputStrea
     @Test
     public void testAvailable() throws IOException {
         final InputStream in = new ContentLengthInputStream(
-                new SessionInputBufferMock(new byte[] {1, 2, 3}), 10L);
+                new SessionInputBufferMock(new byte[] {1, 2, 3}), 3L);
         Assert.assertEquals(0, in.available());
         in.read();
         Assert.assertEquals(2, in.available());
+        in.close();
     }
 
     @Test
@@ -161,6 +164,11 @@ public class TestContentLengthInputStrea
             Assert.fail("ConnectionClosedException should have been closed");
         } catch (final ConnectionClosedException ex) {
         }
+        try {
+            in.close();
+            Assert.fail("ConnectionClosedException should have been closed");
+        } catch (final ConnectionClosedException ex) {
+        }
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthOutputStream.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthOutputStream.java?rev=1480299&r1=1480298&r2=1480299&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthOutputStream.java
(original)
+++ httpcomponents/httpcore/trunk/httpcore/src/test/java/org/apache/http/impl/io/TestContentLengthOutputStream.java
Wed May  8 14:35:43 2013
@@ -39,7 +39,9 @@ public class TestContentLengthOutputStre
 
     @Test
     public void testConstructors() throws Exception {
-        new ContentLengthOutputStream(new SessionOutputBufferMock(), 10L);
+        final ContentLengthOutputStream in = new ContentLengthOutputStream(
+                new SessionOutputBufferMock(), 10L);
+        in.close();
         try {
             new ContentLengthOutputStream(null, 10L);
             Assert.fail("IllegalArgumentException should have been thrown");

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=1480299&r1=1480298&r2=1480299&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
Wed May  8 14:35:43 2013
@@ -41,7 +41,8 @@ public class TestIdentityInputStream {
     @Test
     public void testConstructor() throws Exception {
         final SessionInputBuffer receiver = new SessionInputBufferMock(new byte[] {});
-        new IdentityInputStream(receiver);
+        final IdentityInputStream in = new IdentityInputStream(receiver);
+        in.close();
         try {
             new IdentityInputStream(null);
             Assert.fail("IllegalArgumentException should have been thrown");



Mime
View raw message