commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1304170 - /commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
Date Fri, 23 Mar 2012 02:57:00 GMT
Author: ggregory
Date: Fri Mar 23 02:56:59 2012
New Revision: 1304170

URL: http://svn.apache.org/viewvc?rev=1304170&view=rev
Log:
Add missing tests as discovered with Cobertura.

Modified:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java?rev=1304170&r1=1304169&r2=1304170&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java (original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/IOUtilsTestCase.java Fri Mar
23 02:56:59 2012
@@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.CharArrayReader;
 import java.io.CharArrayWriter;
+import java.io.Closeable;
 import java.io.EOFException;
 import java.io.File;
 import java.io.FileInputStream;
@@ -31,6 +32,8 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringReader;
+import java.net.ServerSocket;
+import java.net.Socket;
 import java.net.URI;
 import java.net.URL;
 import java.nio.channels.Selector;
@@ -109,6 +112,40 @@ public class IOUtilsTestCase extends Fil
         IOUtils.closeQuietly(selector);
     }
 
+    public void testCloseableCloseQuietlyOnException() {
+        IOUtils.closeQuietly(new Closeable() {            
+            public void close() throws IOException {
+                throw new IOException();
+            }
+        });
+    }
+
+    public void testSocketCloseQuietlyOnException() {
+        IOUtils.closeQuietly(new Socket() {            
+            public void close() throws IOException {
+                throw new IOException();
+            }
+        });
+    }
+
+    public void testServerSocketCloseQuietlyOnException() throws IOException {
+        IOUtils.closeQuietly(new ServerSocket() {            
+            public void close() throws IOException {
+                throw new IOException();
+            }
+        });
+    }
+
+    public void testSocketCloseQuietly() {
+        IOUtils.closeQuietly((Socket) null);
+        IOUtils.closeQuietly(new Socket());
+    }
+
+    public void testServerSocketCloseQuietly() throws IOException {
+        IOUtils.closeQuietly((ServerSocket) null);
+        IOUtils.closeQuietly(new ServerSocket());
+    }
+
     public void testCloseQuietlySelector() {
         Selector selector = null;
         try {



Mime
View raw message