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 OneToManyTest.java
Date Mon, 11 Aug 2003 08:53:00 GMT
arminw      2003/08/11 01:53:00

  Modified:    src/test/org/apache/ojb/broker OneToManyTest.java
  Log:
  use tx demarcation for object
  operations
  
  Revision  Changes    Path
  1.8       +27 -16    db-ojb/src/test/org/apache/ojb/broker/OneToManyTest.java
  
  Index: OneToManyTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/OneToManyTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- OneToManyTest.java	8 Aug 2003 10:26:50 -0000	1.7
  +++ OneToManyTest.java	11 Aug 2003 08:53:00 -0000	1.8
  @@ -32,36 +32,45 @@
   	 */
       public void testDeleteWithRemovalAwareCollection()
       {
  -    	ProductGroupWithRemovalAwareCollection pg = new ProductGroupWithRemovalAwareCollection();
  -    	pg.setGroupName("nice group");
  +    	long timestamp = System.currentTimeMillis();
  +
  +        ProductGroupWithRemovalAwareCollection pg = new ProductGroupWithRemovalAwareCollection();
  +    	// auto-increment was not enabled in repository
  +        // thus we set our own
  +        pg.setId((int) timestamp%Integer.MAX_VALUE);
  +        pg.setGroupName("testDeleteWithRemovalAwareCollection_"+timestamp);
   
       	Identity pgId = new Identity(pg, broker);
   
       	Article a = new Article();
  -    	a.setArticleName("a");
  -    	Article b = new Article();
  -    	b.setArticleName("b");
  -    	Article c = new Article();
  -    	c.setArticleName("c");
  +    	a.setArticleName("testDeleteWithRemovalAwareCollection_"+timestamp);
  +
  +        Article b = new Article();
  +    	b.setArticleName("testDeleteWithRemovalAwareCollection_"+timestamp);
  +
  +        Article c = new Article();
  +    	c.setArticleName("testDeleteWithRemovalAwareCollection_"+timestamp);
   
       	pg.add(a);
       	pg.add(b);
       	pg.add(c);
  -
  +        broker.beginTransaction();
       	broker.store(pg);
  +        broker.commitTransaction();
  +
       	broker.clearCache();
       	pg = (ProductGroupWithRemovalAwareCollection) broker.getObjectByIdentity(pgId);
       	assertEquals(3,pg.getAllArticles().size());
   
       	pg.getAllArticles().remove(c);
       	pg.getAllArticles().remove(0);
  +        broker.beginTransaction();
       	broker.store(pg);
  +        broker.commitTransaction();
   
       	broker.clearCache();
       	pg = (ProductGroupWithRemovalAwareCollection) broker.getObjectByIdentity(pgId);
       	assertEquals(1,pg.getAllArticles().size());
  -
  -
       }
   
       /**
  @@ -70,18 +79,22 @@
        */
       public void testPolymorphOneToMany()
       {
  -        Zoo myZoo = new Zoo("London");
  +        long timestamp = System.currentTimeMillis();
  +
  +        Zoo myZoo = new Zoo("London_"+timestamp);
           Identity id = new Identity(myZoo, broker);
   
  -        Mammal elephant = new Mammal(37,"Jumbo",4);
  -        Mammal cat = new Mammal(11,"Silvester",4);
  -        Reptile snake = new Reptile(3,"Kaa","green");
  +        Mammal elephant = new Mammal(0,"Jumbo_"+timestamp,4);
  +        Mammal cat = new Mammal(0,"Silvester_"+timestamp,4);
  +        Reptile snake = new Reptile(0,"Kaa_"+timestamp,"green");
   
           myZoo.addAnimal(snake);
           myZoo.addAnimal(elephant);
           myZoo.addAnimal(cat);
   // System.out.println("## "+myZoo);
  +        broker.beginTransaction();
           broker.store(myZoo);
  +        broker.commitTransaction();
   // System.out.println("## "+myZoo);
   
           broker.clearCache();
  @@ -89,9 +102,7 @@
           Zoo loadedZoo = (Zoo) broker.getObjectByIdentity(id);
           List animals = loadedZoo.getAnimals();
           assertEquals(3, animals.size());
  -
       }
  -
   
       /**
        * Insert the method's description here.
  
  
  

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