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 ReferenceTest.java
Date Thu, 06 Oct 2005 15:21:41 GMT
arminw      2005/10/06 08:21:41

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        ReferenceTest.java
  Log:
  try to reproduce OJB-49 (can't reproduce)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.17.2.4  +62 -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.2.3
  retrieving revision 1.17.2.4
  diff -u -r1.17.2.3 -r1.17.2.4
  --- ReferenceTest.java	8 Aug 2005 13:18:48 -0000	1.17.2.3
  +++ ReferenceTest.java	6 Oct 2005 15:21:41 -0000	1.17.2.4
  @@ -43,6 +43,67 @@
       }
   
       /**
  +     * Test for OJB-49
  +     */
  +    public void testQueryExtentsWithAutoRefreshEnabled() throws Exception
  +    {
  +        String name = "testQueryExtentsWithAutoRefreshEnabled_"+ System.currentTimeMillis();
  +
  +        int cascadeObject = ObjectReferenceDescriptor.CASCADE_OBJECT;
  +        ojbChangeReferenceSetting(ObjA.class, "ref", true, cascadeObject, cascadeObject,
false);
  +        ojbChangeReferenceSetting(ObjB.class, "ref", true, cascadeObject, cascadeObject,
false);
  +
  +        ClassDescriptor cldA = broker.getClassDescriptor(ObjA.class);
  +        ClassDescriptor cldB = broker.getClassDescriptor(ObjB.class);
  +        boolean oldRefreshA = cldA.isAlwaysRefresh();
  +        boolean oldRefreshB = cldB.isAlwaysRefresh();
  +        cldA.setAlwaysRefresh(true);
  +        cldB.setAlwaysRefresh(true);
  +
  +        try
  +        {
  +            ObjA objA = new ObjA();
  +            objA.setName(name);
  +            ObjB objB = new ObjB();
  +            objB.setName(name);
  +            ObjC objC = new ObjC();
  +            objC.setName(name);
  +
  +            ObjA objA2 = new ObjA();
  +            objA2.setName(name);
  +            ObjB objB2 = new ObjB();
  +            objB2.setName(name);
  +            ObjC objC2 = new ObjC();
  +            objC2.setName(name);
  +
  +            List refs = new ArrayList();
  +            refs.add(objA2);
  +            refs.add(objB2);
  +
  +            objA.setRef(objB);
  +            objC2.setReferences(refs);
  +            objB.setRef(objC);
  +            objC2.setRef(objA);
  +
  +            broker.beginTransaction();
  +            broker.store(objA);
  +            broker.store(objC2);
  +            broker.commitTransaction();
  +
  +            Criteria crit = new Criteria();
  +            crit.addLike("name", name);
  +            Query q = QueryFactory.newQuery(RefObject.class, crit);
  +            Collection result = broker.getCollectionByQuery(q);
  +            assertEquals(6, result.size());
  +        }
  +        finally
  +        {
  +            cldA.setAlwaysRefresh(oldRefreshA);
  +            cldB.setAlwaysRefresh(oldRefreshB);
  +        }
  +    }
  +
  +    /**
        * Test the usage of interface as class-ref in collection-descriptor
        * when using inheritance.
        */
  
  
  

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