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 5abe7b1 Rewrite test using JUnit 5 APIs. 5abe7b1 is described below commit 5abe7b15f8ad26c5eed2123a8716e55cf5d81d72 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Mon Jul 12 08:30:07 2021 -0400 Rewrite test using JUnit 5 APIs. --- .../apache/commons/io/output/BrokenWriterTest.java | 49 +++++++--------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/src/test/java/org/apache/commons/io/output/BrokenWriterTest.java b/src/test/java/org/apache/commons/io/output/BrokenWriterTest.java index af9a462..31aa932 100644 --- a/src/test/java/org/apache/commons/io/output/BrokenWriterTest.java +++ b/src/test/java/org/apache/commons/io/output/BrokenWriterTest.java @@ -17,7 +17,7 @@ package org.apache.commons.io.output; 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.Writer; @@ -32,56 +32,37 @@ public class BrokenWriterTest { private IOException exception; - private Writer writer; + private Writer brokenWriter; @BeforeEach public void setUp() { exception = new IOException("test exception"); - writer = new BrokenWriter(exception); + brokenWriter = new BrokenWriter(exception); } @Test - public void testWrite() { - try { - writer.write(1); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + public void testWriteInt() { + assertEquals(exception, assertThrows(IOException.class, () -> brokenWriter.write(1))); + } - try { - writer.write(new char[1]); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + @Test + public void testWriteCharArray() { + assertEquals(exception, assertThrows(IOException.class, () -> brokenWriter.write(new char[1]))); + } - try { - writer.write(new char[1], 0, 1); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + @Test + public void testWriteCharArrayIndexed() { + assertEquals(exception, assertThrows(IOException.class, () -> brokenWriter.write(new char[1], 0, 1))); } @Test public void testFlush() { - try { - writer.flush(); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenWriter.flush())); } @Test public void testClose() { - try { - writer.close(); - fail("Expected exception not thrown."); - } catch (final IOException e) { - assertEquals(exception, e); - } + assertEquals(exception, assertThrows(IOException.class, () -> brokenWriter.close())); } }