commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r897678 - in /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp: TestConnectionPool.java datasources/TestPerUserPoolDataSource.java datasources/TestSharedPoolDataSource.java
Date Sun, 10 Jan 2010 18:21:04 GMT
Author: psteitz
Date: Sun Jan 10 18:21:03 2010
New Revision: 897678

URL: http://svn.apache.org/viewvc?rev=897678&view=rev
Log:
Eliminated unintended looping in mutipleThreads test.

Modified:
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java?rev=897678&r1=897677&r2=897678&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/TestConnectionPool.java Sun
Jan 10 18:21:03 2010
@@ -683,7 +683,21 @@
         }
     }
 
-    protected void multipleThreads(final int holdTime, final boolean expectError, long maxWait)
+    /**
+     * Launches a group of 2 * getMaxActive() threads, each of which will attempt to obtain
a connection
+     * from the pool, hold it for <holdTime> ms, and then return it to the pool.  If
<loopOnce> is false,
+     * threads will continue this process indefinitely.  If <expectingError> is true,
exactly 1/2 of the
+     * threads are expected to either throw exceptions or fail to complete. If <expectingError>
is false,
+     * all threads are expected to complete successfully.
+     * 
+     * @param holdTime time in ms that a thread holds a connection before returning it to
the pool
+     * @param expectError whether or not an error is expected
+     * @param loopOnce whether threads should complete the borrow - hold - return cycle only
once, or loop indefinitely
+     * @param maxWait passed in by client - has no impact on the test itself, but does get
reported
+     * 
+     * @throws Exception
+     */
+    protected void multipleThreads(final int holdTime, final boolean expectError, final boolean
loopOnce, final long maxWait)
             throws Exception {
                 long startTime = timeStamp();
                 final PoolTest[] pts = new PoolTest[2 * getMaxActive()];
@@ -696,8 +710,7 @@
                     }
                 };
                 for (int i = 0; i < pts.length; i++) {
-                    // If we are expecting an error, don't allow successful threads to loop
-                    (pts[i] = new PoolTest(threadGroup, holdTime, expectError)).start();
+                    (pts[i] = new PoolTest(threadGroup, holdTime, expectError, loopOnce)).start();
   
                 }
 
                 Thread.sleep(100L); // Wait for long enough to allow threads to start

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java?rev=897678&r1=897677&r2=897678&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestPerUserPoolDataSource.java
Sun Jan 10 18:21:03 2010
@@ -378,11 +378,11 @@
         final int defaultMaxWait = 430;
         ((PerUserPoolDataSource) ds).setDefaultMaxWait(defaultMaxWait);
         ((PerUserPoolDataSource) ds).setPerUserMaxWait("foo",new Integer(defaultMaxWait));
-        multipleThreads(1, false, defaultMaxWait);
+        multipleThreads(1, false, false, defaultMaxWait);
     }
 
     public void testMultipleThreads2() throws Exception {
-        multipleThreads(2 * (int)(getMaxWait()), true, getMaxWait());
+        multipleThreads(2 * (int)(getMaxWait()), true, false, getMaxWait());
     }
 
     public void testTransactionIsolationBehavior() throws Exception {

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java?rev=897678&r1=897677&r2=897678&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp/datasources/TestSharedPoolDataSource.java
Sun Jan 10 18:21:03 2010
@@ -368,11 +368,11 @@
         // some JVMs, e.g. Windows.
         final int defaultMaxWait = 430;
         ((SharedPoolDataSource) ds).setMaxWait(defaultMaxWait);
-        multipleThreads(1, false, defaultMaxWait);
+        multipleThreads(1, false, false, defaultMaxWait);
     }
 
     public void testMultipleThreads2() throws Exception {
-        multipleThreads(2 * (int)(getMaxWait()), true, getMaxWait());
+        multipleThreads(2 * (int)(getMaxWait()), true, false, getMaxWait());
     }
 
     public void testTransactionIsolationBehavior() throws Exception {



Mime
View raw message