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 M2NTest.java
Date Sun, 13 Nov 2005 16:04:36 GMT
arminw      2005/11/13 08:04:36

  Modified:    src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        M2NTest.java
  Log:
  update tests, use service methods of OJBTestCase to change the metadata settings in tests
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.7.2.10  +62 -71    db-ojb/src/test/org/apache/ojb/broker/M2NTest.java
  
  Index: M2NTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/M2NTest.java,v
  retrieving revision 1.7.2.9
  retrieving revision 1.7.2.10
  diff -u -r1.7.2.9 -r1.7.2.10
  --- M2NTest.java	13 Nov 2005 15:45:54 -0000	1.7.2.9
  +++ M2NTest.java	13 Nov 2005 16:04:36 -0000	1.7.2.10
  @@ -6,11 +6,10 @@
   import java.util.List;
   
   import org.apache.commons.lang.ClassUtils;
  -import org.apache.commons.lang.builder.ToStringBuilder;
  -import org.apache.commons.lang.builder.HashCodeBuilder;
   import org.apache.commons.lang.builder.EqualsBuilder;
  +import org.apache.commons.lang.builder.HashCodeBuilder;
  +import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.lang.time.StopWatch;
  -import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
   import org.apache.ojb.broker.query.Criteria;
  @@ -45,12 +44,6 @@
   
       public void tearDown() throws Exception
       {
  -        if(broker != null)
  -        {
  -            changeActorCollectionDescriptorTo(false, NONE, NONE, false);
  -            changeMovieCollectionDescriptorTo(false, NONE, NONE, false);
  -            broker.close();
  -        }
           super.tearDown();
       }
   
  @@ -117,8 +110,9 @@
   
       public void testSimpleStore()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, OBJECT, false);
           String postfix = "testSimple_" + System.currentTimeMillis();
           Movie m = new MovieImpl(postfix, postfix, null);
           Actor a = new Actor(postfix);
  @@ -142,7 +136,7 @@
        */
       public void testAutoUpdateDeleteSettings()
       {
  -        changeActorCollectionDescriptorTo(false, false, false, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", false, false, false, false);
           CollectionDescriptor ord = broker.getClassDescriptor(Actor.class)
                   .getCollectionDescriptorByName("movies");
           assertEquals(LINK, ord.getCascadingStore());
  @@ -150,7 +144,7 @@
           assertEquals(false, ord.getCascadeStore());
           assertEquals(false, ord.getCascadeDelete());
   
  -        changeActorCollectionDescriptorTo(false, true, true, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", false, true, true, false);
           ord = broker.getClassDescriptor(Actor.class)
                   .getCollectionDescriptorByName("movies");
           assertEquals(OBJECT, ord.getCascadingStore());
  @@ -165,8 +159,9 @@
           long testPeriod = 0;
   
           String postfix = "testMassStoreUpdateAutomatic_" + System.currentTimeMillis();
  -        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, OBJECT, false);
   
           Movie movie = buildMovieWithActors(postfix, actorCount);
           Actor actor = buildActorWithMovies(postfix, movieCount);
  @@ -289,8 +284,9 @@
           long testPeriod = 0;
   
           String postfix = "testMassStoreUpdateLinking" + System.currentTimeMillis();
  -        changeMovieCollectionDescriptorTo(true, NONE, OBJECT, false);
  -        changeActorCollectionDescriptorTo(true, NONE, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, NONE, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, NONE, OBJECT, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, NONE, OBJECT, false);
   
           Movie movie = buildMovieWithActors(postfix, actorCount);
           Actor actor = buildActorWithMovies(postfix, movieCount);
  @@ -427,8 +423,9 @@
       // an object graph
       public void YYYtestStoreAddUpdateDeleteTLLF()
       {
  -        changeMovieCollectionDescriptorTo(true, LINK, LINK, false);
  -        changeActorCollectionDescriptorTo(true, LINK, LINK, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, LINK, LINK, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, LINK, LINK, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, LINK, LINK, false);
           String postfix = "_testStoreTLLF_" + System.currentTimeMillis();
           Movie movie = buildMovieWithActorsAndBackReferences(postfix);
           doTestStoreAddUpdateDeleteTLLX(movie, postfix);
  @@ -436,8 +433,9 @@
   
       public void YYYtestStoreAddUpdateDeleteTLLT()
       {
  -        changeMovieCollectionDescriptorTo(true, LINK, LINK, true);
  -        changeActorCollectionDescriptorTo(true, LINK, LINK, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, LINK, LINK, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, LINK, LINK, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, LINK, LINK, false);
           String postfix = "_testStoreTLLF_" + System.currentTimeMillis();
           Movie movie = buildMovieWithActorsAndBackReferences(postfix);
           doTestStoreAddUpdateDeleteTLLX(movie, postfix);
  @@ -535,8 +533,9 @@
        */
       public void testStoreFFFF()
       {
  -        changeMovieCollectionDescriptorTo(false, NONE, NONE, false);
  -        changeActorCollectionDescriptorTo(false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", false, NONE, NONE, false);
           String postfix = "" + System.currentTimeMillis();
           Movie movie = buildMovieWithActors(postfix);
           doTestStoreFFFX(movie, postfix);
  @@ -548,8 +547,9 @@
        */
       public void testStoreFFFT()
       {
  -        changeMovieCollectionDescriptorTo(false, NONE, NONE, true);
  -        changeActorCollectionDescriptorTo(false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", false, NONE, NONE, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", false, NONE, NONE, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", false, NONE, NONE, false);
           String postfix = "" + System.currentTimeMillis();
           Movie movie = buildMovieWithActors(postfix);
           doTestStoreFFFX(movie, postfix);
  @@ -562,8 +562,9 @@
        */
       public void testStoreFFFF_2()
       {
  -        changeMovieCollectionDescriptorTo(false, NONE, NONE, false);
  -        changeActorCollectionDescriptorTo(false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", false, NONE, NONE, false);
           String postfix = "" + System.currentTimeMillis();
           Movie movie = buildMovieWithActorsAndBackReferences(postfix);
           doTestStoreFFFX(movie, postfix);
  @@ -576,8 +577,9 @@
        */
       public void testStoreFFFT_2()
       {
  -        changeMovieCollectionDescriptorTo(false, NONE, NONE, true);
  -        changeActorCollectionDescriptorTo(false, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", false, NONE, NONE, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", false, NONE, NONE, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", false, NONE, NONE, false);
           String postfix = "" + System.currentTimeMillis();
           Movie movie = buildMovieWithActorsAndBackReferences(postfix);
           doTestStoreFFFX(movie, postfix);
  @@ -705,8 +707,9 @@
        */
       public void testStoreTFFF()
       {
  -        changeMovieCollectionDescriptorTo(true, NONE, NONE, false);
  -        changeActorCollectionDescriptorTo(true, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, NONE, NONE, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, NONE, NONE, false);
           doTestStoreTFFX();
       }
   
  @@ -716,8 +719,9 @@
        */
       public void testStoreTFFT()
       {
  -        changeMovieCollectionDescriptorTo(true, NONE, NONE, true);
  -        changeActorCollectionDescriptorTo(true, NONE, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, NONE, NONE, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, NONE, NONE, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, NONE, NONE, false);
           doTestStoreTFFX();
       }
   
  @@ -868,15 +872,17 @@
   
       public void testStoreTTFF()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, NONE, false);
           doTestStoreTTXX();
       }
   
       public void testStoreTTFT()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, true);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, NONE, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, NONE, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, NONE, false);
           doTestStoreTTXX();
       }
   
  @@ -916,8 +922,9 @@
        */
       public void testStoreTTFT_2()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, true);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, NONE, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, NONE, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, NONE, false);
           doTestStoreTTXX_2();
       }
   
  @@ -952,15 +959,17 @@
       
       public void testStoreUpdateTTFF()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, NONE, false);
           doTestStoreUpdateTTXX();
       }
   
       public void testStoreUpdateTTFF_2()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, true);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, NONE, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, NONE, true);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, NONE, false);
           doTestStoreUpdateTTXX();
       }
   
  @@ -1013,8 +1022,9 @@
   
       public void testStoreUpdateActorTTFF()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, NONE, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, NONE, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, NONE, false);
   
           String postfix = "" + System.currentTimeMillis();
           Actor actor = buildActorWithMovies(postfix);
  @@ -1047,16 +1057,18 @@
   
       public void testAddNewEntriesTTTF()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  -        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, OBJECT, false);
           doTestAddNewEntries();
       }
   
       public void testAddNewEntriesTTTT()
       {
  -        changeMovieCollectionDescriptorTo(true, OBJECT, OBJECT, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors", true, OBJECT, OBJECT, true);
  +        ojbChangeReferenceSetting(MovieImpl.class, "actors2", true, OBJECT, OBJECT, true);
           // default proxy does not work for user defined collection
  -        changeActorCollectionDescriptorTo(true, OBJECT, OBJECT, false);
  +        ojbChangeReferenceSetting(Actor.class, "movies", true, OBJECT, OBJECT, false);
           doTestAddNewEntries();
       }
   
  @@ -1327,27 +1339,6 @@
           return a;
       }
   
  -    void changeActorCollectionDescriptorTo(boolean autoRetrieve, int autoUpdate, int autoDelete,
boolean proxy)
  -    {
  -        ojbChangeReferenceSetting(Actor.class, "movies", autoRetrieve, autoUpdate, autoDelete,
proxy);
  -    }
  -
  -    void changeActorCollectionDescriptorTo(boolean autoRetrieve, boolean autoUpdate, boolean
autoDelete, boolean proxy)
  -    {
  -        ClassDescriptor cld = broker.getClassDescriptor(Actor.class);
  -        CollectionDescriptor cod = (CollectionDescriptor) cld.getCollectionDescriptors().get(0);
  -        cod.setLazy(proxy);
  -        cod.setCascadeRetrieve(autoRetrieve);
  -        cod.setCascadeStore(autoUpdate);
  -        cod.setCascadeDelete(autoDelete);
  -    }
  -
  -    void changeMovieCollectionDescriptorTo(boolean autoRetrieve, int autoUpdate, int autoDelete,
boolean proxy)
  -    {
  -        ojbChangeReferenceSetting(MovieImpl.class, "actors", autoRetrieve, autoUpdate,
autoDelete, proxy);
  -        ojbChangeReferenceSetting(MovieImpl.class, "actors2", autoRetrieve, autoUpdate,
autoDelete, proxy);
  -    }
  -
   
   
       //=======================================================================
  
  
  

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