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 MultithreadedReadTest.java AllTests.java
Date Thu, 05 Feb 2004 17:43:12 GMT
arminw      2004/02/05 09:43:12

  Modified:    src/test/org/apache/ojb repository_junit_reference.xml
               src/test/org/apache/ojb/broker MultithreadedReadTest.java
                        AllTests.java
  Log:
  - add MultithreadedReadTest to test suite
  - add new read test
  - update metadata
  
  Revision  Changes    Path
  1.7       +8 -4      db-ojb/src/test/org/apache/ojb/repository_junit_reference.xml
  
  Index: repository_junit_reference.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/repository_junit_reference.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- repository_junit_reference.xml	4 Feb 2004 00:25:27 -0000	1.6
  +++ repository_junit_reference.xml	5 Feb 2004 17:43:12 -0000	1.7
  @@ -934,6 +934,7 @@
       <class-descriptor
          class="org.apache.ojb.broker.MultithreadedReadTest$AccountImpl"
          table="READTEST_ACCOUNT"
  +        proxy="dynamic"
       >
          <field-descriptor
             name="id"
  @@ -962,7 +963,7 @@
             auto-retrieve="true"
             auto-update="true"
             auto-delete="false"
  -          proxy="true"
  +          proxy="false"
          >
             <foreignkey field-ref="fk"/>
          </reference-descriptor>
  @@ -972,6 +973,7 @@
       <class-descriptor
          class="org.apache.ojb.broker.MultithreadedReadTest$BuyerImpl"
          table="READTEST_BUYER"
  +        proxy="dynamic"
       >
          <field-descriptor
             name="id"
  @@ -1000,7 +1002,7 @@
             auto-retrieve="true"
             auto-update="true"
             auto-delete="false"
  -          proxy="true"
  +          proxy="false"
          >
             <foreignkey field-ref="fk"/>
          </reference-descriptor>
  @@ -1009,6 +1011,7 @@
       <class-descriptor
          class="org.apache.ojb.broker.MultithreadedReadTest$AddressImpl"
          table="READTEST_ADDRESS"
  +        proxy="dynamic"
       >
          <field-descriptor
             name="id"
  @@ -1037,7 +1040,7 @@
             auto-retrieve="true"
             auto-update="true"
             auto-delete="false"
  -          proxy="true"
  +          proxy="false"
          >
             <foreignkey field-ref="fk"/>
          </reference-descriptor>
  @@ -1046,6 +1049,7 @@
       <class-descriptor
          class="org.apache.ojb.broker.MultithreadedReadTest$AddressTypeImpl"
          table="READTEST_ADDRESS_TYPE"
  +        proxy="dynamic"
       >
          <field-descriptor
             name="id"
  
  
  
  1.2       +51 -9     db-ojb/src/test/org/apache/ojb/broker/MultithreadedReadTest.java
  
  Index: MultithreadedReadTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/MultithreadedReadTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultithreadedReadTest.java	4 Feb 2004 00:25:27 -0000	1.1
  +++ MultithreadedReadTest.java	5 Feb 2004 17:43:12 -0000	1.2
  @@ -1,12 +1,13 @@
   package org.apache.ojb.broker;
   
  -import java.util.Iterator;
  +import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Collection;
  +import java.util.Iterator;
   import java.util.List;
  -import java.util.ArrayList;
   
  -import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.broker.query.Criteria;
  +import org.apache.ojb.broker.query.QueryByCriteria;
   
   /**
    * Tests multithreaded read of objects using proxy for nested 1:1 references
  @@ -42,6 +43,42 @@
           super.tearDown();
       }
   
  +    public void testClosedPB() throws Throwable
  +    {
  +        String name = "testClosedPB_"+System.currentTimeMillis();
  +
  +        Integer[] ids = prepareTestRead(name, 5);
  +        Account account = null;
  +        PersistenceBroker broker = null;
  +        try
  +        {
  +            broker = PersistenceBrokerFactory.defaultPersistenceBroker();
  +            Criteria crit = new Criteria();
  +            crit.addIn("id", Arrays.asList(ids));
  +            QueryByCriteria query = new QueryByCriteria(Account.class, crit);
  +            Collection result = broker.getCollectionByQuery(query);
  +            Iterator iter = result.iterator();
  +            //			 iter.next();
  +            account = (Account) iter.next();
  +            while (iter.hasNext())
  +            {
  +                iter.next();
  +            }
  +        }
  +        finally
  +        {
  +            if (broker != null) broker.close();
  +        }
  +
  +        TestCaseRunnable tct [] = new TestCaseRunnable[50];
  +        for (int i = 0; i < concurrentThreads; i++)
  +        {
  +            tct[i] = new TestHandleMaterialize(account, name);
  +        }
  +        // run test classes
  +        runTestCaseRunnables(tct);
  +    }
  +
       /**
        * Read objects using lazy materialization for references from DB. Different threads
        * call the references on the read objects
  @@ -133,19 +170,21 @@
           System.out.println("Multithreaded lazy read of objects - end");
       }
   
  -    private void prepareTestRead(String searchCriteria, int numbers) throws Exception
  +    private Integer[] prepareTestRead(String name, int numbers) throws Exception
       {
  +        Integer[] ids = new Integer[numbers];
           PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();
           try
           {
               broker.beginTransaction();
               for (int i = 0; i < numbers; i++)
               {
  -                AddressType type = new AddressTypeImpl(searchCriteria);
  -                Address address = new AddressImpl(searchCriteria, type);
  -                Buyer buyer = new BuyerImpl(searchCriteria, address);
  -                Account account = new AccountImpl(searchCriteria, buyer);
  +                AddressType type = new AddressTypeImpl(name);
  +                Address address = new AddressImpl(name, type);
  +                Buyer buyer = new BuyerImpl(name, address);
  +                Account account = new AccountImpl(name, buyer);
                   broker.store(account);
  +                ids[i] = account.getId();
               }
               broker.commitTransaction();
               broker.clearCache();
  @@ -154,6 +193,7 @@
           {
               if (broker != null) broker.close();
           }
  +        return ids;
       }
   
       private List prepareTestLazyRead(String searchCriteria, int numbers) throws Exception
  @@ -313,7 +353,9 @@
           {
               assertEquals(name, account.getName());
               assertNotNull("All accounts have a reference to an Buyer", account.getBuyer());
  +            assertEquals(name, account.getBuyer().getName());
               assertNotNull("All buyers have a reference to an Address", account.getBuyer().getAddress());
  +            assertEquals(name, account.getBuyer().getAddress().getName());
               assertNotNull("All addresses have a reference to an AdressType", account.getBuyer().getAddress().getType());
               assertNotNull("All AddressType have a name", account.getBuyer().getAddress().getType().getName());
           }
  
  
  
  1.39      +1 -0      db-ojb/src/test/org/apache/ojb/broker/AllTests.java
  
  Index: AllTests.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/AllTests.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- AllTests.java	27 Jan 2004 19:42:46 -0000	1.38
  +++ AllTests.java	5 Feb 2004 17:43:12 -0000	1.39
  @@ -86,6 +86,7 @@
           suite.addTestSuite(NestedFieldsTest.class);
           suite.addTestSuite(ReadonlyTest.class);
           suite.addTestSuite(ReferenceMapTest.class);
  +        suite.addTestSuite(MultithreadedReadTest.class);
           return suite;
       }
   
  
  
  

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