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 QueryTest.java
Date Fri, 23 Jul 2004 11:31:25 GMT
arminw      2004/07/23 04:31:24

  Modified:    src/test/org/apache/ojb/broker QueryTest.java
  Log:
  add new test case, query extent objects
  
  Revision  Changes    Path
  1.65      +59 -0     db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- QueryTest.java	21 Jul 2004 09:19:20 -0000	1.64
  +++ QueryTest.java	23 Jul 2004 11:31:24 -0000	1.65
  @@ -1565,4 +1565,63 @@
           assertEquals(count, result.size());
       }
   
  +    public void testExtentByInterface()
  +    {
  +        String name = "testExtentByInterface_" + System.currentTimeMillis();
  +        Zoo zoo = new Zoo();
  +        zoo.setName(name);
  +        Mammal m1 = new Mammal();
  +        m1.setName(name);
  +        Mammal m2 = new Mammal();
  +        m2.setName(name);
  +        Reptile r1 = new Reptile();
  +        r1.setName(name);
  +        broker.beginTransaction();
  +        broker.store(zoo);
  +        m1.setZooId(zoo.getZooId());
  +        m2.setZooId(zoo.getZooId());
  +        r1.setZooId(zoo.getZooId());
  +        broker.store(m1);
  +        broker.store(m2);
  +        broker.store(r1);
  +        broker.commitTransaction();
  +
  +        Criteria crit = new Criteria();
  +        crit.addEqualTo("name", name);
  +
  +        QueryByCriteria queryAnimals = QueryFactory.newQuery(InterfaceAnimal.class, crit);
  +        QueryByCriteria queryReptile = QueryFactory.newQuery(Reptile.class, crit);
  +        QueryByCriteria queryMammal = QueryFactory.newQuery(Mammal.class, crit);
  +
  +        Collection resultA = broker.getCollectionByQuery(queryAnimals);
  +        Collection resultR = broker.getCollectionByQuery(queryReptile);
  +        Collection resultM = broker.getCollectionByQuery(queryMammal);
  +
  +        assertEquals(3, resultA.size());
  +        assertEquals(1, resultR.size());
  +        assertEquals(2, resultM.size());
  +
  +        for (Iterator iterator = resultA.iterator(); iterator.hasNext();)
  +        {
  +            InterfaceAnimal a =  (InterfaceAnimal) iterator.next();
  +            assertEquals(name, a.getName());
  +
  +        }
  +        for (Iterator iterator = resultR.iterator(); iterator.hasNext();)
  +        {
  +            Reptile a =  (Reptile) iterator.next();
  +            assertEquals(name, a.getName());
  +        }
  +        for (Iterator iterator = resultM.iterator(); iterator.hasNext();)
  +        {
  +            Mammal a =  (Mammal) iterator.next();
  +            assertEquals(name, a.getName());
  +        }
  +
  +        Reptile reptile = (Reptile) broker.getObjectByQuery(queryReptile);
  +        Mammal mammal = (Mammal) broker.getObjectByQuery(queryMammal);
  +        assertNotNull(reptile);
  +        assertNotNull(mammal);
  +    }
  +
   }
  
  
  

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