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/sequence NativeIdentifierTest.java
Date Thu, 29 Jul 2004 07:23:55 GMT
arminw      2004/07/29 00:23:55

  Modified:    src/test/org/apache/ojb/broker/sequence
                        NativeIdentifierTest.java
  Log:
  update test case (show workaround)
  
  Revision  Changes    Path
  1.12      +54 -15    db-ojb/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java
  
  Index: NativeIdentifierTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/sequence/NativeIdentifierTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- NativeIdentifierTest.java	27 Jul 2004 21:39:20 -0000	1.11
  +++ NativeIdentifierTest.java	29 Jul 2004 07:23:55 -0000	1.12
  @@ -3,6 +3,7 @@
   import java.io.Serializable;
   import java.sql.Connection;
   import java.sql.Statement;
  +import java.sql.SQLException;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Iterator;
  @@ -26,6 +27,7 @@
   import org.apache.ojb.broker.util.sequence.SequenceManagerNativeImpl;
   import org.apache.ojb.junit.PBTestCase;
   import org.apache.ojb.odmg.OJB;
  +import org.apache.ojb.odmg.TransactionExt;
   import org.odmg.Database;
   import org.odmg.Implementation;
   import org.odmg.Transaction;
  @@ -88,9 +90,39 @@
           platform = broker.serviceConnectionManager().getSupportedPlatform();
           if (skipTest()) return;
   
  -
           Connection con;
           Statement stmt;
  +
  +        PersistenceBroker pb = PersistenceBrokerFactory.defaultPersistenceBroker();
  +        try
  +        {
  +            con = pb.serviceConnectionManager().getConnection();
  +            stmt = con.createStatement();
  +            try
  +            {
  +                stmt.execute(DROP);
  +            }
  +            catch (SQLException e)
  +            {
  +            }
  +            stmt.close();
  +
  +            stmt = con.createStatement();
  +            try
  +            {
  +                stmt.execute(DROP_REF);
  +            }
  +            catch (SQLException e)
  +            {
  +            }
  +            stmt.close();
  +        }
  +        finally
  +        {
  +            if (pb != null) pb.close();
  +        }
  +
  +
           try
           {
               con = broker.serviceConnectionManager().getConnection();
  @@ -151,14 +183,14 @@
           PersistenceBroker pb = PersistenceBrokerFactory.defaultPersistenceBroker();
           try
           {
  -            con = pb.serviceConnectionManager().getConnection();
  -            stmt = con.createStatement();
  -            stmt.execute(DROP);
  -            stmt.close();
  -
  -            stmt = con.createStatement();
  -            stmt.execute(DROP_REF);
  -            stmt.close();
  +//            con = pb.serviceConnectionManager().getConnection();
  +//            stmt = con.createStatement();
  +//            stmt.execute(DROP);
  +//            stmt.close();
  +//
  +//            stmt = con.createStatement();
  +//            stmt.execute(DROP_REF);
  +//            stmt.close();
   
               SequenceDescriptor sd = MetadataManager.getInstance().connectionRepository().
                       getDescriptor(pb.getPBKey()).getSequenceDescriptor();
  @@ -522,7 +554,14 @@
   
           Transaction tx = odmg.newTransaction();
           tx.begin();
  -        //db.makePersistent(ref_1);
  +//        // workaround
  +//        PersistenceBroker pb = ((TransactionExt) tx).getBroker();
  +//        if(!pb.isInTransaction())pb.beginTransaction();
  +//        pb.store(s_ref_1);
  +//        pb.store(s_ref_2);
  +//        pb.store(s_ref_3);
  +//        pb.store(s_ref_4);
  +//        // workaround end
           db.makePersistent(obj_1);
           db.makePersistent(obj_2);
           tx.commit();
  @@ -600,12 +639,12 @@
           // add new reference to object
           CollectionReference ref_5 = new CollectionReference(null, nameRef);
           CollectionReference ref_6 = new CollectionReference(null, nameRef);
  +        tx.begin();
  +        tx.lock(obj_1, Transaction.WRITE);
  +        tx.lock(obj_2, Transaction.WRITE);
           obj_1.addReference(ref_5);
           obj_2.addReference(ref_6);
  -        broker.beginTransaction();
  -        broker.store(obj_1);
  -        broker.store(obj_2);
  -        broker.commitTransaction();
  +        tx.commit();
           assertNotNull(ref_5.getRefIdentifier());
           assertNotNull(ref_6.getRefIdentifier());
           assertEquals(id_1, obj_1.getIdentifier());
  
  
  

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