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 MtoNTest.java
Date Thu, 26 Feb 2004 20:22:37 GMT
brj         2004/02/26 12:22:37

  Modified:    src/test/org/apache/ojb/broker MtoNTest.java
  Log:
  additional Testcase with auto-update=false
  
  Revision  Changes    Path
  1.13      +45 -6     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MtoNTest.java	17 Feb 2004 20:52:31 -0000	1.12
  +++ MtoNTest.java	26 Feb 2004 20:22:37 -0000	1.13
  @@ -8,7 +8,6 @@
   import java.util.Arrays;
   import java.util.Collection;
   import java.util.Date;
  -import java.util.Iterator;
   import java.util.List;
   import java.util.Vector;
   
  @@ -96,12 +95,48 @@
           return retPaper;
       }
   
  -    public void testCreate()
  +    /**
  +     * Store m-side and intermediary 
  +     */
  +    public void testStoringWithAutoUpdateFalse1()
       {
  -        Paper paper = createPaper();    
  +        ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
  +        CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
  +        boolean autoUpdate = cod.getCascadeStore();
  +
  +        cod.setCascadeStore(false);
  + 
  +        try
  +        {
  +            String now = new Date().toString();
  +            Paper paper = new Paper();
  +            paper.setAuthor("Jonny Myers");
  +            paper.setDate(now);
  +            Qualifier qual = new Topic();
  +            qual.setName("qual " + now);
  +            paper.setQualifiers(Arrays.asList(new Qualifier[] { qual }));
  +            broker.beginTransaction();
  +            broker.store(paper);        // store Paper and intermediary table only
  +            Identity paperId = new Identity(paper, broker);
  +            broker.commitTransaction();
  +                       
  +            broker.clearCache();
  +            broker.beginTransaction();
  +            Paper retPaper = (Paper) broker.getObjectByIdentity(paperId);
  +            assertEquals(0, retPaper.getQualifiers().size());
  +            broker.commitTransaction();
  +        }
  +        finally
  +        {
  +            cod.setCascadeStore(autoUpdate);
  +        }
       }
   
  -    public void testStoringWithAutoUpdateFalse()
  +    /**
  +     * Store m-side, intermediary and n-side 
  +     * n-side forced by using broker.store()
  +     */
  +    public void testStoringWithAutoUpdateFalse2()
       {
           ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
           CollectionDescriptor cod = cld.getCollectionDescriptorByName("qualifiers");
  @@ -120,13 +155,14 @@
               paper.setQualifiers(Arrays.asList(new Qualifier[] { qual }));
               broker.beginTransaction();
               broker.store(paper);        // store Paper and intermediary table only
  +            broker.store(qual);         // store Qualifier
               Identity paperId = new Identity(paper, broker);
               broker.commitTransaction();
                          
               broker.clearCache();
               broker.beginTransaction();
               Paper retPaper = (Paper) broker.getObjectByIdentity(paperId);
  -            assertEquals(0, retPaper.getQualifiers().size());
  +            assertEquals(1, retPaper.getQualifiers().size());
               broker.commitTransaction();
           }
           finally
  @@ -134,7 +170,10 @@
               cod.setCascadeStore(autoUpdate);
           }
       }
  -
  +    
  +    /**
  +     * Store m-side, intermediary and n-side 
  +     */
       public void testStoringWithAutoUpdateTrue()
       {
           ClassDescriptor cld = broker.getClassDescriptor(Paper.class);
  
  
  

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