This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbutils.git
The following commit(s) were added to refs/heads/master by this push:
new aae968a Modernize exception assertions in ResultSetIteratorTest and
QueryLoaderTest (#415)
aae968a is described below
commit aae968a66efe0fe08f3834dca88d2015bf9d88d4
Author: Mohd Irshad <[email protected]>
AuthorDate: Wed Nov 4 19:02:52 2026 +0530
Modernize exception assertions in ResultSetIteratorTest and QueryLoaderTest
(#415)
Signed-off-by: siddiqueirshad <[email protected]>
---
.../java/org/apache/commons/dbutils/QueryLoaderTest.java | 12 ++++--------
.../org/apache/commons/dbutils/ResultSetIteratorTest.java | 9 ++-------
2 files changed, 6 insertions(+), 15 deletions(-)
diff --git a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
index b600e18..0cb2a5c 100644
--- a/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
+++ b/src/test/java/org/apache/commons/dbutils/QueryLoaderTest.java
@@ -19,7 +19,7 @@ package org.apache.commons.dbutils;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertSame;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.util.Map;
@@ -51,13 +51,9 @@ class QueryLoaderTest extends BaseTestCase {
final QueryLoader queryLoader = QueryLoader.instance();
- try {
- queryLoader.load("e");
- fail("Expecting exception: IllegalArgumentException");
- } catch (final IllegalArgumentException e) {
- assertEquals("e not found.", e.getMessage());
- assertEquals(QueryLoader.class.getName(),
e.getStackTrace()[0].getClassName());
- }
+ final IllegalArgumentException e =
assertThrows(IllegalArgumentException.class, () -> queryLoader.load("e"));
+ assertEquals("e not found.", e.getMessage());
+ assertEquals(QueryLoader.class.getName(),
e.getStackTrace()[0].getClassName());
}
diff --git
a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
index 8dc3619..d6261bd 100644
--- a/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
+++ b/src/test/java/org/apache/commons/dbutils/ResultSetIteratorTest.java
@@ -20,7 +20,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import java.sql.ResultSet;
@@ -75,12 +74,8 @@ class ResultSetIteratorTest extends BaseTestCase {
final Throwable throwable = new Throwable();
final SQLException sqlException = new SQLException(throwable);
- try {
- resultSetIterator.rethrow(sqlException);
- fail("Expecting exception: RuntimeException");
- } catch (final RuntimeException e) {
- assertEquals(ResultSetIterator.class.getName(),
e.getStackTrace()[0].getClassName());
- }
+ final RuntimeException e = assertThrows(RuntimeException.class, () ->
resultSetIterator.rethrow(sqlException));
+ assertEquals(ResultSetIterator.class.getName(),
e.getStackTrace()[0].getClassName());
}