This is an automated email from the ASF dual-hosted git repository.
sebb 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 4cede9a Try with resources
4cede9a is described below
commit 4cede9acdd94448c72abc37acfd2847228d66443
Author: Sebb <sebb@apache.org>
AuthorDate: Sat Aug 8 00:13:41 2020 +0100
Try with resources
---
.../apache/commons/io/LineIteratorTestCase.java | 25 +++++++++++-----------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/src/test/java/org/apache/commons/io/LineIteratorTestCase.java b/src/test/java/org/apache/commons/io/LineIteratorTestCase.java
index 26fcad9..6847f9a 100644
--- a/src/test/java/org/apache/commons/io/LineIteratorTestCase.java
+++ b/src/test/java/org/apache/commons/io/LineIteratorTestCase.java
@@ -19,6 +19,7 @@ package org.apache.commons.io;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@@ -110,12 +111,11 @@ public class LineIteratorTestCase {
@Test
public void testConstructor() throws Exception {
- try {
- new LineIterator(null);
- fail();
- } catch (final IllegalArgumentException ex) {
- // expected
- }
+ assertThrows(IllegalArgumentException.class, () -> {
+ try (
+ LineIterator li = new LineIterator(null);
+ ) { }
+ });
}
@Test
@@ -243,12 +243,13 @@ public class LineIteratorTestCase {
throw new IOException("hasNext");
}
};
- try {
- new LineIterator(reader).hasNext();
- fail("Expected IllegalStateException");
- } catch (final IllegalStateException e) {
- // expected
- }
+ try (
+ LineIterator li = new LineIterator(reader);
+ ) {
+ assertThrows(IllegalStateException.class, () -> {
+ li.hasNext();
+ });
+ }
}
@Test
|