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 b785d75 Rewrite test using JUnit 5 APIs. b785d75 is described below commit b785d75506cf29863a1b333a99aa914ca4d6af4b Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Jul 12 08:27:13 2021 -0400 Rewrite test using JUnit 5 APIs. --- .../apache/commons/io/input/BrokenReaderTest.java | 69 ++++++---------------- 1 file changed, 17 insertions(+), 52 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java b/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java index 29ee726..ba26938 100644 --- a/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java +++ b/src/test/java/org/apache/commons/io/input/BrokenReaderTest.java @@ -18,7 +18,7 @@ package org.apache.commons.io.input; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import java.io.Reader; @@ -29,7 +29,6 @@ import org.junit.jupiter.api.Test; /** * JUnit Test Case for {@link BrokenReader}. */ -@SuppressWarnings("ResultOfMethodCallIgnored") public class BrokenReaderTest { private IOException exception; @@ -44,12 +43,7 @@ public class BrokenReaderTest { @Test public void testClose() { - try { - brokenReader.close(); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.close())); } @Test @@ -59,66 +53,37 @@ public class BrokenReaderTest { @Test public void testMark() { - try { - brokenReader.mark(1); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.mark(1))); } @Test public void testRead() { - try { - brokenReader.read(); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } - - try { - brokenReader.read(new char[1]); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } - - try { - brokenReader.read(new char[1], 0, 1); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.read())); + } + + @Test + public void testReadCharArray() { + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.read(new char[1]))); + } + + @Test + public void testReadCharArrayIndexed() { + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.read(new char[1], 0, 1))); } @Test public void testReady() { - try { - brokenReader.ready(); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.ready())); } @Test public void testReset() { - try { - brokenReader.reset(); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.reset())); } @Test public void testSkip() { - try { - brokenReader.skip(1); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenReader.skip(1))); } }