commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/test/org/apache/commons/dbcp TestBasicDataSource.java
Date Sat, 01 May 2004 12:54:32 GMT
dirkv       2004/05/01 05:54:32

  Modified:    dbcp/src/test/org/apache/commons/dbcp
                        TestBasicDataSource.java
  Log:
  Bugzilla Bug 28251:	Returning dead database connections to BasicDataSource
  - JUnit test
  
  Revision  Changes    Path
  1.18      +23 -1     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestBasicDataSource.java
  
  Index: TestBasicDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestBasicDataSource.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TestBasicDataSource.java	28 Feb 2004 11:47:51 -0000	1.17
  +++ TestBasicDataSource.java	1 May 2004 12:54:32 -0000	1.18
  @@ -16,6 +16,7 @@
   
   package org.apache.commons.dbcp;
   
  +import java.io.IOException;
   import java.sql.Connection;
   import java.sql.SQLException;
   
  @@ -225,5 +226,26 @@
   
           assertEquals(0, ds.getNumActive());
           assertEquals(10, ds.getNumIdle());
  +    }
  +
  +    // Bugzilla Bug 28251:  Returning dead database connections to BasicDataSource
  +    // isClosed() failure blocks returning a connection to the pool 
  +    public void testIsClosedFailure() throws SQLException {
  +        ds.setAccessToUnderlyingConnectionAllowed(true);
  +        Connection conn = ds.getConnection();
  +        assertNotNull(conn);
  +        assertEquals(1, ds.getNumActive());
  +        
  +        // set an IO failure causing the isClosed mathod to fail
  +        TesterConnection tconn = (TesterConnection) ((DelegatingConnection)conn).getInnermostDelegate();
  +        tconn.setFailure(new IOException("network error"));
  +        
  +        try {
  +            conn.close();
  +            fail("Expected SQLException");
  +        }
  +        catch(SQLException ex) { }
  +        
  +        assertEquals(0, ds.getNumActive());
       }
   }
  
  
  

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


Mime
View raw message