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/odmg CollectionsTest.java OdmgExamples.java RITest.java UserTestCases.java
Date Sun, 28 Nov 2004 03:01:58 GMT
arminw      2004/11/27 19:01:58

  Modified:    src/test/org/apache/ojb/odmg/shared Master.java
                        ProductGroup.java
               src/test/org/apache/ojb/odmg CollectionsTest.java
                        OdmgExamples.java RITest.java UserTestCases.java
  Log:
  update&fix tests
  
  Revision  Changes    Path
  1.2       +9 -8      db-ojb/src/test/org/apache/ojb/odmg/shared/Master.java
  
  Index: Master.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/shared/Master.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Master.java	22 Jun 2004 18:16:22 -0000	1.1
  +++ Master.java	28 Nov 2004 03:01:57 -0000	1.2
  @@ -1,7 +1,8 @@
   package org.apache.ojb.odmg.shared;
   
   import java.io.Serializable;
  -import java.util.Vector;
  +import java.util.ArrayList;
  +import java.util.List;
   
   /**
    * the facade to all TestCases in this package.
  @@ -11,8 +12,8 @@
   {
       public Integer masterId;
       public String masterText;
  -    public Vector collDetailFKinPK = new Vector();
  -    public Vector collDetailFKnoPK = new Vector();
  +    public List collDetailFKinPK = new ArrayList();
  +    public List collDetailFKnoPK = new ArrayList();
   
       public Master(Integer id, String text)
       {
  @@ -48,9 +49,9 @@
       }
       /**
        * Gets the collDetailFKinPK.
  -     * @return Returns a java.util.Vector
  +     * @return Returns a java.util.List
        */
  -    public Vector getCollDetailFKinPK()
  +    public List getCollDetailFKinPK()
       {
           return collDetailFKinPK;
       }
  @@ -59,7 +60,7 @@
        * Sets the collDetailFKinPK.
        * @param collDetailFKinPK The collDetailFKinPK to set
        */
  -    public void setCollDetailFKinPK(java.util.Vector collDetailFKinPK)
  +    public void setCollDetailFKinPK(List collDetailFKinPK)
       {
           this.collDetailFKinPK = collDetailFKinPK;
       }
  @@ -68,7 +69,7 @@
        * Gets the collDetailFKnoPK.
        * @return Returns a java.util.Vector
        */
  -    public Vector getCollDetailFKnoPK()
  +    public List getCollDetailFKnoPK()
       {
           return collDetailFKnoPK;
       }
  @@ -77,7 +78,7 @@
        * Sets the collDetailFKnoPK.
        * @param collDetailFKnoPK The collDetailFKnoPK to set
        */
  -    public void setCollDetailFKnoPK(java.util.Vector collDetailFKnoPK)
  +    public void setCollDetailFKnoPK(List collDetailFKnoPK)
       {
           this.collDetailFKnoPK = collDetailFKnoPK;
       }
  
  
  
  1.2       +6 -5      db-ojb/src/test/org/apache/ojb/odmg/shared/ProductGroup.java
  
  Index: ProductGroup.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/shared/ProductGroup.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProductGroup.java	22 Jun 2004 18:16:22 -0000	1.1
  +++ ProductGroup.java	28 Nov 2004 03:01:57 -0000	1.2
  @@ -1,7 +1,8 @@
   package org.apache.ojb.odmg.shared;
   
   import java.io.Serializable;
  -import java.util.Vector;
  +import java.util.List;
  +import java.util.ArrayList;
   
   /** represents a product group containing a set of Articles.
    * @see org.apache.ojb.odmg.shared.Article
  @@ -44,7 +45,7 @@
       }
   
       /** collection containing all articles of a given product group*/
  -    private Vector allArticlesInGroup;
  +    private List allArticlesInGroup;
       /** a textual description of the group*/
       private String description;
       /** the unique id of a product group*/
  @@ -116,7 +117,7 @@
        * Gets the allArticlesInGroup.
        * @return Returns a Vector
        */
  -    public Vector getAllArticlesInGroup()
  +    public List getAllArticlesInGroup()
       {
           return allArticlesInGroup;
       }
  @@ -125,7 +126,7 @@
        * Sets the allArticlesInGroup.
        * @param allArticlesInGroup The allArticlesInGroup to set
        */
  -    public void setAllArticlesInGroup(Vector allArticlesInGroup)
  +    public void setAllArticlesInGroup(List allArticlesInGroup)
       {
           this.allArticlesInGroup = allArticlesInGroup;
       }
  @@ -134,7 +135,7 @@
       {
           if(allArticlesInGroup == null)
           {
  -            allArticlesInGroup = new Vector();
  +            allArticlesInGroup = new ArrayList();
           }
           allArticlesInGroup.add(article);
       }
  
  
  
  1.16      +10 -11    db-ojb/src/test/org/apache/ojb/odmg/CollectionsTest.java
  
  Index: CollectionsTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/CollectionsTest.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- CollectionsTest.java	22 Oct 2004 21:54:45 -0000	1.15
  +++ CollectionsTest.java	28 Nov 2004 03:01:57 -0000	1.16
  @@ -6,7 +6,6 @@
   import java.util.Collection;
   import java.util.Iterator;
   import java.util.List;
  -import java.util.Vector;
   
   import org.apache.ojb.broker.PersistenceBroker;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
  @@ -78,7 +77,7 @@
           tx.lock(child, Transaction.WRITE);
           List childs = new ArrayList();
           childs.add(child);
  -        gat.setCollectiblesB(childs);
  +        gat.setCollectiblesC(childs);
           tx.commit();
           //**********************************************
           // check if gatherer was stored
  @@ -141,7 +140,7 @@
           //*************************************
           tx.lock(fetchedGat, Transaction.WRITE);
           // Remove collection object
  -        database.deletePersistent(fetchedGat.getCollectiblesC().remove(0));
  +        fetchedGat.getCollectiblesC().remove(0);
           //*************************************
           tx.commit();
   
  @@ -291,8 +290,8 @@
           tx.getBroker().clearCache();
           //*************************************
           tx.lock(fetchedGat, Transaction.WRITE);
  -        tx.markDelete(fetchedGat.getCollectiblesA().remove(0));
  -        tx.markDelete(fetchedGat.getCollectiblesB().remove(0));
  +        fetchedGat.getCollectiblesA().remove(0);
  +        fetchedGat.getCollectiblesB().remove(0);
           //*************************************
           tx.commit();
   
  @@ -596,7 +595,7 @@
           newCols.add(colC.get(2));
           // lock object before do changes
           tx.lock(fetchedGat, Transaction.WRITE);
  -        fetchedGat.setCollectiblesA(newCols);
  +        fetchedGat.setCollectiblesC(newCols);
           // todo: we need to delete removed object explicit?
           database.deletePersistent(colC.get(0));
           //**********************************************************
  @@ -962,9 +961,9 @@
       {
           private Integer gatId;
           private String name;
  -        private List collectiblesA = new Vector();
  -        private List collectiblesB = new Vector();
  -        private List collectiblesC = new Vector();
  +        private List collectiblesA = new ArrayList();
  +        private List collectiblesB = new ArrayList();
  +        private List collectiblesC = new ArrayList();
   
           public Gatherer()
           {
  @@ -972,7 +971,7 @@
   
           public void addCollectibleA(CollectibleA colA)
           {
  -            if (collectiblesA == null) collectiblesA = new Vector();
  +            if (collectiblesA == null) collectiblesA = new ArrayList();
               collectiblesA.add(colA);
           }
   
  
  
  
  1.17      +2 -2      db-ojb/src/test/org/apache/ojb/odmg/OdmgExamples.java
  
  Index: OdmgExamples.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/OdmgExamples.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- OdmgExamples.java	14 Sep 2004 16:50:02 -0000	1.16
  +++ OdmgExamples.java	28 Nov 2004 03:01:57 -0000	1.17
  @@ -76,7 +76,7 @@
           }
       }
   
  -    public void testOQLQuery()
  +    public void testOQLQuery() throws Exception
       {
           Transaction tx = odmg.newTransaction();
   
  @@ -109,7 +109,7 @@
           catch (Exception ex)
           {
               tx.abort();
  -            fail("ODMGException: " + ex.getMessage());
  +            throw ex;
           }
       }
   
  
  
  
  1.15      +148 -177  db-ojb/src/test/org/apache/ojb/odmg/RITest.java
  
  Index: RITest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/RITest.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- RITest.java	22 Jun 2004 18:16:22 -0000	1.14
  +++ RITest.java	28 Nov 2004 03:01:58 -0000	1.15
  @@ -38,34 +38,27 @@
       public void testStoreFKnoPK() throws Exception
       {
           long timestamp = System.currentTimeMillis();
  -        try
  -        {
  -            Transaction tx = odmg.newTransaction();
  -            tx.begin();
  -            Master master_1 = populatedMasterFKnoPK(tx, 5, timestamp);
  -            Master master_2 = populatedMasterFKnoPK(tx, 5, timestamp);
  -
  -            database.makePersistent(master_1);
  -            database.makePersistent(master_2);
  -            tx.commit();
  -
  -            // Check stored objects
  -            OQLQuery query = odmg.newOQLQuery();
  -            query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  -            query.bind("%" + timestamp);
  -            DList allMasters = (DList) query.execute();
  -            assertEquals("We should found master objects", 2, allMasters.size());
  -            Master lookup_1 = (Master) allMasters.get(0);
  -
  -            Collection col_in = lookup_1.getCollDetailFKinPK();
  -            Collection col_no = lookup_1.getCollDetailFKnoPK();
  -            assertEquals("Should found none " + DetailFKinPK.class.getName() + " objects",
0, col_in.size());
  -            assertEquals("Should found " + DetailFKnoPK.class.getName() + " objects", 5,
col_no.size());
  -        }
  -        finally
  -        {
  -            database.close();
  -        }
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +        Master master_1 = populatedMasterFKnoPK(tx, 5, timestamp);
  +        Master master_2 = populatedMasterFKnoPK(tx, 5, timestamp);
  +
  +        database.makePersistent(master_1);
  +        database.makePersistent(master_2);
  +        tx.commit();
  +
  +        // Check stored objects
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  +        query.bind("%" + timestamp);
  +        DList allMasters = (DList) query.execute();
  +        assertEquals("We should found master objects", 2, allMasters.size());
  +        Master lookup_1 = (Master) allMasters.get(0);
  +
  +        Collection col_in = lookup_1.getCollDetailFKinPK();
  +        Collection col_no = lookup_1.getCollDetailFKnoPK();
  +        assertEquals("Should found none " + DetailFKinPK.class.getName() + " objects",
0, col_in.size());
  +        assertEquals("Should found " + DetailFKnoPK.class.getName() + " objects", 5, col_no.size());
       }
   
       /**
  @@ -75,34 +68,27 @@
       public void testStoreFKinPK() throws Exception
       {
           final long timestamp = System.currentTimeMillis();
  -        try
  -        {
  -            Transaction tx = odmg.newTransaction();
  -            tx.begin();
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
   
  -            Master master_1 = populatedMasterFKinPK(tx, 5, timestamp);
  -            Master master_2 = populatedMasterFKinPK(tx, 5, timestamp);
  +        Master master_1 = populatedMasterFKinPK(tx, 5, timestamp);
  +        Master master_2 = populatedMasterFKinPK(tx, 5, timestamp);
   
  -            database.makePersistent(master_1);
  -            database.makePersistent(master_2);
  -            tx.commit();
  -
  -            // Check stored objects
  -            OQLQuery query = odmg.newOQLQuery();
  -            query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  -            query.bind("%" + timestamp);
  -            DList allMasters = (DList) query.execute();
  -            assertEquals("We should found master objects", 2, allMasters.size());
  -            Master lookup_1 = (Master) allMasters.get(0);
  -            Collection col_in = lookup_1.getCollDetailFKinPK();
  -            Collection col_no = lookup_1.getCollDetailFKnoPK();
  -            assertEquals("Should found none " + DetailFKnoPK.class.getName() + " objects",
0, col_no.size());
  -            assertEquals("Should found " + DetailFKinPK.class.getName() + " objects", 5,
col_in.size());
  -        }
  -        finally
  -        {
  -            database.close();
  -        }
  +        database.makePersistent(master_1);
  +        database.makePersistent(master_2);
  +        tx.commit();
  +
  +        // Check stored objects
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  +        query.bind("%" + timestamp);
  +        DList allMasters = (DList) query.execute();
  +        assertEquals("We should found master objects", 2, allMasters.size());
  +        Master lookup_1 = (Master) allMasters.get(0);
  +        Collection col_in = lookup_1.getCollDetailFKinPK();
  +        Collection col_no = lookup_1.getCollDetailFKnoPK();
  +        assertEquals("Should found none " + DetailFKnoPK.class.getName() + " objects",
0, col_no.size());
  +        assertEquals("Should found " + DetailFKinPK.class.getName() + " objects", 5, col_in.size());
       }
   
       private Master populatedMasterFKnoPK(Transaction tx, int countDetailObjects, long timestamp)
  @@ -142,60 +128,51 @@
       public void testDelete() throws Exception
       {
           long timestamp = System.currentTimeMillis();
  -        try
  -        {
  -            // 2. Get a list of all Masters
  -            Transaction tx = odmg.newTransaction();
  -            tx.begin();
  -            // 1. Insert some objects into the database, some of them with
  -            // details in DetailFKinPK, some of them in DetailFKnoPK
  -            Master master_1 = populatedMasterFKinPK(tx, 7, timestamp);
  -            Master master_2 = populatedMasterFKinPK(tx, 6, timestamp);
  -            Master master_3 = populatedMasterFKnoPK(tx, 7, timestamp);
  -            Master master_4 = populatedMasterFKnoPK(tx, 6, timestamp);
  -
  -            tx.lock(master_1, Transaction.WRITE);
  -            tx.lock(master_2, Transaction.WRITE);
  -            tx.lock(master_3, Transaction.WRITE);
  -            tx.lock(master_4, Transaction.WRITE);
  -            tx.commit();
  -
  -            tx.begin();
  -            OQLQuery query = odmg.newOQLQuery();
  -            query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  -            query.bind("%" + timestamp);
  -            DList allMasters = (DList) query.execute();
  -
  -            // Iterator over all Master objects
  -            Iterator it = allMasters.iterator();
  -            int counter = 0;
  -            while (it.hasNext())
  -            {
  -                ++counter;
  -                Master aMaster = (Master) it.next();
  -                Iterator it2 = aMaster.collDetailFKinPK.iterator();
  -                while (it2.hasNext())
  -                    database.deletePersistent(it2.next());
  -                it2 = aMaster.collDetailFKnoPK.iterator();
  -                while (it2.hasNext())
  -                    database.deletePersistent(it2.next());
  -                database.deletePersistent(aMaster);
  -            }
  -            tx.commit();
  -            assertEquals("Wrong count of Master objects found", 4, counter);
  -
  -            query = odmg.newOQLQuery();
  -            query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  -            query.bind("%" + timestamp);
  -            allMasters = (DList) query.execute();
  -            assertEquals("Delete of Master objects failed", 0, allMasters.size());
  -
  -            database.close();
  -        }
  -        finally
  -        {
  -
  -        }
  +        // 2. Get a list of all Masters
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +        // 1. Insert some objects into the database, some of them with
  +        // details in DetailFKinPK, some of them in DetailFKnoPK
  +        Master master_1 = populatedMasterFKinPK(tx, 7, timestamp);
  +        Master master_2 = populatedMasterFKinPK(tx, 6, timestamp);
  +        Master master_3 = populatedMasterFKnoPK(tx, 7, timestamp);
  +        Master master_4 = populatedMasterFKnoPK(tx, 6, timestamp);
  +
  +        tx.lock(master_1, Transaction.WRITE);
  +        tx.lock(master_2, Transaction.WRITE);
  +        tx.lock(master_3, Transaction.WRITE);
  +        tx.lock(master_4, Transaction.WRITE);
  +        tx.commit();
  +
  +        tx.begin();
  +        OQLQuery query = odmg.newOQLQuery();
  +        query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  +        query.bind("%" + timestamp);
  +        DList allMasters = (DList) query.execute();
  +
  +        // Iterator over all Master objects
  +        Iterator it = allMasters.iterator();
  +        int counter = 0;
  +        while (it.hasNext())
  +        {
  +            ++counter;
  +            Master aMaster = (Master) it.next();
  +            Iterator it2 = aMaster.collDetailFKinPK.iterator();
  +            while (it2.hasNext())
  +                database.deletePersistent(it2.next());
  +            it2 = aMaster.collDetailFKnoPK.iterator();
  +            while (it2.hasNext())
  +                database.deletePersistent(it2.next());
  +            database.deletePersistent(aMaster);
  +        }
  +        tx.commit();
  +        assertEquals("Wrong count of Master objects found", 4, counter);
  +
  +        query = odmg.newOQLQuery();
  +        query.create("select masters from " + Master.class.getName() + " where masterText
like $1");
  +        query.bind("%" + timestamp);
  +        allMasters = (DList) query.execute();
  +        assertEquals("Delete of Master objects failed", 0, allMasters.size());
       }
   
       public void testInsertAfterDelete() throws Exception
  @@ -209,76 +186,70 @@
   
           obj2.setPk(contractPk);
           obj2.setContractValue2(2);
  -        try
  -        {
  -            // 1. Insert object
  -            Transaction tx = odmg.newTransaction();
  -            tx.begin();
  -            /*
  -            arminw:
  -            seems to have problems when within a tx a object
  -            was stored/deleted.
  -            Without obj1 test pass
  -            TODO: fix this
  -            */
  -            //database.makePersistent(obj1);
  -            database.makePersistent(obj2);
  -            //database.deletePersistent(obj1);
  -            /*
  -             thma: I checked this, and don't see a problem here.
  -            obj1 and obj2 have the same Identity. Thus the 
  -            calls database.makePersistent(obj1); and database.makePersistent(obj2);
  -            will only register one instance to the transaction.
  -            The second call does not add a second instance, but just marks the
  -            existing instance as dirty a second time.
  -            So it's no wonder why after deletePersistent(obj1); no contract is found.
  -            Works as designed.
  -            The Lesson to learn: never let business objects have the same primary key values!
  -             * */
  -            tx.commit();
  -            Collection result = getContract(contractPk, odmg);
  -            assertEquals("We should found exact one contract", 1, result.size());
  -            obj2 = (Contract) result.iterator().next();
  -            if (obj2 == null)
  -            {
  -                fail("Contract not found");
  -            }
  -            else if (obj2.getContractValue2() != 2)
  -            {
  -                fail("Wrong contract found");
  -            }
  -
  -            // 2. Delete, then insert object with the same identity
  -            tx.begin();
  -            database.deletePersistent(obj2);
  -            database.makePersistent(obj1);
  -            tx.commit();
  -            result = getContract(contractPk, odmg);
  -            assertEquals("We should found exact one contract", 1, result.size());
  -            obj1 = (Contract) result.iterator().next();
  -            if (obj1 == null)
  -            {
  -                fail("Contract not found");
  -            }
  -            else if (obj1.getContractValue2() != 1)
  -            {
  -                fail("Wrong contract found");
  -            }
  -
  -            // 3. Delete
  -            tx.begin();
  -            database.deletePersistent(obj1);
  -            tx.commit();
  -
  -            result = getContract(contractPk, odmg);
  -            if (result.size() > 0)
  -            {
  -                fail("Contract was not deleted");
  -            }
  -        }
  -        finally
  +        
  +        // 1. Insert object
  +        Transaction tx = odmg.newTransaction();
  +        tx.begin();
  +        /*
  +        arminw:
  +        seems to have problems when within a tx a object
  +        was stored/deleted.
  +        Without obj1 test pass
  +        TODO: fix this
  +        */
  +        //database.makePersistent(obj1);
  +        database.makePersistent(obj2);
  +        //database.deletePersistent(obj1);
  +        /*
  +         thma: I checked this, and don't see a problem here.
  +        obj1 and obj2 have the same Identity. Thus the
  +        calls database.makePersistent(obj1); and database.makePersistent(obj2);
  +        will only register one instance to the transaction.
  +        The second call does not add a second instance, but just marks the
  +        existing instance as dirty a second time.
  +        So it's no wonder why after deletePersistent(obj1); no contract is found.
  +        Works as designed.
  +        The Lesson to learn: never let business objects have the same primary key values!
  +         * */
  +        tx.commit();
  +        Collection result = getContract(contractPk, odmg);
  +        assertEquals("We should found exact one contract", 1, result.size());
  +        obj2 = (Contract) result.iterator().next();
  +        if (obj2 == null)
  +        {
  +            fail("Contract not found");
  +        }
  +        else if (obj2.getContractValue2() != 2)
  +        {
  +            fail("Wrong contract found");
  +        }
  +
  +        // 2. Delete, then insert object with the same identity
  +        tx.begin();
  +        database.deletePersistent(obj2);
  +        database.makePersistent(obj1);
  +        tx.commit();
  +        result = getContract(contractPk, odmg);
  +        assertEquals("We should found exact one contract", 1, result.size());
  +        obj1 = (Contract) result.iterator().next();
  +        if (obj1 == null)
  +        {
  +            fail("Contract not found");
  +        }
  +        else if (obj1.getContractValue2() != 1)
  +        {
  +            fail("Wrong contract found");
  +        }
  +
  +        // 3. Delete
  +        tx.begin();
  +        database.deletePersistent(obj1);
  +        tx.commit();
  +
  +        result = getContract(contractPk, odmg);
  +        if (result.size() > 0)
           {
  -            database.close();
  +            fail("Contract was not deleted");
           }
       }
   
  
  
  
  1.18      +16 -15    db-ojb/src/test/org/apache/ojb/odmg/UserTestCases.java
  
  Index: UserTestCases.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/UserTestCases.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- UserTestCases.java	14 Nov 2004 09:42:54 -0000	1.17
  +++ UserTestCases.java	28 Nov 2004 03:01:58 -0000	1.18
  @@ -220,36 +220,37 @@
        */
       public void testStoreRetrieveSameTxn()
       {
  -        try
  -        {
  +            String name = "testStoreRetrieveSameTxn_" + System.currentTimeMillis();
               Person mum = new PersonImpl();
  -            TransactionImpl txn = (TransactionImpl) odmg.newTransaction();
  +            mum.setFirstname(name);
  +
  +            TransactionExt txn = (TransactionExt)odmg.newTransaction();
               txn.begin();
               txn.lock(mum, Transaction.WRITE);
               // System.out.println("locked for write: " + mum);
  -            Identity mumId = new Identity(mum, txn.getBroker());
               txn.commit();
  -            txn.begin();
   
  -            Person mum2 = (Person) txn.getObjectByIdentity(mumId);
  +            txn.begin();
  +            txn.getBroker().clearCache();
  +            Identity mumId = txn.getBroker().serviceIdentity().buildIdentity(mum);
  +            Person mum2 = (Person) txn.getBroker().getObjectByIdentity(mumId);
               // System.out.println("retrieved: " + mum2);
               txn.commit();
  -        }
  -        catch (Exception exc)
  -        {
  -            exc.printStackTrace();
  -            fail("caught unexpected exception: " + exc.toString());
  -        }
  +
  +            assertNotNull(mum2);
  +            assertEquals(name, mum2.getFirstname());
       }
   
       public void testRetrieveNonExistent()
       {
           try
           {
  -            // construct an id that does not exist in the database
  -            Identity id = new Identity(PersonImpl.class, Person.class, new Integer[]{new
Integer(-1000000)});
               TransactionImpl txn = (TransactionImpl) odmg.newTransaction();
               txn.begin();
  +            // construct an id that does not exist in the database
  +            Identity id = txn.getBroker().serviceIdentity().buildIdentity(
  +                    PersonImpl.class, Person.class, new Integer[]{new Integer(-1000000)});
  +
               txn.getObjectByIdentity(id);
               txn.abort();
           }
  
  
  

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