Skip to content

Commit 55a8ab7

Browse files
committed
Add AutoCloseInputStream tests
1 parent b5c1049 commit 55a8ab7

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/test/java/org/apache/commons/io/input/AutoCloseInputStreamTest.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class AutoCloseInputStreamTest {
4040

4141
private boolean closed;
4242

43+
@SuppressWarnings("deprecation")
4344
@BeforeEach
4445
public void setUp() {
4546
data = new byte[] { 'x', 'y', 'z' };
@@ -52,6 +53,16 @@ public void close() {
5253
closed = false;
5354
}
5455

56+
@Test
57+
public void testAvailableAfterClose() throws IOException {
58+
final InputStream shadow;
59+
try (InputStream inputStream = new AutoCloseInputStream(new ByteArrayInputStream(data))) {
60+
assertEquals(3, inputStream.available());
61+
shadow = inputStream;
62+
}
63+
assertEquals(0, shadow.available());
64+
}
65+
5566
@Test
5667
public void testAvailableAll() throws IOException {
5768
try (InputStream inputStream = new AutoCloseInputStream(new ByteArrayInputStream(data))) {
@@ -178,4 +189,14 @@ public void testResetBeforeEndSetInputStream() throws IOException {
178189
}
179190
}
180191

192+
@Test
193+
public void testrReadAfterClose() throws IOException {
194+
final InputStream shadow;
195+
try (InputStream inputStream = new AutoCloseInputStream(new ByteArrayInputStream(data))) {
196+
assertEquals(3, inputStream.available());
197+
shadow = inputStream;
198+
}
199+
assertEquals(IOUtils.EOF, shadow.read());
200+
}
201+
181202
}

0 commit comments

Comments
 (0)