You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/12/14 14:07:54 UTC

(commons-dbcp) 05/19: Use JUnit 5's assertThrows()

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-dbcp.git

commit 282d4214d9b983b96daac2d955d0be8c5f3c8f61
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Dec 14 08:25:38 2024 -0500

    Use JUnit 5's assertThrows()
---
 .../java/org/apache/commons/dbcp2/TestPoolableConnection.java  | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java b/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
index 164cb25a..a49d10cd 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestPoolableConnection.java
@@ -121,13 +121,9 @@ public class TestPoolableConnection {
 
         // Set up non-fatal exception
         nativeConnection.setFailure(new SQLException("Not fatal error.", "Invalid syntax."));
-        try {
-            conn.createStatement();
-            fail("Should throw SQL exception.");
-        } catch (final SQLException ignored) {
-            // cleanup failure
-            nativeConnection.setFailure(null);
-        }
+        assertThrows(SQLException.class, conn::createStatement);
+        // cleanup failure
+        nativeConnection.setFailure(null);
 
         // validate should not fail - error was not fatal and condition was cleaned up
         conn.validate("SELECT 1", 1000);