This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git
The following commit(s) were added to refs/heads/master by this push:
new 95248e3 Rewrite test using JUnit 5 APIs.
95248e3 is described below
commit 95248e3798a4fa4091f735cee9e540770e057cd7
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Jul 12 09:09:41 2021 -0400
Rewrite test using JUnit 5 APIs.
---
.../commons/io/input/BrokenInputStreamTest.java | 62 +++++-----------------
1 file changed, 12 insertions(+), 50 deletions(-)
diff --git
a/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
b/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
index 0394162..62727dc 100644
--- a/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BrokenInputStreamTest.java
@@ -17,7 +17,7 @@
package org.apache.commons.io.input;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.io.InputStream;
@@ -28,7 +28,6 @@ import org.junit.jupiter.api.Test;
/**
* JUnit Test Case for {@link BrokenInputStream}.
*/
-@SuppressWarnings("ResultOfMethodCallIgnored")
public class BrokenInputStreamTest {
private IOException exception;
@@ -42,67 +41,30 @@ public class BrokenInputStreamTest {
}
@Test
- public void testRead() {
- try {
- stream.read();
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
-
- try {
- stream.read(new byte[1]);
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
-
- try {
- stream.read(new byte[1], 0, 1);
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
+ public void testAvailable() {
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.available()));
}
@Test
- public void testAvailable() {
- try {
- stream.available();
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
+ public void testClose() {
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.close()));
}
@Test
- public void testSkip() {
- try {
- stream.skip(1);
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
+ public void testRead() {
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.read()));
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.read(new byte[1])));
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.read(new byte[1], 0, 1)));
}
@Test
public void testReset() {
- try {
- stream.reset();
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.reset()));
}
@Test
- public void testClose() {
- try {
- stream.close();
- fail("Expected exception not thrown.");
- } catch (final IOException e) {
- assertEquals(exception, e);
- }
+ public void testSkip() {
+ assertEquals(exception, assertThrows(IOException.class, () ->
stream.skip(1)));
}
}