db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r416098 - /db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java
Date Wed, 21 Jun 2006 20:13:35 GMT
Author: tfischer
Date: Wed Jun 21 13:13:35 2006
New Revision: 416098

URL: http://svn.apache.org/viewvc?rev=416098&view=rev
Log:
Added Testcase for TORQUE-34

Modified:
    db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java

Modified: db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java
URL: http://svn.apache.org/viewvc/db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java?rev=416098&r1=416097&r2=416098&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java (original)
+++ db/torque/runtime/trunk/src/test/org/apache/torque/util/CriteriaTest.java Wed Jun 21 13:13:35
2006
@@ -25,8 +25,12 @@
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.lang.SerializationUtils;
 import org.apache.torque.BaseTestCase;
+import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.adapter.DBFactory;
+import org.apache.torque.map.ColumnMap;
+import org.apache.torque.map.DatabaseMap;
+import org.apache.torque.map.TableMap;
 import org.apache.torque.util.Criteria.Criterion;
 import org.apache.torque.util.Criteria.Join;
 
@@ -577,14 +581,41 @@
     }
 
     /**
-     * test for TRQS25
+     * Checks whether orderBy works.
      */
-/*
- *    public void testCriteriaAndString()
- *    {
- *        Criteria c = new Criteria()
- *                .add("TABLE.COLUMN1", "string")
- *                .and("TABLE.COLUMN2", "string", Criteria.LIKE);
- *    }
- */
+    public void testOrderBy() throws TorqueException
+    {
+        // we need a rudementary databaseMap for this test case to work
+        DatabaseMap dbMap = Torque.getDatabaseMap(Torque.getDefaultDB());
+        
+        TableMap tableMap = new TableMap("AUTHOR", dbMap);
+        dbMap.addTable(tableMap);
+        
+        ColumnMap columnMap = new ColumnMap("NAME", tableMap);
+        columnMap.setType("");
+        tableMap.addColumn(columnMap);
+        
+        columnMap = new ColumnMap("AUTHOR_ID", tableMap);
+        columnMap.setType(new Integer(0));
+        tableMap.addColumn(columnMap);
+        
+        // check that alias'ed tables are referenced by their alias
+        // name when added to the select clause.
+        Criteria criteria = new Criteria();
+        criteria.addSelectColumn("AUTHOR.NAME");
+        criteria.addAlias("a", "AUTHOR");
+        criteria.addJoin(
+                "AUTHOR.AUTHOR_ID",
+                "a." + "AUTHOR_ID");
+        criteria.addAscendingOrderByColumn(
+                "a.NAME");
+        
+        String result = BasePeer.createQueryString(criteria);
+        assertEquals("SELECT AUTHOR.NAME, a.NAME "
+                    + "FROM AUTHOR, AUTHOR a "
+                    + "WHERE AUTHOR.AUTHOR_ID=a.AUTHOR_ID "
+                    + "ORDER BY a.NAME ASC", 
+                result);
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message