You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/08/13 17:47:17 UTC

cvs commit: jakarta-commons/dbcp/src/test/org/apache/commons/dbcp TesterConnection.java TestConnectionPool.java TestBasicDataSource.java

dirkv       2003/08/13 08:47:17

  Modified:    dbcp/src/test/org/apache/commons/dbcp TesterConnection.java
                        TestConnectionPool.java TestBasicDataSource.java
  Log:
  testClearWarnings promoted to general connection test
  
  Revision  Changes    Path
  1.6       +7 -4      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterConnection.java
  
  Index: TesterConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TesterConnection.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TesterConnection.java	11 Aug 2003 23:40:40 -0000	1.5
  +++ TesterConnection.java	13 Aug 2003 15:47:17 -0000	1.6
  @@ -153,6 +153,9 @@
   
       public CallableStatement prepareCall(String sql) throws SQLException {
           checkOpen();
  +        if ("warning".equals(sql)) {
  +            setWarnings(new SQLWarning("warning in prepareCall"));
  +        }
           return null;
       }
   
  
  
  
  1.6       +36 -4     jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestConnectionPool.java
  
  Index: TestConnectionPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestConnectionPool.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestConnectionPool.java	11 Aug 2003 23:47:03 -0000	1.5
  +++ TestConnectionPool.java	13 Aug 2003 15:47:17 -0000	1.6
  @@ -103,7 +103,39 @@
       protected long getMaxWait() {
           return 100L;
       }
  +
  +    public void testClearWarnings() throws Exception {
  +        Connection[] c = new Connection[getMaxActive()];
  +        for (int i = 0; i < c.length; i++) {
  +            c[i] = getConnection();
  +            assertTrue(c[i] != null);
  +            
  +            // generate SQLWarning on connection
  +            c[i].prepareCall("warning");
  +        }
  +
  +        for (int i = 0; i < c.length; i++) {
  +            assertNotNull(c[i].getWarnings());
  +        }
  +
  +        for (int i = 0; i < c.length; i++) {
  +            c[i].close();
  +        }
           
  +        for (int i = 0; i < c.length; i++) {
  +            c[i] = getConnection();
  +        }        
  +
  +        for (int i = 0; i < c.length; i++) {
  +            // warnings should have been cleared by putting the connection back in the pool
  +            assertNull(c[i].getWarnings());
  +        }
  +
  +        for (int i = 0; i < c.length; i++) {
  +            c[i].close();
  +        }
  +    }
  +
       public void testIsClosed() throws Exception {
           for(int i=0;i<getMaxActive();i++) {
               Connection conn = getConnection();
  
  
  
  1.4       +4 -41     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestBasicDataSource.java	11 Aug 2003 23:41:56 -0000	1.3
  +++ TestBasicDataSource.java	13 Aug 2003 15:47:17 -0000	1.4
  @@ -61,7 +61,6 @@
   package org.apache.commons.dbcp;
   
   import java.sql.Connection;
  -import java.sql.SQLWarning;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
  @@ -101,40 +100,4 @@
       public void tearDown() throws Exception {
           ds = null;
       }
  -    
  -    public void testClearWarnings() throws Exception {
  -        Connection[] c = new Connection[getMaxActive()];
  -        for (int i = 0; i < c.length; i++) {
  -            c[i] = getConnection();
  -            assertTrue(c[i] != null);
  -            if (c[i] instanceof DelegatingConnection) {
  -                Connection conn = ((DelegatingConnection) c[i]).getInnermostDelegate();
  -                if (conn instanceof TesterConnection){
  -                    ((TesterConnection) conn).setWarnings(new SQLWarning("warn1"));
  -                }
  -            }
  -        }
  -
  -        for (int i = 0; i < c.length; i++) {
  -            assertNotNull(c[i].getWarnings());
  -        }
  -
  -        for (int i = 0; i < c.length; i++) {
  -            c[i].close();
  -        }
  -        
  -        for (int i = 0; i < c.length; i++) {
  -            c[i] = getConnection();
  -        }        
  -
  -        for (int i = 0; i < c.length; i++) {
  -            // warnings should have been cleared by putting the connection back in the pool
  -            assertNull(c[i].getWarnings());
  -        }
  -
  -        for (int i = 0; i < c.length; i++) {
  -            c[i].close();
  -        }
  -    }
  -
   }
  
  
  

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