Skip to content

Commit b5444a5

Browse files
committed
Add missing tests as discovered with Cobertura.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1304170 13f79535-47bb-0310-9956-ffa450edef68
1 parent c0e29f7 commit b5444a5

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

src/test/java/org/apache/commons/io/IOUtilsTestCase.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.ByteArrayOutputStream;
2121
import java.io.CharArrayReader;
2222
import java.io.CharArrayWriter;
23+
import java.io.Closeable;
2324
import java.io.EOFException;
2425
import java.io.File;
2526
import java.io.FileInputStream;
@@ -31,6 +32,8 @@
3132
import java.io.InputStreamReader;
3233
import java.io.Reader;
3334
import java.io.StringReader;
35+
import java.net.ServerSocket;
36+
import java.net.Socket;
3437
import java.net.URI;
3538
import java.net.URL;
3639
import java.nio.channels.Selector;
@@ -109,6 +112,40 @@ public void testCloseQuietlyNullSelector() {
109112
IOUtils.closeQuietly(selector);
110113
}
111114

115+
public void testCloseableCloseQuietlyOnException() {
116+
IOUtils.closeQuietly(new Closeable() {
117+
public void close() throws IOException {
118+
throw new IOException();
119+
}
120+
});
121+
}
122+
123+
public void testSocketCloseQuietlyOnException() {
124+
IOUtils.closeQuietly(new Socket() {
125+
public void close() throws IOException {
126+
throw new IOException();
127+
}
128+
});
129+
}
130+
131+
public void testServerSocketCloseQuietlyOnException() throws IOException {
132+
IOUtils.closeQuietly(new ServerSocket() {
133+
public void close() throws IOException {
134+
throw new IOException();
135+
}
136+
});
137+
}
138+
139+
public void testSocketCloseQuietly() {
140+
IOUtils.closeQuietly((Socket) null);
141+
IOUtils.closeQuietly(new Socket());
142+
}
143+
144+
public void testServerSocketCloseQuietly() throws IOException {
145+
IOUtils.closeQuietly((ServerSocket) null);
146+
IOUtils.closeQuietly(new ServerSocket());
147+
}
148+
112149
public void testCloseQuietlySelector() {
113150
Selector selector = null;
114151
try {

0 commit comments

Comments
 (0)