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 TestPStmtPoolingBasicDataSource.java TestBasicDataSource.java TestAll.java TestAbandonedBasicDataSource.java
Date Sun, 02 Nov 2003 17:53:55 GMT
dirkv       2003/11/02 09:53:55

  Modified:    dbcp/src/test/org/apache/commons/dbcp
                        TestBasicDataSource.java TestAll.java
                        TestAbandonedBasicDataSource.java
  Added:       dbcp/src/test/org/apache/commons/dbcp
                        TestPStmtPoolingBasicDataSource.java
  Log:
  new testsuite for BasicDataSource with prepared statement pooling enabled
  
  Revision  Changes    Path
  1.14      +6 -42     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- TestBasicDataSource.java	9 Oct 2003 21:05:29 -0000	1.13
  +++ TestBasicDataSource.java	2 Nov 2003 17:53:55 -0000	1.14
  @@ -62,13 +62,15 @@
   package org.apache.commons.dbcp;
   
   import java.sql.Connection;
  -import java.sql.PreparedStatement;
   import java.sql.SQLException;
   
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
   /**
  + * TestSuite for BasicDataSource
  + * 
  + * @author Dirk Verbeeck
    * @version $Revision$ $Date$
    */
   public class TestBasicDataSource extends TestConnectionPool {
  @@ -125,44 +127,6 @@
           conn3.close();
       }
   
  -    public void testPreparedStatementPooling() throws Exception {
  -        ds.setPoolPreparedStatements(true);
  -        ds.setMaxOpenPreparedStatements(2);
  -        
  -        Connection conn = getConnection();
  -        assertNotNull(conn);
  -        
  -        PreparedStatement stmt1 = conn.prepareStatement("select 'a' from dual");
  -        assertNotNull(stmt1);
  -        
  -        PreparedStatement stmt2 = conn.prepareStatement("select 'b' from dual");
  -        assertNotNull(stmt2);
  -        
  -        assertTrue(stmt1 != stmt2);
  -        
  -        // go over the maxOpen limit
  -        PreparedStatement stmt3 = null;
  -		try {
  -			stmt3 = conn.prepareStatement("select 'c' from dual");
  -            fail("expected SQLException");
  -		} 
  -        catch (SQLException e) {}
  -        
  -        // make idle
  -        stmt2.close();
  -
  -        // test cleanup the 'b' statement
  -        stmt3 = conn.prepareStatement("select 'c' from dual");
  -        assertNotNull(stmt3);
  -        assertTrue(stmt3 != stmt1);
  -        assertTrue(stmt3 != stmt2);
  -        
  -        // normal reuse of statement
  -        stmt1.close();
  -        PreparedStatement stmt4 = conn.prepareStatement("select 'a' from dual");
  -        assertNotNull(stmt4);
  -    }
  -    
       public void testPooling() throws Exception {
           // this also needs access to the undelying connection
           ds.setAccessToUnderlyingConnectionAllowed(true);
  
  
  
  1.12      +4 -3      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestAll.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestAll.java	26 Oct 2003 17:18:11 -0000	1.11
  +++ TestAll.java	2 Nov 2003 17:53:55 -0000	1.12
  @@ -81,6 +81,7 @@
           suite.addTest(TestJOCLed.suite());
           suite.addTest(TestBasicDataSource.suite());
           suite.addTest(TestAbandonedBasicDataSource.suite());
  +        suite.addTest(TestPStmtPoolingBasicDataSource.suite());
           suite.addTest(TestDelegatingConnection.suite());
           suite.addTest(TestDelegatingStatement.suite());
           suite.addTest(TestDelegatingPreparedStatement.suite());
  
  
  
  1.6       +6 -3      jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java
  
  Index: TestAbandonedBasicDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestAbandonedBasicDataSource.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestAbandonedBasicDataSource.java	9 Oct 2003 21:05:29 -0000	1.5
  +++ TestAbandonedBasicDataSource.java	2 Nov 2003 17:53:55 -0000	1.6
  @@ -67,6 +67,9 @@
   import junit.framework.TestSuite;
   
   /**
  + * TestSuite for BasicDataSource with abandoned connection trace enabled
  + * 
  + * @author Dirk Verbeeck
    * @version $Revision$ $Date$
    */
   public class TestAbandonedBasicDataSource extends TestConnectionPool {
  
  
  
  1.1                  jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestPStmtPoolingBasicDataSource.java
  
  Index: TestPStmtPoolingBasicDataSource.java
  ===================================================================
  /*
   * $Source: /home/cvs/jakarta-commons/dbcp/src/test/org/apache/commons/dbcp/TestPStmtPoolingBasicDataSource.java,v
$
   * $Revision: 1.1 $
   * $Date: 2003/11/02 17:53:55 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowledgement:
   *       "This product includes software developed by the
   *        Apache Software Foundation - http://www.apache.org/"
   *    Alternately, this acknowledgement may appear in the software itself,
   *    if and wherever such third-party acknowledgements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * http://www.apache.org/
   *
   */
  
  package org.apache.commons.dbcp;
  
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  
  import junit.framework.Test;
  import junit.framework.TestSuite;
  
  /**
   * TestSuite for BasicDataSource with prepared statement pooling enabled
   * 
   * @author Dirk Verbeeck
   * @version $Revision: 1.1 $ $Date: 2003/11/02 17:53:55 $
   */
  public class TestPStmtPoolingBasicDataSource extends TestConnectionPool {
      public TestPStmtPoolingBasicDataSource(String testName) {
          super(testName);
      }
  
      public static Test suite() {
          return new TestSuite(TestPStmtPoolingBasicDataSource.class);
      }
  
      protected Connection getConnection() throws Exception {
          return ds.getConnection();
      }
  
      private BasicDataSource ds = null;
      
      public void setUp() throws Exception {
          super.setUp();
          ds = new BasicDataSource();
          ds.setDriverClassName("org.apache.commons.dbcp.TesterDriver");
          ds.setUrl("jdbc:apache:commons:testdriver");
          ds.setMaxActive(getMaxActive());
          ds.setMaxWait(getMaxWait());
          ds.setDefaultAutoCommit(true);
          ds.setDefaultReadOnly(false);
          ds.setUsername("username");
          ds.setPassword("password");
          ds.setValidationQuery("SELECT DUMMY FROM DUAL");
  
          // PoolPreparedStatements enabled, should not affect the basic tests
          ds.setPoolPreparedStatements(true);
          ds.setMaxOpenPreparedStatements(2);
      }
  
      public void tearDown() throws Exception {
          ds = null;
      }
  
      public void testPreparedStatementPooling() throws Exception {
          Connection conn = getConnection();
          assertNotNull(conn);
          
          PreparedStatement stmt1 = conn.prepareStatement("select 'a' from dual");
          assertNotNull(stmt1);
          
          PreparedStatement stmt2 = conn.prepareStatement("select 'b' from dual");
          assertNotNull(stmt2);
          
          assertTrue(stmt1 != stmt2);
          
          // go over the maxOpen limit
          PreparedStatement stmt3 = null;
          try {
              stmt3 = conn.prepareStatement("select 'c' from dual");
              fail("expected SQLException");
          } 
          catch (SQLException e) {}
          
          // make idle
          stmt2.close();
  
          // test cleanup the 'b' statement
          stmt3 = conn.prepareStatement("select 'c' from dual");
          assertNotNull(stmt3);
          assertTrue(stmt3 != stmt1);
          assertTrue(stmt3 != stmt2);
          
          // normal reuse of statement
          stmt1.close();
          PreparedStatement stmt4 = conn.prepareStatement("select 'a' from dual");
          assertNotNull(stmt4);
      }
  }
  
  
  

---------------------------------------------------------------------
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