You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ma...@apache.org on 2003/06/25 19:01:19 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/broker PerformanceJdbcReferenceTest.java

mattbaird    2003/06/25 10:01:19

  Modified:    src/test/org/apache/ojb/broker
                        PerformanceJdbcReferenceTest.java
  Log:
  release connections in test or you will run out.
  
  Revision  Changes    Path
  1.13      +37 -3     db-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcReferenceTest.java
  
  Index: PerformanceJdbcReferenceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcReferenceTest.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- PerformanceJdbcReferenceTest.java	8 Apr 2003 20:19:27 -0000	1.12
  +++ PerformanceJdbcReferenceTest.java	25 Jun 2003 17:01:19 -0000	1.13
  @@ -134,6 +134,17 @@
           return conn;
       }
   
  +	 private void returnConnection(Connection conn) throws Exception
  +    {
  +        // Use OJB API to obtain JDBC Connection. All settings are read from
  +        // the repository.xml file.
  +        ClassDescriptor cld = broker.getClassDescriptor(PerformanceArticle.class);
  +        JdbcConnectionDescriptor jcd = MetadataManager.getInstance().connectionRepository()
  +                .getDescriptor(TestHelper.DEF_KEY);
  +        ConnectionFactory cf = ConnectionFactoryFactory.getInstance().createConnectionFactory();
  +		cf.releaseConnection(jcd, conn);
  +    }
  +
       /**
        * deletes all PerformanceArticle created by <code>insertNewArticles</code>.
        */
  @@ -166,6 +177,11 @@
               logger.error(t);
               fail(t.getMessage());
           }
  +		finally
  +		{
  +			if (conn != null)
  +				returnConnection(conn);
  +		}
           long stop = System.currentTimeMillis();
           logger.info("deleting " + articleCount + " Objects: " + (stop - start) + " msec");
       }
  @@ -216,6 +232,11 @@
               logger.error(t);
               fail(t.getMessage());
           }
  +		finally
  +		{
  +			if (conn != null)
  +				returnConnection(conn);
  +		}
           long stop = System.currentTimeMillis();
           logger.info("inserting " + articleCount + " Objects: " + (stop - start) + " msec");
   
  @@ -230,6 +251,7 @@
           String sql = "DELETE FROM " + table + " WHERE " + column + " >= " + offsetId;
           PreparedStatement stmt = conn.prepareStatement(sql);
           stmt.execute();
  +		returnConnection(conn);
       }
   
       /**
  @@ -285,7 +307,11 @@
               logger.error(t);
               fail(t.getMessage());
           }
  -
  +		finally
  +		{
  +			if (conn != null)
  +				returnConnection(conn);
  +		}
   
           long stop = System.currentTimeMillis();
           logger.info("querying " + articleCount + " Objects: " + (stop - start) + " msec");
  @@ -355,7 +381,11 @@
               logger.error(t);
               fail(t.getMessage());
           }
  -
  +		finally
  +		{
  +			if (conn != null)
  +				returnConnection(conn);
  +		}
   
           long stop = System.currentTimeMillis();
           logger.info("fetching " + fetchCount + " Objects: " + (stop - start) + " msec");
  @@ -408,7 +438,11 @@
               logger.error(t);
               fail(t.getMessage());
           }
  -
  +		finally
  +		{
  +			if (conn != null)
  +				returnConnection(conn);
  +		}
           long stop = System.currentTimeMillis();
           logger.info("updating " + articleCount + " Objects: " + (stop - start) + " msec");