db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject svn commit: r434474 - /db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java
Date Thu, 24 Aug 2006 19:22:36 GMT
Author: brj
Date: Thu Aug 24 12:22:32 2006
New Revision: 434474

URL: http://svn.apache.org/viewvc?rev=434474&view=rev
Log:
testCase for bug OJB-120

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

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java?rev=434474&r1=434473&r2=434474&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/broker/QueryTest.java Thu Aug
24 12:22:32 2006
@@ -37,6 +37,8 @@
 import org.apache.ojb.broker.query.QueryByCriteria;
 import org.apache.ojb.broker.query.QueryFactory;
 import org.apache.ojb.broker.query.ReportQueryByCriteria;
+import org.apache.ojb.broker.util.collections.ManageableHashSet;
+import org.apache.ojb.broker.util.collections.RemovalAwareSet;
 import org.apache.ojb.junit.PBTestCase;
 
 /**
@@ -277,6 +279,27 @@
     }
 
     /**
+     * test OrderBy joined column. Read all Projects
+     */
+    public void _testOrderByJoined2()
+    {
+        Criteria crit = new Criteria();
+        QueryByCriteria q = QueryFactory.newQuery(Project.class, crit);
+        q.addOrderByAscending("persons.lastname");
+
+        Collection results = broker.getCollectionByQuery(q);
+        assertNotNull(results);
+
+        // compare with count
+        int count = broker.getCount(q);
+        assertEquals(results.size(), count);
+        
+        // check duplicates
+        Set resultsAsSet = new HashSet(results);
+        assertEquals(resultsAsSet.size(), results.size());
+    }
+
+    /**
      * test Subquery get all product groups without articles
      * <p/>
      * test may fail if db does not support sub queries
@@ -322,7 +345,6 @@
      */
     public void testSubQuery1()
     {
-
         ReportQueryByCriteria subQuery;
         Criteria subCrit = new Criteria();
         Criteria crit = new Criteria();
@@ -373,7 +395,6 @@
      */
     public void testSubQuery4()
     {
-
         ReportQueryByCriteria subQuery;
         Criteria subCrit = new Criteria();
         Criteria crit = new Criteria();
@@ -391,6 +412,32 @@
         Collection results = broker.getCollectionByQuery(q);
         assertNotNull(results);
         assertEquals(4, results.size());
+    }
+
+    /**
+     * test Subquery get all product groups containing Tofu
+     * testCase for bug OJB-120
+     * <p/>
+     * test may fail if db does not support sub queries
+     */
+    public void testSubQueryExists()
+    {
+        ReportQueryByCriteria subQuery;
+        Criteria subCrit = new Criteria();
+        Criteria crit = new Criteria();
+
+        subCrit.addEqualToField("productGroupId", Criteria.PARENT_QUERY_PREFIX + "groupId");
+        subCrit.addLike("articleName", "%Tofu%");
+        subQuery = QueryFactory.newReportQuery(Article.class, subCrit);
+        subQuery.setAttributes(new String[]{"articleId"});
+        subQuery.addOrderByAscending("articleId");
+
+        crit.addExists(subQuery);
+        Query q = QueryFactory.newQuery(ProductGroup.class, crit);
+
+        Collection results = broker.getCollectionByQuery(q);
+        assertNotNull(results);
+        assertEquals(1, results.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