db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker ReferenceTest.java
Date Wed, 29 Sep 2004 20:05:47 GMT
brj         2004/09/29 13:05:47

  Modified:    src/test/org/apache/ojb/broker ReferenceTest.java
  Log:
  new testcase for bidirectional reference
  
  Revision  Changes    Path
  1.18      +34 -1     db-ojb/src/test/org/apache/ojb/broker/ReferenceTest.java
  
  Index: ReferenceTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ReferenceTest.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ReferenceTest.java	22 May 2004 16:23:45 -0000	1.17
  +++ ReferenceTest.java	29 Sep 2004 20:05:47 -0000	1.18
  @@ -324,6 +324,39 @@
           assertEquals(wine.getRegion().getCountry(), loadedWine.getRegion().getCountry());
       }
   
  +    public void testStoreBidirectionalReference()
  +    {
  +        String name = "testStoreBidirectionalReference_" + System.currentTimeMillis();
  +        RefObject a = new ObjA();
  +        RefObject b = new ObjB();
  +
  +        b.setName(name+"_second_1");
  +        a.setName(name+"_first_1");
  +
  +        a.setRef(b);
  +        b.setRef(a);
  +
  +        broker.beginTransaction();
  +        broker.store(a);
  +        broker.commitTransaction();
  +        
  +        broker.clearCache();
  +        
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("name",name+"_second_1");
  +        Query q = QueryFactory.newQuery(ObjB.class, crit);
  +        Collection result = broker.getCollectionByQuery(q);
  +        
  +        assertEquals(result.size(), 1);
  +        
  +        Object[] obj = result.toArray();
  +        ObjB obj_b = (ObjB)obj[0];
  +        ObjA obj_a = (ObjA)obj_b.ref;
  +        
  +        assertNotNull(obj_a);
  +        assertEquals(obj_a.name, name+"_first_1");
  +    }
  +    
       public void testStoreReferencesMappedToSameTable()
       {
           String referenceNamePrefix = "testStoreReferencesMappedToSameTable" + System.currentTimeMillis();
  
  
  

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