diff --git a/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java b/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java index 574b79fc0..eaf64e67b 100644 --- a/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java +++ b/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java @@ -459,7 +459,12 @@ public void testDbcp597() throws SQLException { // The tester statement throws a SQLTimeoutException when the timeout is > 0 and < 5. sharedPoolDataSource.setValidationQueryTimeout(Duration.ofSeconds(1)); // The SQLTimeoutException is lost for now - final SQLException e = assertThrows(SQLException.class, sharedPoolDataSource::getConnection); + SQLException e = assertThrows(SQLException.class, sharedPoolDataSource::getConnection); + assertEquals(NoSuchElementException.class, e.getCause().getClass()); + // timeout > 0 and < 1 + sharedPoolDataSource.setValidationQueryTimeout(Duration.ofMillis(999)); + // The SQLTimeoutException is lost for now + e = assertThrows(SQLException.class, sharedPoolDataSource::getConnection); assertEquals(NoSuchElementException.class, e.getCause().getClass()); } }