You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2004/02/18 13:49:32 UTC

cvs commit: db-ojb/src/test/org/apache/ojb/broker CollectionTest.java

arminw      2004/02/18 04:49:32

  Modified:    src/test/org/apache/ojb/broker CollectionTest.java
  Log:
  add new test
  
  Revision  Changes    Path
  1.8       +29 -7     db-ojb/src/test/org/apache/ojb/broker/CollectionTest.java
  
  Index: CollectionTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/CollectionTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CollectionTest.java	29 Jan 2004 12:33:39 -0000	1.7
  +++ CollectionTest.java	18 Feb 2004 12:49:32 -0000	1.8
  @@ -75,20 +75,42 @@
           junit.textui.TestRunner.main(arr);
       }
   
  -    public void setUp() throws PBFactoryException
  +    public void setUp() throws Exception
       {
           broker = PersistenceBrokerFactory.defaultPersistenceBroker();
       }
   
       public void tearDown()
       {
  -        try
  -        {
  -            broker.close();
  -        }
  -        catch (PersistenceBrokerException e)
  +        if(broker != null) broker.close();
  +    }
  +
  +    public void testReadProxyCollection() throws Exception
  +    {
  +        String name = "testReadProxyCollection_"+System.currentTimeMillis();
  +        Gatherer gat = new Gatherer(null, name);
  +        CollectibleB[] cols = prepareCollectibleB(name);
  +
  +        gat.setCollectiblesB(Arrays.asList(cols));
  +        broker.beginTransaction();
  +        broker.store(gat);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +        Criteria crit = new Criteria();
  +        crit.addLike("name", name);
  +        Query q = QueryFactory.newQuery(Gatherer.class, crit);
  +        Gatherer newGat = (Gatherer)broker.getObjectByQuery(q);
  +
  +        Iterator it = newGat.getCollectiblesB().iterator();
  +        int i = 0;
  +        while(it.hasNext())
           {
  +            CollectibleB colB = (CollectibleB) it.next();
  +            assertTrue(colB.getName().indexOf(name) > -1);
  +            i++;
           }
  +        assertEquals(4, i);
       }
   
       public void testStoreReadOfUserDefinedCollectionClass()
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org