db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker ConnectionFactoryTest.java
Date Tue, 30 Nov 2004 21:04:36 GMT
arminw      2004/11/30 13:04:35

  Modified:    src/test/org/apache/ojb/broker ConnectionFactoryTest.java
  Log:
  fix test case
  
  Revision  Changes    Path
  1.10      +13 -8     db-ojb/src/test/org/apache/ojb/broker/ConnectionFactoryTest.java
  
  Index: ConnectionFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ConnectionFactoryTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ConnectionFactoryTest.java	15 Nov 2004 22:51:40 -0000	1.9
  +++ ConnectionFactoryTest.java	30 Nov 2004 21:04:35 -0000	1.10
  @@ -10,6 +10,7 @@
   import org.apache.ojb.broker.metadata.JdbcConnectionDescriptor;
   import org.apache.ojb.broker.util.pooling.PoolConfiguration;
   import org.apache.ojb.junit.PBTestCase;
  +import org.apache.commons.lang.SerializationUtils;
   
   /**
    * ConnectionFactory implementation related tests.
  @@ -99,17 +100,19 @@
   
       private void checkFactoryPoolExhausted(Class factory) throws Exception
       {
  -        JdbcConnectionDescriptor jcd = broker.getConfiguration().getJdbcConnectionDescriptor();
  +        // close used broker instance
  +        broker.close();
  +
  +        JdbcConnectionDescriptor jcd = ojb.getConfiguration(null).getJdbcConnectionDescriptor();
           Class oldCF = jcd.getConnectionFactoryDescriptor().getConnectionFactoryClass();
           int oldAutoCommit = jcd.getUseAutoCommit();
           String oldMaxActive = jcd.getConnectionFactoryDescriptor().getAttribute(PoolConfiguration.MAX_ACTIVE);
           try
           {
  -            // release connection factory of current broker
  -            broker.serviceConnectionManager().releaseConnection();
  +            // close all used connections and broker
  +            ojb.releaseAllConnections();
               // set connection factory we want to test
               jcd.getConnectionFactoryDescriptor().setConnectionFactoryClass(factory);
  -
               jcd.setUseAutoCommit(1);
               jcd.getConnectionFactoryDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE,
"2");
               jcd.getConnectionFactoryDescriptor().setConnectionFactoryClass(factory);
  @@ -117,10 +120,12 @@
               Connection con = null;
               Connection con2 = null;
               Connection con3 = null;
  +            PersistenceBroker pb = null;
               try
               {
                   // get the connetion factory for used JCD
  -                ConnectionFactory cf = broker.serviceConnectionManager().getConnectionFactory();
  +                pb = ojb.lookupBroker();
  +                ConnectionFactory cf = pb.serviceConnectionManager().getConnectionFactory();
                   con = cf.lookupConnection();
                   con2 = cf.lookupConnection();
                   try
  @@ -145,6 +150,7 @@
               {
                   try
                   {
  +                    if(pb != null) pb.close();
                       con.close();
                       con2.close();
                   }
  @@ -155,12 +161,11 @@
           }
           finally
           {
  -            // release connection factory of current broker
  -            broker.serviceConnectionManager().releaseConnection();
               // restore settings
               jcd.setUseAutoCommit(oldAutoCommit);
               jcd.getConnectionFactoryDescriptor().setConnectionFactoryClass(oldCF);
               jcd.getConnectionFactoryDescriptor().addAttribute(PoolConfiguration.MAX_ACTIVE,
oldMaxActive);
  +            ojb.releaseAllConnections();
           }
       }
   }
  
  
  

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


Mime
View raw message