db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: jakarta-ojb/src/test/org/apache/ojb/broker MtoNMapping.java
Date Sun, 08 Dec 2002 13:16:06 GMT
brj         2002/12/08 05:16:06

  Modified:    src/test/org/apache/ojb/broker MtoNMapping.java
  Log:
  new testcase for delete and insert
  
  Revision  Changes    Path
  1.7       +32 -0     jakarta-ojb/src/test/org/apache/ojb/broker/MtoNMapping.java
  
  Index: MtoNMapping.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/broker/MtoNMapping.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MtoNMapping.java	3 Nov 2002 20:22:44 -0000	1.6
  +++ MtoNMapping.java	8 Dec 2002 13:16:05 -0000	1.7
  @@ -198,6 +198,38 @@
   
       }
   
  +    /** Add a new Project, delete an existing Project */
  +    public void testInsertAndDelete() throws Exception
  +    {
  +        Person pers = new Person();
  +        pers.setId(2);
  +        Query query = QueryFactory.newQuery(pers);
  +        pers = (Person) broker.getObjectByQuery(query);
  +        Collection projects = pers.getProjects();
  +        Project[] projectArray = (Project[]) projects.toArray(new Project[0]);
  +        Project oldProj, newProj; 
  +        int count = projects.size();
  +         
  +        oldProj = projectArray[0];
  +        projects.remove(oldProj);
  +        
  +        newProj = new Project();
  +        newProj.setTitle("Test Project for Person 2");
  +        newProj.setDescription("This is a Test Project for Person 2");
  +        projects.add(newProj);
  +        
  +        broker.beginTransaction();
  +        broker.delete(oldProj);
  +        broker.store(pers);
  +        broker.commitTransaction();
  +
  +        broker.clearCache();
  +
  +        pers = (Person) broker.getObjectByQuery(query);
  +        assertEquals(count , pers.getProjects().size());
  +
  +    }
  +        
       /** test deleting objects from an m:n association*/
       public void testDeletion() throws Exception
       {
  
  
  

Mime
View raw message