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 d9d7a57da31992dc7ebdd18e700c066325660daf
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Dec 11 17:48:43 2025 -0500

    Sort members
---
 .../apache/commons/dbcp2/TestBasicDataSource.java  | 60 +++++++++++-----------
 .../datasources/TestCPDSConnectionFactory.java     | 12 ++---
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java 
b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
index 86800651..90a03ba8 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
@@ -62,6 +62,36 @@ public class TestBasicDataSource extends TestConnectionPool {
 
     protected BasicDataSource ds;
 
+    /**
+     * Cycle through idle connections and verify that they are all valid.
+     * Assumes we are the only client of the pool.
+     *
+     * @throws Exception if an error occurs
+     */
+    private void checkIdleValid() throws Exception {
+        final Set<Connection> idleConnections = new HashSet<>(); // idle 
connections
+        // Get idle connections by repeatedly making connection requests up to 
NumIdle
+        for (int i = 0; i < ds.getNumIdle(); i++) {
+            final Connection conn = ds.getConnection();
+            idleConnections.add(conn);
+        }
+        // Cycle through idle connections and verify that they are valid
+        for (final Connection conn : idleConnections) {
+            assertTrue(conn.isValid(2), "Connection should be valid");
+            conn.close();
+        }
+    }
+
+    /**
+     * Check that maxTotal and maxIdle are not exceeded
+     *
+     * @throws Exception
+     */
+    private void checkLimits() throws Exception {
+        assertTrue(ds.getNumActive() + ds.getNumIdle() <= getMaxTotal(), 
"Total connections exceed maxTotal");
+        assertTrue(ds.getNumIdle() <= ds.getMaxIdle(), "Idle connections 
exceed maxIdle");
+    }
+
     protected BasicDataSource createDataSource() throws Exception {
         return new BasicDataSource();
     }
@@ -568,36 +598,6 @@ public class TestBasicDataSource extends 
TestConnectionPool {
         assertNull(ds.getRegisteredJmxName());
     }
 
-    /**
-     * Cycle through idle connections and verify that they are all valid.
-     * Assumes we are the only client of the pool.
-     *
-     * @throws Exception if an error occurs
-     */
-    private void checkIdleValid() throws Exception {
-        final Set<Connection> idleConnections = new HashSet<>(); // idle 
connections
-        // Get idle connections by repeatedly making connection requests up to 
NumIdle
-        for (int i = 0; i < ds.getNumIdle(); i++) {
-            final Connection conn = ds.getConnection();
-            idleConnections.add(conn);
-        }
-        // Cycle through idle connections and verify that they are valid
-        for (final Connection conn : idleConnections) {
-            assertTrue(conn.isValid(2), "Connection should be valid");
-            conn.close();
-        }
-    }
-
-    /**
-     * Check that maxTotal and maxIdle are not exceeded
-     *
-     * @throws Exception
-     */
-    private void checkLimits() throws Exception {
-        assertTrue(ds.getNumActive() + ds.getNumIdle() <= getMaxTotal(), 
"Total connections exceed maxTotal");
-        assertTrue(ds.getNumIdle() <= ds.getMaxIdle(), "Idle connections 
exceed maxIdle");
-    }
-
 
     @Test
     void testInvalidateConnection() throws Exception {
diff --git 
a/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
 
b/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
index 5f94e39d..4cc0418f 100644
--- 
a/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
+++ 
b/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
@@ -40,6 +40,12 @@ public class TestCPDSConnectionFactory {
 
     protected ConnectionPoolDataSourceProxy cpds;
 
+    private void checkPoolLimits(final 
GenericObjectPool<PooledConnectionAndInfo> pool) {
+        assertTrue(pool.getNumActive() + pool.getNumIdle() <= 
pool.getMaxTotal(),
+                "Active + Idle should be <= MaxTotal");
+        assertTrue(pool.getNumIdle() <= pool.getMaxIdle(), "Idle should be <= 
MaxIdle");
+    }
+
     @BeforeEach
     public void setUp() throws Exception {
         cpds = new ConnectionPoolDataSourceProxy(new DriverAdapterCPDS());
@@ -50,12 +56,6 @@ public class TestCPDSConnectionFactory {
         delegate.setPassword("password");
     }
 
-    private void checkPoolLimits(final 
GenericObjectPool<PooledConnectionAndInfo> pool) {
-        assertTrue(pool.getNumActive() + pool.getNumIdle() <= 
pool.getMaxTotal(),
-                "Active + Idle should be <= MaxTotal");
-        assertTrue(pool.getNumIdle() <= pool.getMaxIdle(), "Idle should be <= 
MaxIdle");
-    }
-
     /**
      * JIRA DBCP-216
      *

Reply via email to