db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mka...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/odmg ObjectImageTest.java
Date Thu, 14 Apr 2005 17:48:43 GMT
mkalen      2005/04/14 10:48:43

  Modified:    src/test/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        ObjectImageTest.java
  Log:
  Make testCollectionReference_2a independent of book->review ordering returned from RDBMS.
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.4   +39 -27    db-ojb/src/test/org/apache/ojb/odmg/ObjectImageTest.java
  
  Index: ObjectImageTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/ObjectImageTest.java,v
  retrieving revision 1.1.2.3
  retrieving revision 1.1.2.4
  diff -u -r1.1.2.3 -r1.1.2.4
  --- ObjectImageTest.java	18 Mar 2005 19:22:30 -0000	1.1.2.3
  +++ ObjectImageTest.java	14 Apr 2005 17:48:43 -0000	1.1.2.4
  @@ -1,5 +1,20 @@
   package org.apache.ojb.odmg;
   
  +/* Copyright 2002-2005 The Apache Software Foundation
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
   import java.io.Serializable;
   import java.util.ArrayList;
   import java.util.Collection;
  @@ -19,42 +34,22 @@
   import org.odmg.OQLQuery;
   import org.odmg.Transaction;
   
  -/* Copyright 2002-2004 The Apache Software Foundation
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *     http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
   /**
    * Check the quality of object image comparison:
    * - new referenced objects
    * - deleted referenced objects
    * - deleted referenced objects
  - * ...etc
  + * ...etc.
    *
  - * TODO: make all tests work. Test cases for refactored odmg-api implementation. These
tests
  - * reproduce all outstanding issues of current implementation and make tests of proxy object
handling
  - * in odmg-api.
  + * Test cases for refactored odmg-api implementation. These tests asserts previously outstanding
  + * ODMG-issues and proxy object handling in the ODMG API.
    * 
    * @author <a href="mailto:arminw@apache.org">Armin Waibel</a>
    * @version $Id$
    */
   public class ObjectImageTest extends ODMGTestCase
   {
  -    public static void main(String[] args)
  -    {
  -        junit.textui.TestRunner.main(new String[]{ObjectImageTest.class.getName()});
  -    }
  -    
  +
       /**
        * only lock object, no changes made
        */
  @@ -809,6 +804,7 @@
           tx.lock(b, Transaction.WRITE);
           Review newR2 = (Review) b.getReviews().get(1);
           newR2.setSummary("updated" + name);
  +        final int newR2id = newR2.getId().intValue();
           tx.commit();
   
           assertEquals(versionBook, b.getVersion());
  @@ -826,7 +822,18 @@
           b = (Book) result.iterator().next();
           assertNotNull(b.getReviews());
           assertEquals(3, b.getReviews().size());
  -        newR2 = (Review) b.getReviews().get(1);
  +
  +        // Search for the updated R2:
  +        final List updatedReviews = b.getReviews();
  +        for (int i = 0; i < updatedReviews.size(); i++)
  +        {
  +            newR2 = (Review) updatedReviews.get(i);
  +            if (newR2id == newR2.getId().intValue()) {
  +                break;
  +            }
  +        }
  +        assertEquals("Could not find the updated review in the returned results",
  +                newR2id, newR2.getId().intValue());
           assertEquals("updated" + name, newR2.getSummary());
           assertEquals(versionBook, b.getVersion());
           // this referenced object was not updated
  @@ -1114,7 +1121,7 @@
           tx.lock(b, Transaction.WRITE);
           tx.setCascadingDelete(Book.class, "reviews", true);
           // remove from collection with cascading delete
  -        Review newR1 = (Review) b.getReviews().remove(0);
  +        b.getReviews().remove(0);
           tx.commit();
   
           // only the removed reference has changed
  @@ -1317,6 +1324,11 @@
           assertEquals(0, result.size());
       }
   
  +    public static void main(String[] args)
  +    {
  +        junit.textui.TestRunner.main(new String[]{ObjectImageTest.class.getName()});
  +    }
  +
       //=======================================================
       // inner test classes
       //=======================================================
  
  
  

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