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 repository_junit.xml
Date Sun, 12 Dec 2004 01:35:13 GMT
arminw      2004/12/11 17:35:13

  Modified:    src/schema Tag: OJB_1_0_RELEASE ojbtest-data.dtd
                        ojbtest-data.xml ojbtest-schema.xml
               src/test/org/apache/ojb/broker Tag: OJB_1_0_RELEASE
                        BatchModeTest.java
                        OptimisticLockingMultithreadedTest.java
                        QueryTest.java
               src/test/org/apache/ojb/junit Tag: OJB_1_0_RELEASE
                        OJBTestCase.java
               src/test/org/apache/ojb/odmg Tag: OJB_1_0_RELEASE
                        MultiDBUsageTest.java
               src/test/org/apache/ojb Tag: OJB_1_0_RELEASE
                        repository_junit.xml
  Log:
  update tests, remove unused test class
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.14.2.1  +0 -9      db-ojb/src/schema/ojbtest-data.dtd
  
  Index: ojbtest-data.dtd
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-data.dtd,v
  retrieving revision 1.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- ojbtest-data.dtd	5 Apr 2004 13:58:59 -0000	1.14
  +++ ojbtest-data.dtd	12 Dec 2004 01:35:12 -0000	1.14.2.1
  @@ -27,7 +27,6 @@
       Person*,
       Project*,
       PersonProject*,
  -    Task*,
       FamilyMember*,
       LockedByVersion*,
       LockedByTimestamp*,
  @@ -159,14 +158,6 @@
       Id CDATA #REQUIRED
       Title CDATA #IMPLIED
       Description CDATA #IMPLIED
  ->
  -
  -<!ELEMENT Task EMPTY>
  -<!ATTLIST Task
  -  TaskId CDATA #REQUIRED
  -  PersonId CDATA #REQUIRED
  -  ProjectId CDATA #REQUIRED
  -  Taskname CDATA #IMPLIED
   >
   
   <!ELEMENT PersonProject EMPTY>
  
  
  
  1.15.2.1  +0 -5      db-ojb/src/schema/ojbtest-data.xml
  
  Index: ojbtest-data.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-data.xml,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- ojbtest-data.xml	5 Apr 2004 13:58:59 -0000	1.15
  +++ ojbtest-data.xml	12 Dec 2004 01:35:12 -0000	1.15.2.1
  @@ -148,11 +148,6 @@
       <PersonProject PersonId="7" ProjectId="5" Rolename="founder"/>
       <PersonProject PersonId="7" ProjectId="6" Rolename="tester"/>
   
  -    <Task TaskId="1" PersonId="2" ProjectId="1" Taskname="Initial Layout"/>
  -    <Task TaskId="2" PersonId="2" ProjectId="1" Taskname="Initial Spec"/>
  -    <Task TaskId="3" PersonId="2" ProjectId="2" Taskname="Project Cleanup"/>
  -    <Task TaskId="4" PersonId="2" ProjectId="3" Taskname="Testing Scripts"/>
  -
       <ConversionReferrer Pk1="1" Ref1="50" TestId="10"/>
       <ConversionReferrer Pk1="2" Ref1="51" TestId="11"/>
       <ConversionReferrer Pk1="3" Ref1="52" TestId="12"/>
  
  
  
  1.80.2.6  +30 -41    db-ojb/src/schema/ojbtest-schema.xml
  
  Index: ojbtest-schema.xml
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/schema/ojbtest-schema.xml,v
  retrieving revision 1.80.2.5
  retrieving revision 1.80.2.6
  diff -u -r1.80.2.5 -r1.80.2.6
  --- ojbtest-schema.xml	4 Dec 2004 14:50:50 -0000	1.80.2.5
  +++ ojbtest-schema.xml	12 Dec 2004 01:35:12 -0000	1.80.2.6
  @@ -40,9 +40,9 @@
            javaName="ProductGroup">
       <column name="Kategorie_Nr" required="true" primaryKey="true" type="INTEGER"
               javaName="groupId"/>
  -    <column name="KategorieName" type="VARCHAR" size="60"
  +    <column name="KategorieName" type="VARCHAR" size="150"
               javaName="groupName"/>
  -    <column name="Beschreibung" type="VARCHAR" size="60"
  +    <column name="Beschreibung" type="VARCHAR" size="150"
               javaName="description"/>
     </table>
   
  @@ -51,13 +51,13 @@
            javaName="Article">
       <column name="Artikel_Nr" required="true" primaryKey="true" type="INTEGER"
               javaName="articleId"/>
  -    <column name="Artikelname" type="VARCHAR" size="60"
  +    <column name="Artikelname" type="VARCHAR" size="150"
               javaName="articleName"/>
       <column name="Lieferanten_Nr" type="INTEGER"
               javaName="supplierId"/>
       <column name="Kategorie_Nr" type="INTEGER"
               javaName="productGroupId"/>
  -    <column name="Liefereinheit" type="VARCHAR" size="30"
  +    <column name="Liefereinheit" type="VARCHAR" size="150"
               javaName="unit"/>
       <column name="Einzelpreis" type="FLOAT"
               javaName="price"/>
  @@ -76,17 +76,17 @@
   
     <table name="BOOKS">
       <column name="Artikel_Nr" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="Artikelname" type="VARCHAR" size="60"/>
  +    <column name="Artikelname" type="VARCHAR" size="150"/>
       <column name="Lieferanten_Nr" type="INTEGER"/>
       <column name="Kategorie_Nr" type="INTEGER"/>
  -    <column name="Liefereinheit" type="VARCHAR" size="30"/>
  +    <column name="Liefereinheit" type="VARCHAR" size="150"/>
       <column name="Einzelpreis" type="FLOAT"/>
       <column name="Lagerbestand" type="INTEGER"/>
       <column name="BestellteEinheiten" type="INTEGER"/>
       <column name="MindestBestand" type="INTEGER"/>
       <column name="Auslaufartikel" type="INTEGER"/>
       <column name="ISBN" type="CHAR" size="10"/>
  -    <column name="AUTHOR" type="VARCHAR" size="50"/>
  +    <column name="AUTHOR" type="VARCHAR" size="150"/>
       <foreign-key foreignTable="Kategorien">
         <reference local="Kategorie_Nr" foreign="Kategorie_Nr"/>
       </foreign-key>
  @@ -94,16 +94,16 @@
   
     <table name="CDS">
       <column name="Artikel_Nr" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="Artikelname" type="VARCHAR" size="60"/>
  +    <column name="Artikelname" type="VARCHAR" size="150"/>
       <column name="Lieferanten_Nr" type="INTEGER"/>
       <column name="Kategorie_Nr" type="INTEGER"/>
  -    <column name="Liefereinheit" type="VARCHAR" size="30"/>
  +    <column name="Liefereinheit" type="VARCHAR" size="150"/>
       <column name="Einzelpreis" type="FLOAT"/>
       <column name="Lagerbestand" type="INTEGER"/>
       <column name="BestellteEinheiten" type="INTEGER"/>
       <column name="MindestBestand" type="INTEGER"/>
       <column name="Auslaufartikel" type="INTEGER"/>
  -    <column name="LABEL" type="VARCHAR" size="50"/>
  +    <column name="LABEL" type="VARCHAR" size="150"/>
       <column name="MUSICIANS" type="VARCHAR" size="250"/>
       <foreign-key foreignTable="Kategorien">
         <reference local="Kategorie_Nr" foreign="Kategorie_Nr"/>
  @@ -118,50 +118,50 @@
   
     <table name="TREE">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="DATA" type="VARCHAR" size="50"/>
  +    <column name="DATA" type="VARCHAR" size="150"/>
       <column name="PARENT_ID" type="INTEGER"/>
     </table>
   
     <table name="TREEGROUP">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="DATA" type="VARCHAR" size="50"/>
  +    <column name="DATA" type="VARCHAR" size="150"/>
       <column name="PARENT_ID" type="INTEGER"/>
       <column name="GROUP_ID" type="INTEGER"/>
     </table>
   
     <table name="AB_TABLE">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="CLASS_NAME" type="VARCHAR" size="60"/>
  +    <column name="CLASS_NAME" type="VARCHAR" size="150"/>
       <column name="VALUE_" type="INTEGER"/>
  -    <column name="A_FIELD" type="VARCHAR" size="60"/>
  -    <column name="B_FIELD" type="VARCHAR" size="60"/>
  +    <column name="A_FIELD" type="VARCHAR" size="150"/>
  +    <column name="B_FIELD" type="VARCHAR" size="150"/>
     </table>
   
     <!-- Product Table for Tutorial 1, 2 & 4-->
     <table name="PRODUCT">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"
               javaName="_id"/>
  -    <column name="NAME" type="VARCHAR" size="100"/>
  +    <column name="NAME" type="VARCHAR" size="150"/>
       <column name="PRICE" type="FLOAT"/>
       <column name="STOCK" type="INTEGER"/>
     </table>
   
     <table name="PERSON">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="FIRSTNAME" type="VARCHAR" size="50"/>
  -    <column name="LASTNAME" type="VARCHAR" size="50"/>
  +    <column name="FIRSTNAME" type="VARCHAR" size="150"/>
  +    <column name="LASTNAME" type="VARCHAR" size="150"/>
     </table>
   
     <table name="PROJECT">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="TITLE" type="VARCHAR" size="50"/>
  +    <column name="TITLE" type="VARCHAR" size="150"/>
       <column name="DESCRIPTION" type="VARCHAR" size="250"/>
     </table>
   
     <table name="PERSON_PROJECT">
       <column name="PERSON_ID" required="true" primaryKey="true" type="INTEGER"/>
       <column name="PROJECT_ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="ROLENAME" type="VARCHAR" size="20"/>
  +    <column name="ROLENAME" type="VARCHAR" size="150"/>
       <foreign-key foreignTable="PERSON">
         <reference local="PERSON_ID" foreign="ID"/>
       </foreign-key>
  @@ -170,34 +170,23 @@
       </foreign-key>
     </table>
   
  -  <table name="TASK">
  -    <column name="TASK_ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="PERSON_ID" required="true" type="INTEGER"/>
  -    <column name="PROJECT_ID" required="true" type="INTEGER"/>
  -    <column name="TASKNAME" type="VARCHAR" size="20"/>
  -    <foreign-key foreignTable="PERSON_PROJECT">
  -      <reference local="PERSON_ID" foreign="PERSON_ID"/>
  -      <reference local="PROJECT_ID" foreign="PROJECT_ID"/>
  -    </foreign-key>
  -  </table>
  -
     <table name="FAMILY_MEMBER">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="FIRSTNAME" type="VARCHAR" size="50"/>
  -    <column name="LASTNAME" type="VARCHAR" size="50"/>
  +    <column name="FIRSTNAME" type="VARCHAR" size="150"/>
  +    <column name="LASTNAME" type="VARCHAR" size="150"/>
       <column name="MOTHER_ID" type="INTEGER"/>
       <column name="FATHER_ID" type="INTEGER"/>
     </table>
   
     <table name="LOCKED_BY_VERSION">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="VALUE_" type="VARCHAR" size="60"/>
  +    <column name="VALUE_" type="VARCHAR" size="150"/>
       <column name="VERSION_" type="INTEGER"/>
     </table>
   
     <table name="LOCKED_BY_TIMESTAMP">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="VALUE_" type="VARCHAR" size="60"/>
  +    <column name="VALUE_" type="VARCHAR" size="150"/>
       <column name="TIMESTAMP_" type="TIMESTAMP"/>
     </table>
   
  @@ -238,7 +227,7 @@
   
     <table name="GRAPH_NODE">
       <column name="ID" required="true" primaryKey="true" type="INTEGER"/>
  -    <column name="NAME" required="true" type="VARCHAR" size="50"/>
  +    <column name="NAME" required="true" type="VARCHAR" size="150"/>
       <column name="LOCATION" type="INTEGER"/>
     </table>
   
  @@ -250,20 +239,20 @@
   
     <table name="TestClassA">
       <column name="id" required="true" primaryKey="true" type="VARCHAR" size="48"/>
  -    <column name="value1" required="false" type="VARCHAR" size="64"/>
  -    <column name="value2" required="false" type="VARCHAR" size="64"/>
  +    <column name="value1" required="false" type="VARCHAR" size="150"/>
  +    <column name="value2" required="false" type="VARCHAR" size="150"/>
       <column name="value3" required="true" type="INTEGER" />
       <column name="bOid" required="false" type="VARCHAR" size="48"/>
     </table>
   
     <table name="TestClassB">
       <column name="id" required="true" primaryKey="true" type="VARCHAR" size="48"/>
  -    <column name="value1" required="false" type="VARCHAR" size="64"/>
  +    <column name="value1" required="false" type="VARCHAR" size="150"/>
       <column name="aOid" required="false" type="VARCHAR" size="48"/>
     </table>
       <table name="RelatedToContract">
           <column name="pk" required="true" primaryKey="true" type="VARCHAR" size="48"/>
  -        <column name="relatedValue1" required="false" type="VARCHAR" size="64"/>
  +        <column name="relatedValue1" required="false" type="VARCHAR" size="150"/>
           <column name="relatedValue2" required="false" type="INTEGER"/>
           <column name="relatedValue3" required="false" type="TIMESTAMP"/>
       </table>
  
  
  
  No                   revision
  No                   revision
  1.8.2.3   +100 -38   db-ojb/src/test/org/apache/ojb/broker/BatchModeTest.java
  
  Index: BatchModeTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/BatchModeTest.java,v
  retrieving revision 1.8.2.2
  retrieving revision 1.8.2.3
  diff -u -r1.8.2.2 -r1.8.2.3
  --- BatchModeTest.java	6 Dec 2004 14:51:19 -0000	1.8.2.2
  +++ BatchModeTest.java	12 Dec 2004 01:35:12 -0000	1.8.2.3
  @@ -23,7 +23,6 @@
   public class BatchModeTest extends PBTestCase
   {
       private static long timestamp = System.currentTimeMillis();
  -    private boolean oldState;
   
       public BatchModeTest(String testName)
       {
  @@ -44,83 +43,102 @@
       public void setUp() throws Exception
       {
           super.setUp();
  -        oldState = broker.serviceConnectionManager().isBatchMode();
           broker.serviceConnectionManager().setBatchMode(true);
  +        // lookup connection to enable batch mode
  +        broker.serviceConnectionManager().getConnection();
       }
   
  -    public void tearDown() throws Exception
  +    boolean batchModeDisabled()
       {
  -        // OJB will automatic change state on PB.close() to 'false'
  -        // so this is not needed
  -        broker.serviceConnectionManager().setBatchMode(oldState);
  -        super.tearDown();
  +        if(broker.serviceConnectionManager().isBatchMode())
  +        {
  +            return false;
  +        }
  +        else
  +        {
  +            System.out.println("[" + BatchModeTest.class.getName() + "] Skip test, batch mode was not enabled or supported");
  +            return true;
  +        }
       }
   
  +
       /**
        * A common (no specific batch) test
        */
  -    public void testEquals() throws Exception
  +    public void testDelete()
       {
  +        if(batchModeDisabled()) return;
  +
           long pk = getNewId();
  -        String nameMain = "testEquals_Main_" + pk;
  -        String nameSub = "testEquals_Sub_" + pk;
  +        String nameMain = "testDelete_Main_" + pk;
  +        String nameSub = "testDelete_Sub_" + pk;
   
           MainObject main1 = new MainObject(pk, nameMain);
  +        SubObject sub = new SubObject(nameSub);
  +        main1.add(sub);
           main1.add(new SubObject(nameSub));
  -        MainObject main2 = new MainObject(pk, nameMain );
  -        main2.add(new SubObject(nameSub));
   
           broker.beginTransaction();
           broker.store(main1);
  -        // delete object before add new instance with same PK
  +        Identity oid_main = broker.serviceIdentity().buildIdentity(main1);
  +        Identity oid_sub = broker.serviceIdentity().buildIdentity(sub);
           broker.delete(main1);
  -        broker.store(main2);
           broker.commitTransaction();
   
  -        // new PB instance
  -        super.tearDown();
  -        super.setUp();
  -
  -        MainObject main3 = new MainObject(pk, nameMain);
  -        main3.add(new SubObject(nameSub));
   
  -        Identity oid = new Identity(main1, broker);
  -        broker.clearCache();
  -        MainObject main4 = (MainObject) broker.getObjectByIdentity(oid);
  +        MainObject newMain = (MainObject) broker.getObjectByIdentity(oid_main);
  +        assertNull(newMain);
  +        SubObject newSub = (SubObject) broker.getObjectByIdentity(oid_sub);
  +        assertNull(newSub);
   
  -        assertEquals(main3, main4);
  +        Criteria crit = new Criteria();
  +        crit.addLike("name", nameSub);
  +        Query q = QueryFactory.newQuery(SubObject.class, crit);
  +        Collection result = broker.getCollectionByQuery(q);
  +        assertEquals(0, result.size());
       }
   
       /**
        * A common (no specific batch) test
        */
  -    public void testDelete()
  +    public void testEquals() throws Exception
       {
  +        if(batchModeDisabled()) return;
  +
           long pk = getNewId();
  -        String nameMain = "testDelete_Main_" + pk;
  -        String nameSub = "testDelete_Sub_" + pk;
  +        String nameMain = "testEquals_Main_" + pk;
  +        String nameSub = "testEquals_Sub_" + pk;
   
           MainObject main1 = new MainObject(pk, nameMain);
           main1.add(new SubObject(nameSub));
  -        main1.add(new SubObject(nameSub));
  +        MainObject main2 = new MainObject(pk, nameMain);
  +        main2.add(new SubObject(nameSub));
   
           broker.beginTransaction();
           broker.store(main1);
  +        // delete object before add new instance with same PK
           broker.delete(main1);
  +        broker.store(main2);
           broker.commitTransaction();
   
  -        Identity oid = new Identity(main1, broker);
  -        MainObject newMain = (MainObject) broker.getObjectByIdentity(oid);
  -        assertNull(newMain);
  -        Criteria crit = new Criteria();
  -        crit.addLike("name", nameSub);
  -        Query q = QueryFactory.newQuery(SubObject.class, crit);
  -        Collection result = broker.getCollectionByQuery(q);
  -        assertEquals(0, result.size());
  +        // new PB instance
  +        super.tearDown();
  +        super.setUp();
  +
  +        MainObject main3 = new MainObject(pk, nameMain);
  +        main3.add(new SubObject(nameSub));
  +
  +        Identity oid = broker.serviceIdentity().buildIdentity(main1);
  +        broker.clearCache();
  +        MainObject main4 = (MainObject) broker.getObjectByIdentity(oid);
  +
  +        assertEquals(main3, main4);
       }
   
       public void testDeleteInsert()
       {
  +        if(batchModeDisabled()) return;
  +
           long pk = getNewId();
           String nameMain = "testDeleteInsert_Main_" + pk;
           String nameSub = "testDeleteInsert_Sub_" + pk;
  @@ -133,7 +151,7 @@
   
           // enable batch mode before start tx
           broker.serviceConnectionManager().setBatchMode(true);
  -        Identity oid = new Identity(main1, broker);
  +        Identity oid = broker.serviceIdentity().buildIdentity(main1);
           broker.beginTransaction();
           broker.delete(main1);
           MainObject main2 = new MainObject(pk, nameMain);
  @@ -151,6 +169,8 @@
   
       public void testBatchStatementsOrder()
       {
  +        if(batchModeDisabled()) return;
  +
           String name = "testBatchStatementsOrder_" + System.currentTimeMillis();
           ConnectionManagerIF conMan = broker.serviceConnectionManager();
           // try to enable batch mode
  @@ -219,6 +239,8 @@
        */
       public void testBatchStatementsOrder2()
       {
  +        if(batchModeDisabled()) return;
  +
           ConnectionManagerIF conMan = broker.serviceConnectionManager();
           broker.beginTransaction();
   
  @@ -278,6 +300,8 @@
   
       public void testMassInsertDelete()
       {
  +        if(batchModeDisabled()) return;
  +
           String name = "testMassInsert_" + System.currentTimeMillis();
   
           broker.serviceConnectionManager().setBatchMode(true);
  @@ -285,7 +309,7 @@
           for(int i = 200 - 1; i >= 0; i--)
           {
               Person p = new Person();
  -            p.setFirstname("a mass test");
  +            p.setFirstname("a mass test_" + i);
               p.setLastname(name);
               broker.store(p);
           }
  @@ -313,6 +337,8 @@
   
       public void testBatchModeDeclaration() throws Exception
       {
  +        if(batchModeDisabled()) return;
  +
           String name = "testBatchModeDeclaration_" + System.currentTimeMillis();
   
           broker.serviceConnectionManager().setBatchMode(true);
  @@ -366,6 +392,42 @@
           broker.serviceConnectionManager().setBatchMode(true);
           broker.serviceConnectionManager().getConnection();
           broker.abortTransaction();
  +    }
  +
  +    /**
  +     * A common (no specific batch) test
  +     */
  +    public void testStoreDeleteStore()
  +    {
  +        if(batchModeDisabled()) return;
  +
  +        long pk = getNewId();
  +        String nameMain = "testDelete_Main_" + pk;
  +        String nameSub = "testDelete_Sub_" + pk;
  +
  +        MainObject main1 = new MainObject(pk, nameMain);
  +        main1.add(new SubObject(nameSub));
  +        main1.add(new SubObject(nameSub));
  +
  +        broker.beginTransaction();
  +        broker.store(main1);
  +        broker.delete(main1);
  +        broker.store(main1);
  +        broker.delete(main1);
  +        broker.store(main1);
  +        broker.commitTransaction();
  +
  +        Identity oid = broker.serviceIdentity().buildIdentity(main1);
  +        broker.clearCache();
  +        MainObject newMain = (MainObject) broker.getObjectByIdentity(oid);
  +        assertNotNull(newMain);
  +        assertEquals(2, newMain.getSubObjects().size());
  +        broker.clearCache();
  +        Criteria crit = new Criteria();
  +        crit.addLike("name", nameSub);
  +        Query q = QueryFactory.newQuery(SubObject.class, crit);
  +        Collection result = broker.getCollectionByQuery(q);
  +        assertEquals(2, result.size());
       }
   
   
  
  
  
  1.1.2.2   +2 -2      db-ojb/src/test/org/apache/ojb/broker/Attic/OptimisticLockingMultithreadedTest.java
  
  Index: OptimisticLockingMultithreadedTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/Attic/OptimisticLockingMultithreadedTest.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- OptimisticLockingMultithreadedTest.java	4 Dec 2004 14:01:07 -0000	1.1.2.1
  +++ OptimisticLockingMultithreadedTest.java	12 Dec 2004 01:35:12 -0000	1.1.2.2
  @@ -201,7 +201,7 @@
               {
                   token = "-";
               }
  -            if (obj.getValue().length() < 150)
  +            if (obj.getValue().length() < 120)
               {
                   obj.setValue(obj.getValue() + token + threadNumber);
               }
  
  
  
  1.61.2.7  +358 -237  db-ojb/src/test/org/apache/ojb/broker/QueryTest.java
  
  Index: QueryTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/QueryTest.java,v
  retrieving revision 1.61.2.6
  retrieving revision 1.61.2.7
  diff -u -r1.61.2.6 -r1.61.2.7
  --- QueryTest.java	4 Dec 2004 14:01:07 -0000	1.61.2.6
  +++ QueryTest.java	12 Dec 2004 01:35:12 -0000	1.61.2.7
  @@ -27,8 +27,8 @@
   public class QueryTest extends PBTestCase
   {
       /**
  -	 * BrokerTests constructor comment.
  -	 */
  +     * BrokerTests constructor comment.
  +     */
       public QueryTest(String name)
       {
           super(name);
  @@ -44,7 +44,7 @@
       {
           String name = "testQueryZero_" + System.currentTimeMillis();
           ObjectRepository.Group group = new ObjectRepository.Group();
  - 	    group.setId(new Integer(0));
  +        group.setId(new Integer(0));
           group.setName(name);
   
           // prepare test
  @@ -54,8 +54,8 @@
           broker.commitTransaction();
           broker.clearCache();
   
  - 	    QueryByCriteria query = new QueryByCriteria(group);
  - 	    ObjectRepository.Group newGroup = ( ObjectRepository.Group ) broker.getObjectByQuery(query);
  +        QueryByCriteria query = new QueryByCriteria(group);
  +        ObjectRepository.Group newGroup = (ObjectRepository.Group) broker.getObjectByQuery(query);
           assertNull(newGroup);
   
           broker.beginTransaction();
  @@ -63,18 +63,18 @@
           broker.commitTransaction();
   
           ObjectRepository.Group groupTemp = new ObjectRepository.Group();
  - 	    groupTemp.setId(new Integer(0));
  +        groupTemp.setId(new Integer(0));
           Query queryNew = QueryFactory.newQuery(groupTemp);
  - 	    newGroup = ( ObjectRepository.Group ) broker.getObjectByQuery(queryNew);
  +        newGroup = (ObjectRepository.Group) broker.getObjectByQuery(queryNew);
           assertNotNull(newGroup);
           assertEquals(new Integer(0), newGroup.getId());
   
  - 	    newGroup = ( ObjectRepository.Group ) broker.getObjectByQuery(queryNew);
  +        newGroup = (ObjectRepository.Group) broker.getObjectByQuery(queryNew);
           assertNotNull(newGroup);
           assertEquals(new Integer(0), newGroup.getId());
   
           broker.clearCache();
  -        newGroup = ( ObjectRepository.Group ) broker.getObjectByQuery(queryNew);
  +        newGroup = (ObjectRepository.Group) broker.getObjectByQuery(queryNew);
           assertNotNull(newGroup);
           assertEquals(new Integer(0), newGroup.getId());
       }
  @@ -84,14 +84,33 @@
        */
       public void testCriteria()
       {
  +        String name = "testCriteria_" + System.currentTimeMillis();
  +        Person p1 = new Person();
  +        p1.setFirstname("tomm");
  +        p1.setLastname(name);
  +
  +        Person p2 = new Person();
  +        p2.setFirstname("tom");
  +        p2.setLastname(name);
  +
  +        Person p3 = new Person();
  +        p3.setFirstname("xtom");
  +        p3.setLastname(name);
  +
  +        broker.beginTransaction();
  +        broker.store(p1);
  +        broker.store(p2);
  +        broker.store(p3);
  +        broker.commitTransaction();
  +
           Criteria crit1 = new Criteria();
           Criteria crit2 = new Criteria();
           Criteria crit3 = new Criteria();
   
  -        crit2.addEqualTo("lastname","tom");
  -        crit2.setNegative(true);
  +        crit2.addEqualTo("lastname", name);
  +        crit2.setNegative(false);
   
  -        crit3.addEqualTo("firstname","tom");
  +        crit3.addEqualTo("firstname", "tom");
           crit3.setNegative(true);
   
           crit1.addAndCriteria(crit2);
  @@ -101,12 +120,12 @@
           Collection results = broker.getCollectionByQuery(q);
   
           // all persons except tom
  -        assertEquals(results.size(), 9);
  +        assertEquals(2, results.size());
       }
   
       /**
  -	 * test EqualTo Criteria
  -	 */
  +     * test EqualTo Criteria
  +     */
       public void testEqualCriteria()
       {
           Criteria crit = new Criteria();
  @@ -119,11 +138,11 @@
       }
   
       /**
  -	 * test sql Criteria
  -	 */
  +     * test sql Criteria
  +     */
       public void testSqlCriteria()
       {
  -        Criteria crit; 
  +        Criteria crit;
           Query q;
           Collection results;
           
  @@ -138,7 +157,7 @@
           // sql plus attribute 
           crit = new Criteria();
           crit.addSql("upper(firstname) = 'TOM'");
  -        crit.addEqualTo("id",new Integer(1));
  +        crit.addEqualTo("id", new Integer(1));
           q = QueryFactory.newQuery(Person.class, crit);
   
           results = broker.getCollectionByQuery(q);
  @@ -146,21 +165,21 @@
           
           // attribute plus sql 
           crit = new Criteria();
  -        crit.addEqualTo("upper(firstname)","TOM");
  +        crit.addEqualTo("upper(firstname)", "TOM");
           crit.addSql("id = 1");
           q = QueryFactory.newQuery(Person.class, crit);
   
           results = broker.getCollectionByQuery(q);
           int size3 = results.size();
  -        
  +
           assertTrue(size2 == size1);
           assertTrue(size3 == size2);
       }
   
  -   
  +
       /**
  -	 * test OrderBy and Count
  -	 */
  +     * test OrderBy and Count
  +     */
       public void testOrderByCount()
       {
           Criteria crit = new Criteria();
  @@ -174,15 +193,50 @@
           
           // compare with count
           int count = broker.getCount(q);
  -        assertEquals(results.size(), count);        
  +        assertEquals(results.size(), count);
       }
   
       /**
  -	 * test OrderBy joined column
  -	 */
  +     * test OrderBy joined column
  +     */
       public void testOrderByJoined()
       {
  +        String name = "testOrderByJoined" + System.currentTimeMillis();
  +        Person p = new Person();
  +        p.setFirstname("tom");
  +        p.setLastname(name);
  +
  +        Project p1 = new Project();
  +        p1.setTitle(name);
  +        ArrayList list_1 = new ArrayList();
  +        list_1.add(p);
  +        p1.setPersons(list_1);
  +
  +        Project p2 = new Project();
  +        p2.setTitle(name);
  +        ArrayList list_2 = new ArrayList();
  +        list_2.add(p);
  +        p2.setPersons(list_2);
  +
  +        ArrayList list_projects = new ArrayList();
  +        list_projects.add(p1);
  +        list_projects.add(p2);
  +        p.setProjects(list_projects);
  +
  +        Project p3 = new Project();
  +        p3.setTitle(name);
  +        ArrayList list_3 = new ArrayList();
  +        // empty list
  +        p3.setPersons(list_3);
  +
  +        broker.beginTransaction();
  +        broker.store(p1);
  +        //broker.store(p2);
  +        //broker.store(p3);
  +        broker.commitTransaction();
  +
           Criteria crit = new Criteria();
  +        crit.addLike("title", name);
           QueryByCriteria q = QueryFactory.newQuery(Project.class, crit);
           q.addOrderByAscending("title");
           q.addOrderByAscending("persons.lastname");
  @@ -190,18 +244,18 @@
   
           Collection results = broker.getCollectionByQuery(q);
           assertNotNull(results);
  -        assertTrue(results.size() == 14);
  -        
  +        assertEquals(2, results.size());
  +
           // compare with count
           int count = broker.getCount(q);
  -        assertEquals(results.size(), count);        
  +        assertEquals(results.size(), count);
       }
   
       /**
  -	 * test Subquery get all product groups without articles
  -	 *
  -	 * test may fail if db does not support sub queries
  -	 */
  +     * test Subquery get all product groups without articles
  +     * <p/>
  +     * test may fail if db does not support sub queries
  +     */
       public void testSubQuery2()
       {
           Collection results = null;
  @@ -209,7 +263,7 @@
           int loops = 10;
           // create ProductGroups without article
           broker.beginTransaction();
  -        for (int i = 0; i < loops; i++)
  +        for(int i = 0; i < loops; i++)
           {
               ProductGroup pg = new ProductGroup();
               pg.setGroupName("test group " + stamp);
  @@ -223,7 +277,7 @@
           Criteria crit = new Criteria();
   
           subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  -        subQuery.setAttributes(new String[] { "productGroupId" });
  +        subQuery.setAttributes(new String[]{"productGroupId"});
           subQuery.setDistinct(true);
   
           crit.addEqualTo("groupName", "test group " + stamp);
  @@ -238,11 +292,11 @@
       }
   
       /**
  -	 * test Subquery get all articles with price > avg(price) PROBLEM:
  -	 * avg(price) is NOT extent aware !!
  -	 *
  -	 * test may fail if db does not support sub queries
  -	 */
  +     * test Subquery get all articles with price > avg(price) PROBLEM:
  +     * avg(price) is NOT extent aware !!
  +     * <p/>
  +     * test may fail if db does not support sub queries
  +     */
       public void testSubQuery1()
       {
   
  @@ -252,7 +306,7 @@
   
           subCrit.addLike("articleName", "A%");
           subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  -        subQuery.setAttributes(new String[] { "avg(price)" });
  +        subQuery.setAttributes(new String[]{"avg(price)"});
   
           crit.addGreaterOrEqualThan("price", subQuery);
           Query q = QueryFactory.newQuery(Article.class, crit);
  @@ -264,11 +318,11 @@
       }
   
       /**
  -	 * test Subquery get all product groups with more than 10 articles, uses
  -	 * attribute as value ! see testSubQuery4 for a better way
  -	 *
  -	 * test may fail if db does not support sub queries
  -	 */
  +     * test Subquery get all product groups with more than 10 articles, uses
  +     * attribute as value ! see testSubQuery4 for a better way
  +     * <p/>
  +     * test may fail if db does not support sub queries
  +     */
       public void testSubQuery3()
       {
   
  @@ -278,10 +332,10 @@
   
           subCrit.addEqualToField("productGroupId", Criteria.PARENT_QUERY_PREFIX + "groupId");
           subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  -        subQuery.setAttributes(new String[] { "count(productGroupId)" });
  +        subQuery.setAttributes(new String[]{"count(productGroupId)"});
   
           crit.addLessThan("10", subQuery); // MORE than 10 articles, uses
  -										  // attribute as value !
  +        // attribute as value !
           crit.addLessThan("groupId", new Integer(987654));
           Query q = QueryFactory.newQuery(ProductGroup.class, crit);
   
  @@ -291,10 +345,10 @@
       }
   
       /**
  -	 * test Subquery get all product groups with more than 10 articles
  -	 *
  -	 * test may fail if db does not support sub queries
  -	 */
  +     * test Subquery get all product groups with more than 10 articles
  +     * <p/>
  +     * test may fail if db does not support sub queries
  +     */
       public void testSubQuery4()
       {
   
  @@ -304,7 +358,7 @@
   
           subCrit.addEqualToField("productGroupId", Criteria.PARENT_QUERY_PREFIX + "groupId");
           subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
  -        subQuery.setAttributes(new String[] { "count(productGroupId)" });
  +        subQuery.setAttributes(new String[]{"count(productGroupId)"});
   
           crit.addGreaterThan(subQuery, "10"); // MORE than 10 articles
           crit.addLessThan("groupId", new Integer(987654));
  @@ -316,8 +370,8 @@
       }
   
       /**
  -	 * test Like Criteria
  -	 */
  +     * test Like Criteria
  +     */
       public void testLikeCriteria()
       {
   
  @@ -373,21 +427,32 @@
       }
   
       /**
  -	 * test Null Criteria
  -	 */
  +     * test Null Criteria
  +     */
       public void testNullCriteria()
       {
  +        String name = "testNullCriteria_" + System.currentTimeMillis();
  +        Person p = new Person();
  +        p.setLastname(name);
  +        broker.beginTransaction();
  +        broker.store(p);
  +        broker.commitTransaction();
  +
           Criteria crit = new Criteria();
           crit.addIsNull("firstname");
  +        Criteria crit2 = new Criteria();
  +        crit2.addLike("lastname", name);
  +        crit.addAndCriteria(crit2);
  +        
           Query q = QueryFactory.newQuery(Person.class, crit);
   
           Collection results = broker.getCollectionByQuery(q);
           assertNotNull(results);
  -        assertTrue(results.size() == 0);
  +        assertEquals(1, results.size());
       }
   
       /**
  -     * Add an empty criteria 
  +     * Add an empty criteria
        */
       public void testEmptyORed() throws Exception
       {
  @@ -409,7 +474,7 @@
       }
   
       /**
  -     * Add an empty criteria 
  +     * Add an empty criteria
        */
       public void testEmptyANDed() throws Exception
       {
  @@ -429,10 +494,10 @@
           int count = broker.getCount(q);
           assertEquals(count, result.size());
       }
  -    
  +
       /**
  -	 * test Between Criteria
  -	 */
  +     * test Between Criteria
  +     */
       public void testBetweenCriteria()
       {
   
  @@ -450,8 +515,8 @@
       }
   
       /**
  -	 * test In Criteria
  -	 */
  +     * test In Criteria
  +     */
       public void testInCriteria()
       {
   
  @@ -474,18 +539,16 @@
       }
   
       /**
  -	 * Single Path Expression
  -	 */
  +     * Single Path Expression
  +     */
       public void testPathExpressions()
       {
   
           Criteria crit = new Criteria();
           crit.addEqualTo("productGroup.groupName", "Liquors");
           Query q = QueryFactory.newQuery(Article.class, crit);
  -        //System.out.println(q.toString());
   
           Collection results = broker.getCollectionByQuery(q);
  -        //System.out.println(results.toString());
           assertNotNull(results);
           assertTrue(results.size() > 0);
   
  @@ -495,8 +558,8 @@
       }
   
       /**
  -	 * Multi Path Expression over decomposed m:n
  -	 */
  +     * Multi Path Expression over decomposed m:n
  +     */
       public void testPathExpressionsMtoNDecomposed()
       {
   
  @@ -511,8 +574,8 @@
       }
   
       /**
  -	 * Multi Path Expression over nondecomposed m:n
  -	 */
  +     * Multi Path Expression over nondecomposed m:n
  +     */
       public void testPathExpressionsMtoN()
       {
   
  @@ -526,9 +589,9 @@
       }
   
       /**
  -	 * Multi Path Expression over nondecomposed m:n new test case for the 'not
  -	 * unique alias' problem with m:n relationship
  -	 */
  +     * Multi Path Expression over nondecomposed m:n new test case for the 'not
  +     * unique alias' problem with m:n relationship
  +     */
       public void testPathExpressionsMtoN2()
       {
           Criteria crit = new Criteria();
  @@ -582,30 +645,49 @@
       }
   
       /**
  -	 * Simple ReportQuery returning rows with 3 columns of Person
  -	 */
  +     * Simple ReportQuery returning rows with 3 columns of Person
  +     */
       public void testReportQuery()
       {
  +        String name = "testReportQuery_" + System.currentTimeMillis();
  +        Person p1 = new Person();
  +        p1.setFirstname("Robert");
  +        p1.setLastname(name);
  +        Person p2 = new Person();
  +        p2.setFirstname("Tom");
  +        p2.setLastname(name);
  +        Person p3 = new Person();
  +        p3.setFirstname("Roger");
  +        p3.setLastname(name);
  +        broker.beginTransaction();
  +        broker.store(p1);
  +        broker.store(p2);
  +        broker.store(p3);
  +        broker.commitTransaction();
  +
   
           Criteria crit = new Criteria();
           Collection results = new Vector();
           crit.addLike("firstname", "%o%");
  +        Criteria crit2 = new Criteria();
  +        crit2.addLike("lastname", name);
  +        crit.addAndCriteria(crit2);
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  -        q.setAttributes(new String[] { "id", "firstname", "count(*)" });
  -        q.addGroupBy(new String[] { "id", "firstname" });
  +        q.setAttributes(new String[]{"id", "firstname", "count(*)"});
  +        q.addGroupBy(new String[]{"id", "firstname"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
  -            Object[] row = (Object[])iter.next();
  +            Object[] row = (Object[]) iter.next();
               assertEquals(row.length, 3);
   
               results.add(row);
           }
   
  -        assertEquals(results.size(), 5);
  +        assertEquals(3, results.size());
   
           // compare with count
           int count = broker.getCount(q);
  @@ -613,58 +695,97 @@
       }
   
       /**
  -	 * Simple ReportQuery returning rows with max(id) of Person grouped by not selected columns
  -	 */
  +     * Simple ReportQuery returning rows with max(id) of Person grouped by not selected columns
  +     */
       public void testReportQueryGroupByNonSelectColumns()
       {
  +        String name = "testReportQueryGroupByNonSelectColumns_" + System.currentTimeMillis();
  +        Person p1 = new Person();
  +        p1.setFirstname("Robert");
  +        p1.setLastname(name);
  +        Person p2 = new Person();
  +        p2.setFirstname("Tom");
  +        p2.setLastname(name);
  +        Person p3 = new Person();
  +        p3.setFirstname("Roger");
  +        p3.setLastname(name);
  +        broker.beginTransaction();
  +        broker.store(p1);
  +        broker.store(p2);
  +        broker.store(p3);
  +        broker.commitTransaction();
   
           Criteria crit = new Criteria();
           Collection results = new Vector();
  +        crit.addLike("firstname", "%o%");
  +        Criteria crit2 = new Criteria();
  +        crit2.addLike("lastname", name);
  +        crit.addAndCriteria(crit2);
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  -        q.setAttributes(new String[] { "max(id)" });
  -        q.addGroupBy(new String[] { "lastname", "firstname" });
  +        q.setAttributes(new String[]{"max(id)"});
  +        q.addGroupBy(new String[]{"lastname", "firstname"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
  -            Object[] row = (Object[])iter.next();
  +            Object[] row = (Object[]) iter.next();
               assertEquals(row.length, 1);
   
               results.add(row);
           }
   
  -        assertEquals(results.size(), 10);
  +        assertEquals(3, results.size());
   
           // compare with count
           int count = broker.getCount(q);
           assertEquals(results.size(), count);
       }
  -    
  +
       /**
        * Simple ReportQuery returning rows with 3 columns of Person
        * Type of column data defined by sqltypes
  +     *
        * @see java.sql.Types
        */
       public void testReportQueryWithJdbcTypes()
       {
  +        String name = "testReportQuery_" + System.currentTimeMillis();
  +        Person p1 = new Person();
  +        p1.setFirstname("Robert");
  +        p1.setLastname(name);
  +        Person p2 = new Person();
  +        p2.setFirstname("Tom");
  +        p2.setLastname(name);
  +        Person p3 = new Person();
  +        p3.setFirstname("Roger");
  +        p3.setLastname(name);
  +        broker.beginTransaction();
  +        broker.store(p1);
  +        broker.store(p2);
  +        broker.store(p3);
  +        broker.commitTransaction();
  +
  +        int types[] = new int[]{Types.DECIMAL, Types.VARCHAR, Types.BIGINT};
           Criteria crit = new Criteria();
           Collection results = new Vector();
  -        int types[] = new int[]{Types.DECIMAL, Types.VARCHAR, Types.BIGINT};
  -
           crit.addLike("firstname", "%o%");
  +        Criteria crit2 = new Criteria();
  +        crit2.addLike("lastname", name);
  +        crit.addAndCriteria(crit2);
  +
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  -        q.setAttributes(new String[] { "id", "firstname", "count(*)" });
  -        q.addGroupBy(new String[] { "id", "firstname" });
  +        q.setAttributes(new String[]{"id", "firstname", "count(*)"});
  +        q.addGroupBy(new String[]{"id", "firstname"});
           q.setJdbcTypes(types);
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
  -            Object[] row = (Object[])iter.next();
  +            Object[] row = (Object[]) iter.next();
               assertEquals(row.length, 3);
   
   //            assertEquals(row[0].getClass(), BigDecimal.class);
  @@ -674,14 +795,14 @@
               results.add(row);
           }
   
  -        assertEquals(results.size(), 5);
  +        assertEquals(3, results.size());
   
       }
   
       /**
  -	 * Simple ReportQuery returning rows with 2 columns of Person
  +     * Simple ReportQuery returning rows with 2 columns of Person
        * needs SQL paging
  -	 */
  +     */
       public void _testReportQueryWithStartAndEnd()
       {
   
  @@ -689,15 +810,15 @@
           Collection results = new Vector();
           crit.addLike("firstname", "%o%");
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit);
  -        q.setAttributes(new String[] { "id", "firstname", "count(*)" });
  -        q.addGroupBy(new String[] { "id", "firstname" });
  +        q.setAttributes(new String[]{"id", "firstname", "count(*)"});
  +        q.addGroupBy(new String[]{"id", "firstname"});
   
           q.setStartAtIndex(3);
           q.setEndAtIndex(5);
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -706,8 +827,8 @@
       }
   
       /**
  -	 * Simple ReportQuery returning rows with 2 columns of Person
  -	 */
  +     * Simple ReportQuery returning rows with 2 columns of Person
  +     */
       public void testReportQueryExtent()
       {
   
  @@ -715,12 +836,12 @@
           Collection results = new Vector();
           crit.addLike("articleName", "%o%");
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  -        q.setAttributes(new String[] { "articleId", "articleName", "price" });
  +        q.setAttributes(new String[]{"articleId", "articleName", "price"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -736,7 +857,7 @@
        */
       public void testSubQueryAgainstConcreteClass()
       {
  -        String name = "testSubQueryAgainstConcreteClass_"+System.currentTimeMillis();
  +        String name = "testSubQueryAgainstConcreteClass_" + System.currentTimeMillis();
           Article article = new BookArticle();
           article.setArticleName(name);
           ProductGroup group = new ProductGroup();
  @@ -753,16 +874,16 @@
   
           critSub.addEqualTo("articleName", name);
           ReportQueryByCriteria querySub = QueryFactory.newReportQuery(BookArticle.class, critSub);
  -        querySub.setAttributes(new String[] { "productGroupId"});
  +        querySub.setAttributes(new String[]{"productGroupId"});
   
           ReportQueryByCriteria queryMain = QueryFactory.newReportQuery(AbstractProductGroup.class, critMain);
  -        queryMain.setAttributes(new String[] { "groupId", "groupName"});
  +        queryMain.setAttributes(new String[]{"groupId", "groupName"});
           critMain.addIn("groupId", querySub);
   
           Iterator iter = broker.getReportQueryIteratorByQuery(queryMain);
           int result = 0;
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               iter.next();
               ++result;
  @@ -780,40 +901,40 @@
        */
       public void testSubQueryAgainstExtents()
       {
  -        String name = "testSubQueryAgainstExtents_"+System.currentTimeMillis();
  +        String name = "testSubQueryAgainstExtents_" + System.currentTimeMillis();
           Article article = new BookArticle();
           article.setArticleName(name);
           ProductGroup group = new ProductGroup();
           group.setGroupName(name);
           article.setProductGroup(group);
  -    
  +
           broker.beginTransaction();
           broker.store(group);
           broker.store(article);
           broker.commitTransaction();
  -    
  +
           Criteria critMain = new Criteria();
           Criteria critSub = new Criteria();
  -    
  +
           critSub.addEqualTo("articleName", name);
           ReportQueryByCriteria querySub = QueryFactory.newReportQuery(Article.class, critSub);
  -        querySub.setAttributes(new String[] { "productGroupId"});
  +        querySub.setAttributes(new String[]{"productGroupId"});
           Iterator subIter = broker.getReportQueryIteratorByQuery(querySub);
           Collection subIds = new ArrayList();
  -        while (subIter.hasNext())
  +        while(subIter.hasNext())
           {
  -            Object[] id = (Object[])subIter.next();
  +            Object[] id = (Object[]) subIter.next();
               subIds.add(id[0]);
           }
  -            
  +
           ReportQueryByCriteria queryMain = QueryFactory.newReportQuery(AbstractProductGroup.class, critMain);
  -        queryMain.setAttributes(new String[] { "groupId", "groupName"});
  +        queryMain.setAttributes(new String[]{"groupId", "groupName"});
           critMain.addIn("groupId", subIds);
  -    
  +
           Iterator iter = broker.getReportQueryIteratorByQuery(queryMain);
           int result = 0;
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               iter.next();
               ++result;
  @@ -824,7 +945,7 @@
           int count = broker.getCount(queryMain);
           assertEquals(result, count);
       }
  -    
  +
       /**
        * ReportQuery with pathExpression in columns
        */
  @@ -834,12 +955,12 @@
           Collection results = new Vector();
           crit.addLike("articleName", "C%");
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  -        q.setAttributes(new String[] { "productGroup.groupName","articleId", "articleName", "price" });
  +        q.setAttributes(new String[]{"productGroup.groupName", "articleId", "articleName", "price"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -852,8 +973,8 @@
       }
   
       /**
  -	 * ReportQuery returning rows with some "Liquor" data ordered by price
  -	 */
  +     * ReportQuery returning rows with some "Liquor" data ordered by price
  +     */
       public void testReportQueryOrderBy()
       {
   
  @@ -861,12 +982,12 @@
           Collection results = new Vector();
           crit.addEqualTo("productGroup.groupName", "Liquors");
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  -        q.setAttributes(new String[] { "articleId", "articleName", "price" });
  +        q.setAttributes(new String[]{"articleId", "articleName", "price"});
           q.addOrderByAscending("price");
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -888,12 +1009,12 @@
           Collection results = new Vector();
           crit.addEqualTo("productGroup.groupName", "Liquors");
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  -        q.setAttributes(new String[] { "articleId", "articleName", "price" });
  +        q.setAttributes(new String[]{"articleId", "articleName", "price"});
           q.addOrderByAscending("productGroup.groupId");
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -906,16 +1027,16 @@
       }
   
       /**
  -	 * ReportQuery returning rows with summed stock and price per article group
  -	 * The selected columns point to a class having extents.<br>
  -	 * The query produces a wrong sql, selecting only rows of the top-class
  -	 */
  +     * ReportQuery returning rows with summed stock and price per article group
  +     * The selected columns point to a class having extents.<br>
  +     * The query produces a wrong sql, selecting only rows of the top-class
  +     */
       public void testReportQueryGroupByExtents2()
       {
           Criteria crit = new Criteria();
           Collection results = new Vector();
           ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit);
  -        q.setAttributes(new String[] { "groupName", "sum(allArticlesInGroup.stock)", "sum(allArticlesInGroup.price)" });
  +        q.setAttributes(new String[]{"groupName", "sum(allArticlesInGroup.stock)", "sum(allArticlesInGroup.price)"});
           q.addGroupBy("groupName");
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  @@ -928,7 +1049,7 @@
   //        GROUP BY A0.KategorieName
           
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -940,17 +1061,17 @@
       }
   
       /**
  -	 * ReportQuery returning rows with summed stock and price per article group
  -	 * The selected class has the extents.<br>
  -	 * The query returns summed values for each row, so there may be multiple rows
  -	 * for one productgroup because one query for each extent is executed.
  -	 */
  +     * ReportQuery returning rows with summed stock and price per article group
  +     * The selected class has the extents.<br>
  +     * The query returns summed values for each row, so there may be multiple rows
  +     * for one productgroup because one query for each extent is executed.
  +     */
       public void testReportQueryGroupByExtents1()
       {
           Criteria crit = new Criteria();
           Collection results = new Vector();
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Article.class, crit);
  -        q.setAttributes(new String[] { "productGroup.groupName", "sum(stock)", "sum(price)" });
  +        q.setAttributes(new String[]{"productGroup.groupName", "sum(stock)", "sum(price)"});
           q.addGroupBy("productGroup.groupName");
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  @@ -971,7 +1092,7 @@
   //        GROUP BY A1.KategorieName
   
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -981,10 +1102,10 @@
           int count = broker.getCount(q);
           // assertEquals(results.size(), count);   // FAILS !
       }
  -    
  +
       /**
  -	 * Read a CD and then read the ProductGroup for the CD
  -	 */
  +     * Read a CD and then read the ProductGroup for the CD
  +     */
       public void testInversePathExpression()
       {
           QueryByCriteria query;
  @@ -1018,9 +1139,9 @@
       }
   
       /**
  -	 * prefetch Articles for ProductGroupsWithArray, Does not yet work with
  -	 * Arrays
  -	 */
  +     * prefetch Articles for ProductGroupsWithArray, Does not yet work with
  +     * Arrays
  +     */
       public void testPrefetchedArraySingleKey()
       {
           ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
  @@ -1043,7 +1164,7 @@
           assertTrue(results.size() > 0);
           ProductGroupWithArray pg = (ProductGroupWithArray) results.toArray()[0];
           int articleSize = pg.getAllArticles().length;
  -        assertTrue(articleSize != 0 );
  +        assertTrue(articleSize != 0);
           String articleString = Arrays.asList(pg.getAllArticles()).toString();
   
           //
  @@ -1060,10 +1181,10 @@
           ProductGroupWithArray pg2 = (ProductGroupWithArray) results.toArray()[0];
           InterfaceArticle[] articles = pg2.getAllArticles();
           assertNotNull("Array of articles should not be null!", articles);
  -        assertTrue("Array should contain more than 0 entries!",articles.length != 0);
  +        assertTrue("Array should contain more than 0 entries!", articles.length != 0);
   
           // force materialization
  -        for (int i = 0; i < articles.length; i++)
  +        for(int i = 0; i < articles.length; i++)
           {
               articles[i].getArticleName();
           }
  @@ -1079,8 +1200,8 @@
       }
   
       /**
  -	 * prefetch Articles for ProductGroups
  -	 */
  +     * prefetch Articles for ProductGroups
  +     */
       public void testPrefetchedCollectionSingleKey()
       {
           ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
  @@ -1130,7 +1251,7 @@
           results = broker.getCollectionByQuery(q);
           InterfaceProductGroup pg2 = (InterfaceProductGroup) results.toArray()[0];
           // force materialization
  -        for (Iterator it = pg2.getAllArticles().iterator(); it.hasNext();)
  +        for(Iterator it = pg2.getAllArticles().iterator(); it.hasNext();)
           {
               ((InterfaceArticle) it.next()).getArticleName();
           }
  @@ -1145,8 +1266,8 @@
       }
   
       /**
  -	 * Test nested joins using pathExpressions
  -	 */
  +     * Test nested joins using pathExpressions
  +     */
       public void testNestedJoins()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1154,10 +1275,10 @@
           Criteria crit = new Criteria();
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Person.class, crit, true);
   
  -        q.setAttributes(new String[] { "roles.roleName", "roles.project.title", "firstname", });
  +        q.setAttributes(new String[]{"roles.roleName", "roles.project.title", "firstname", });
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1166,8 +1287,8 @@
       }
   
       /**
  -	 * Test multiple non nested joins using pathExpressions
  -	 */
  +     * Test multiple non nested joins using pathExpressions
  +     */
       public void testMultipleJoins()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1175,10 +1296,10 @@
           Criteria crit = new Criteria();
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Role.class, crit, true);
   
  -        q.setAttributes(new String[] { "roleName", "project.title", "person.firstname", });
  +        q.setAttributes(new String[]{"roleName", "project.title", "person.firstname", });
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1187,19 +1308,19 @@
       }
   
       /**
  -	 * Test nested joins using pathExpressions *** Fails under hsqldb because
  -	 * of join using multiple keys ***
  -	 */
  +     * Test nested joins using pathExpressions *** Fails under hsqldb because
  +     * of join using multiple keys ***
  +     */
       public void tesXNestedJoins2()
       {
           ArrayList list = new ArrayList();
           Criteria crit = new Criteria();
           ReportQueryByCriteria q = QueryFactory.newReportQuery(Task.class, crit);
   
  -        q.setAttributes(new String[] { "role.roleName", "role.project.title", "role.person.firstname", });
  +        q.setAttributes(new String[]{"role.roleName", "role.project.title", "role.person.firstname", });
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1207,8 +1328,8 @@
       }
   
       /**
  -	 * prefetch ProductGroups for Articles
  -	 */
  +     * prefetch ProductGroups for Articles
  +     */
       public void testPrefetchedReferencesSingleKey()
       {
           ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
  @@ -1237,7 +1358,7 @@
           Collection results = broker.getCollectionByQuery(q);
           Set pgs = new HashSet();
           Iterator iter = results.iterator();
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               InterfaceArticle a = (InterfaceArticle) iter.next();
               pgs.add(a.getProductGroup().getName());
  @@ -1266,7 +1387,7 @@
           results = broker.getCollectionByQuery(q);
           Set pgs2 = new HashSet();
           iter = results.iterator();
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               InterfaceArticle a = (InterfaceArticle) iter.next();
               pgs2.add(a.getProductGroup().getName());
  @@ -1284,22 +1405,22 @@
       }
   
       /**
  -	 * test PathExpression pointing to abstract class (InterfaceArticle)
  -	 */
  +     * test PathExpression pointing to abstract class (InterfaceArticle)
  +     */
       public void testReportPathExpressionAbstractExtent()
       {
           // TODO: make path expressions extent aware
  -        if(ojbSkipKnownIssueProblem()) return;
  +        if(ojbSkipKnownIssueProblem("Make path expressions extent aware")) return;
   
           ArrayList list = new ArrayList();
           Criteria crit = new Criteria();
           crit.addEqualTo("groupId", new Integer(5));
   
           ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroupWithAbstractArticles.class, crit, true);
  -        q.setAttributes(new String[] { "groupId", "groupName", "allArticlesInGroup.articleId", "allArticlesInGroup.articleName" });
  +        q.setAttributes(new String[]{"groupId", "groupName", "allArticlesInGroup.articleId", "allArticlesInGroup.articleName"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1323,7 +1444,7 @@
   
           Iterator iter = broker.getIteratorByQuery(q);
           assertNotNull(iter);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               results.add(iter.next());
           }
  @@ -1332,8 +1453,8 @@
       }
   
       /**
  -	 * test PathExpression pointing to abstract class (InterfaceArticle)
  -	 */
  +     * test PathExpression pointing to abstract class (InterfaceArticle)
  +     */
       public void testPathExpressionForAbstractExtent()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1348,7 +1469,7 @@
           q.addOrderByAscending("groupId");
   
           Iterator iter = broker.getIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1361,8 +1482,8 @@
       }
   
       /**
  -	 * Test pathExpression and Extents
  -	 */
  +     * Test pathExpression and Extents
  +     */
       public void testReportPathExpressionForExtents1()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1372,10 +1493,10 @@
           crit.addLessOrEqualThan("allArticlesInGroup.articleId", new Integer(5));
   
           ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit, true);
  -        q.setAttributes(new String[] { "groupId", "groupName", "allArticlesInGroup.articleId" });
  +        q.setAttributes(new String[]{"groupId", "groupName", "allArticlesInGroup.articleId"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               Object obj = iter.next();
               list.add(obj);
  @@ -1392,15 +1513,15 @@
   //                        + "  " + ((Object[]) obj)[1]
   //                        + "  " + ((Object[]) obj)[2]);
   
  -                int i = ((Integer)((Object[]) obj)[2]).intValue();
  -                assertTrue("i=" + i, i<6 & i>0);
  +                int i = ((Integer) ((Object[]) obj)[2]).intValue();
  +                assertTrue("i=" + i, i < 6 & i > 0);
               }
           }
       }
   
       /**
  -	 * Test pathExpression and Extents
  -	 */
  +     * Test pathExpression and Extents
  +     */
       public void testReportPathExpressionForExtents2()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1410,10 +1531,10 @@
           crit.addLike("allArticlesInGroup.articleName", "%\u00f6%"); //unicode for รถ
   
           ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit, true);
  -        q.setAttributes(new String[] { "groupId", "groupName" });
  +        q.setAttributes(new String[]{"groupId", "groupName"});
   
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1423,8 +1544,8 @@
       }
   
       /**
  -	 * Test pathExpression and Extents
  -	 */
  +     * Test pathExpression and Extents
  +     */
       public void testPathExpressionForExtents1()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1435,7 +1556,7 @@
           Query q = QueryFactory.newQuery(ProductGroup.class, crit, true);
   
           Iterator iter = broker.getIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1445,8 +1566,8 @@
       }
   
       /**
  -	 * Test pathExpression and Extents
  -	 */
  +     * Test pathExpression and Extents
  +     */
       public void testPathExpressionForExtents2()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1457,7 +1578,7 @@
           Query q = QueryFactory.newQuery(ProductGroup.class, crit, true);
   
           Iterator iter = broker.getIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1468,8 +1589,8 @@
       }
   
       /**
  -	 * Test pathExpression and Extents musicians is only defined in CD
  -	 */
  +     * Test pathExpression and Extents musicians is only defined in CD
  +     */
       public void testPathExpressionForExtents3()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1481,7 +1602,7 @@
           q.setPathClass("allArticlesInGroup", CdArticle.class);
   
           Iterator iter = broker.getIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1491,8 +1612,8 @@
       }
   
       /**
  -	 * Test pathExpression and Extents Abstract Base
  -	 */
  +     * Test pathExpression and Extents Abstract Base
  +     */
       public void testPathExpressionForExtents4()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1503,7 +1624,7 @@
           Query q = QueryFactory.newQuery(AbstractProductGroup.class, crit, true);
   
           Iterator iter = broker.getIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1513,8 +1634,8 @@
       }
   
       /**
  -	 * Test pathExpression and Extents using Alias
  -	 */
  +     * Test pathExpression and Extents using Alias
  +     */
       public void testPathExpressionForExtentsAlias()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1530,7 +1651,7 @@
           Query q = QueryFactory.newQuery(ProductGroup.class, crit1, true);
   
           Iterator iter = broker.getIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1540,8 +1661,8 @@
       }
   
       /**
  -	 * Test ReportQuery and Alias
  -	 */
  +     * Test ReportQuery and Alias
  +     */
       public void testReportQueryAlias()
       {
           ArrayList list = new java.util.ArrayList();
  @@ -1556,13 +1677,14 @@
   
           crit1.addAndCriteria(crit2);
           ReportQueryByCriteria q = QueryFactory.newReportQuery(ProductGroup.class, crit1);
  -        q.setAttributes(new String[]{"groupId", "groupName", "STOCKS.allArticlesInGroup.articleName","NAMES.allArticlesInGroup.stock"});
  +        q.setAttributes(new String[]{"groupId", "groupName", "STOCKS.allArticlesInGroup.articleName",
  +                                     "NAMES.allArticlesInGroup.articleName", "NAMES.allArticlesInGroup.stock"});
  +
  +        // Due to AliasPrefixes ArticleName is taken from A2 and A1, Stock from A1,
  +        // SELECT A0.Kategorie_Nr,A0.KategorieName,A2.Artikelname,A1.Artikelname,A1.Lagerbestand FROM
   
  -        // Due to AliasPrefixes ArticleName is taken from A2, Stock from A1, 
  -        // SELECT A0.Kategorie_Nr,A0.KategorieName,A2.Artikelname,A1.Lagerbestand FROM Kategorien ...
  -        
           Iterator iter = broker.getReportQueryIteratorByQuery(q);
  -        while (iter.hasNext())
  +        while(iter.hasNext())
           {
               list.add(iter.next());
           }
  @@ -1570,19 +1692,19 @@
           // ProductGroup 4 with it's Articles
           assertEquals("check size", list.size(), 1);
       }
  -    
  +
       /**
  -	 * Run a query range test that includes one record less than the total
  -	 * number of records that exist.
  -	 */
  +     * Run a query range test that includes one record less than the total
  +     * number of records that exist.
  +     */
       public void testQueryRangeOneLessThanTotal()
       {
           this.runQueryRangeTest(-1);
       }
   
       /**
  -	 * Run a query range test that includes all of the records that exist.
  -	 */
  +     * Run a query range test that includes all of the records that exist.
  +     */
       public void testQueryRangeAllRecords()
       {
           this.runQueryRangeTest(0);
  @@ -1645,21 +1767,20 @@
       }
   
       /**
  -	 * Run a query range test that includes one record more than the total
  -	 * number of records that exist.
  -	 */
  +     * Run a query range test that includes one record more than the total
  +     * number of records that exist.
  +     */
       public void testQueryRangeOneMoreThanTotal()
       {
           this.runQueryRangeTest(+1);
       }
   
       /**
  -	 * Run a query range test.
  -	 *
  -	 * @param delta
  -	 *            the amount to add to the existing record count when setting
  -	 *            the start/end index for the query that we'll use.
  -	 */
  +     * Run a query range test.
  +     *
  +     * @param delta the amount to add to the existing record count when setting
  +     *              the start/end index for the query that we'll use.
  +     */
       private void runQueryRangeTest(int delta)
       {
   
  @@ -1678,7 +1799,7 @@
           Object[] theObjects = broker.getCollectionByQuery(listQuery).toArray();
   
           // Verify the record count
  -        if (delta <= 0)
  +        if(delta <= 0)
           {
               assertEquals("record count", (recordCount + delta), theObjects.length);
           }
  @@ -1852,20 +1973,20 @@
           assertEquals(1, resultR.size());
           assertEquals(2, resultM.size());
   
  -        for (Iterator iterator = resultA.iterator(); iterator.hasNext();)
  +        for(Iterator iterator = resultA.iterator(); iterator.hasNext();)
           {
  -            InterfaceAnimal a =  (InterfaceAnimal) iterator.next();
  +            InterfaceAnimal a = (InterfaceAnimal) iterator.next();
               assertEquals(name, a.getName());
   
           }
  -        for (Iterator iterator = resultR.iterator(); iterator.hasNext();)
  +        for(Iterator iterator = resultR.iterator(); iterator.hasNext();)
           {
  -            Reptile a =  (Reptile) iterator.next();
  +            Reptile a = (Reptile) iterator.next();
               assertEquals(name, a.getName());
           }
  -        for (Iterator iterator = resultM.iterator(); iterator.hasNext();)
  +        for(Iterator iterator = resultM.iterator(); iterator.hasNext();)
           {
  -            Mammal a =  (Mammal) iterator.next();
  +            Mammal a = (Mammal) iterator.next();
               assertEquals(name, a.getName());
           }
   
  
  
  
  No                   revision
  No                   revision
  1.5.2.4   +3 -3      db-ojb/src/test/org/apache/ojb/junit/OJBTestCase.java
  
  Index: OJBTestCase.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/junit/OJBTestCase.java,v
  retrieving revision 1.5.2.3
  retrieving revision 1.5.2.4
  diff -u -r1.5.2.3 -r1.5.2.4
  --- OJBTestCase.java	4 Dec 2004 14:01:08 -0000	1.5.2.3
  +++ OJBTestCase.java	12 Dec 2004 01:35:12 -0000	1.5.2.4
  @@ -109,10 +109,10 @@
           {
               if(message == null)
               {
  -               message = "Will skip a known issue";
  +               message = "No description, please see test case";
               }
               String className = this.getClass().getName();
  -            System.out.println("# [Skip test in " + className + "] " + message + " #");
  +            System.out.println("# [Skip known issue in " + className + "] " + message + " #");
           }
           return skip;
       }
  
  
  
  No                   revision
  No                   revision
  1.8.2.2   +72 -49    db-ojb/src/test/org/apache/ojb/odmg/MultiDBUsageTest.java
  
  Index: MultiDBUsageTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/odmg/MultiDBUsageTest.java,v
  retrieving revision 1.8.2.1
  retrieving revision 1.8.2.2
  diff -u -r1.8.2.1 -r1.8.2.2
  --- MultiDBUsageTest.java	27 Jul 2004 00:31:50 -0000	1.8.2.1
  +++ MultiDBUsageTest.java	12 Dec 2004 01:35:12 -0000	1.8.2.2
  @@ -1,6 +1,5 @@
   package org.apache.ojb.odmg;
   
  -import junit.framework.TestCase;
   import org.apache.ojb.broker.FarAwayClass;
   import org.apache.ojb.broker.PBKey;
   import org.apache.ojb.broker.PersistenceBroker;
  @@ -14,6 +13,7 @@
   import org.apache.ojb.broker.query.QueryByCriteria;
   import org.apache.ojb.odmg.shared.Project;
   import org.apache.ojb.odmg.shared.ODMGZoo;
  +import org.apache.ojb.junit.OJBTestCase;
   import org.odmg.Database;
   import org.odmg.Implementation;
   import org.odmg.OQLQuery;
  @@ -28,7 +28,7 @@
    * Do some rollback tests and check behavior within transactions.
    * CAUTION: This tests works only against the default repository.
    */
  -public class MultiDBUsageTest extends TestCase
  +public class MultiDBUsageTest extends OJBTestCase
   {
       private Implementation odmg_1;
       private Database db_1;
  @@ -105,8 +105,10 @@
       /**
        * Test store / delete objects to different db
        */
  -    public void XXXtestStore() throws Exception
  +    public void testStore() throws Exception
       {
  +        String name = "testStoreDelete_" + System.currentTimeMillis();
  +
           // little hack for the test. use PB and ODMG api to verify results
           int odmgZoosBefore = getDBObjectCountWithNewPB(((DatabaseImpl) db_1).getPBKey(), ODMGZoo.class);
           int projectsBefore = getDBObjectCountWithNewPB(((DatabaseImpl) db_1).getPBKey(), Project.class);
  @@ -115,19 +117,19 @@
           Transaction tx_1 = odmg_1.newTransaction();
           tx_1.begin();
           //store
  -        storeObjects(tx_1, getNewODMGZoos(5));
  -        storeObjects(tx_1, getNewProjects(3));
  +        storeObjects(tx_1, getNewODMGZoos(name, 5));
  +        storeObjects(tx_1, getNewProjects(name, 3));
           //store more
  -        storeObjects(tx_1, getNewODMGZoos(5));
  -        storeObjects(tx_1, getNewProjects(2));
  +        storeObjects(tx_1, getNewODMGZoos(name, 5));
  +        storeObjects(tx_1, getNewProjects(name, 2));
           tx_1.commit();
   
           Transaction tx_2 = odmg_2.newTransaction();
           tx_2.begin();
           //store
  -        storeObjects(tx_2, getNewFarAways(9));
  +        storeObjects(tx_2, getNewFarAways(name, 9));
           //store more
  -        storeObjects(tx_2, getNewFarAways(11));
  +        storeObjects(tx_2, getNewFarAways(name, 11));
           tx_2.commit();
   
           int odmgZoosAfter = getDBObjectCountWithNewPB(((DatabaseImpl) db_1).getPBKey(), ODMGZoo.class);
  @@ -154,18 +156,18 @@
   
           tx_1.begin();
           //store
  -        storeObjects(tx_1, getNewODMGZoos(5));
  -        storeObjects(tx_1, getNewProjects(3));
  +        storeObjects(tx_1, getNewODMGZoos(name, 5));
  +        storeObjects(tx_1, getNewProjects(name, 3));
           //store more
  -        storeObjects(tx_1, getNewODMGZoos(5));
  -        storeObjects(tx_1, getNewProjects(2));
  +        storeObjects(tx_1, getNewODMGZoos(name, 5));
  +        storeObjects(tx_1, getNewProjects(name, 2));
           tx_1.commit();
   
           tx_2.begin();
           //store
  -        storeObjects(tx_2, getNewFarAways(9));
  +        storeObjects(tx_2, getNewFarAways(name, 9));
           //store more
  -        storeObjects(tx_2, getNewFarAways(11));
  +        storeObjects(tx_2, getNewFarAways(name, 11));
           tx_2.commit();
   
           odmgZoosAfter = getDBObjectCountWithNewPB(((DatabaseImpl) db_1).getPBKey(), ODMGZoo.class);
  @@ -181,35 +183,56 @@
           assertEquals("Wrong number of projects found", (projectsBefore + 5), projectsAfterOQL);
           assertEquals("Wrong number of farAways found", (farAwaysBefore + 20), farAwaysAfter);
           assertEquals("Wrong number of farAways found", (farAwaysBefore + 20), farAwaysAfterOQL);
  -    }
   
  -    public void testDelete() throws Exception
  -    {
  -        Transaction tx_1 = odmg_1.newTransaction();
  +        List result;
           tx_1.begin();
  -        deleteObjects(db_1, getAllObjects(odmg_1, ODMGZoo.class));
  -        deleteObjects(db_1, getAllObjects(odmg_1, Project.class));
  +        OQLQuery query = odmg_1.newOQLQuery();
  +        query.create("select projects from " + Project.class.getName() + " where title like $1");
  +        query.bind(name);
  +        result = (List) query.execute();
  +        deleteObjects(db_1, result);
  +        tx_1.commit();
  +
  +        tx_1.begin();
  +        query = odmg_1.newOQLQuery();
  +        query.create("select projects from " + ODMGZoo.class.getName() + " where name like $1");
  +        query.bind(name);
  +        result = (List) query.execute();
  +        deleteObjects(db_1, result);
           tx_1.commit();
   
  -        Transaction tx_2 = odmg_2.newTransaction();
           tx_2.begin();
  -        deleteObjects(db_2, getAllObjects(odmg_2, FarAwayClass.class));
  +        query = odmg_2.newOQLQuery();
  +        query.create("select projects from " + FarAwayClass.class.getName() + " where name like $1");
  +        query.bind(name);
  +        result = (List) query.execute();
  +        deleteObjects(db_2, result);
           tx_2.commit();
   
  -        int odmgZoosAfter = getDBObjectCountWithNewPB(((DatabaseImpl) db_1).getPBKey(), ODMGZoo.class);
  -        int projectsAfter = getDBObjectCountWithNewPB(((DatabaseImpl) db_1).getPBKey(), Project.class);
  -        int farAwaysAfter = getDBObjectCountWithNewPB(((DatabaseImpl) db_2).getPBKey(), FarAwayClass.class);
  -        //
  -        int odmgZoosAfterOQL = getDBObjectCountViaOqlQuery(odmg_1, ODMGZoo.class);
  -        int projectsAfterOQL = getDBObjectCountViaOqlQuery(odmg_1, Project.class);
  -        int farAwaysAfterOQL = getDBObjectCountViaOqlQuery(odmg_2, FarAwayClass.class);
  -
  -        assertEquals("Wrong number of odmgZoos found", 0, odmgZoosAfter);
  -        assertEquals("Wrong number of projects found", 0, projectsAfter);
  -        assertEquals("Wrong number of odmgZoos found", 0, odmgZoosAfterOQL);
  -        assertEquals("Wrong number of projects found", 0, projectsAfterOQL);
  -        assertEquals("Wrong number of farAways found", 0, farAwaysAfter);
  -        assertEquals("Wrong number of farAways found", 0, farAwaysAfterOQL);
  +
  +        tx_1.begin();
  +        query = odmg_1.newOQLQuery();
  +        query.create("select projects from " + Project.class.getName() + " where title like $1");
  +        query.bind(name);
  +        result = (List) query.execute();
  +        tx_1.commit();
  +        assertEquals(0, result.size());
  +
  +        tx_1.begin();
  +        query = odmg_1.newOQLQuery();
  +        query.create("select projects from " + ODMGZoo.class.getName() + " where name like $1");
  +        query.bind(name);
  +        result = (List) query.execute();
  +        tx_1.commit();
  +        assertEquals(0, result.size());
  +
  +        tx_2.begin();
  +        query = odmg_2.newOQLQuery();
  +        query.create("select projects from " + FarAwayClass.class.getName() + " where name like $1");
  +        query.bind(name);
  +        result = (List) query.execute();
  +        tx_2.commit();
  +        assertEquals(0, result.size());
       }
   
   
  @@ -231,58 +254,58 @@
   
       private static int counter;
   
  -    protected Collection getNewProjects(int count)
  +    protected Collection getNewProjects(String name, int count)
       {
           ArrayList list = new ArrayList();
           for (int i = 0; i < count; i++)
           {
  -            list.add(newProject());
  +            list.add(newProject(name));
           }
           return list;
       }
   
  -    protected Project newProject()
  +    protected Project newProject(String name)
       {
           Project p = new Project();
           ++counter;
           p.setDescription("Test project " + counter);
  -        p.setTitle("Test " + counter);
  +        p.setTitle(name);
           return p;
       }
   
  -    protected Collection getNewODMGZoos(int count)
  +    protected Collection getNewODMGZoos(String name, int count)
       {
           ArrayList list = new ArrayList();
           for (int i = 0; i < count; i++)
           {
  -            list.add(newODMGZoo());
  +            list.add(newODMGZoo(name));
           }
           return list;
       }
   
  -    protected Collection getNewFarAways(int count)
  +    protected Collection getNewFarAways(String name, int count)
       {
           ArrayList list = new ArrayList();
           for (int i = 0; i < count; i++)
           {
  -            list.add(newFarAway());
  +            list.add(newFarAway(name));
           }
           return list;
       }
   
  -    protected ODMGZoo newODMGZoo()
  +    protected ODMGZoo newODMGZoo(String name)
       {
           ODMGZoo odmgZoo = new ODMGZoo();
           ++counter;
  -        odmgZoo.setName("animal " + counter);
  +        odmgZoo.setName(name);
           return odmgZoo;
       }
   
  -    private FarAwayClass newFarAway()
  +    private FarAwayClass newFarAway(String name)
       {
           FarAwayClass fa = new FarAwayClass();
           counter++;
  -        fa.setName("away from " + counter);
  +        fa.setName(name);
           fa.setDescription("so far away from " + counter);
           return fa;
       }
  
  
  
  No                   revision
  No                   revision
  1.112.2.7 +2 -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.112.2.6
  retrieving revision 1.112.2.7
  diff -u -r1.112.2.6 -r1.112.2.7
  --- repository_junit.xml	4 Dec 2004 14:01:08 -0000	1.112.2.6
  +++ repository_junit.xml	12 Dec 2004 01:35:13 -0000	1.112.2.7
  @@ -989,7 +989,7 @@
            name="persons"
            element-class-ref="org.apache.ojb.broker.Person"
            auto-retrieve="true"
  -         auto-update="false"
  +         auto-update="true"
            indirection-table="PERSON_PROJECT"
         >
            <fk-pointing-to-this-class column="PROJECT_ID"/>
  
  
  

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