Author: fhanik
Date: Sun Nov 16 20:42:29 2008
New Revision: 718170
URL: http://svn.apache.org/viewvc?rev=718170&view=rev
Log:
Add timeout test
Added:
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
Added:
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/BorrowWaitTest.java?rev=718170&view=auto
==============================================================================
---
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
(added)
+++
tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
Sun Nov 16 20:42:29 2008
@@ -0,0 +1,55 @@
+package org.apache.tomcat.jdbc.test;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class BorrowWaitTest extends DefaultTestCase {
+
+ public BorrowWaitTest(String name) {
+ super(name);
+ }
+
+ public void testWaitTime() throws Exception {
+ int wait = 10000;
+ this.init();
+ this.datasource.setMaxActive(1);
+ this.datasource.setMaxWait(wait);
+ Connection con = datasource.getConnection();
+ long start = System.currentTimeMillis();
+ try {
+ Connection con2 = datasource.getConnection();
+ assertFalse("This should not happen, connection should be
unavailable.",true);
+ }catch (SQLException x) {
+ long delta = System.currentTimeMillis();
+ boolean inrange = Math.abs(wait-delta) < 1000;
+ assertTrue("Connection should have been acquired within +/- 1
second.",true);
+ }
+ con.close();
+ }
+
+ public void testWaitTimeInfinite() throws Exception {
+ if(true){
+ System.err.println("testWaitTimeInfinite() test is disabled.");
+ return;//this would lock up the test suite
+ }
+ int wait = -1;
+ this.init();
+ this.datasource.setMaxActive(1);
+ this.datasource.setMaxWait(wait);
+ Connection con = datasource.getConnection();
+ long start = System.currentTimeMillis();
+ try {
+ Connection con2 = datasource.getConnection();
+ assertFalse("This should not happen, connection should be
unavailable.",true);
+ }catch (SQLException x) {
+ long delta = System.currentTimeMillis();
+ boolean inrange = Math.abs(wait-delta) < 1000;
+ assertTrue("Connection should have been acquired within +/- 1
second.",true);
+ }
+ con.close();
+ }
+
+
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]