db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r528051 - in /db/ojb/branches/OJB_1_0_RELEASE/src: schema/ test/org/apache/ojb/ test/org/apache/ojb/broker/sqlcount/
Date Thu, 12 Apr 2007 17:26:11 GMT
Author: arminw
Date: Thu Apr 12 10:26:10 2007
New Revision: 528051

URL: http://svn.apache.org/viewvc?view=rev&rev=528051
Log:
update, add new tests

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml?view=diff&rev=528051&r1=528050&r2=528051
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/schema/ojbtest-schema.xml Thu Apr 12 10:26:10 2007
@@ -2151,9 +2151,15 @@
         <column
            name="FK_PUBLISHER"
            type="INTEGER"/>
+        <column
+           name="FK_GROUP"
+           type="INTEGER"/>
         <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
                 <reference local="FK_PUBLISHER" foreign="ID_"/>
         </foreign-key>
+        <foreign-key foreignTable="SQLCOUNT_GROUP">
+                <reference local="FK_GROUP" foreign="ID_"/>
+        </foreign-key>
     </table>
 
     <table name="SQLCOUNT_CD">
@@ -2178,9 +2184,15 @@
         <column
            name="FK_PUBLISHER"
            type="INTEGER"/>
+        <column
+           name="FK_GROUP"
+           type="INTEGER"/>
         <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
                 <reference local="FK_PUBLISHER" foreign="ID_"/>
         </foreign-key>
+        <foreign-key foreignTable="SQLCOUNT_GROUP">
+                <reference local="FK_GROUP" foreign="ID_"/>
+        </foreign-key>
     </table>
 
     <table name="SQLCOUNT_DVD">
@@ -2205,9 +2217,15 @@
         <column
            name="FK_PUBLISHER"
            type="INTEGER"/>
+        <column
+           name="FK_GROUP"
+           type="INTEGER"/>
         <foreign-key foreignTable="SQLCOUNT_PUBLISHER">
                 <reference local="FK_PUBLISHER" foreign="ID_"/>
         </foreign-key>
+        <foreign-key foreignTable="SQLCOUNT_GROUP">
+                <reference local="FK_GROUP" foreign="ID_"/>
+        </foreign-key>
     </table>
 
     <table name="SQLCOUNT_PUBLICATION">
@@ -2323,6 +2341,18 @@
         <!--<foreign-key foreignTable="SQLCOUNT_DVD">-->
                 <!--<reference local="FK_MEDIUM" foreign="ID_"/>-->
         <!--</foreign-key>-->
+    </table>
+
+    <table name="SQLCOUNT_GROUP">
+        <column
+           name="ID_"
+           type="INTEGER"
+           primaryKey="true"
+           autoIncrement="true"/>
+        <column
+           name="NAME_"
+           type="VARCHAR"
+           size="250"/>
     </table>
 
 </database>

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java?view=diff&rev=528051&r1=528050&r2=528051
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/BaseCountTest.java
Thu Apr 12 10:26:10 2007
@@ -67,6 +67,7 @@
         private byte[] cover;
         private Integer version;
         private Integer fkPublisher;
+        private ProductGroup productGroup;
 
         private List authors;
         private List reviews;
@@ -201,6 +202,16 @@
         {
             this.publisher = publisher;
         }
+
+        public ProductGroup getProductGroup()
+        {
+            return productGroup;
+        }
+
+        public void setProductGroup(ProductGroup productGroup)
+        {
+            this.productGroup = productGroup;
+        }
     }
 
     public static class Book extends Medium
@@ -604,6 +615,58 @@
         public void setAuthor(Author author)
         {
             this.author = author;
+        }
+    }
+
+    public static class ProductGroup
+    {
+        private Integer id;
+        private String name;
+        private List media;
+
+        public ProductGroup()
+        {
+        }
+
+        public ProductGroup(String name)
+        {
+            this.name = name;
+        }
+
+        public Integer getId()
+        {
+            return id;
+        }
+
+        public void setId(Integer id)
+        {
+            this.id = id;
+        }
+
+        public List getMedia()
+        {
+            return media;
+        }
+
+        public void setMedia(List media)
+        {
+            this.media = media;
+        }
+
+        public void addMedium(Medium medium)
+        {
+            if(media == null) media = new ArrayList();
+            if(!media.contains(medium)) media.add(medium);
+        }
+
+        public String getName()
+        {
+            return name;
+        }
+
+        public void setName(String name)
+        {
+            this.name = name;
         }
     }
 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java?view=diff&rev=528051&r1=528050&r2=528051
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/CollectionCountTest.java
Thu Apr 12 10:26:10 2007
@@ -5,31 +5,26 @@
 
 package org.apache.ojb.broker.sqlcount;
 
-import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Date;
 import java.util.Iterator;
-import java.util.List;
 
-import org.apache.ojb.broker.Article;
-import org.apache.ojb.broker.InterfaceArticle;
-import org.apache.ojb.broker.InterfaceProductGroup;
-import org.apache.ojb.broker.Person;
-import org.apache.ojb.broker.ProductGroup;
-import org.apache.ojb.broker.Project;
-import org.apache.ojb.broker.metadata.ClassDescriptor;
+import org.apache.ojb.broker.metadata.CollectionDescriptor;
 import org.apache.ojb.broker.query.Criteria;
-import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.ojb.broker.util.ObjectModification;
+import org.apache.ojb.broker.core.PersistenceBrokerConfiguration;
+import org.apache.ojb.broker.PersistenceBrokerFactory;
 import org.apache.ojb.p6spy.CountLogger;
 
 /**
  * @version $Id$
  */
-public class CollectionCountTest extends AbstractCountTest
+public class CollectionCountTest extends BaseCountTest
 {
+    int sqlInLimit;
+
     public void setUp() throws Exception
     {
         super.setUp();
@@ -37,6 +32,10 @@
         String[] excludePattern_2 = new String[]{"OJB_HL_SEQ"};
         CountLogger.addExcludePattern(excludePattern_1);
         CountLogger.addExcludePattern(excludePattern_2);
+
+        PersistenceBrokerConfiguration config = (PersistenceBrokerConfiguration) PersistenceBrokerFactory
+                    .getConfigurator().getConfigurationFor(broker);
+        sqlInLimit = config.getSqlInLimit();
     }
 
     public void tearDown() throws Exception
@@ -45,246 +44,156 @@
         super.tearDown();
     }
 
-    /**
-     * retrieve all product groups.
-     */
-    public void testAllProductGroups()
+    /*
+    * insert a ProductGroup with an empty Article collection.
+    */
+    public void testInsertEmptyProductGroup()
     {
+        String name = ojbTestMethodIdentifier();
         resetStmtCount();
         broker.clearCache();
         broker.beginTransaction();
-        Query qry = QueryFactory.newQuery(ProductGroup.class, new Criteria());
-        assertStmtCount("preparation", 0);
-        Iterator iter = broker.getIteratorByQuery(qry);
-        assertStmtCount("getIteratorByQuery", 1);
-        while(iter.hasNext())
-        {
-            resetStmtCount();
-            InterfaceProductGroup next = (InterfaceProductGroup) iter.next();
-            assertStmtCount("next", 0);
-            List articles = next.getAllArticles();
-            // SELECT ... FROM Kategorien
-            // SELECT ... FROM Artikel
-            // SELECT ... FROM BOOKS
-            // SELECT ... FROM CDS
-            assertStmtCount("getAllArticles", 4);
-        }
+        ProductGroup pg = new ProductGroup(name);
+        broker.store(pg);
+        assertStmtCount("insert ProductGroup with empty collection.", 1);
+        resetStmtCount();
+        pg = new ProductGroup(name);
+        broker.store(pg, ObjectModification.INSERT);
         broker.commitTransaction();
+        assertStmtCount("insert second Productgroup with empty collection.", 1);
     }
 
-    /**
-     * retrieve Product group number 5 and its 12 articles
-     */
-    public void testProductGroup5()
+    public void testPrefetched_0()
     {
-        resetStmtCount();
-        broker.clearCache();
-        broker.beginTransaction();
-        ProductGroup pg = (ProductGroup) broker.getObjectByIdentity(
-                broker.serviceIdentity().buildIdentity(null, ProductGroup.class, new Object[]{new
Integer(5)}));
-        assertStmtCount("getObjectByIdentity", 4);
-        resetStmtCount();
-        List articles = pg.getAllArticles();
-        assertEquals(12, articles.size());
-        assertStmtCount("getAllArticles", 0);
-        resetStmtCount();
-        for(Iterator articleIterator = articles.iterator(); articleIterator.hasNext();)
-        {
-            InterfaceArticle article = (InterfaceArticle) articleIterator.next();
-            logger.info("articleId " + article.getArticleId());
-            // SELECT ... FROM Artikel WHERE Artikel_Nr = ...
-        }
-        assertStmtCount("collect ids: ", 1);  // batch retrieval!
-        resetStmtCount();
-        String str = pg.toString();
-        // SELECT ... FROM Kategorien WHERE Kategorie_Nr = '5'
-        // SELECT ... FROM Artikel A0 WHERE Kategorie_Nr =  '5'
-        // SELECT ... FROM BOOKS A0   WHERE Kategorie_Nr =  '5'
-        // SELECT ... FROM CDS A0     WHERE Kategorie_Nr =  '5'
-        assertStmtCount("toString", 4);
-        logger.info(str);
-        broker.commitTransaction();
+        int pgCount = 1;
+        int mediumCount = 0;
+        String name = ojbTestMethodIdentifier();
+        int i = (int) Math.round(((double)pgCount/sqlInLimit) + 0.5);
+        int expectedInsert = 1;
+        int expectedSelect = i*3 + 1;
+        performPrefetched(name, mediumCount, pgCount, expectedInsert, expectedSelect);
     }
 
-    /*
-    * insert a person with an empty project collection.
-    * note: the <em>first</em> Person and Project require extra lookups
-    * in the table OJB_HL_SEQ.
-    */
-    public void testPersonEmptyProjectsInsert()
+    public void testPrefetched_1()
     {
-        resetStmtCount();
-        broker.clearCache();
-        broker.beginTransaction();
-        Person pers = new Person();
-        logStmtCount("Storing first person");
-        broker.store(pers);
-        assertStmtCount("insert second Person with empty collection.", 1);
-        logStmtCount("Storing second person");
-        resetStmtCount();
-        pers = new Person();
-        broker.store(pers, ObjectModification.INSERT);
-        broker.commitTransaction();
-        // INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('172','','')
-        // commit
-        assertStmtCount("insert second Person with empty collection.", 1);
+        int pgCount = 1;
+        int mediumCount = 1;
+        String name = ojbTestMethodIdentifier();
+        int i = (int) Math.round(((double)pgCount/sqlInLimit) + 0.5);
+        int expectedInsert = 2;
+        int expectedSelect = i*3 + 1;
+        performPrefetched(name, mediumCount, pgCount, expectedInsert, expectedSelect);
     }
 
-    /**
-     * insert a person with a project collection with one fresh element.
-     * note: the <em>first</em> Person and Project require extra lookups
-     * in the table OJB_HL_SEQ.
-     */
-    public void testPersonSingleProjectInsert()
+    public void testPrefetched_2()
     {
-        resetStmtCount();
-        broker.clearCache();
-        broker.beginTransaction();
-        Person pers = new Person();
-        pers.setFirstname("testPersonSingleProjectInsert(1)");
-        Project proj = new Project();
-        proj.setTitle("testPersonSingleProjectInsert(1)");
-        broker.store(pers);
-        broker.store(proj);
-        logStmtCount("Storing first person and first project");
-        // 12. oma: why so many? double lookup in OJB_HL_SEQ !
-        resetStmtCount();
-        pers = new Person();
-        Project proj2 = new Project();
-        proj2.setTitle("proj2");
-        Collection projects = Arrays.asList(new Project[]{proj2});
-        pers.setProjects(projects);
-        broker.store(pers, ObjectModification.INSERT);
-        broker.commitTransaction();
-        /*
-        new:
-        INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('200001','testPersonSingleProjectInsert(1)','')
-        INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('200001','testPersonSingleProjectInsert(1)','')
-        // now do real store
-        INSERT INTO PERSON (ID,FIRSTNAME,LASTNAME) VALUES ('200002','','')
-        INSERT INTO PROJECT (ID,TITLE,DESCRIPTION) VALUES ('200002','proj2','')
-        INSERT INTO PERSON_PROJECT (PERSON_ID,PROJECT_ID) VALUES ('200002','200002')
-        */
-        assertStmtCount("insert second Person, singleton collection.", 3);
+        int pgCount = 2;
+        int mediumCount = 3;
+        String name = ojbTestMethodIdentifier();
+        int i = (int) Math.round(((double)pgCount/sqlInLimit) + 0.5);
+        int expectedInsert = 8;
+        int expectedSelect = i*3 + 1;
+        performPrefetched(name, mediumCount, pgCount, expectedInsert, expectedSelect);
     }
 
-
-    public void testPrefetched()
+    public void testPrefetched_3()
     {
-        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
-        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
-        Class productGroupProxy = cldProductGroup.getProxyClass();
-        Class articleProxy = cldArticle.getProxyClass();
-
-        //
-        // use ProductGroup and Articles with disabled Proxy
-        //
-        cldProductGroup.setProxyClass(null);
-        cldProductGroup.setProxyClassName(null);
-        cldArticle.setProxyClass(null);
-        cldArticle.setProxyClassName(null);
-
-        try
-        {
-            resetStmtCount();
-            broker.clearCache();
-
-
-            broker.beginTransaction();
-
-            Criteria crit = new Criteria();
-            crit.addLessOrEqualThan("groupId", new Integer(5));
-            QueryByCriteria q = QueryFactory.newQuery(ProductGroup.class, crit);
-            q.addOrderByDescending("groupId");
-            q.addPrefetchedRelationship("allArticlesInGroup");
-
-            Collection results = broker.getCollectionByQuery(q);
-            assertEquals("Number of ProductGroups", 5, results.size());
-            Collection articles = new ArrayList();
-            for(Iterator it = results.iterator(); it.hasNext();)
-            {
-                ProductGroup p = (ProductGroup) it.next();
-                articles.addAll(p.getAllArticles());
-            }
-            assertEquals("Total number of Articles", 59, articles.size());
+        int pgCount = 51;
+        int mediumCount = 6;
+        String name = ojbTestMethodIdentifier();
+        int i = (int) Math.round(((double)pgCount/sqlInLimit) + 0.5);
+        int expectedInsert = 357;
+        int expectedSelect = i*3 + 1;
+        performPrefetched(name, mediumCount, pgCount, expectedInsert, expectedSelect);
+    }
 
-            //SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0
WHERE A0.Kategorie_Nr <=  '5'
-            //SELECT ... FROM CDS A0 WHERE A0.Kategorie_Nr IN ( '1' , '4' , '2' , '5' , '3'
)
-            //SELECT ... FROM Artikel A0 WHERE A0.Kategorie_Nr IN ( '1' , '4' , '2' , '5'
, '3' )
-            //SELECT ... FROM BOOKS A0 WHERE A0.Kategorie_Nr IN ( '1' , '4' , '2' , '5' ,
'3' )
-            assertStmtCount("Read Prefetched.", 4);
-            broker.commitTransaction();
-        }
-        finally
-        {
-            //
-            // Reset original Proxy settings
-            //
-            cldProductGroup.setProxyClass(productGroupProxy);
-            cldProductGroup.setProxyClassName(productGroupProxy.getName());
-            cldArticle.setProxyClass(articleProxy);
-            cldArticle.setProxyClassName(articleProxy.getName());
-        }
+    public void testPrefetched_4()
+    {
+        int pgCount = 500;
+        int mediumCount = 3;
+        String name = ojbTestMethodIdentifier();
+        int i = (int) Math.round(((double)pgCount/sqlInLimit) + 0.5);
+        int expectedInsert = 2000;
+        int expectedSelect = i*3 + 1;
+        performPrefetched(name, mediumCount, pgCount, expectedInsert, expectedSelect);
     }
 
     // OJB always use prefetching
     public void YYYtestNonPrefetched()
     {
-        ClassDescriptor cldProductGroup = broker.getClassDescriptor(ProductGroup.class);
-        ClassDescriptor cldArticle = broker.getClassDescriptor(Article.class);
-        Class productGroupProxy = cldProductGroup.getProxyClass();
-        Class articleProxy = cldArticle.getProxyClass();
-
-        //
-        // use ProductGroup and Articles with disabled Proxy
-        //
-        cldProductGroup.setProxyClass(null);
-        cldProductGroup.setProxyClassName(null);
-        cldArticle.setProxyClass(null);
-        cldArticle.setProxyClassName(null);
+        int pgCount = 1;
+        int mediumCount = 3;
+        String name = ojbTestMethodIdentifier();
+        performPrefetched(name, mediumCount, pgCount, 4, 4);
+    }
+
+    public void performPrefetched(String name, int mediumCount, int pgCount, int expectedInsert,
int expectedSelect)
+    {
+        ojbChangeReferenceSetting(ProductGroup.class,
+                "media", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(Book.class,
+                "productGroup", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(CD.class,
+                "productGroup", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
+        ojbChangeReferenceSetting(DVD.class,
+                "productGroup", true,
+                CollectionDescriptor.CASCADE_OBJECT,
+                CollectionDescriptor.CASCADE_OBJECT,
+                false);
 
+        broker.beginTransaction();
         resetStmtCount();
-        broker.clearCache();
+        for(int k=0; k < pgCount;k++)
+        {
+            ProductGroup pg = new ProductGroup(name);
+            for(int i = 0; i<mediumCount;i++)
+            {
+                Medium m = null;
+                if(i%3 == 0) m = new Book(name, new Date(), null);
+                if(i%3 == 1) m = new CD(name, new Date(), null);
+                if(i%3 == 2) m = new DVD(name, new Date(), null);
+                pg.addMedium(m);
+            }
+            broker.store(pg, ObjectModification.INSERT);
+        }
+        broker.commitTransaction();
+        assertStmtCount("Insert ProductGroup's with Medium objects", expectedInsert);
 
+        resetStmtCount();
+        broker.clearCache();
         broker.beginTransaction();
 
         Criteria crit = new Criteria();
-        crit.addLessOrEqualThan("groupId", new Integer(5));
+        crit.addEqualTo("name", name);
         QueryByCriteria q = QueryFactory.newQuery(ProductGroup.class, crit);
-        q.addOrderByDescending("groupId");
+        q.addOrderByDescending("id");
+        //q.addPrefetchedRelationship("allArticlesInGroup");
 
         Collection results = broker.getCollectionByQuery(q);
-        assertEquals("Number of ProductGroups", 5, results.size());
-        Collection articles = new ArrayList();
+        broker.commitTransaction();
+        assertEquals("Number of ProductGroups", pgCount, results.size());
         for(Iterator it = results.iterator(); it.hasNext();)
         {
             ProductGroup p = (ProductGroup) it.next();
-            articles.addAll(p.getAllArticles());
+            assertNotNull(p.getMedia());
+            assertEquals(mediumCount, p.getMedia().size());
         }
-        assertEquals("Total number of Articles", 59, articles.size());
-
-        //SELECT A0.KategorieName,A0.Kategorie_Nr,A0.Beschreibung FROM Kategorien A0 WHERE
A0.Kategorie_Nr <=  '5'
-        //SELECT ... FROM CDS A0 WHERE A0.Kategorie_Nr =  '5'
-        //SELECT ... FROM Artikel A0 WHERE A0.Kategorie_Nr =  '5'
-        //SELECT ... FROM BOOKS A0 WHERE A0.Kategorie_Nr =  '5'
-        //SELECT ... FROM CDS A0 WHERE A0.Kategorie_Nr =  '4'
-        //SELECT ... FROM Artikel A0 WHERE A0.Kategorie_Nr =  '4'
-        //SELECT ... FROM BOOKS A0 WHERE A0.Kategorie_Nr =  '4'
-        //...
-        //SELECT ... FROM CDS A0 WHERE A0.Kategorie_Nr =  '1'
-        //SELECT ... FROM Artikel A0 WHERE A0.Kategorie_Nr =  '1'
-        //SELECT ... FROM BOOKS A0 WHERE A0.Kategorie_Nr =  '1'
-        assertStmtCount("Read Non-Prefetched.", 16);
-        broker.commitTransaction();
-
-        //
-        // Reset original Proxy settings
-        //
-        cldProductGroup.setProxyClass(productGroupProxy);
-        cldProductGroup.setProxyClassName(productGroupProxy.getName());
-        cldArticle.setProxyClass(articleProxy);
-        cldArticle.setProxyClassName(articleProxy.getName());
 
+        /*
+        SELECT A0.ID_,A0.NAME_ FROM SQLCOUNT_GROUP A0 WHERE A0.NAME_ = '_testPrefetched_2_1176312175593_'
ORDER BY 1 DESC
+        SELECT A0.ID_,A0.TITLE_,A0.DATE_,A0.COVER_,A0.VERSION_,A0.FK_PUBLISHER,A0.FK_GROUP
FROM SQLCOUNT_BOOK A0 WHERE A0.FK_GROUP IN ('202936','202935')
+        SELECT A0.ID_,A0.TITLE_,A0.DATE_,A0.COVER_,A0.VERSION_,A0.FK_PUBLISHER,A0.FK_GROUP
FROM SQLCOUNT_CD A0 WHERE A0.FK_GROUP IN ('202936','202935')
+        SELECT A0.ID_,A0.TITLE_,A0.DATE_,A0.COVER_,A0.VERSION_,A0.FK_PUBLISHER,A0.FK_GROUP
FROM SQLCOUNT_DVD A0 WHERE A0.FK_GROUP IN ('202936','202935')
+        */
+        assertStmtCount("Read prefetched", expectedSelect);
     }
-
 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java?view=diff&rev=528051&r1=528050&r2=528051
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/EmptyCacheCountTest.java
Thu Apr 12 10:26:10 2007
@@ -5,36 +5,64 @@
 
 package org.apache.ojb.broker.sqlcount;
 
-import org.apache.ojb.broker.CdArticle;
+import java.util.Date;
+
 import org.apache.ojb.broker.Identity;
-import org.apache.ojb.broker.InterfaceArticle;
-import org.apache.ojb.broker.PersistenceBroker;
-import org.apache.ojb.broker.PersistenceBrokerFactory;
-import org.apache.ojb.broker.cache.ObjectCacheEmptyImpl;
-import org.apache.ojb.broker.util.configuration.impl.OjbConfiguration;
-import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
+import org.apache.ojb.p6spy.CountLogger;
 
 /**
- * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
  * @version $Id$
  */
-public class EmptyCacheCountTest extends AbstractCountTest
+public class EmptyCacheCountTest extends BaseCountTest
 {
+
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        String[] excludePattern_1 = new String[]{"select", "max","("};
+        String[] excludePattern_2 = new String[]{"OJB_HL_SEQ"};
+        CountLogger.addExcludePattern(excludePattern_1);
+        CountLogger.addExcludePattern(excludePattern_2);
+    }
+
+    public void tearDown() throws Exception
+    {
+        CountLogger.clearExludePattern();
+        super.tearDown();
+    }
+
     /**
      * retrieve one CdArticle twice.
      */
     public void testAccessArticleTwice()
     {
+        String name = ojbTestMethodIdentifier();
+        CD cd = new CD(name, new Date(), null);
+        broker.beginTransaction();
+        broker.store(cd);
+        broker.commitTransaction();
+        Identity id = broker.serviceIdentity().buildIdentity(Medium.class, cd.getId());
+        resetStmtCount();
+        broker.clearCache();
+        broker.beginTransaction();
+        CD result = (CD) broker.getObjectByIdentity(id);
+        assertNotNull(result);
+        assertStmtCount("access one CD", 1, 3); // 3 tables: BOOKS, CD, DVD
+        resetStmtCount();
+        broker.getObjectByIdentity(id);
+        assertStmtCount("access one CD again", 0, 1); // lookup from session cache expected
+        broker.commitTransaction();
+
+        id = broker.serviceIdentity().buildIdentity(cd);
         resetStmtCount();
         broker.clearCache();
         broker.beginTransaction();
-        Identity id = broker.serviceIdentity().buildIdentity(InterfaceArticle.class, new
Integer(200));
-        InterfaceArticle result = (InterfaceArticle) broker.getObjectByIdentity(id);
-        assertTrue(result instanceof CdArticle);
-        assertStmtCount("access one cd", 1, 3); // 3 tables: Artikel, BOOKS, CDS
+        result = (CD) broker.getObjectByIdentity(id);
+        assertNotNull(result);
+        assertStmtCount("access one CD", 1, 3); // 3 tables: BOOKS, CD, DVD
         resetStmtCount();
         broker.getObjectByIdentity(id);
-        assertStmtCount("access one cd again", 0, 1); // lookup from session cache expected
+        assertStmtCount("access one CD again", 0, 1); // lookup from session cache expected
         broker.commitTransaction();
     }
 }

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java?view=diff&rev=528051&r1=528050&r2=528051
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/sqlcount/TwoLevelSimpleTest.java
Thu Apr 12 10:26:10 2007
@@ -11,7 +11,6 @@
 import org.apache.ojb.broker.cloneable.CloneableGroup;
 
 /**
- * @author <a href="mailto:om@ppi.de">Oliver Matz</a>
  * @version $Id$
  */
 public class TwoLevelSimpleTest extends AbstractCountTest

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml?view=diff&rev=528051&r1=528050&r2=528051
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/repository_junit_sqlcount.xml
Thu Apr 12 10:26:10 2007
@@ -53,6 +53,13 @@
         field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
         />
 
+    <field-descriptor
+        name="fkProductGroup"
+        column="FK_GROUP"
+        jdbc-type="INTEGER"
+        access="anonymous"
+        />
+
     <reference-descriptor name="publisher"
         class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
         proxy="true"
@@ -63,6 +70,16 @@
         <foreignkey field-ref="fkPublisher"/>
     </reference-descriptor>
 
+    <reference-descriptor name="productGroup"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$ProductGroup"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkProductGroup"/>
+    </reference-descriptor>
+
     <collection-descriptor
         name="reviews"
         element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
@@ -134,6 +151,13 @@
         field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
         />
 
+    <field-descriptor
+        name="fkProductGroup"
+        column="FK_GROUP"
+        jdbc-type="INTEGER"
+        access="anonymous"
+        />
+
     <reference-descriptor name="publisher"
         class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
         proxy="true"
@@ -144,6 +168,16 @@
         <foreignkey field-ref="fkPublisher"/>
     </reference-descriptor>
 
+    <reference-descriptor name="productGroup"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$ProductGroup"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkProductGroup"/>
+    </reference-descriptor>
+
     <collection-descriptor
         name="reviews"
         element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
@@ -216,6 +250,13 @@
         field-class="org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldDirectImpl"
         />
 
+    <field-descriptor
+        name="fkProductGroup"
+        column="FK_GROUP"
+        jdbc-type="INTEGER"
+        access="anonymous"
+        />
+
     <reference-descriptor name="publisher"
         class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Publisher"
         proxy="true"
@@ -226,6 +267,16 @@
         <foreignkey field-ref="fkPublisher"/>
     </reference-descriptor>
 
+    <reference-descriptor name="productGroup"
+        class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$ProductGroup"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <foreignkey field-ref="fkProductGroup"/>
+    </reference-descriptor>
+
     <collection-descriptor
         name="reviews"
         element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Review"
@@ -479,5 +530,37 @@
         >
         <foreignkey field-ref="fkMedium"/>
     </reference-descriptor>
+
+</class-descriptor>
+
+
+<class-descriptor
+    class="org.apache.ojb.broker.sqlcount.BaseCountTest$ProductGroup"
+    table="SQLCOUNT_GROUP"
+    >
+    <field-descriptor
+        name="id"
+        column="ID_"
+        jdbc-type="INTEGER"
+        primarykey="true"
+        autoincrement="true"
+        />
+
+    <field-descriptor
+        name="name"
+        column="NAME_"
+        jdbc-type="VARCHAR"
+        />
+
+    <collection-descriptor
+        name="media"
+        element-class-ref="org.apache.ojb.broker.sqlcount.BaseCountTest$Medium"
+        proxy="true"
+        auto-retrieve="true"
+        auto-update="object"
+        auto-delete="object"
+        >
+        <inverse-foreignkey field-ref="fkProductGroup"/>
+    </collection-descriptor>
 
 </class-descriptor>



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