tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r710199 [4/4] - in /tomcat/trunk/modules/jdbc-pool: ./ doc/ java/org/apache/tomcat/jdbc/pool/ java/org/apache/tomcat/jdbc/pool/jmx/ test/org/apache/tomcat/jdbc/test/
Date Mon, 03 Nov 2008 22:38:56 GMT
Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java Mon Nov  3 14:38:55 2008
@@ -1,371 +1,371 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.test;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.sql.ResultSet;
-
-import javax.sql.DataSource;
-
-import org.apache.tomcat.jdbc.pool.DataSourceFactory;
-
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class CheckOutThreadTest extends DefaultTestCase {
-    public CheckOutThreadTest(String name) {
-        super(name);
-    }
-
-    CountDownLatch latch = null;
-
-    public void testDBCPThreads10Connections10() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.threadcount = 10;
-        this.transferProperties();
-        this.tDatasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-dbcp-"+i);
-            t.d = this.tDatasource;
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testDBCPThreads10Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads10Connections10() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.threadcount = 10;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads10Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testDBCPThreads20Connections10() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.threadcount = 20;
-        this.transferProperties();
-        this.tDatasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-dbcp-"+i);
-            t.d = this.tDatasource;
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testDBCPThreads20Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads20Connections10() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.threadcount = 20;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads20Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads20Connections10Fair() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setFairQueue(true);
-        this.threadcount = 20;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads20Connections10Fair]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    
-    public void testDBCPThreads10Connections10Validate() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
-        this.datasource.getPoolProperties().setTestOnBorrow(true);
-        this.threadcount = 10;
-        this.transferProperties();
-        this.tDatasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-dbcp-validate-"+i);
-            t.d = this.tDatasource;
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testDBCPThreads10Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads10Connections10Validate() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
-        this.datasource.getPoolProperties().setTestOnBorrow(true);
-        this.threadcount = 10;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-validate-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads10Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testDBCPThreads20Connections10Validate() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
-        this.datasource.getPoolProperties().setTestOnBorrow(true);
-        this.threadcount = 20;
-        this.transferProperties();
-        this.tDatasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-dbcp-validate-"+i);
-            t.d = this.tDatasource;
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testDBCPThreads20Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads10Connections20Validate() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
-        this.datasource.getPoolProperties().setTestOnBorrow(true);
-        this.threadcount = 20;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-validate-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads20Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-    
-    public void testDBCPThreads10Connections10WithQuery() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setTestOnBorrow(false);
-        this.threadcount = 10;
-        this.transferProperties();
-        this.tDatasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-dbcp-"+i);
-            t.d = this.tDatasource;
-            t.query = "select * from user";
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testDBCPThreads10Connections10WithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads10Connections10WithQuery() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setTestOnBorrow(false);
-        this.threadcount = 10;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.query = "select * from user";
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads10Connections10WithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-    
-    public void testDBCPThreads10Connections10WithValidateWithQuery() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setTestOnBorrow(true);
-        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
-        this.threadcount = 10;
-        this.transferProperties();
-        this.tDatasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-dbcp-"+i);
-            t.d = this.tDatasource;
-            t.query = "select * from user";
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testDBCPThreads10Connections10WithValidateWithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-
-    public void testPoolThreads10Connections10WithValidateWithQuery() throws Exception {
-        init();
-        this.datasource.getPoolProperties().setMaxActive(10);
-        this.datasource.getPoolProperties().setTestOnBorrow(true);
-        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
-        this.threadcount = 10;
-        this.transferProperties();
-        this.datasource.getConnection().close();
-        latch = new CountDownLatch(threadcount);
-        long start = System.currentTimeMillis();
-        for (int i=0; i<threadcount; i++) {
-            TestThread t = new TestThread();
-            t.setName("tomcat-pool-"+i);
-            t.d = DataSourceFactory.getDataSource(this.datasource);
-            t.query = "select * from user";
-            t.start();
-        }
-        latch.await();
-        long delta = System.currentTimeMillis() - start;
-        System.out.println("[testPoolThreads10Connections10WithValidateWithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
-        tearDown();
-    }
-    
-    public class TestThread extends Thread {
-        protected DataSource d;
-        protected String query = null;
-        public void run() {
-            long max = -1, totalmax=0, totalcmax=0, cmax = -1, nroffetch = 0, totalruntime = 0;
-            try {
-                for (int i = 0; i < CheckOutThreadTest.this.iterations; i++) {
-                    long start = System.nanoTime();
-                    Connection con = null;
-                    try {
-                        con = d.getConnection();
-                        long delta = System.nanoTime() - start;
-                        totalmax += delta;
-                        max = Math.max(delta, max);
-                        nroffetch++;
-                        if (query!=null) {
-                            Statement st = con.createStatement();
-                            ResultSet rs = st.executeQuery(query);
-                            while (rs.next()) {
-                            }
-                            rs.close();
-                            st.close();
-                        }
-                    } finally {
-                        long cstart = System.nanoTime();
-                        if (con!=null) try {con.close();}catch(Exception x) {x.printStackTrace();}
-                        long cdelta = System.nanoTime() - cstart;
-                        totalcmax += cdelta;
-                        cmax = Math.max(cdelta, cmax);
-                    }
-                    totalruntime+=(System.nanoTime()-start);
-                }
-
-            } catch (Exception x) {
-                x.printStackTrace();
-            } finally {
-                CheckOutThreadTest.this.latch.countDown();
-            }
-            if (System.getProperty("print-thread-stats")!=null) {
-                System.out.println("["+getName()+"] "+
-                    "\n\tMax time to retrieve connection:"+(((float)max)/1000f/1000f)+" ms."+
-                    "\n\tTotal time to retrieve connection:"+(((float)totalmax)/1000f/1000f)+" ms."+
-                    "\n\tAverage time to retrieve connection:"+(((float)totalmax)/1000f/1000f)/(float)nroffetch+" ms."+
-                    "\n\tMax time to close connection:"+(((float)cmax)/1000f/1000f)+" ms."+
-                    "\n\tTotal time to close connection:"+(((float)totalcmax)/1000f/1000f)+" ms."+
-                    "\n\tAverage time to close connection:"+(((float)totalcmax)/1000f/1000f)/(float)nroffetch+" ms."+
-                    "\n\tRun time:"+(((float)totalruntime)/1000f/1000f)+" ms."+
-                    "\n\tNr of fetch:"+nroffetch);
-            }
-        }
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.test;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.sql.ResultSet;
+
+import javax.sql.DataSource;
+
+import org.apache.tomcat.jdbc.pool.DataSourceFactory;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class CheckOutThreadTest extends DefaultTestCase {
+    public CheckOutThreadTest(String name) {
+        super(name);
+    }
+
+    CountDownLatch latch = null;
+
+    public void testDBCPThreads10Connections10() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.tDatasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-dbcp-"+i);
+            t.d = this.tDatasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testDBCPThreads10Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads10Connections10() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads10Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testDBCPThreads20Connections10() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.threadcount = 20;
+        this.transferProperties();
+        this.tDatasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-dbcp-"+i);
+            t.d = this.tDatasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testDBCPThreads20Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads20Connections10() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.threadcount = 20;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads20Connections10]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads20Connections10Fair() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setFairQueue(true);
+        this.threadcount = 20;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads20Connections10Fair]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    
+    public void testDBCPThreads10Connections10Validate() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.tDatasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-dbcp-validate-"+i);
+            t.d = this.tDatasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testDBCPThreads10Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads10Connections10Validate() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-validate-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads10Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testDBCPThreads20Connections10Validate() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.threadcount = 20;
+        this.transferProperties();
+        this.tDatasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-dbcp-validate-"+i);
+            t.d = this.tDatasource;
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testDBCPThreads20Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads10Connections20Validate() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.threadcount = 20;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-validate-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads20Connections10Validate]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+    
+    public void testDBCPThreads10Connections10WithQuery() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setTestOnBorrow(false);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.tDatasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-dbcp-"+i);
+            t.d = this.tDatasource;
+            t.query = "select * from user";
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testDBCPThreads10Connections10WithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads10Connections10WithQuery() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setTestOnBorrow(false);
+        this.threadcount = 10;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.query = "select * from user";
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads10Connections10WithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+    
+    public void testDBCPThreads10Connections10WithValidateWithQuery() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.threadcount = 10;
+        this.transferProperties();
+        this.tDatasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-dbcp-"+i);
+            t.d = this.tDatasource;
+            t.query = "select * from user";
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testDBCPThreads10Connections10WithValidateWithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+
+    public void testPoolThreads10Connections10WithValidateWithQuery() throws Exception {
+        init();
+        this.datasource.getPoolProperties().setMaxActive(10);
+        this.datasource.getPoolProperties().setTestOnBorrow(true);
+        this.datasource.getPoolProperties().setValidationQuery("SELECT 1");
+        this.threadcount = 10;
+        this.transferProperties();
+        this.datasource.getConnection().close();
+        latch = new CountDownLatch(threadcount);
+        long start = System.currentTimeMillis();
+        for (int i=0; i<threadcount; i++) {
+            TestThread t = new TestThread();
+            t.setName("tomcat-pool-"+i);
+            t.d = DataSourceFactory.getDataSource(this.datasource);
+            t.query = "select * from user";
+            t.start();
+        }
+        latch.await();
+        long delta = System.currentTimeMillis() - start;
+        System.out.println("[testPoolThreads10Connections10WithValidateWithQuery]Test complete:"+delta+" ms. Iterations:"+(threadcount*this.iterations));
+        tearDown();
+    }
+    
+    public class TestThread extends Thread {
+        protected DataSource d;
+        protected String query = null;
+        public void run() {
+            long max = -1, totalmax=0, totalcmax=0, cmax = -1, nroffetch = 0, totalruntime = 0;
+            try {
+                for (int i = 0; i < CheckOutThreadTest.this.iterations; i++) {
+                    long start = System.nanoTime();
+                    Connection con = null;
+                    try {
+                        con = d.getConnection();
+                        long delta = System.nanoTime() - start;
+                        totalmax += delta;
+                        max = Math.max(delta, max);
+                        nroffetch++;
+                        if (query!=null) {
+                            Statement st = con.createStatement();
+                            ResultSet rs = st.executeQuery(query);
+                            while (rs.next()) {
+                            }
+                            rs.close();
+                            st.close();
+                        }
+                    } finally {
+                        long cstart = System.nanoTime();
+                        if (con!=null) try {con.close();}catch(Exception x) {x.printStackTrace();}
+                        long cdelta = System.nanoTime() - cstart;
+                        totalcmax += cdelta;
+                        cmax = Math.max(cdelta, cmax);
+                    }
+                    totalruntime+=(System.nanoTime()-start);
+                }
+
+            } catch (Exception x) {
+                x.printStackTrace();
+            } finally {
+                CheckOutThreadTest.this.latch.countDown();
+            }
+            if (System.getProperty("print-thread-stats")!=null) {
+                System.out.println("["+getName()+"] "+
+                    "\n\tMax time to retrieve connection:"+(((float)max)/1000f/1000f)+" ms."+
+                    "\n\tTotal time to retrieve connection:"+(((float)totalmax)/1000f/1000f)+" ms."+
+                    "\n\tAverage time to retrieve connection:"+(((float)totalmax)/1000f/1000f)/(float)nroffetch+" ms."+
+                    "\n\tMax time to close connection:"+(((float)cmax)/1000f/1000f)+" ms."+
+                    "\n\tTotal time to close connection:"+(((float)totalcmax)/1000f/1000f)+" ms."+
+                    "\n\tAverage time to close connection:"+(((float)totalcmax)/1000f/1000f)/(float)nroffetch+" ms."+
+                    "\n\tRun time:"+(((float)totalruntime)/1000f/1000f)+" ms."+
+                    "\n\tNr of fetch:"+nroffetch);
+            }
+        }
+    }
+}

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CheckOutThreadTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java Mon Nov  3 14:38:55 2008
@@ -1,63 +1,63 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.test;
-
-import java.util.Properties;
-
-import org.apache.tomcat.jdbc.pool.DataSourceFactory;
-import org.apache.tomcat.jdbc.pool.PoolProperties;
-
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class DefaultProperties extends PoolProperties {
-    public DefaultProperties() {
-        dbProperties = new Properties();
-        url = "jdbc:mysql://localhost:3306/mysql?autoReconnect=true";
-        driverClassName = "com.mysql.jdbc.Driver";
-        password = "password";
-        username = "root";
-        defaultAutoCommit = true;
-        defaultReadOnly = false;
-        defaultTransactionIsolation = DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION;
-        connectionProperties = null;
-        defaultCatalog = null;
-        initialSize = 10;
-        maxActive = 100;
-        maxIdle = initialSize;
-        minIdle = initialSize;
-        maxWait = 10000;
-        validationQuery = "SELECT 1";
-        testOnBorrow = true;
-        testOnReturn = false;
-        testWhileIdle = true;
-        timeBetweenEvictionRunsMillis = 5000;
-        numTestsPerEvictionRun = 0;
-        minEvictableIdleTimeMillis = 1000;
-        accessToUnderlyingConnectionAllowed = false;
-        removeAbandoned = true;
-        removeAbandonedTimeout = 5000;
-        logAbandoned = true;
-        loginTimeout = 0;
-        validationInterval = 0; //always validate
-        initSQL = null;
-        testOnConnect = false;;
-        dbProperties.setProperty("user",username);
-        dbProperties.setProperty("password",password);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.test;
+
+import java.util.Properties;
+
+import org.apache.tomcat.jdbc.pool.DataSourceFactory;
+import org.apache.tomcat.jdbc.pool.PoolProperties;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class DefaultProperties extends PoolProperties {
+    public DefaultProperties() {
+        dbProperties = new Properties();
+        url = "jdbc:mysql://localhost:3306/mysql?autoReconnect=true";
+        driverClassName = "com.mysql.jdbc.Driver";
+        password = "password";
+        username = "root";
+        defaultAutoCommit = true;
+        defaultReadOnly = false;
+        defaultTransactionIsolation = DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION;
+        connectionProperties = null;
+        defaultCatalog = null;
+        initialSize = 10;
+        maxActive = 100;
+        maxIdle = initialSize;
+        minIdle = initialSize;
+        maxWait = 10000;
+        validationQuery = "SELECT 1";
+        testOnBorrow = true;
+        testOnReturn = false;
+        testWhileIdle = true;
+        timeBetweenEvictionRunsMillis = 5000;
+        numTestsPerEvictionRun = 0;
+        minEvictableIdleTimeMillis = 1000;
+        accessToUnderlyingConnectionAllowed = false;
+        removeAbandoned = true;
+        removeAbandonedTimeout = 5000;
+        logAbandoned = true;
+        loginTimeout = 0;
+        validationInterval = 0; //always validate
+        initSQL = null;
+        testOnConnect = false;;
+        dbProperties.setProperty("user",username);
+        dbProperties.setProperty("password",password);
+    }
+}

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultProperties.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java Mon Nov  3 14:38:55 2008
@@ -1,158 +1,158 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.test;
-
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
-import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory;
-
-import junit.framework.TestCase;
-import org.apache.tomcat.jdbc.pool.PoolProperties;
-import org.apache.tomcat.jdbc.pool.DataSourceProxy;
-
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class DefaultTestCase extends TestCase {
-    protected DataSourceProxy datasource;
-    protected BasicDataSource tDatasource;
-    protected int threadcount = 10;
-    protected int iterations = 100000;
-    public DefaultTestCase(String name) {
-        super(name);
-    }
-
-    protected void init() throws Exception {
-        PoolProperties p = new DefaultProperties();
-        p.setJmxEnabled(false);
-        p.setTestWhileIdle(false);
-        p.setTestOnBorrow(false);
-        p.setTestOnReturn(false);
-        p.setValidationInterval(30000);
-        p.setTimeBetweenEvictionRunsMillis(30000);
-        p.setMaxActive(threadcount);
-        p.setInitialSize(threadcount);
-        p.setMaxWait(10000);
-        p.setRemoveAbandonedTimeout(10);
-        p.setMinEvictableIdleTimeMillis(10000);
-        p.setMinIdle(threadcount);
-        p.setLogAbandoned(false);
-        p.setRemoveAbandoned(false);
-        datasource = new org.apache.tomcat.jdbc.pool.DataSourceProxy();
-        datasource.setPoolProperties(p);
-    }
-
-    protected void transferProperties() {
-        try {
-            BasicDataSourceFactory factory = new BasicDataSourceFactory();
-            Properties p = new Properties();
-
-            for (int i=0; i<this.ALL_PROPERTIES.length; i++) {
-                String name = "get" + Character.toUpperCase(ALL_PROPERTIES[i].charAt(0)) + ALL_PROPERTIES[i].substring(1);
-                String bname = "is" + name.substring(3);
-                Method get = null;
-                try {
-                    get = PoolProperties.class.getMethod(name, new Class[0]);
-                }catch (NoSuchMethodException x) {
-                    try {
-                    get = PoolProperties.class.getMethod(bname, new Class[0]);
-                    }catch (NoSuchMethodException x2) {
-                        System.err.println(x2.getMessage());
-                    }
-                }
-                   if (get!=null) {
-                       Object value = get.invoke(datasource.getPoolProperties(), new Object[0]);
-                       if (value!=null) {
-                           p.setProperty(ALL_PROPERTIES[i], value.toString());
-                       }
-                }
-            }
-            tDatasource = (BasicDataSource)factory.createDataSource(p);
-        }catch (Exception x) {
-            x.printStackTrace();
-        }
-    }
-
-
-    protected void tearDown() throws Exception {
-        datasource = null;
-        tDatasource = null;
-        System.gc();
-    }
-
-    private final static String PROP_DEFAULTAUTOCOMMIT = "defaultAutoCommit";
-    private final static String PROP_DEFAULTREADONLY = "defaultReadOnly";
-    private final static String PROP_DEFAULTTRANSACTIONISOLATION = "defaultTransactionIsolation";
-    private final static String PROP_DEFAULTCATALOG = "defaultCatalog";
-    private final static String PROP_DRIVERCLASSNAME = "driverClassName";
-    private final static String PROP_MAXACTIVE = "maxActive";
-    private final static String PROP_MAXIDLE = "maxIdle";
-    private final static String PROP_MINIDLE = "minIdle";
-    private final static String PROP_INITIALSIZE = "initialSize";
-    private final static String PROP_MAXWAIT = "maxWait";
-    private final static String PROP_TESTONBORROW = "testOnBorrow";
-    private final static String PROP_TESTONRETURN = "testOnReturn";
-    private final static String PROP_TIMEBETWEENEVICTIONRUNSMILLIS = "timeBetweenEvictionRunsMillis";
-    private final static String PROP_NUMTESTSPEREVICTIONRUN = "numTestsPerEvictionRun";
-    private final static String PROP_MINEVICTABLEIDLETIMEMILLIS = "minEvictableIdleTimeMillis";
-    private final static String PROP_TESTWHILEIDLE = "testWhileIdle";
-    private final static String PROP_PASSWORD = "password";
-    private final static String PROP_URL = "url";
-    private final static String PROP_USERNAME = "username";
-    private final static String PROP_VALIDATIONQUERY = "validationQuery";
-    private final static String PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED = "accessToUnderlyingConnectionAllowed";
-    private final static String PROP_REMOVEABANDONED = "removeAbandoned";
-    private final static String PROP_REMOVEABANDONEDTIMEOUT = "removeAbandonedTimeout";
-    private final static String PROP_LOGABANDONED = "logAbandoned";
-    private final static String PROP_POOLPREPAREDSTATEMENTS = "poolPreparedStatements";
-    private final static String PROP_MAXOPENPREPAREDSTATEMENTS = "maxOpenPreparedStatements";
-    private final static String PROP_CONNECTIONPROPERTIES = "connectionProperties";
-
-    private final static String[] ALL_PROPERTIES = {
-        PROP_DEFAULTAUTOCOMMIT,
-        PROP_DEFAULTREADONLY,
-        PROP_DEFAULTTRANSACTIONISOLATION,
-        PROP_DEFAULTCATALOG,
-        PROP_DRIVERCLASSNAME,
-        PROP_MAXACTIVE,
-        PROP_MAXIDLE,
-        PROP_MINIDLE,
-        PROP_INITIALSIZE,
-        PROP_MAXWAIT,
-        PROP_TESTONBORROW,
-        PROP_TESTONRETURN,
-        PROP_TIMEBETWEENEVICTIONRUNSMILLIS,
-        PROP_NUMTESTSPEREVICTIONRUN,
-        PROP_MINEVICTABLEIDLETIMEMILLIS,
-        PROP_TESTWHILEIDLE,
-        PROP_PASSWORD,
-        PROP_URL,
-        PROP_USERNAME,
-        PROP_VALIDATIONQUERY,
-        PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED,
-        PROP_REMOVEABANDONED,
-        PROP_REMOVEABANDONEDTIMEOUT,
-        PROP_LOGABANDONED,
-        PROP_CONNECTIONPROPERTIES
-    };
-
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.test;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
+import org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory;
+
+import junit.framework.TestCase;
+import org.apache.tomcat.jdbc.pool.PoolProperties;
+import org.apache.tomcat.jdbc.pool.DataSourceProxy;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class DefaultTestCase extends TestCase {
+    protected DataSourceProxy datasource;
+    protected BasicDataSource tDatasource;
+    protected int threadcount = 10;
+    protected int iterations = 100000;
+    public DefaultTestCase(String name) {
+        super(name);
+    }
+
+    protected void init() throws Exception {
+        PoolProperties p = new DefaultProperties();
+        p.setJmxEnabled(false);
+        p.setTestWhileIdle(false);
+        p.setTestOnBorrow(false);
+        p.setTestOnReturn(false);
+        p.setValidationInterval(30000);
+        p.setTimeBetweenEvictionRunsMillis(30000);
+        p.setMaxActive(threadcount);
+        p.setInitialSize(threadcount);
+        p.setMaxWait(10000);
+        p.setRemoveAbandonedTimeout(10);
+        p.setMinEvictableIdleTimeMillis(10000);
+        p.setMinIdle(threadcount);
+        p.setLogAbandoned(false);
+        p.setRemoveAbandoned(false);
+        datasource = new org.apache.tomcat.jdbc.pool.DataSourceProxy();
+        datasource.setPoolProperties(p);
+    }
+
+    protected void transferProperties() {
+        try {
+            BasicDataSourceFactory factory = new BasicDataSourceFactory();
+            Properties p = new Properties();
+
+            for (int i=0; i<this.ALL_PROPERTIES.length; i++) {
+                String name = "get" + Character.toUpperCase(ALL_PROPERTIES[i].charAt(0)) + ALL_PROPERTIES[i].substring(1);
+                String bname = "is" + name.substring(3);
+                Method get = null;
+                try {
+                    get = PoolProperties.class.getMethod(name, new Class[0]);
+                }catch (NoSuchMethodException x) {
+                    try {
+                    get = PoolProperties.class.getMethod(bname, new Class[0]);
+                    }catch (NoSuchMethodException x2) {
+                        System.err.println(x2.getMessage());
+                    }
+                }
+                   if (get!=null) {
+                       Object value = get.invoke(datasource.getPoolProperties(), new Object[0]);
+                       if (value!=null) {
+                           p.setProperty(ALL_PROPERTIES[i], value.toString());
+                       }
+                }
+            }
+            tDatasource = (BasicDataSource)factory.createDataSource(p);
+        }catch (Exception x) {
+            x.printStackTrace();
+        }
+    }
+
+
+    protected void tearDown() throws Exception {
+        datasource = null;
+        tDatasource = null;
+        System.gc();
+    }
+
+    private final static String PROP_DEFAULTAUTOCOMMIT = "defaultAutoCommit";
+    private final static String PROP_DEFAULTREADONLY = "defaultReadOnly";
+    private final static String PROP_DEFAULTTRANSACTIONISOLATION = "defaultTransactionIsolation";
+    private final static String PROP_DEFAULTCATALOG = "defaultCatalog";
+    private final static String PROP_DRIVERCLASSNAME = "driverClassName";
+    private final static String PROP_MAXACTIVE = "maxActive";
+    private final static String PROP_MAXIDLE = "maxIdle";
+    private final static String PROP_MINIDLE = "minIdle";
+    private final static String PROP_INITIALSIZE = "initialSize";
+    private final static String PROP_MAXWAIT = "maxWait";
+    private final static String PROP_TESTONBORROW = "testOnBorrow";
+    private final static String PROP_TESTONRETURN = "testOnReturn";
+    private final static String PROP_TIMEBETWEENEVICTIONRUNSMILLIS = "timeBetweenEvictionRunsMillis";
+    private final static String PROP_NUMTESTSPEREVICTIONRUN = "numTestsPerEvictionRun";
+    private final static String PROP_MINEVICTABLEIDLETIMEMILLIS = "minEvictableIdleTimeMillis";
+    private final static String PROP_TESTWHILEIDLE = "testWhileIdle";
+    private final static String PROP_PASSWORD = "password";
+    private final static String PROP_URL = "url";
+    private final static String PROP_USERNAME = "username";
+    private final static String PROP_VALIDATIONQUERY = "validationQuery";
+    private final static String PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED = "accessToUnderlyingConnectionAllowed";
+    private final static String PROP_REMOVEABANDONED = "removeAbandoned";
+    private final static String PROP_REMOVEABANDONEDTIMEOUT = "removeAbandonedTimeout";
+    private final static String PROP_LOGABANDONED = "logAbandoned";
+    private final static String PROP_POOLPREPAREDSTATEMENTS = "poolPreparedStatements";
+    private final static String PROP_MAXOPENPREPAREDSTATEMENTS = "maxOpenPreparedStatements";
+    private final static String PROP_CONNECTIONPROPERTIES = "connectionProperties";
+
+    private final static String[] ALL_PROPERTIES = {
+        PROP_DEFAULTAUTOCOMMIT,
+        PROP_DEFAULTREADONLY,
+        PROP_DEFAULTTRANSACTIONISOLATION,
+        PROP_DEFAULTCATALOG,
+        PROP_DRIVERCLASSNAME,
+        PROP_MAXACTIVE,
+        PROP_MAXIDLE,
+        PROP_MINIDLE,
+        PROP_INITIALSIZE,
+        PROP_MAXWAIT,
+        PROP_TESTONBORROW,
+        PROP_TESTONRETURN,
+        PROP_TIMEBETWEENEVICTIONRUNSMILLIS,
+        PROP_NUMTESTSPEREVICTIONRUN,
+        PROP_MINEVICTABLEIDLETIMEMILLIS,
+        PROP_TESTWHILEIDLE,
+        PROP_PASSWORD,
+        PROP_URL,
+        PROP_USERNAME,
+        PROP_VALIDATIONQUERY,
+        PROP_ACCESSTOUNDERLYINGCONNECTIONALLOWED,
+        PROP_REMOVEABANDONED,
+        PROP_REMOVEABANDONEDTIMEOUT,
+        PROP_LOGABANDONED,
+        PROP_CONNECTIONPROPERTIES
+    };
+
+
+
+}

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/DefaultTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/FairnessTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestGCClose.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestGCClose.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestGCClose.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestGCClose.java Mon Nov  3 14:38:55 2008
@@ -1,43 +1,43 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.test;
-
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class TestGCClose extends DefaultTestCase {
-    public TestGCClose(String name) {
-        super(name);
-    }
-    
-    public void testGCStop() throws Exception {
-        init();
-        datasource.getConnection();
-        System.out.println("Got a connection, but didn't return it");
-        tearDown();
-        Thread.sleep(20000);
-    }
-    
-    public void testClose() throws Exception {
-        init();
-        datasource.getConnection();
-        System.out.println("Got a connection, but didn't return it");
-        datasource.close(true);
-        Thread.sleep(20000);
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.test;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class TestGCClose extends DefaultTestCase {
+    public TestGCClose(String name) {
+        super(name);
+    }
+    
+    public void testGCStop() throws Exception {
+        init();
+        datasource.getConnection();
+        System.out.println("Got a connection, but didn't return it");
+        tearDown();
+        Thread.sleep(20000);
+    }
+    
+    public void testClose() throws Exception {
+        init();
+        datasource.getConnection();
+        System.out.println("Got a connection, but didn't return it");
+        datasource.close(true);
+        Thread.sleep(20000);
+    }
+}

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestGCClose.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestGCClose.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java?rev=710199&r1=710198&r2=710199&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java (original)
+++ tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java Mon Nov  3 14:38:55 2008
@@ -1,154 +1,154 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.test;
-
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * @author Filip Hanik
- * @version 1.0
- */
-public class TestTimeout extends DefaultTestCase {
-    public TestTimeout(String name) {
-        super(name);
-    }
-
-    AtomicInteger counter = new AtomicInteger(0);
-
-    public void testCheckoutTimeout() throws Exception {
-        try {
-            init();
-            this.datasource.getPoolProperties().setTestWhileIdle(true);
-            this.datasource.getPoolProperties().setTestOnBorrow(false);
-            this.datasource.getPoolProperties().setTestOnReturn(false);
-            this.datasource.getPoolProperties().setValidationInterval(30000);
-            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
-            this.datasource.getPoolProperties().setMaxActive(20);
-            this.datasource.getPoolProperties().setMaxWait(3000);
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
-            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
-            this.datasource.getPoolProperties().setMinIdle(5);
-            this.datasource.getPoolProperties().setLogAbandoned(true);
-            System.out.println("About to test connection pool:"+datasource);
-            for (int i = 0; i < 21; i++) {
-                long now = System.currentTimeMillis();
-                this.datasource.getConnection();
-                long delta = System.currentTimeMillis()-now;
-                System.out.println("Got connection #"+i+" in "+delta+" ms.");
-            }
-        } catch ( Exception x ) {
-            x.printStackTrace();
-        }finally {
-            Thread.sleep(20000);
-            tearDown();
-        }
-    }
-
-    public void testCheckoutTimeoutFair() throws Exception {
-        try {
-            init();
-            this.datasource.getPoolProperties().setFairQueue(true);
-            this.datasource.getPoolProperties().setTestWhileIdle(true);
-            this.datasource.getPoolProperties().setTestOnBorrow(false);
-            this.datasource.getPoolProperties().setTestOnReturn(false);
-            this.datasource.getPoolProperties().setValidationInterval(30000);
-            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
-            this.datasource.getPoolProperties().setMaxActive(20);
-            this.datasource.getPoolProperties().setMaxWait(3000);
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
-            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
-            this.datasource.getPoolProperties().setMinIdle(5);
-            this.datasource.getPoolProperties().setLogAbandoned(true);
-            System.out.println("About to test connection pool:"+datasource);
-            for (int i = 0; i < 21; i++) {
-                long now = System.currentTimeMillis();
-                this.datasource.getConnection();
-                long delta = System.currentTimeMillis()-now;
-                System.out.println("Got connection #"+i+" in "+delta+" ms.");
-            }
-        } catch ( Exception x ) {
-            x.printStackTrace();
-        }finally {
-            Thread.sleep(20000);
-            tearDown();
-        }
-    }
-    
-
-    public void testRemoveAbandoned() throws Exception {
-        try {
-            init();
-            this.datasource.getPoolProperties().setTestWhileIdle(true);
-            this.datasource.getPoolProperties().setTestOnBorrow(false);
-            this.datasource.getPoolProperties().setTestOnReturn(false);
-            this.datasource.getPoolProperties().setValidationInterval(30000);
-            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
-            this.datasource.getPoolProperties().setMaxActive(20);
-            this.datasource.getPoolProperties().setMaxWait(3000);
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
-            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
-            this.datasource.getPoolProperties().setMinIdle(5);
-            this.datasource.getPoolProperties().setRemoveAbandoned(true);
-            this.datasource.getPoolProperties().setLogAbandoned(true);
-            System.out.println("About to test connection pool:"+datasource);
-            for (int i = 0; i < threadcount; i++) {
-                long now = System.currentTimeMillis();
-                this.datasource.getConnection();
-                long delta = System.currentTimeMillis()-now;
-                System.out.println("Got connection #"+i+" in "+delta+" ms.");
-            }
-        } catch ( Exception x ) {
-            x.printStackTrace();
-        }finally {
-            Thread.sleep(20000);
-            tearDown();
-        }
-    }
-    
-    public void testRemoveAbandonedFair() throws Exception {
-        try {
-            init();
-            this.datasource.getPoolProperties().setFairQueue(true);
-            this.datasource.getPoolProperties().setTestWhileIdle(true);
-            this.datasource.getPoolProperties().setTestOnBorrow(false);
-            this.datasource.getPoolProperties().setTestOnReturn(false);
-            this.datasource.getPoolProperties().setValidationInterval(30000);
-            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
-            this.datasource.getPoolProperties().setMaxActive(20);
-            this.datasource.getPoolProperties().setMaxWait(3000);
-            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
-            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
-            this.datasource.getPoolProperties().setMinIdle(5);
-            this.datasource.getPoolProperties().setRemoveAbandoned(true);
-            this.datasource.getPoolProperties().setLogAbandoned(true);
-            System.out.println("About to test connection pool:"+datasource);
-            for (int i = 0; i < threadcount; i++) {
-                long now = System.currentTimeMillis();
-                this.datasource.getConnection();
-                long delta = System.currentTimeMillis()-now;
-                System.out.println("Got connection #"+i+" in "+delta+" ms.");
-            }
-        } catch ( Exception x ) {
-            x.printStackTrace();
-        }finally {
-            Thread.sleep(20000);
-            tearDown();
-        }
-    }
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class TestTimeout extends DefaultTestCase {
+    public TestTimeout(String name) {
+        super(name);
+    }
+
+    AtomicInteger counter = new AtomicInteger(0);
+
+    public void testCheckoutTimeout() throws Exception {
+        try {
+            init();
+            this.datasource.getPoolProperties().setTestWhileIdle(true);
+            this.datasource.getPoolProperties().setTestOnBorrow(false);
+            this.datasource.getPoolProperties().setTestOnReturn(false);
+            this.datasource.getPoolProperties().setValidationInterval(30000);
+            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
+            this.datasource.getPoolProperties().setMaxActive(20);
+            this.datasource.getPoolProperties().setMaxWait(3000);
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
+            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
+            this.datasource.getPoolProperties().setMinIdle(5);
+            this.datasource.getPoolProperties().setLogAbandoned(true);
+            System.out.println("About to test connection pool:"+datasource);
+            for (int i = 0; i < 21; i++) {
+                long now = System.currentTimeMillis();
+                this.datasource.getConnection();
+                long delta = System.currentTimeMillis()-now;
+                System.out.println("Got connection #"+i+" in "+delta+" ms.");
+            }
+        } catch ( Exception x ) {
+            x.printStackTrace();
+        }finally {
+            Thread.sleep(20000);
+            tearDown();
+        }
+    }
+
+    public void testCheckoutTimeoutFair() throws Exception {
+        try {
+            init();
+            this.datasource.getPoolProperties().setFairQueue(true);
+            this.datasource.getPoolProperties().setTestWhileIdle(true);
+            this.datasource.getPoolProperties().setTestOnBorrow(false);
+            this.datasource.getPoolProperties().setTestOnReturn(false);
+            this.datasource.getPoolProperties().setValidationInterval(30000);
+            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
+            this.datasource.getPoolProperties().setMaxActive(20);
+            this.datasource.getPoolProperties().setMaxWait(3000);
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
+            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
+            this.datasource.getPoolProperties().setMinIdle(5);
+            this.datasource.getPoolProperties().setLogAbandoned(true);
+            System.out.println("About to test connection pool:"+datasource);
+            for (int i = 0; i < 21; i++) {
+                long now = System.currentTimeMillis();
+                this.datasource.getConnection();
+                long delta = System.currentTimeMillis()-now;
+                System.out.println("Got connection #"+i+" in "+delta+" ms.");
+            }
+        } catch ( Exception x ) {
+            x.printStackTrace();
+        }finally {
+            Thread.sleep(20000);
+            tearDown();
+        }
+    }
+    
+
+    public void testRemoveAbandoned() throws Exception {
+        try {
+            init();
+            this.datasource.getPoolProperties().setTestWhileIdle(true);
+            this.datasource.getPoolProperties().setTestOnBorrow(false);
+            this.datasource.getPoolProperties().setTestOnReturn(false);
+            this.datasource.getPoolProperties().setValidationInterval(30000);
+            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
+            this.datasource.getPoolProperties().setMaxActive(20);
+            this.datasource.getPoolProperties().setMaxWait(3000);
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
+            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
+            this.datasource.getPoolProperties().setMinIdle(5);
+            this.datasource.getPoolProperties().setRemoveAbandoned(true);
+            this.datasource.getPoolProperties().setLogAbandoned(true);
+            System.out.println("About to test connection pool:"+datasource);
+            for (int i = 0; i < threadcount; i++) {
+                long now = System.currentTimeMillis();
+                this.datasource.getConnection();
+                long delta = System.currentTimeMillis()-now;
+                System.out.println("Got connection #"+i+" in "+delta+" ms.");
+            }
+        } catch ( Exception x ) {
+            x.printStackTrace();
+        }finally {
+            Thread.sleep(20000);
+            tearDown();
+        }
+    }
+    
+    public void testRemoveAbandonedFair() throws Exception {
+        try {
+            init();
+            this.datasource.getPoolProperties().setFairQueue(true);
+            this.datasource.getPoolProperties().setTestWhileIdle(true);
+            this.datasource.getPoolProperties().setTestOnBorrow(false);
+            this.datasource.getPoolProperties().setTestOnReturn(false);
+            this.datasource.getPoolProperties().setValidationInterval(30000);
+            this.datasource.getPoolProperties().setTimeBetweenEvictionRunsMillis(1000);
+            this.datasource.getPoolProperties().setMaxActive(20);
+            this.datasource.getPoolProperties().setMaxWait(3000);
+            this.datasource.getPoolProperties().setRemoveAbandonedTimeout(5);
+            this.datasource.getPoolProperties().setMinEvictableIdleTimeMillis(5000);
+            this.datasource.getPoolProperties().setMinIdle(5);
+            this.datasource.getPoolProperties().setRemoveAbandoned(true);
+            this.datasource.getPoolProperties().setLogAbandoned(true);
+            System.out.println("About to test connection pool:"+datasource);
+            for (int i = 0; i < threadcount; i++) {
+                long now = System.currentTimeMillis();
+                this.datasource.getConnection();
+                long delta = System.currentTimeMillis()-now;
+                System.out.println("Got connection #"+i+" in "+delta+" ms.");
+            }
+        } catch ( Exception x ) {
+            x.printStackTrace();
+        }finally {
+            Thread.sleep(20000);
+            tearDown();
+        }
+    }
+
+
+}

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestTimeout.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message