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 90d8d2bfd3345b20e375c421f35b7be9730c21d9 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Aug 27 16:21:34 2023 -0400 Use try-with-resources --- .../commons/dbcp2/TestDelegatingCallableStatement.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java b/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java index 6d9be2b8..eca74a27 100644 --- a/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java +++ b/src/test/java/org/apache/commons/dbcp2/TestDelegatingCallableStatement.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.verify; import java.sql.CallableStatement; import java.sql.Connection; +import java.sql.ResultSet; import java.sql.SQLException; import org.junit.jupiter.api.BeforeEach; @@ -42,22 +43,25 @@ public class TestDelegatingCallableStatement { public void setUp() throws Exception { conn = new TesterConnection("test", "test"); obj = mock(CallableStatement.class); - final DelegatingConnection<Connection> delegatingConnection = new DelegatingConnection<>(conn); - delegate = new DelegatingCallableStatement(delegatingConnection, obj); + delegate = new DelegatingCallableStatement(new DelegatingConnection<>(conn), obj); } @Test public void testExecuteQueryReturnsNotNull() throws Exception { - final TesterCallableStatement delegateStmt = new TesterCallableStatement(conn,"select * from foo"); + final TesterCallableStatement delegateStmt = new TesterCallableStatement(conn, "select * from foo"); obj = new DelegatingCallableStatement(new DelegatingConnection<>(conn), delegateStmt); - assertNotNull(obj.executeQuery()); + try (ResultSet rs = obj.executeQuery()) { + assertNotNull(rs); + } } @Test public void testExecuteQueryReturnsNull() throws Exception { final TesterCallableStatement delegateStmt = new TesterCallableStatement(conn,"null"); obj = new DelegatingCallableStatement(new DelegatingConnection<>(conn), delegateStmt); - assertNull(obj.executeQuery()); + try (ResultSet rs = obj.executeQuery()) { + assertNotNull(rs); + } } @Test