db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r417155 - /db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
Date Mon, 26 Jun 2006 10:11:51 GMT
Author: arminw
Date: Mon Jun 26 03:11:51 2006
New Revision: 417155

URL: http://svn.apache.org/viewvc?rev=417155&view=rev
Log:
use QueryFactory to build query

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java?rev=417155&r1=417154&r2=417155&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/ExtentAwarePathExpressionsTest.java
Mon Jun 26 03:11:51 2006
@@ -6,14 +6,15 @@
 import org.apache.ojb.broker.query.Criteria;
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
+import org.apache.ojb.broker.query.Query;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
  * Tests for extent aware path expressions
- * 
+ *
  * @author <a href="leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz</a>
- * 
- * $Id$
+ *
+ *         $Id$
  */
 public class ExtentAwarePathExpressionsTest extends PBTestCase
 {
@@ -32,7 +33,7 @@
     {
         Criteria criteria = new Criteria();
         criteria.addEqualTo("qualifiers.name", "Cars");
-        QueryByCriteria query = new QueryByCriteria(News.class, criteria);
+        Query query = QueryFactory.newQuery(News.class, criteria);
 
         broker.clearCache();
         List content = (List) broker.getCollectionByQuery(query);
@@ -43,7 +44,7 @@
     {
         Criteria criteria = new Criteria();
         criteria.addLike("qualifiers.name", "%ers%");
-        QueryByCriteria query = new QueryByCriteria(BaseContentImpl.class, criteria, true);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
 
         broker.clearCache();
         List content = (List) broker.getCollectionByQuery(query);
@@ -54,23 +55,23 @@
     {
         Criteria criteria = new Criteria();
         criteria.addNotNull("qualifiers.name");
-        QueryByCriteria query = new QueryByCriteria(BaseContentImpl.class, criteria, true);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(4,content.size());
+        assertEquals(4, content.size());
     }
 
     public void testSetPathClass()
     {
         Criteria criteria = new Criteria();
         criteria.addNotNull("qualifiers.name");
-        QueryByCriteria query = new QueryByCriteria(BaseContentImpl.class, criteria, true);
-        query.setPathClass("qualifiers",Category.class);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        query.setPathClass("qualifiers", Category.class);
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(2,content.size());
-        for (Iterator iter = content.iterator(); iter.hasNext();)
+        assertEquals(2, content.size());
+        for(Iterator iter = content.iterator(); iter.hasNext();)
         {
             BaseContentImpl element = (BaseContentImpl) iter.next();
-            assertTrue(element.getId() <=3 && element.getId() >=2);
+            assertTrue(element.getId() <= 3 && element.getId() >= 2);
         }
 
     }
@@ -82,15 +83,15 @@
         criteria.addNotNull("qualifiers.name");
         criteria.setPathClass("qualifiers", Category.class);
 
-        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
-        assertEquals(2,content.size());
-        for (Iterator iter = content.iterator(); iter.hasNext();)
+        assertEquals(2, content.size());
+        for(Iterator iter = content.iterator(); iter.hasNext();)
         {
             BaseContentImpl element = (BaseContentImpl) iter.next();
 
-            assertTrue(element.getId() <=3 && element.getId() >=2);
+            assertTrue(element.getId() <= 3 && element.getId() >= 2);
         }
 
     }
@@ -99,12 +100,12 @@
     {
         Criteria criteria = new Criteria();
         criteria.addNotNull("qualifiers.name");
-        QueryByCriteria query = new QueryByCriteria(BaseContentImpl.class, criteria, true);
-        query.addPathClass("qualifiers",Qualifier.class);
-        query.addPathClass("qualifiers",Area.class);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        query.addPathClass("qualifiers", Qualifier.class);
+        query.addPathClass("qualifiers", Area.class);
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(1,content.size());
-        assertEquals(10,((Paper)content.get(0)).getId());
+        assertEquals(1, content.size());
+        assertEquals(10, ((Paper) content.get(0)).getId());
     }
 
     public void testAddPathClassInCriteria()
@@ -115,33 +116,33 @@
         criteria.addPathClass("qualifiers", Qualifier.class);
         criteria.addPathClass("qualifiers", Area.class);
 
-        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(10, ((Paper)content.get(0)).getId());
+        assertEquals(10, ((Paper) content.get(0)).getId());
     }
 
     /**
-     * The order of criteria elements influences the use of parenthesis, 
-     *  If we add the Like element before the NotNull one we get the wrong query 
+     * The order of criteria elements influences the use of parenthesis,
+     * If we add the Like element before the NotNull one we get the wrong query
      * Right clause : WHERE WHERE (A2.NAME IS NOT NULL  OR A2E1.NAME IS NOT NULL ) AND A0.HEADLINE
LIKE  'Bra%
-     * Wrong clause : WHERE (A0.HEADLINE LIKE  'Bra%' ) AND A2.NAME IS NOT NULL  OR A2E1.NAME
IS NOT NULL 
+     * Wrong clause : WHERE (A0.HEADLINE LIKE  'Bra%' ) AND A2.NAME IS NOT NULL  OR A2E1.NAME
IS NOT NULL
      */
     public void testAddPathClasses()
     {
         Criteria criteria = new Criteria();
 
-        criteria.addLike("headline","Bra%");
+        criteria.addLike("headline", "Bra%");
         criteria.addNotNull("qualifiers.name");
-        QueryByCriteria query = new QueryByCriteria(BaseContentImpl.class, criteria, true);
-        query.addPathClass("qualifiers",Qualifier.class);
-        query.addPathClass("qualifiers",Topic.class);
-        query.addPathClass("qualifiers",Category.class);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        query.addPathClass("qualifiers", Qualifier.class);
+        query.addPathClass("qualifiers", Topic.class);
+        query.addPathClass("qualifiers", Category.class);
 
         List content = (List) broker.getCollectionByQuery(query);
-        assertEquals(1,content.size());
-        assertEquals(3,((News)content.get(0)).getId());
+        assertEquals(1, content.size());
+        assertEquals(3, ((News) content.get(0)).getId());
     }
 
     public void testAddPathClassesInCriteria()
@@ -154,19 +155,19 @@
         criteria.addPathClass("qualifiers", Topic.class);
         criteria.addPathClass("qualifiers", Category.class);
 
-        QueryByCriteria query   = new QueryByCriteria(BaseContentImpl.class, criteria, true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(3, ((News)content.get(0)).getId());
+        assertEquals(3, ((News) content.get(0)).getId());
     }
 
     // Test for OJB-50
     public void testComplexCriteriaWithPathClasses_1()
     {
-        Criteria criteria         = new Criteria();
+        Criteria criteria = new Criteria();
         Criteria categoryCriteria = new Criteria();
-        Criteria topicCriteria    = new Criteria();
+        Criteria topicCriteria = new Criteria();
 
         topicCriteria.addEqualTo("qualifiers.importance", "important");
         topicCriteria.addPathClass("qualifiers", Topic.class);
@@ -175,19 +176,19 @@
         categoryCriteria.addPathClass("qualifiers", Category.class);
         criteria.addOrCriteria(categoryCriteria);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
-        List            content = (List)broker.getCollectionByQuery(query);
+        Query query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
+        assertEquals(2, ((News) content.get(0)).getId());
     }
 
     // Test for OJB-50
     public void testComplexCriteriaWithPathClasses_2()
     {
-        Criteria criteria         = new Criteria();
+        Criteria criteria = new Criteria();
         Criteria categoryCriteria = new Criteria();
-        Criteria topicCriteria    = new Criteria();
+        Criteria topicCriteria = new Criteria();
 
         categoryCriteria.addLike("qualifiers.description", "The%");
         categoryCriteria.addPathClass("qualifiers", Category.class);
@@ -200,23 +201,23 @@
         criteria.addOrCriteria(categoryCriteria);
         criteria.addOrCriteria(topicCriteria);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
-        List            content = (List) broker.getCollectionByQuery(query);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
-        assertNotNull(((News)content.get(0)).getQualifiers());
-        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
+        assertEquals(2, ((News) content.get(0)).getId());
+        assertNotNull(((News) content.get(0)).getQualifiers());
+        assertEquals(3, ((News) content.get(0)).getQualifiers().size());
     }
 
     // Test for OJB-50
     public void testComplexCriteriaWithPathClasses_3()
     {
-        Criteria criteria         = new Criteria();
-        Criteria criteriaTopicExtAndCategory         = new Criteria();
+        Criteria criteria = new Criteria();
+        Criteria criteriaTopicExtAndCategory = new Criteria();
         Criteria categoryCriteria = new Criteria();
-        Criteria topicCriteria    = new Criteria();
-        Criteria topicExtCriteria    = new Criteria();
+        Criteria topicCriteria = new Criteria();
+        Criteria topicExtCriteria = new Criteria();
 
         categoryCriteria.addLike("qualifiers.description", "The buyer");
         categoryCriteria.addPathClass("qualifiers", Category.class);
@@ -234,13 +235,13 @@
         criteria.addAndCriteria(criteriaTopicExtAndCategory);
         criteria.addAndCriteria(topicCriteria);
 
-        QueryByCriteria query   = QueryFactory.newQuery(BaseContentImpl.class, criteria,
true);
-        List            content = (List) broker.getCollectionByQuery(query);
+        QueryByCriteria query = QueryFactory.newQuery(BaseContentImpl.class, criteria, true);
+        List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
-        assertNotNull(((News)content.get(0)).getQualifiers());
-        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
+        assertEquals(2, ((News) content.get(0)).getId());
+        assertNotNull(((News) content.get(0)).getQualifiers());
+        assertEquals(3, ((News) content.get(0)).getQualifiers().size());
     }
 
     // Test for OJB-62
@@ -253,9 +254,9 @@
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(2, ((News)content.get(0)).getId());
-        assertNotNull(((News)content.get(0)).getQualifiers());
-        assertEquals(3, ((News)content.get(0)).getQualifiers().size());
+        assertEquals(2, ((News) content.get(0)).getId());
+        assertNotNull(((News) content.get(0)).getQualifiers());
+        assertEquals(3, ((News) content.get(0)).getQualifiers().size());
     }
 
     // Test for OJB-62
@@ -284,9 +285,9 @@
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 
     // Test multiple path class on query object
@@ -303,9 +304,9 @@
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 
     // Test multiple path class on criteria object
@@ -322,9 +323,9 @@
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 
     // Test multiple path class on query object
@@ -341,8 +342,8 @@
         List content = (List) broker.getCollectionByQuery(query);
 
         assertEquals(1, content.size());
-        assertEquals(11, ((Paper)content.get(0)).getId());
-        assertNotNull(((Paper)content.get(0)).getQualifiers());
-        assertEquals(2, ((Paper)content.get(0)).getQualifiers().size());
+        assertEquals(11, ((Paper) content.get(0)).getId());
+        assertNotNull(((Paper) content.get(0)).getQualifiers());
+        assertEquals(2, ((Paper) content.get(0)).getQualifiers().size());
     }
 }



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