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 to...@apache.org on 2004/12/05 18:48:39 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/junit PBTestCase.java

tomdz       2004/12/05 09:48:39

  Modified:    src/test/org/apache/ojb/junit PBTestCase.java
  Log:
  Added broker clean-up helper method for unit tests (e.g. when they create additional broker instances) and changed tearDown to use it on the broker instance that were created in setUp
  
  Revision  Changes    Path
  1.7       +15 -5     db-ojb/src/test/org/apache/ojb/junit/PBTestCase.java
  
  Index: PBTestCase.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/junit/PBTestCase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PBTestCase.java	14 Nov 2004 09:42:55 -0000	1.6
  +++ PBTestCase.java	5 Dec 2004 17:48:39 -0000	1.7
  @@ -1,5 +1,6 @@
   package org.apache.ojb.junit;
   
  +import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerInternal;
   import org.apache.ojb.broker.PersistenceConfiguration;
   
  @@ -38,13 +39,22 @@
   
       public void tearDown() throws Exception
       {
  -        if (broker != null)
  -        {
  -            broker.close();
  -        }
  +        cleanUpBroker(broker);
           persistenceConf.getCacheManager().clearCaches();
           persistenceConf.releaseAllInstances();
           persistenceConf = null;
           super.tearDown();
  +    }
  +
  +    protected void cleanUpBroker(PersistenceBroker broker)
  +    {
  +        if (broker != null)
  +        {
  +            if (broker.isInTransaction())
  +            {
  +                broker.abortTransaction();
  +            }
  +            broker.close();
  +        }
       }
   }
  
  
  

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