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 CollectionTest.java
Date Wed, 09 Mar 2005 20:58:39 GMT
brj         2005/03/09 12:58:39

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        CollectionTest.java
  Log:
  Testcase for RemovalAwareCollection ProductGroup/Article
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.11.2.3  +67 -2     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.11.2.2
  retrieving revision 1.11.2.3
  diff -u -r1.11.2.2 -r1.11.2.3
  --- CollectionTest.java	9 Mar 2005 19:42:17 -0000	1.11.2.2
  +++ CollectionTest.java	9 Mar 2005 20:58:39 -0000	1.11.2.3
  @@ -831,7 +831,72 @@
           assertTrue(loadedCopy.getCollectiblesBase() instanceof RemovalAwareCollection);
           assertEquals(0, loadedCopy.getCollectiblesBase().size());
       }
  -    
  +
  +    /**
  +     * Test RemovalAwareCollection remove() and clear()
  +     */
  +    public void testRemovalAwareCollectionProxy()
  +    {
  +        String prefix = "testRemovalAwareCollectionProxy_" + System.currentTimeMillis();
  +
  +        Identity pgId;
  +        ProductGroup loadedCopy;
  +        InterfaceArticle article;
  +        ProductGroup pg = new ProductGroup(null, "PG_" + prefix, null);
  +        article = new Article();
  +        article.setArticleName("Art_1_" + prefix);
  +        pg.add(article);
  +        article = new Article();
  +        article.setArticleName("Art_2_" + prefix);
  +        pg.add(article);
  +        article = new Article();
  +        article.setArticleName("Art_3_" + prefix);
  +        pg.add(article);
  +
  +        broker.beginTransaction();
  +        broker.store(pg);
  +        broker.commitTransaction();
  +        assertTrue(pg.getGroupId() != null);
  +        pgId = broker.serviceIdentity().buildIdentity(pg);
  +
  +        broker.clearCache();
  +        loadedCopy = (ProductGroup) broker.getObjectByIdentity(pgId);
  +        assertNotNull(loadedCopy);
  +        assertNotNull(loadedCopy.getAllArticlesInGroup());
  +        assertTrue(loadedCopy.getAllArticlesInGroup() instanceof RemovalAwareCollection);
  +        assertEquals(3, loadedCopy.getAllArticlesInGroup().size());
  +        
  +        //
  +        // Remove a single element
  +        //
  +        broker.beginTransaction();
  +        loadedCopy.getAllArticlesInGroup().remove(2);
  +        broker.store(loadedCopy);
  +        broker.commitTransaction();
  +        
  +        broker.clearCache();
  +        loadedCopy = (ProductGroup) broker.getObjectByIdentity(pgId);
  +        assertNotNull(loadedCopy);
  +        assertNotNull(loadedCopy.getAllArticlesInGroup());
  +        assertTrue(loadedCopy.getAllArticlesInGroup() instanceof RemovalAwareCollection);
  +        assertEquals(2, loadedCopy.getAllArticlesInGroup().size());
  +
  +        //
  +        // Remove all elements
  +        //
  +        broker.beginTransaction();
  +        loadedCopy.getAllArticlesInGroup().clear();
  +        broker.store(loadedCopy);
  +        broker.commitTransaction();
  +        
  +        broker.clearCache();
  +        loadedCopy = (ProductGroup) broker.getObjectByIdentity(pgId);
  +        assertNotNull(loadedCopy);
  +        assertNotNull(loadedCopy.getAllArticlesInGroup());
  +        assertTrue(loadedCopy.getAllArticlesInGroup() instanceof RemovalAwareCollection);
  +        assertEquals(0, loadedCopy.getAllArticlesInGroup().size());
  +    }
  +
       //************************************************************
       // helper methods
       //************************************************************
  
  
  

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