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 repository_junit.xml
Date Sat, 20 Dec 2003 21:01:48 GMT
brj         2003/12/20 13:01:48

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_BRANCH_1_0
                        MtoNTest.java
               src/test/org/apache/ojb Tag: OJB_BRANCH_1_0
                        repository_junit.xml
  Added:       src/test/org/apache/ojb/broker Tag: OJB_BRANCH_1_0
                        PersonWithArray.java ProjectWithArray.java
  Log:
  testcases for m:n relationship using Array
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.9.2.1   +62 -0     db-ojb/src/test/org/apache/ojb/broker/MtoNTest.java
  
  Index: MtoNTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MtoNTest.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- MtoNTest.java	11 Jul 2003 19:01:24 -0000	1.9
  +++ MtoNTest.java	20 Dec 2003 21:01:48 -0000	1.9.2.1
  @@ -4,12 +4,15 @@
   
   package org.apache.ojb.broker;
   
  +import java.util.ArrayList;
   import java.util.Arrays;
  +import java.util.Collection;
   import java.util.Date;
   import java.util.List;
   import java.util.Vector;
   
   import junit.framework.TestCase;
  +
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.util.collections.ManageableArrayList;
  @@ -359,5 +362,64 @@
   //        }
           assertEquals(1,newNews.getQualifiers().size());
       }
  + 
  +    // Bidirectional m:n relationship using Collection
  +    public void testStoreBidirectionalCollection()
  +    {
  +        int id = (int)System.currentTimeMillis();
  +        Person personA = new Person();
  +        personA.setId(id++);
  +        personA.setFirstname("Anton");
  +
  +        Project proj1 = new Project();
  +        proj1.setId(id++);
  +        proj1.setTitle("Project 1");
  +
  +        Project proj2 = new Project();
  +        proj2.setId(id++);
  +        proj2.setTitle("Project 2");
  +
  +        Collection persons = new ArrayList();
  +        persons.add(personA);
  +        proj1.setPersons(persons);
  +        proj2.setPersons(persons);
  +        
  +        Collection projects = new ArrayList();
  +        projects.add(proj1);
  +        projects.add(proj2);
  +        personA.setProjects(projects);
  +
  +        broker.beginTransaction();
  +        broker.store(personA);
  +        broker.store(proj1);
  +        broker.store(proj2);
  +        broker.commitTransaction();
  +    }  
       
  +    // Bidirectional m:n relationship using Array
  +    public void testStoreBidirectionalArray()
  +    {
  +        int id = (int)System.currentTimeMillis();
  +        PersonWithArray personA = new PersonWithArray();
  +        personA.setId(id++);
  +        personA.setFirstname("Anton");
  +
  +        ProjectWithArray proj1 = new ProjectWithArray();
  +        proj1.setId(id++);
  +        proj1.setTitle("Project 1");
  +
  +        ProjectWithArray proj2 = new ProjectWithArray();
  +        proj2.setId(id++);
  +        proj2.setTitle("Project 2");
  +
  +        proj1.setPersons(new PersonWithArray[] { personA });
  +        proj2.setPersons(new PersonWithArray[] { personA });
  +        personA.setProjects(new ProjectWithArray[] { proj1, proj2 });
  +
  +        broker.beginTransaction();
  +        broker.store(personA);
  +        broker.store(proj1);
  +        broker.store(proj2);
  +        broker.commitTransaction();
  +    }    
   }
  
  
  
  No                   revision
  
  Index: MtoNTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MtoNTest.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- MtoNTest.java	11 Jul 2003 19:01:24 -0000	1.9
  +++ MtoNTest.java	20 Dec 2003 21:01:48 -0000	1.9.2.1
  @@ -4,12 +4,15 @@
   
   package org.apache.ojb.broker;
   
  +import java.util.ArrayList;
   import java.util.Arrays;
  +import java.util.Collection;
   import java.util.Date;
   import java.util.List;
   import java.util.Vector;
   
   import junit.framework.TestCase;
  +
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.util.collections.ManageableArrayList;
  @@ -359,5 +362,64 @@
   //        }
           assertEquals(1,newNews.getQualifiers().size());
       }
  + 
  +    // Bidirectional m:n relationship using Collection
  +    public void testStoreBidirectionalCollection()
  +    {
  +        int id = (int)System.currentTimeMillis();
  +        Person personA = new Person();
  +        personA.setId(id++);
  +        personA.setFirstname("Anton");
  +
  +        Project proj1 = new Project();
  +        proj1.setId(id++);
  +        proj1.setTitle("Project 1");
  +
  +        Project proj2 = new Project();
  +        proj2.setId(id++);
  +        proj2.setTitle("Project 2");
  +
  +        Collection persons = new ArrayList();
  +        persons.add(personA);
  +        proj1.setPersons(persons);
  +        proj2.setPersons(persons);
  +        
  +        Collection projects = new ArrayList();
  +        projects.add(proj1);
  +        projects.add(proj2);
  +        personA.setProjects(projects);
  +
  +        broker.beginTransaction();
  +        broker.store(personA);
  +        broker.store(proj1);
  +        broker.store(proj2);
  +        broker.commitTransaction();
  +    }  
       
  +    // Bidirectional m:n relationship using Array
  +    public void testStoreBidirectionalArray()
  +    {
  +        int id = (int)System.currentTimeMillis();
  +        PersonWithArray personA = new PersonWithArray();
  +        personA.setId(id++);
  +        personA.setFirstname("Anton");
  +
  +        ProjectWithArray proj1 = new ProjectWithArray();
  +        proj1.setId(id++);
  +        proj1.setTitle("Project 1");
  +
  +        ProjectWithArray proj2 = new ProjectWithArray();
  +        proj2.setId(id++);
  +        proj2.setTitle("Project 2");
  +
  +        proj1.setPersons(new PersonWithArray[] { personA });
  +        proj2.setPersons(new PersonWithArray[] { personA });
  +        personA.setProjects(new ProjectWithArray[] { proj1, proj2 });
  +
  +        broker.beginTransaction();
  +        broker.store(personA);
  +        broker.store(proj1);
  +        broker.store(proj2);
  +        broker.commitTransaction();
  +    }    
   }
  
  
  
  No                   revision
  
  Index: MtoNTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MtoNTest.java,v
  retrieving revision 1.9
  retrieving revision 1.9.2.1
  diff -u -r1.9 -r1.9.2.1
  --- MtoNTest.java	11 Jul 2003 19:01:24 -0000	1.9
  +++ MtoNTest.java	20 Dec 2003 21:01:48 -0000	1.9.2.1
  @@ -4,12 +4,15 @@
   
   package org.apache.ojb.broker;
   
  +import java.util.ArrayList;
   import java.util.Arrays;
  +import java.util.Collection;
   import java.util.Date;
   import java.util.List;
   import java.util.Vector;
   
   import junit.framework.TestCase;
  +
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.util.collections.ManageableArrayList;
  @@ -359,5 +362,64 @@
   //        }
           assertEquals(1,newNews.getQualifiers().size());
       }
  + 
  +    // Bidirectional m:n relationship using Collection
  +    public void testStoreBidirectionalCollection()
  +    {
  +        int id = (int)System.currentTimeMillis();
  +        Person personA = new Person();
  +        personA.setId(id++);
  +        personA.setFirstname("Anton");
  +
  +        Project proj1 = new Project();
  +        proj1.setId(id++);
  +        proj1.setTitle("Project 1");
  +
  +        Project proj2 = new Project();
  +        proj2.setId(id++);
  +        proj2.setTitle("Project 2");
  +
  +        Collection persons = new ArrayList();
  +        persons.add(personA);
  +        proj1.setPersons(persons);
  +        proj2.setPersons(persons);
  +        
  +        Collection projects = new ArrayList();
  +        projects.add(proj1);
  +        projects.add(proj2);
  +        personA.setProjects(projects);
  +
  +        broker.beginTransaction();
  +        broker.store(personA);
  +        broker.store(proj1);
  +        broker.store(proj2);
  +        broker.commitTransaction();
  +    }  
       
  +    // Bidirectional m:n relationship using Array
  +    public void testStoreBidirectionalArray()
  +    {
  +        int id = (int)System.currentTimeMillis();
  +        PersonWithArray personA = new PersonWithArray();
  +        personA.setId(id++);
  +        personA.setFirstname("Anton");
  +
  +        ProjectWithArray proj1 = new ProjectWithArray();
  +        proj1.setId(id++);
  +        proj1.setTitle("Project 1");
  +
  +        ProjectWithArray proj2 = new ProjectWithArray();
  +        proj2.setId(id++);
  +        proj2.setTitle("Project 2");
  +
  +        proj1.setPersons(new PersonWithArray[] { personA });
  +        proj2.setPersons(new PersonWithArray[] { personA });
  +        personA.setProjects(new ProjectWithArray[] { proj1, proj2 });
  +
  +        broker.beginTransaction();
  +        broker.store(personA);
  +        broker.store(proj1);
  +        broker.store(proj2);
  +        broker.commitTransaction();
  +    }    
   }
  
  
  
  1.1.2.1   +1 -1      db-ojb/src/test/org/apache/ojb/broker/PersonWithArray.java
  
  Index: PersonWithArray.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PersonWithArray.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  
  
  
  1.1.2.1   +1 -1      db-ojb/src/test/org/apache/ojb/broker/ProjectWithArray.java
  
  Index: ProjectWithArray.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/ProjectWithArray.java,v
  retrieving revision 1.1
  retrieving revision 1.1.2.1
  diff -u -r1.1 -r1.1.2.1
  
  
  
  No                   revision
  No                   revision
  1.102.2.1 +72 -2     db-ojb/src/test/org/apache/ojb/repository_junit.xml
  
  Index: repository_junit.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit.xml,v
  retrieving revision 1.102
  retrieving revision 1.102.2.1
  diff -u -r1.102 -r1.102.2.1
  --- repository_junit.xml	9 Dec 2003 13:46:46 -0000	1.102
  +++ repository_junit.xml	20 Dec 2003 21:01:48 -0000	1.102.2.1
  @@ -904,6 +904,41 @@
         </collection-descriptor>
      </class-descriptor>
   
  +<!-- Definitions for org.apache.ojb.broker.PersonWithArray -->
  +   <class-descriptor
  +   	  class="org.apache.ojb.broker.PersonWithArray"
  +   	  table="PERSON"
  +   >
  +      <field-descriptor
  +         name="id"
  +         column="ID"
  +         jdbc-type="INTEGER"
  +         primarykey="true"
  +         autoincrement="true"
  +      />
  +      <field-descriptor
  +         name="firstname"
  +         column="FIRSTNAME"
  +         jdbc-type="VARCHAR"
  +      />
  +      <field-descriptor
  +         name="lastname"
  +         column="LASTNAME"
  +         jdbc-type="VARCHAR"
  +      />
  +      <collection-descriptor
  +         name="projects"
  +         element-class-ref="org.apache.ojb.broker.ProjectWithArray"
  +         auto-retrieve="true"
  +         auto-update="true"
  +         indirection-table="PERSON_PROJECT"
  +      >
  +         <fk-pointing-to-this-class column="PERSON_ID"/>
  +         <fk-pointing-to-element-class column="PROJECT_ID"/>
  +      </collection-descriptor>
  +   </class-descriptor>
  +
  +
   <!-- Definitions for org.apache.ojb.broker.Project -->
      <class-descriptor
   	  class="org.apache.ojb.broker.Project"
  @@ -945,6 +980,41 @@
         </collection-descriptor>
      </class-descriptor>
   
  +<!-- Definitions for org.apache.ojb.broker.ProjectWithArray -->
  +   <class-descriptor
  +	  class="org.apache.ojb.broker.ProjectWithArray"
  +	  table="PROJECT"
  +   >
  +      <field-descriptor
  +         name="id"
  +         column="ID"
  +         jdbc-type="INTEGER"
  +         primarykey="true"
  +         autoincrement="true"
  +      />
  +      <field-descriptor
  +         name="title"
  +         column="TITLE"
  +         jdbc-type="VARCHAR"
  +      />
  +      <field-descriptor
  +         name="description"
  +         column="DESCRIPTION"
  +         jdbc-type="VARCHAR"
  +      />
  +      <collection-descriptor
  +         name="persons"
  +         element-class-ref="org.apache.ojb.broker.PersonWithArray"
  +         auto-retrieve="true"
  +         auto-update="false"
  +         indirection-table="PERSON_PROJECT"
  +      >
  +         <fk-pointing-to-this-class column="PROJECT_ID"/>
  +         <fk-pointing-to-element-class column="PERSON_ID"/>
  +      </collection-descriptor>
  +   </class-descriptor>
  +
  +
   <!-- Definitions for org.apache.ojb.broker.Role -->
      <class-descriptor
      	  class="org.apache.ojb.broker.Role"
  @@ -3005,4 +3075,4 @@
           />
       </class-descriptor>
   
  -<!-- Mapping of classes used in junit tests and tutorials ends here -->
  +<!-- Mapping of classes used in junit tests and tutorials ends here -->
  \ No newline at end of file
  
  
  

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