db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1028130 [6/6] - in /db/torque/torque4/branches/trunk-without-village: torque-runtime/ torque-runtime/src/main/java/org/apache/torque/map/ torque-runtime/src/main/java/org/apache/torque/oid/ torque-runtime/src/main/java/org/apache/torque/om...
Date Wed, 27 Oct 2010 22:52:18 GMT
Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/om/templates/peer/base/retrieveByPK.vm Wed Oct 27 22:52:15 2010
@@ -31,7 +31,7 @@
 #if (!$primaryKeyColumnElements.isEmpty())
   #if ($primaryKeyColumnElements.size() == 1)
     #set ( $columnElement = $primaryKeyColumnElements.get(0) )
-    #set ( $fieldType = $columnElement.getAttribute("fieldType"))
+    #set ( $columnFieldType = $columnElement.getAttribute("fieldType"))
     /**
      * Retrieve a single object by pk
      *
@@ -41,7 +41,7 @@
      * @throws NoRowsException Primary key was not found in database.
      * @throws TooManyRowsException Primary key was not found in database.
      */
-    public static $dbObjectClassName retrieveByPK($fieldType pk)
+    public static $dbObjectClassName retrieveByPK($columnFieldType pk)
         throws TorqueException, NoRowsException, TooManyRowsException
     {
         return ${peerClassName}.retrieveByPK(SimpleKey.keyFor(pk));
@@ -57,7 +57,7 @@
      * @throws NoRowsException Primary key was not found in database.
      * @throws TooManyRowsException Primary key was not found in database.
      */
-    public static $dbObjectClassName retrieveByPK($fieldType pk, Connection con)
+    public static $dbObjectClassName retrieveByPK($columnFieldType pk, Connection con)
         throws TorqueException, NoRowsException, TooManyRowsException
     {
         return ${peerClassName}.retrieveByPK(SimpleKey.keyFor(pk), con);
@@ -70,17 +70,17 @@
      * retrieve object using using pk values.
      *
     #foreach ($columnElement in $primaryKeyColumnElements)
-    #set ( $field = $columnElement.getAttribute("field") )
-    #set ( $fieldType = $columnElement.getAttribute("fieldType") )
-     * @param $field $fieldType
+    #set ( $columnField = $columnElement.getAttribute("field") )
+    #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+     * @param $columnField $columnFieldType
     #end
      */
     public static $dbObjectClassName retrieveByPK(
     #set ( $elementCount = 1 )
     #foreach ($columnElement in $primaryKeyColumnElements)
-      #set ( $field = $columnElement.getAttribute("field") )
-      #set ( $fieldType = $columnElement.getAttribute("fieldType") )
-            $fieldType $field#if($elementCount != $primaryKeyColumnElements.size()),#else)#end
+      #set ( $columnField = $columnElement.getAttribute("field") )
+      #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+            $columnFieldType $columnField#if($elementCount != $primaryKeyColumnElements.size()),#else)#end
 
       #set ( $elementCount = $elementCount + 1 )
     #end
@@ -93,8 +93,8 @@
            db = Torque.getConnection(DATABASE_NAME);
            retVal = retrieveByPK(
     #foreach ($columnElement in $primaryKeyColumnElements)
-      #set ( $field = $columnElement.getAttribute("field") )
-               ${field},
+      #set ( $columnField = $columnElement.getAttribute("field") )
+               ${columnField},
     #end
                db);
         }
@@ -109,26 +109,26 @@
      * retrieve object using using pk values.
      *
     #foreach ($columnElement in $primaryKeyColumnElements)
-      #set ( $field = $columnElement.getAttribute("field") )
-      #set ( $fieldType = $columnElement.getAttribute("fieldType") )
-     * @param $field $fieldType
+      #set ( $columnField = $columnElement.getAttribute("field") )
+      #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+     * @param $columnField $columnFieldType
     #end
      * @param con Connection
      */
     public static $dbObjectClassName retrieveByPK(
     #foreach ($columnElement in $primaryKeyColumnElements)
-      #set ( $field = $columnElement.getAttribute("field") )
-      #set ( $fieldType = $columnElement.getAttribute("fieldType") )
-            $fieldType ${field},
+      #set ( $columnField = $columnElement.getAttribute("field") )
+      #set ( $columnFieldType = $columnElement.getAttribute("fieldType") )
+            $columnFieldType ${columnField},
     #end
             Connection con) throws TorqueException
     {
 
         Criteria criteria = new Criteria(5);
     #foreach ($columnElement in $primaryKeyColumnElements)
-      #set ( $field = $columnElement.getAttribute("field") )
+      #set ( $columnField = $columnElement.getAttribute("field") )
       #set ( $peerColumnName = $columnElement.getAttribute("peerColumnName") )
-        criteria.add($peerColumnName, $field);
+        criteria.add($peerColumnName, $columnField);
     #end
         List<${dbObjectClassName}> v = doSelect(criteria, con);
         if (v.size() == 1)

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/derby/table.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/derby/table.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/derby/table.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/derby/table.vm Wed Oct 27 22:52:15 2010
@@ -18,7 +18,6 @@
 -- -----------------------------------------------------------------------
 -- $name
 -- -----------------------------------------------------------------------
-$torqueGen.mergepoint("drop")
 CREATE TABLE $name
 (
 #set ( $cols = $torqueGen.mergepoint("columns") )

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mssql/table.vm Wed Oct 27 22:52:15 2010
@@ -18,7 +18,6 @@
 /* ---------------------------------------------------------------------- */
 /* $name                                                      */
 /* ---------------------------------------------------------------------- */
-$torqueGen.mergepoint("drop")
 CREATE TABLE $name
 (
 #set ( $cols = $torqueGen.mergepoint("columns") )

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/mysql/table.vm Wed Oct 27 22:52:15 2010
@@ -18,7 +18,6 @@
 # -----------------------------------------------------------------------
 # $name
 # -----------------------------------------------------------------------
-$torqueGen.mergepoint("drop")
 CREATE TABLE $name
 (
 #set ( $cols = $torqueGen.mergepoint("columns") )

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/oracle/table.vm Wed Oct 27 22:52:15 2010
@@ -18,7 +18,6 @@
 -----------------------------------------------------------------------------
 -- $name
 -----------------------------------------------------------------------------
-$torqueGen.mergepoint("drop")
 CREATE TABLE $name
 (
 #set ( $cols = $torqueGen.mergepoint("columns") )

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/table.vm
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/table.vm?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/table.vm (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/sql/templates/ddl/postgresql/table.vm Wed Oct 27 22:52:15 2010
@@ -18,8 +18,6 @@
 -----------------------------------------------------------------------------
 -- $name
 -----------------------------------------------------------------------------
-$torqueGen.mergepoint("drop")
-
 CREATE TABLE $name
 (
 #set ( $cols = $torqueGen.mergepoint("columns") )

Modified: db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/transformer/om/OMTableTransformer.properties
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/transformer/om/OMTableTransformer.properties?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/transformer/om/OMTableTransformer.properties (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-templates/src/main/resources/org/apache/torque/templates/transformer/om/OMTableTransformer.properties Wed Oct 27 22:52:15 2010
@@ -22,6 +22,7 @@ ${attribute(noOverride):basePeerClassNam
 ${attribute(noOverride):beanClassName}=${option:torque.om.className.beanClassNamePrefix}${attribute:javaName}${option:torque.om.className.beanClassNameSuffix}
 ${attribute(noOverride):baseBeanClassName}=${option:torque.om.className.baseBeanClassNamePrefix}${attribute:javaName}${option:torque.om.className.baseBeanClassNameSuffix}
 ${attribute(noOverride):mapBuilderClassName}=${option:torque.om.className.mapBuilderClassNamePrefix}${attribute:javaName}${option:torque.om.className.mapBuilderClassNameSuffix}
+${attribute(noOverride):recordMapperClass}=${option:torque.om.className.recordMapperClassNamePrefix}${attribute:javaName}${option:torque.om.className.recordMapperClassNameSuffix}
 
 ${attribute(noOverride):dbObjectPackage}=${option:torque.om.package.package}${option:torque.om.package.dbObjectPackageSuffix}
 ${attribute(noOverride):baseDbObjectPackage}=${option:torque.om.package.package}${option:torque.om.package.baseDbObjectPackageSuffix}

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/BaseRuntimeTestCase.java Wed Oct 27 22:52:15 2010
@@ -25,12 +25,10 @@ import junit.framework.TestCase;
 
 import org.apache.torque.adapter.DB;
 import org.apache.torque.adapter.DBMM;
+import org.apache.torque.map.TableMap;
+import org.apache.torque.om.mapper.StringMapper;
 import org.apache.torque.util.BasePeer;
 
-import com.workingdogs.village.DataSetException;
-import com.workingdogs.village.Record;
-import com.workingdogs.village.Value;
-
 /**
  * Base functionality to be extended by all Torque test cases.  Test
  * case implementations are used to automate unit testing via JUnit.
@@ -73,10 +71,8 @@ public abstract class BaseRuntimeTestCas
      * Queries mysql for its version.
      * @return the version String mysql returns
      * @throws TorqueException if the database is not mysql or the query fails.
-     * @throws DataSetException if the version string can not be extracted from
-     *         the select result.
      */
-    protected String getMysqlVersion() throws TorqueException, DataSetException
+    protected String getMysqlVersion() throws TorqueException
     {
         DB adapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
         if (!(adapter instanceof DBMM))
@@ -85,24 +81,23 @@ public abstract class BaseRuntimeTestCas
                     "getMysqlVersion called but database adapter is "
                         + adapter.getClass().getName());
         }
-        List records = BasePeer.executeQuery("show variables like \"version\"");
-        Record record = (Record) records.get(0);
-        Value versionValue = record.getValue("Value");
-        String version = versionValue.asString();
-        return version;
+        List<String> records = BasePeer.doSelect(
+                "show variables like \"version\"",
+                new StringMapper(1),
+                (TableMap) null,
+                (String) null);
+        return records.get(0);
     }
 
     /**
      * Queries mysql for its major version. (format is major.minor.release)
      * @return the major version of mysql
      * @throws TorqueException if the database is not mysql or the query fails.
-     * @throws DataSetException if the version string can not be extracted from
-     *         the select result.
      * @throws NumberFormatException if the mysql major version cannot be 
      *         converted to an int 
      */
     protected int getMysqlMajorVersion()
-        throws TorqueException, DataSetException
+        throws TorqueException
     {
         String completeVersion = getMysqlVersion();
         String majorVersion
@@ -114,11 +109,9 @@ public abstract class BaseRuntimeTestCas
      * Queries mysql for its minor version. (format is major.minor.release)
      * @return the minor version of mysql
      * @throws TorqueException if the database is not mysql or the query fails.
-     * @throws DataSetException if the version string can not be extracted from
-     *         the select result.
      */
     protected int getMysqlMinorVersion()
-        throws TorqueException, DataSetException
+        throws TorqueException
     {
         String completeVersion = getMysqlVersion();
         String minorVersion

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java Wed Oct 27 22:52:15 2010
@@ -20,14 +20,17 @@ package org.apache.torque;
  */
 
 import java.sql.Connection;
+import java.sql.ResultSet;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -46,6 +49,9 @@ import org.apache.torque.adapter.DBOracl
 import org.apache.torque.adapter.DBSybase;
 import org.apache.torque.adapter.DBWeblogic;
 import org.apache.torque.om.StringKey;
+import org.apache.torque.om.mapper.CompositeMapper;
+import org.apache.torque.om.mapper.IntegerMapper;
+import org.apache.torque.om.mapper.RecordMapper;
 import org.apache.torque.test.A;
 import org.apache.torque.test.APeer;
 import org.apache.torque.test.Author;
@@ -97,8 +103,6 @@ import org.apache.torque.util.CountHelpe
 import org.apache.torque.util.Criteria;
 import org.apache.torque.util.Transaction;
 
-import com.workingdogs.village.Record;
-
 /**
  * Runtime tests.
  *
@@ -205,21 +209,23 @@ public class DataTest extends BaseRuntim
     }
 
     private static final String[] validTitles = {
-        "Book 7 - Author 8", "Book 6 - Author 8", "Book 7 - Author 7",
-        "Book 6 - Author 7", "Book 7 - Author 6", "Book 6 - Author 6",
-        "Book 7 - Author 5", "Book 6 - Author 5", "Book 7 - Author 4",
-        "Book 6 - Author 4"};
+        "Book 6 - Author 4", "Book 6 - Author 5", "Book 6 - Author 6",
+        "Book 6 - Author 7", "Book 6 - Author 8", 
+        "Book 7 - Author 4", "Book 7 - Author 5", "Book 7 - Author 6",
+        "Book 7 - Author 7", "Book 7 - Author 8"
+        };
 
     /**
-     * test limit/offset which was broken for oracle (TRQ47)
+     * test limit/offset
+     *
      * @throws Exception if the test fails
      */
     public void testLimitOffset() throws Exception
     {
-        Map titleMap = new HashMap();
+        Set<String> titleSet = new HashSet<String>();
         for (int j = 0; j < validTitles.length; j++)
         {
-            titleMap.put(validTitles[j], null);
+            titleSet.add(validTitles[j]);
         }
 
         Criteria crit = new Criteria();
@@ -231,15 +237,17 @@ public class DataTest extends BaseRuntim
         crit.addDescendingOrderByColumn(BookPeer.BOOK_ID);
         crit.setLimit(10);
         crit.setOffset(5);
-        List books = BookPeer.doSelect(crit);
+        List<Book> books = BookPeer.doSelect(crit);
         assertTrue("List should have 10 books, not " + books.size(),
                 books.size() == 10);
-        for (Iterator i = books.iterator(); i.hasNext();)
+        for (Book book : books)
         {
-            String title = ((Book) i.next()).getTitle();
+            String title = book.getTitle();
             assertTrue("Incorrect title: " + title,
-                    titleMap.containsKey(title));
+                    titleSet.contains(title));
         }
+
+        // Test limit of zero works
         crit.clear();
         crit.setLimit(0);
         try
@@ -265,7 +273,7 @@ public class DataTest extends BaseRuntim
         books = MyBookPeer.doSelect(crit);
         assertTrue("List should have 95 books, not " + books.size(),
                 books.size() == 95);
-        
+
         // Check that limiting also works if a table with an equal column name
         // is joined. This is problematic for oracle, see TORQUE-10.
         
@@ -431,7 +439,7 @@ public class DataTest extends BaseRuntim
         BitCompositePkPeer.doDelete(criteria);
 
         BitCompositePk bitCompositePk = new BitCompositePk();
-        bitCompositePk.setPk1("value");
+        bitCompositePk.setPk1("false value");
         bitCompositePk.setPk2(Boolean.FALSE);
         bitCompositePk.setPayload("false payload");
         bitCompositePk.save();
@@ -439,18 +447,18 @@ public class DataTest extends BaseRuntim
         bitCompositePk = new BitCompositePk();
         bitCompositePk.setPk1("true value");
         bitCompositePk.setPk2(Boolean.TRUE);
-        bitCompositePk.setPayload("double true payload");
+        bitCompositePk.setPayload("true payload");
         bitCompositePk.save();
 
         bitCompositePk = new BitCompositePk();
         bitCompositePk.setPk1("value");
         bitCompositePk.setPk2(Boolean.TRUE);
-        bitCompositePk.setPayload("true payload");
+        bitCompositePk.setPayload("payload");
         bitCompositePk.save();
 
         // check we get correct result when pks match
         criteria = new Criteria();
-        criteria.and(BitCompositePkPeer.PK1, "value");
+        criteria.and(BitCompositePkPeer.PK1, "false value");
         criteria.and(BitCompositePkPeer.PK2, Boolean.FALSE);
         List<BitCompositePk> result 
             = BitCompositePkPeer.doSelect(criteria);
@@ -462,18 +470,18 @@ public class DataTest extends BaseRuntim
         criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
         result = BitCompositePkPeer.doSelect(criteria);
         assertEquals(1, result.size());
-        assertEquals("double true payload", result.get(0).getPayload());
+        assertEquals("true payload", result.get(0).getPayload());
         
         // check updating works
-        result.get(0).setPk2(Boolean.FALSE);
+        result.get(0).setPayload("true updated payload");
         result.get(0).save();
         
         criteria = new Criteria();
         criteria.and(BitCompositePkPeer.PK1, "true value");
-        criteria.and(BitCompositePkPeer.PK2, Boolean.FALSE);
+        criteria.and(BitCompositePkPeer.PK2, Boolean.TRUE);
         result = BitCompositePkPeer.doSelect(criteria);
         assertEquals(1, result.size());
-        assertEquals("double true payload", result.get(0).getPayload());
+        assertEquals("true updated payload", result.get(0).getPayload());
     }
 
     /**
@@ -746,41 +754,44 @@ public class DataTest extends BaseRuntim
         book.setIsbn("ISBN");
         book.save();
 
-        criteria.clear();
-        criteria.add(BookPeer.AUTHOR_ID, author.getAuthorId());
-        criteria.addJoin(AuthorPeer.AUTHOR_ID, BookPeer.AUTHOR_ID);
-        // The following where clause is not necessary from a sql point of view.
-        // However, it adds a second table to the where clauses of the
-        // criteria, so that it cannot be determined from the criteria alone
-        // which table should be deleted from. So this may cause data to
-        // disappear from both tables (TORQUE-93)
-        criteria.add(AuthorPeer.AUTHOR_ID, book.getAuthorId());
-        BookPeer.doDelete(criteria);
-        authorResult = AuthorPeer.doSelect(new Criteria());
-        bookResult = BookPeer.doSelect(new Criteria());
-        assertTrue("deleted not enough records",
-                bookResult.size() == 0);
-        assertTrue("delete also deleted objects in joined table",
-                authorResult.size() == 1);
-        
-        // recreate book, test whether deletes using joins work
-        book = new Book();
-        book.setTitle("title");
-        book.setAuthor(author);
-        book.setIsbn("ISBN");
-        book.save();
-
-        criteria.clear();
-        criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID);
-        criteria.add(AuthorPeer.NAME, author.getName());
-        BookPeer.doDelete(criteria);
-
-        authorResult = AuthorPeer.doSelect(new Criteria());
-        bookResult = BookPeer.doSelect(new Criteria());
-        assertTrue("deleted not enough records",
-                bookResult.size() == 0);
-        assertTrue("delete also deleted objects in joined table",
-                authorResult.size() == 1);
+//        criteria.clear();
+//        criteria.add(BookPeer.AUTHOR_ID, author.getAuthorId());
+//        criteria.addJoin(
+//                AuthorPeer.AUTHOR_ID,
+//                BookPeer.AUTHOR_ID,
+//                SqlEnum.INNER_JOIN);
+//        // The following where clause is not necessary from a sql point of view.
+//        // However, it adds a second table to the where clauses of the
+//        // criteria, so that it cannot be determined from the criteria alone
+//        // which table should be deleted from. So this may cause data to
+//        // disappear from both tables (TORQUE-93)
+//        criteria.add(AuthorPeer.AUTHOR_ID, book.getAuthorId());
+//        BookPeer.doDelete(criteria);
+//        authorResult = AuthorPeer.doSelect(new Criteria());
+//        bookResult = BookPeer.doSelect(new Criteria());
+//        assertTrue("deleted not enough records",
+//                bookResult.size() == 0);
+//        assertTrue("delete also deleted objects in joined table",
+//                authorResult.size() == 1);
+//        
+//        // recreate book, test whether deletes using joins work
+//        book = new Book();
+//        book.setTitle("title");
+//        book.setAuthor(author);
+//        book.setIsbn("ISBN");
+//        book.save();
+//
+//        criteria.clear();
+//        criteria.addJoin(BookPeer.AUTHOR_ID, AuthorPeer.AUTHOR_ID);
+//        criteria.add(AuthorPeer.NAME, author.getName());
+//        BookPeer.doDelete(criteria);
+//
+//        authorResult = AuthorPeer.doSelect(new Criteria());
+//        bookResult = BookPeer.doSelect(new Criteria());
+//        assertTrue("deleted not enough records",
+//                bookResult.size() == 0);
+//        assertTrue("delete also deleted objects in joined table",
+//                authorResult.size() == 1);
     }
 
     /**
@@ -913,12 +924,12 @@ public class DataTest extends BaseRuntim
         // test double functions in select columns
         Criteria criteria = new Criteria();
         criteria.addSelectColumn("count(distinct(" + BookPeer.BOOK_ID + "))");
-        BookPeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null);
 
         // test qualifiers in function in select columns
         criteria = new Criteria();
         criteria.addSelectColumn("count(distinct " + BookPeer.BOOK_ID + ")");
-        BookPeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null);
     }
 
     /**
@@ -931,7 +942,7 @@ public class DataTest extends BaseRuntim
         
         criteria.addSelectColumn(BookPeer.BOOK_ID);
 
-        BasePeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null);
     }
 
     /**
@@ -939,10 +950,11 @@ public class DataTest extends BaseRuntim
      * but it is null. All methods on the user level should be able to
      * handle this.
      */
-    public void testNullConnection() throws Exception
+    // ignored connection handling has changed
+    public void ignoredTestNullConnection() throws Exception
     {
         Criteria criteria = new Criteria();
-        BookPeer.doSelectVillageRecords(criteria, null);
+        BasePeer.doSelect(criteria, new IntegerMapper(), null, null);
 
         criteria = new Criteria();
         criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
@@ -1098,7 +1110,7 @@ public class DataTest extends BaseRuntim
         // using the test data from testJoins()
         Criteria criteria = new Criteria();
         criteria.addAscendingOrderByColumn(BookPeer.TITLE);
-        List books = MyBookPeer.doSelectJoinAuthor(criteria);
+        List<Book> books = MyBookPeer.doSelectJoinAuthor(criteria);
         assertTrue("books should contain 4 books but contains "
                 + books.size(), books.size() == 4);
         Book bookTwo = (Book) books.get(1);
@@ -1140,11 +1152,11 @@ public class DataTest extends BaseRuntim
         
         Criteria criteria =  new Criteria();
         criteria.add(APeer.A_ID, a.getAId());
-        List list = MyCPeer.doSelectJoinAllExceptA(criteria);
+        List<C> list = MyCPeer.doSelectJoinAllExceptA(criteria);
         assertTrue("list should contain 1 entry but contains "
                 + list.size(), list.size() == 1);
         
-        C c1 = (C)list.get(0);
+        C c1 = list.get(0);
         B b1 = c1.getB();
         RAb rab1 = c1.getRAb();
         
@@ -1467,7 +1479,7 @@ public class DataTest extends BaseRuntim
         // we need an additional column to select from,
         // to indicate the table we want use
         criteria.addSelectColumn(AuthorPeer.AUTHOR_ID);
-        BasePeer.doSelectVillageRecords(criteria);
+        BasePeer.doSelect(criteria, new DoNothingMapper(), null);
     }
 
     /**
@@ -1498,12 +1510,17 @@ public class DataTest extends BaseRuntim
         AuthorPeer.addSelectColumns(criteria);
         // basically a BaseBookPeer.setDbName(criteria);
         // and BasePeer.doSelect(criteria);
-        List villageRecords = BookPeer.doSelectVillageRecords(criteria);
-        Record record = (Record) villageRecords.get(0);
-        book = new Book();
-        BookPeer.populateObject(record, 1, book);
-        author = new Author();
-        AuthorPeer.populateObject(record, BookPeer.numColumns + 1, author);
+        CompositeMapper mapper = new CompositeMapper();
+        mapper.addMapper(new BookPeer.BookRecordMapper(), 0);
+        mapper.addMapper(
+                new AuthorPeer.AuthorRecordMapper(),
+                BookPeer.numColumns);
+        
+        List<List<Object>> queryResult
+                = BookPeer.doSelect(criteria, mapper, null);
+        List<Object> mappedRow = queryResult.get(0);
+        book = (Book) mappedRow.get(0);
+        author = (Author) mappedRow.get(1);
 
         if (book.getAuthorId() == author.getAuthorId())
         {
@@ -1554,6 +1571,7 @@ public class DataTest extends BaseRuntim
                 + dateFormat.format(loadedDateTest.getTimestampValue()));
 
         // compute time differences between reloaded and original object
+        // TODO asserts rather than System.out.println!
         long dateDifference
                 = dateTest.getDateValue().getTime()
                     - loadedDateTest.getDateValue().getTime();
@@ -1730,12 +1748,45 @@ public class DataTest extends BaseRuntim
 
         // read the BlobTests from the database
         // and check the values against the original values
-        List blobTestList = BlobTestPeer.doSelect(new Criteria());
+        List<BlobTest> blobTestList = BlobTestPeer.doSelect(new Criteria());
         assertTrue("blobTestList should contain 1 object but contains "
                 + blobTestList.size(),
                 blobTestList.size() == 1);
 
-        BlobTest readBlobTest = (BlobTest) blobTestList.get(0);
+        BlobTest readBlobTest = blobTestList.get(0);
+        assertTrue("read and written blobs should be equal. "
+                + "Size of read blob is"
+                + readBlobTest.getBlobValue().length
+                + " size of written blob is "
+                + blobTest.getBlobValue().length,
+                Arrays.equals(
+                        blobTest.getBlobValue(),
+                        readBlobTest.getBlobValue()));
+
+        // test updating
+        blobTest = readBlobTest;
+        {
+            int length = 200000;
+            byte[] bytes = new byte[length];
+            StringBuffer chars = new StringBuffer();
+            String charTemplate = "9876543210abcdefghijklmnopqrstuvwxyz";
+            for (int i = 0; i < length; ++i)
+            {
+                bytes[i] = new Integer(i % 256).byteValue();
+                chars.append(charTemplate.charAt(i % charTemplate.length()));
+            }
+            blobTest.setBlobValue(bytes);
+        }
+        blobTest.save();
+
+        // read the BlobTests from the database
+        // and check the values against the updated values
+        blobTestList = BlobTestPeer.doSelect(new Criteria());
+        assertTrue("blobTestList should contain 1 object but contains "
+                + blobTestList.size(),
+                blobTestList.size() == 1);
+
+        readBlobTest = blobTestList.get(0);
         assertTrue("read and written blobs should be equal. "
                 + "Size of read blob is"
                 + readBlobTest.getBlobValue().length
@@ -1790,49 +1841,43 @@ public class DataTest extends BaseRuntim
 
         // read the ClobTests from the database
         // and check the values against the original values
-        List clobTestList = ClobTestPeer.doSelect(new Criteria());
+        List<ClobTest> clobTestList = ClobTestPeer.doSelect(new Criteria());
         assertTrue("clobTestList should contain 1 object but contains "
                 + clobTestList.size(),
                 clobTestList.size() == 1);
 
-        ClobTest readClobTest = (ClobTest) clobTestList.get(0);
+        ClobTest readClobTest = clobTestList.get(0);
         assertTrue("read and written clobs should be equal",
                 clobTest.getClobValue().equals(readClobTest.getClobValue()));
-    }
 
-    /**
-     * Test whether we can execute queries as prepared statements
-     * @throws Exception
-     */
-    public void testPreparedStatements() throws Exception
-    {
-        // clean LargePk table
-        Criteria criteria = new Criteria();
-        criteria.add(
-                LargePkPeer.LARGE_PK_ID,
-                (Long) null,
-                Criteria.NOT_EQUAL);
-        LargePkPeer.doDelete(criteria);
-
-        LargePk largePk = new LargePk();
-        largePk.setLargePkId(1);
-        largePk.setName("testLargePk");
-        largePk.save();
+        
+        // Test updating
+        clobTest = readClobTest;
+        {
+            int length = 20000;
+            StringBuffer chars = new StringBuffer();
+            String charTemplate = "0987654321abcdefghijklmnopqrstuvwxyz";
+            for (int i = 0; i < length; ++i)
+            {
+                 chars.append(charTemplate.charAt(i % charTemplate.length()));
+            }
+            clobTest.setClobValue(chars.toString());
+        }
+        clobTest.save();
 
-        largePk = new LargePk();
-        largePk.setLargePkId(2);
-        largePk.setName("testLargePk");
-        largePk.save();
+        // read the ClobTests from the database
+        // and check the values against the original values
+        clobTestList = ClobTestPeer.doSelect(new Criteria());
+        assertTrue("clobTestList should contain 1 object but contains "
+                + clobTestList.size(),
+                clobTestList.size() == 1);
 
-        criteria = new Criteria();
-        criteria.add(LargePkPeer.LARGE_PK_ID, 2, Criteria.LESS_THAN);
-        LargePkPeer.addSelectColumns(criteria);
-        List result = BasePeer.doPSSelect(criteria);
-        assertTrue("Size of largePk list should be 1 but is "
-                + result.size(),
-                result.size() == 1);
+        readClobTest = clobTestList.get(0);
+        assertTrue("read and written clobs should be equal",
+                clobTest.getClobValue().equals(readClobTest.getClobValue()));
     }
 
+
     /**
      * Test whether equals() is working correctly
      * @throws Exception
@@ -2027,7 +2072,8 @@ public class DataTest extends BaseRuntim
                 InheritanceTestPeer.INHERITANCE_TEST);
         
         // Check that the class of the object is retained when loading
-        List inheritanceObjects = InheritanceTestPeer.doSelect(criteria);
+        List<InheritanceTest> inheritanceObjects 
+                = InheritanceTestPeer.doSelect(criteria);
         assertEquals(
                 InheritanceTest.class, 
                 inheritanceObjects.get(0).getClass());
@@ -2264,7 +2310,7 @@ public class DataTest extends BaseRuntim
      */
     static class MyBookPeer extends BookPeer
     {
-        public static List doSelectJoinAuthor(Criteria criteria)
+        public static List<Book> doSelectJoinAuthor(Criteria criteria)
                 throws TorqueException
         {
             return BookPeer.doSelectJoinAuthor(criteria);
@@ -2276,10 +2322,20 @@ public class DataTest extends BaseRuntim
      */
     static class MyCPeer extends CPeer
     {
-        public static List doSelectJoinAllExceptA(Criteria criteria)
+        public static List<C> doSelectJoinAllExceptA(Criteria criteria)
                 throws TorqueException
         {
             return CPeer.doSelectJoinAllExceptA(criteria);
         }
     }
+    
+    static class DoNothingMapper implements RecordMapper<Object>
+    {
+
+        public Object processRow(ResultSet resultSet, int rowOffset)
+                throws TorqueException
+        {
+            return null;
+        }
+    }
 }

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DocsTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DocsTest.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DocsTest.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DocsTest.java Wed Oct 27 22:52:15 2010
@@ -25,6 +25,8 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.adapter.DB;
 import org.apache.torque.adapter.DBMM;
+import org.apache.torque.map.TableMap;
+import org.apache.torque.om.mapper.ObjectListMapper;
 import org.apache.torque.test.Author;
 import org.apache.torque.test.AuthorPeer;
 import org.apache.torque.test.Book;
@@ -32,8 +34,6 @@ import org.apache.torque.test.BookPeer;
 import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.Criteria;
 
-import com.workingdogs.village.DataSetException;
-
 /**
  * Runtime tests to make sure that the code which is supplied
  * in the documentation actually works ;-)
@@ -224,13 +224,16 @@ public class DocsTest extends BaseRuntim
                 bookAuthors.size() == 3);
 
         // test explicit sql statements from details section
-        List result = null;
+        List<List<Object>> result = null;
         try
         {
-            result = BasePeer.executeQuery(
+            result = BasePeer.doSelect(
                     "SELECT book.* FROM book "
-                    + "INNER JOIN author "
-                    + "ON book.AUTHOR_ID=author.AUTHOR_ID");
+                        + "INNER JOIN author "
+                        + "ON book.AUTHOR_ID=author.AUTHOR_ID",
+                    new ObjectListMapper(),
+                    (TableMap) null,
+                    (String) null);
         }
         catch (Exception e)
         {
@@ -248,9 +251,12 @@ public class DocsTest extends BaseRuntim
         result = null;
         try
         {
-            result = BasePeer.executeQuery(
+            result = BasePeer.doSelect(
                     "SELECT book.* FROM book,author "
-                    + "WHERE book.AUTHOR_ID=author.AUTHOR_ID");
+                        + "WHERE book.AUTHOR_ID=author.AUTHOR_ID",
+                    new ObjectListMapper(),
+                    (TableMap) null,
+                    (String) null);
         }
         catch (Exception e)
         {
@@ -372,7 +378,7 @@ public class DocsTest extends BaseRuntim
     /**
      * Criteria Howto, section "subselects"
      */
-    public void testSubselects() throws TorqueException, DataSetException
+    public void testSubselects() throws TorqueException
     {
         DB adapter = Torque.getDatabase(Torque.getDefaultDB()).getAdapter();
         if (adapter instanceof DBMM)

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/map/DatabaseMapTest.java Wed Oct 27 22:52:15 2010
@@ -151,14 +151,8 @@ public class DatabaseMapTest extends Bas
     }
 
     /**
-     * Test that XML table order is preserved in DatabaseMap objects.
+     * Check that the external schema tables are added to the database map.
      * <p>
-     * Assumptions:
-     * <ul>
-     * The default database is bookstore<br>
-     * TABLE_NAME1 is followed by TABLE_NAME2 in the array<br>
-     * </ul>
-     * 
      * @throws TorqueException
      */
     public void testExternalSchemaTables() throws TorqueException

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/LargeSelectTest.java Wed Oct 27 22:52:15 2010
@@ -87,8 +87,7 @@ public class LargeSelectTest extends Bas
      */
     public void testCriteria() throws TorqueException
     {
-        List result = null;
-        result = AuthorPeer.doSelect(criteria);
+        List<Author> result = AuthorPeer.doSelect(criteria);
         assertEquals("Selected rows", TEST_ROWS, result.size());
     }
 
@@ -100,8 +99,9 @@ public class LargeSelectTest extends Bas
         criteria.setLimit(1);
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE,
-                    "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -117,8 +117,9 @@ public class LargeSelectTest extends Bas
         criteria.setOffset(1);
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE,
-                    "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -133,7 +134,9 @@ public class LargeSelectTest extends Bas
     {
         try
         {
-            new LargeSelect(criteria, 0, "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, 0,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -148,8 +151,9 @@ public class LargeSelectTest extends Bas
     {
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE, 0,
-                    "org.apache.torque.test.AuthorPeer");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE, 0,
+                    "org.apache.torque.test.AuthorPeer",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -164,8 +168,9 @@ public class LargeSelectTest extends Bas
     {
         try
         {
-            new LargeSelect(criteria, TEST_PAGE_SIZE,
-                    "org.apache.torque.test.Author");
+            new LargeSelect<Author>(criteria, TEST_PAGE_SIZE,
+                    "org.apache.torque.test.Author",
+                    new AuthorPeer.AuthorRecordMapper());
         }
         catch (IllegalArgumentException success)
         {
@@ -197,13 +202,15 @@ public class LargeSelectTest extends Bas
      */
     public void testLargeSelect() throws TorqueException
     {
-        LargeSelect ls = new LargeSelect(criteria, TEST_PAGE_SIZE,
-                "org.apache.torque.test.AuthorPeer");
+        LargeSelect<Author> ls = new LargeSelect<Author>(
+                criteria,
+                TEST_PAGE_SIZE,
+                "org.apache.torque.test.AuthorPeer",
+                new AuthorPeer.AuthorRecordMapper());
 
         assertEquals("Page size", TEST_PAGE_SIZE, ls.getPageSize());
         assertTrue("Paginated", ls.getPaginated());
 
-
         // Page 0
         assertEquals("Current page number", 0, ls.getCurrentPageNumber());
         assertFalse("Previous results available", ls.getPreviousResultsAvailable());
@@ -217,7 +224,7 @@ public class LargeSelectTest extends Bas
         assertEquals("Page progress text", "0 of &gt; 0", ls.getPageProgressText());
         assertEquals("Record progress text", "0 - 0 of &gt; 0", ls.getRecordProgressText());
 
-        List results = ls.getNextResults();
+        List<Author> results = ls.getNextResults();
         // Page 1
         assertEquals("results.size()", TEST_PAGE_SIZE, results.size());
         assertEquals("Current page number", 1, ls.getCurrentPageNumber());
@@ -296,7 +303,7 @@ public class LargeSelectTest extends Bas
         assertEquals("Page progress text", "2 of 9", ls.getPageProgressText());
         assertEquals("Record progress text", "10 - 18 of 81", ls.getRecordProgressText());
 
-        List sameResults = ls.getCurrentPageResults();
+        List<Author> sameResults = ls.getCurrentPageResults();
         // Page 2
         assertSame("Same results", results, sameResults);
 
@@ -324,11 +331,14 @@ public class LargeSelectTest extends Bas
         // Alter criteria to retrieve only one row
         criteria.add(AuthorPeer.AUTHOR_ID, firstAuthorId);
 
-        LargeSelect ls = new LargeSelect(criteria, TEST_PAGE_SIZE,
-                "org.apache.torque.test.AuthorPeer");
+        LargeSelect<Author> ls = new LargeSelect<Author>(
+                criteria, 
+                TEST_PAGE_SIZE,
+                "org.apache.torque.test.AuthorPeer",
+                new AuthorPeer.AuthorRecordMapper());
 
         // Page 1
-        List results = ls.getNextResults();
+        List<Author> results = ls.getNextResults();
         assertTrue("Totals finalised", ls.getTotalsFinalized());
         assertFalse("Paginated", ls.getPaginated());
         assertEquals("results.size()", 1, results.size());
@@ -350,8 +360,11 @@ public class LargeSelectTest extends Bas
      */
     public void testInvalidateResult() throws Exception
     {
-        LargeSelect ls = new LargeSelect(criteria, TEST_PAGE_SIZE,
-                "org.apache.torque.test.AuthorPeer");
+        LargeSelect<Author> ls = new LargeSelect<Author>(
+                criteria,
+                TEST_PAGE_SIZE,
+                "org.apache.torque.test.AuthorPeer",
+                new AuthorPeer.AuthorRecordMapper());
 
         assertEquals("Page size", TEST_PAGE_SIZE, ls.getPageSize());
         assertTrue("Paginated", ls.getPaginated());
@@ -369,7 +382,7 @@ public class LargeSelectTest extends Bas
         assertEquals("Page progress text", "0 of &gt; 0", ls.getPageProgressText());
         assertEquals("Record progress text", "0 - 0 of &gt; 0", ls.getRecordProgressText());
 
-        List results = ls.getNextResults();
+        List<Author> results = ls.getNextResults();
         // Page 1
         assertEquals("results.size()", TEST_PAGE_SIZE, results.size());
         assertEquals("Current page number", 1, ls.getCurrentPageNumber());

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java?rev=1028130&r1=1028129&r2=1028130&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java Wed Oct 27 22:52:15 2010
@@ -20,6 +20,7 @@ package org.apache.torque.util;
  */
 
 import java.io.StringWriter;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.collections.OrderedMap;
@@ -31,9 +32,6 @@ import org.apache.torque.test.Summarize1
 import org.apache.torque.test.Summarize1Peer;
 import org.apache.torque.util.functions.FunctionFactory;
 
-import com.workingdogs.village.Value;
-
-
 /**
  * Test code for SummaryHelper.
  *
@@ -114,33 +112,53 @@ public class SummaryHelperTest extends B
         SummaryHelper summary = new SummaryHelper();
 
         summary.setExcludeExprColumns(true);
+        List<Class<?>> returnTypes = new ArrayList<Class<?>>();
+
         summary.addGroupBy ( Summarize1Peer.GROUP_BY1 );
+        returnTypes.add(String.class);
+
         summary.addAggregate("COUNT_RECS",
                                 FunctionFactory.count(Summarize1Peer.ID));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("AVG_INT1",
                                 FunctionFactory.avg(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("MIN_INT1",
                                 FunctionFactory.min(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("MAX_INT1",
                                 FunctionFactory.max(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("SUM_INT1",
                                 FunctionFactory.sum(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
 
         summary.addAggregate("AVG_FLOAT1",
                                 FunctionFactory.avg(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
+
         summary.addAggregate("MIN_FLOAT1",
                                 FunctionFactory.min(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
+
         summary.addAggregate("MAX_FLOAT1",
                                 FunctionFactory.max(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
+
         summary.addAggregate("SUM_FLOAT1",
                                 FunctionFactory.sum(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
 
-        List results = summary.summarize( c );
+        List<OrderedMap> results = summary.summarize(c, returnTypes);
 
         StringWriter out = new StringWriter();
         summary.dumpResults(out, results, true);
         out.close();
-        logger.debug("\n"+out.toString());
+        logger.debug("\n" + out.toString());
 
         assertTrue("No results returned", results.size() > 0 );
         assertTrue("Invalid number of records returned. Expected 4 but got " +
@@ -148,57 +166,32 @@ public class SummaryHelperTest extends B
 
         OrderedMap rec = (OrderedMap) results.get(0);
 
-        int expectedColumns;
-        if (Summarize1Peer.GROUP_BY1.equals(
-              Torque.getDatabase("bookstore").getAdapter().ignoreCaseInOrderBy(
-                Summarize1Peer.GROUP_BY1)))
-        {
-            expectedColumns = 10;
-        }
-        else
-        {
-            // addAscendingOrderByColumn will add the uppercased column
-            // to the select columns, therefore an additional column appears
-            expectedColumns = 11;
-        }
-        assertEquals("Number of columns incorrect! Expected " 
-                        + expectedColumns
-                        + " but got " 
-                        + rec.size(), 
-                    expectedColumns, 
-                    rec.size());
         assertTrue( "GROUP_BY1 valued not correct",
-                "A1".equals(((Value) rec.get("GROUP_BY1")).asString()) );
+                "A1".equals(rec.get("GROUP_BY1").toString()) );
         assertTrue("COUNT_RECS not correct value",
-                ((Value) rec.get("COUNT_RECS")).asInt() == 4 );
+                ((Integer) rec.get("COUNT_RECS")).intValue() == 4 );
         assertTrue("AVG_INT1 not correct value",
-                ((Value) rec.get("AVG_INT1")).asInt() == 2 );
+                ((Integer) rec.get("AVG_INT1")).intValue() == 2 );
         assertTrue("MIN_INT1 not correct value",
-                ((Value) rec.get("MIN_INT1")).asInt() == 1 );
+                ((Integer) rec.get("MIN_INT1")).intValue() == 1 );
         assertTrue("MAX_INT1 not correct value",
-                ((Value) rec.get("MAX_INT1")).asInt() == 4 );
+                ((Integer) rec.get("MAX_INT1")).intValue() == 4 );
         assertTrue("SUM_INT1 not correct value",
-                ((Value) rec.get("SUM_INT1")).asInt() == 10 );
+                ((Integer) rec.get("SUM_INT1")).intValue() == 10 );
 
         rec = (OrderedMap) results.get(3);
-        assertEquals("Number of columns incorrect! Expected " 
-                + expectedColumns
-                + " but got " 
-                + rec.size(), 
-            expectedColumns, 
-            rec.size());
         assertTrue( "GROUP_BY1 valued not correct",
-                "D1".equals(((Value) rec.get("GROUP_BY1")).asString()) );
+                "D1".equals((String) rec.get("GROUP_BY1")));
         assertTrue("COUNT_RECS not correct value",
-                ((Value) rec.get("COUNT_RECS")).asInt() == 4 );
+                ((Integer) rec.get("COUNT_RECS")).intValue() == 4 );
         assertTrue("AVG_FLOAT1 not correct value",
-                ((Value) rec.get("AVG_FLOAT1")).asFloat() == 11.0f );
+                ((Float) rec.get("AVG_FLOAT1")).floatValue() == 11.0f );
         assertTrue("MIN_FLOAT1 not correct value",
-                ((Value) rec.get("MIN_FLOAT1")).asFloat() == 8.0f );
+                ((Float) rec.get("MIN_FLOAT1")).floatValue() == 8.0f );
         assertTrue("MAX_FLOAT1 not correct value",
-                ((Value) rec.get("MAX_FLOAT1")).asFloat() == 14.0f );
+                ((Float) rec.get("MAX_FLOAT1")).floatValue() == 14.0f );
         assertTrue("SUM_FLOAT1 not correct value",
-                ((Value) rec.get("SUM_FLOAT1")).asFloat() == 44.0f );
+                ((Float) rec.get("SUM_FLOAT1")).floatValue() == 44.0f );
 
     }
     /*
@@ -210,27 +203,45 @@ public class SummaryHelperTest extends B
         SummaryHelper summary = new SummaryHelper();
 
         summary.setExcludeExprColumns(true);
+        List<Class<?>> returnTypes = new ArrayList<Class<?>>();
+
         summary.addAggregate("COUNT_RECS",
                                 FunctionFactory.count(Summarize1Peer.ID));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("AVG_INT1",
                                 FunctionFactory.avg(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("MIN_INT1",
                                 FunctionFactory.min(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("MAX_INT1",
                                 FunctionFactory.max(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
+
         summary.addAggregate("SUM_INT1",
                                 FunctionFactory.sum(Summarize1Peer.INT_1));
+        returnTypes.add(Integer.class);
 
         summary.addAggregate("AVG_FLOAT1",
                 FunctionFactory.avg(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
+
         summary.addAggregate("MIN_FLOAT1",
                 FunctionFactory.min(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
+
         summary.addAggregate("MAX_FLOAT1",
                 FunctionFactory.max(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
+
         summary.addAggregate("SUM_FLOAT1",
                 FunctionFactory.sum(Summarize1Peer.FLOAT1));
+        returnTypes.add(Float.class);
 
-        List results = summary.summarize(c);
+        List<OrderedMap> results = summary.summarize(c, returnTypes);
 
         StringWriter out = new StringWriter();
         summary.dumpResults(out, results, true);
@@ -246,24 +257,24 @@ public class SummaryHelperTest extends B
         assertTrue( "Number of columns incorrect! Did ExcludeExpColumns work? " +
                        "Expected 9 but got " + rec.size(), rec.size() == 9 );
         assertTrue("COUNT_RECS not correct value",
-                ((Value) rec.get("COUNT_RECS")).asInt() == 16 );
+                ((Integer) rec.get("COUNT_RECS")).intValue() == 16 );
         assertTrue("AVG_INT1 not correct value",
-                ((Value) rec.get("AVG_INT1")).asInt() == 4 );
+                ((Integer) rec.get("AVG_INT1")).intValue() == 4 );
         assertTrue("MIN_INT1 not correct value",
-                ((Value) rec.get("MIN_INT1")).asInt() == 1 );
+                ((Integer) rec.get("MIN_INT1")).intValue() == 1 );
         assertTrue("MAX_INT1 not correct value",
-                ((Value) rec.get("MAX_INT1")).asInt() == 7 );
+                ((Integer) rec.get("MAX_INT1")).intValue() == 7 );
         assertTrue("SUM_INT1 not correct value",
-                ((Value) rec.get("SUM_INT1")).asInt() == 64 );
+                ((Integer) rec.get("SUM_INT1")).intValue() == 64 );
 
         assertTrue("AVG_FLOAT1 not correct value",
-                ((Value) rec.get("AVG_FLOAT1")).asFloat() == 8.0f );
+                ((Float) rec.get("AVG_FLOAT1")).floatValue() == 8.0f );
         assertTrue("MIN_FLOAT1 not correct value",
-                ((Value) rec.get("MIN_FLOAT1")).asFloat() == 2.0f );
+                ((Float) rec.get("MIN_FLOAT1")).floatValue() == 2.0f );
         assertTrue("MAX_FLOAT1 not correct value",
-                ((Value) rec.get("MAX_FLOAT1")).asFloat() == 14.0f );
+                ((Float) rec.get("MAX_FLOAT1")).floatValue() == 14.0f );
         assertTrue("SUM_FLOAT1 not correct value",
-                ((Value) rec.get("SUM_FLOAT1")).asFloat() == 128.0f );
+                ((Float) rec.get("SUM_FLOAT1")).floatValue() == 128.0f );
     }
 
 }



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