You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by gm...@apache.org on 2010/12/03 17:11:24 UTC

svn commit: r1041895 - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/util/ torque-site/src/changes/ torque-test/src/test/java/org/apache/torque/util/

Author: gmonroe
Date: Fri Dec  3 16:11:24 2010
New Revision: 1041895

URL: http://svn.apache.org/viewvc?rev=1041895&view=rev
Log:
Copying the SummaryHelper changes made in 3.x branch to this branch.
Updated changes.xml.

Added:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java
Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
    db/torque/torque4/trunk/torque-site/src/changes/changes.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java

Added: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java?rev=1041895&view=auto
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java (added)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/ListOrderedMapCI.java Fri Dec  3 16:11:24 2010
@@ -0,0 +1,99 @@
+package org.apache.torque.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.collections.map.ListOrderedMap;
+
+/**
+ * A subclass of the Apache Commons ListOrderedMap that has case insensitive
+ * String key methods.  This is done by converting all String keys to 
+ * lower case.
+ *
+ * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
+ * @version $Id$
+ */
+public class ListOrderedMapCI extends ListOrderedMap
+{
+    private static final long serialVersionUID = -4349246328751938554L;
+
+    /**
+     * Constructs a new empty ListOrderedMap.
+     */
+    public ListOrderedMapCI() {
+        super();
+    }
+
+    /**
+     * Get the object associated with this key.
+     * 
+     * @param key A case insensitive String.
+     * @return The value for this key
+     */
+    public Object get( String key ) {
+       return super.get( key.toLowerCase() ); 
+    }
+    /**
+     * Adds a value to the end of the list with the specified key.
+     * 
+     * @param key A case insensitive String.
+     * @param value The value to add
+     * @return The value for previously mapped to this key
+     */
+    public Object put( String key, Object value ) {
+        return super.put( key.toLowerCase(), value ); 
+    }
+    /**
+     * Puts a key-value mapping into the map at the specified index.
+     * 
+     * @param index The index at which the mapping should be inserted.  
+     * @param key A case insensitive String.
+     * @param value The value.
+     * @return The value for previously mapped to this key
+     */
+    public Object put( int index, String key, Object value ) {
+        return super.put(index, key.toLowerCase(), value );
+    }
+    /**
+     * Gets the index of the specified key.
+     * 
+     * @param key A case insensitive String.
+     * @return the index, or -1 if not found
+     */
+    public int indexOf( String key ) {
+        return super.indexOf( key.toLowerCase() );
+    }
+    /**
+     * Removes the mapping for the specified key.
+     * @param key A case insensitive String.
+     * @return the removed value, or null if none existed
+     */
+    public Object remove ( String key ) {
+        return super.remove( key.toLowerCase() );
+    }
+    /**
+     * Test if the key exists in the mapping.
+     * 
+     * @param key The case insensitive key to test for.
+     * @return True if the key exists.
+     */
+    public boolean containsKey( String key ) {
+        return super.containsKey( key.toLowerCase());
+    }
+}

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java?rev=1041895&r1=1041894&r2=1041895&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/SummaryHelper.java Fri Dec  3 16:11:24 2010
@@ -26,9 +26,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Vector;
 
-import org.apache.commons.collections.OrderedMap;
 import org.apache.commons.collections.OrderedMapIterator;
-import org.apache.commons.collections.map.ListOrderedMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.TorqueException;
@@ -63,10 +61,11 @@ import com.workingdogs.village.Value;
  *    sHelper.addAggregate(FunctionFactory.Max(TimeSheetPeer.HOURS),"Max_Hrs");
  *    List results = sHelper.summarize( c );
  * </pre>
- * <p>The results list will be an OrderedMap with a key of either the group by
- * column name or the name specified for the aggregate function (e.g. EMPLOYEE
- * or Hours).  The value will be a Village Value Class.  Below is a simple
- * way to do this.  See the dumpResults* method code for a more complex example.
+ * <p>The results list will be an ListOrderedMapCI with a key of either the
+ * group by column name or the name specified for the aggregate function (e.g.
+ * EMPLOYEE or Hours).  The value will be a Village Value Class.  Below is
+ * a simple way to do this.  See the dumpResults* method code for a more
+ * complex example.
  * </p>
  * <pre>
  *    String emp = results.get("EMPLOYEE").asString();
@@ -84,18 +83,19 @@ import com.workingdogs.village.Value;
  *
  * @see org.apache.torque.util.functions.FunctionFactory
  * @author <a href="mailto:greg.monroe@dukece.com">Greg Monroe</a>
- * @version $Id
+ * @version $Id$
  */
 public class SummaryHelper
 {
-    /** The class log. */
-    private static Log logger = LogFactory.getLog(SummaryHelper.class);
+    static Log logger = LogFactory.getLog(SummaryHelper.class);
 
     /** A list of the group by columns names (e.g. TABLE.COLUMN) */
-    private List<String> groupByColumns;
-    /** A OrderMap<String,Aggregate.Function> with the aggregate functions
-     * to use in generating results. */
-    private OrderedMap aggregates;
+    private List groupByColumns;
+    /**
+     * A ListOrderMapCI<String,Aggregate.Function> with the aggregate
+     * functions to use in generating results.
+     */
+    private ListOrderedMapCI aggregates;
     /** Flag for excluding unnamed columns. */
     private boolean excludeExprColumns = false;
 
@@ -108,61 +108,64 @@ public class SummaryHelper
     }
 
     /**
-     * Return a list of OrderedMap objects with the results of the summary
-     * query.  The OrderedMap objects have a key of the column name or
+     * Return a list of ListOrderedMapCI objects with the results of the summary
+     * query.  The ListOrderedMapCI objects have a key of the column name or
      * function alias and are in the order generated by the query.
      *
      * @param crit The base criteria to build on.
-     * @return Results as a OrderMap<String,Values> object.
+     * @return Results as a ListOrderMapCI<String,Values> object.
      * @throws TorqueException
      * @throws DataSetException
      */
-    public List<OrderedMap> summarize(Criteria crit)
+    public List summarize( Criteria crit )
                                 throws TorqueException, DataSetException
     {
-        return summarize(crit, null);
+        return summarize( crit, null );
     }
 
     /**
-     * Return a list of OrderedMap objects with the results of the summary
-     * query.  The OrderedMap objects have a key of the column name or
-     * function alias and are in the order generated by the query.
+     * Return a list of ListOrderedMapCI objects with the results of the
+     * summary query.  The ListOrderedMapCI objects have a key of the column
+     * name or function alias and are in the order generated by the query.
      *
      * @param crit The base criteria to build on.
      * @param conn The DB Connection to use.
-     * @return Results as a OrderMap<String,Values> object.
+     * @return Results as a ListOrderMapCI<String,Values> object.
      * @throws TorqueException
      * @throws DataSetException
+     * @see ListOrderedMapCI
      */
-    public List<OrderedMap> summarize(Criteria crit, Connection conn)
+    public List summarize( Criteria crit, Connection conn )
                                  throws TorqueException, DataSetException
     {
-        Criteria c = buildCriteria(crit);
+        Criteria c = buildCriteria( crit );
 
-        List<Record> results;
+        List results;
         if (conn == null)
         {
-            results = BasePeer.doSelectVillageRecords(c);
+            results = BasePeer.doSelect(c);
         }
         else
         {
-            results = BasePeer.doSelectVillageRecords(c, conn);
+            results = BasePeer.doSelect(c, conn);
         }
 
-        Vector<OrderedMap> resultsList = new Vector<OrderedMap>(results.size());
-        for (Record rec : results)
+        Iterator r = results.iterator();
+
+        Vector resultsList = new Vector(results.size());
+        while ( r.hasNext() )
         {
-            ListOrderedMap recordMap = new ListOrderedMap();
+            ListOrderedMapCI recordMap = new ListOrderedMapCI();
+            Record rec = (Record) r.next();
             String cName = null;
             Value value = null;
-            for (int i = 1; i <= rec.size(); i++)
+            for ( int i = 1; i <= rec.size(); i++ )
             {
                 value = rec.getValue(i);
                 cName = rec.schema().column(i).name();
-                if (cName == null || cName.equals(""))
+                if ( cName == null || cName.equals("") )
                  {
-                    if (excludeExprColumns())
-                    {
+                    if ( excludeExprColumns() ) {
                         continue;
                     }
                     cName = "Expr" + i;
@@ -182,12 +185,12 @@ public class SummaryHelper
      * @return A criteria to use in summarizing the information.
      * @throws TorqueException
      */
-    public Criteria buildCriteria(Criteria c) throws TorqueException
-    {
+    public Criteria buildCriteria( Criteria c ) throws TorqueException {
+
         c.getSelectColumns().clear();
         c.getGroupByColumns().clear();
 
-        UniqueList<String> criteriaSelectModifiers;
+        UniqueList criteriaSelectModifiers;
         criteriaSelectModifiers = c.getSelectModifiers();
 
         if (criteriaSelectModifiers != null
@@ -198,55 +201,56 @@ public class SummaryHelper
         }
         c.setIgnoreCase(false);
 
-        List<String> cols = null;
+        List cols = null;
+        Iterator i = null;
 
         cols = getGroupByColumns();
-        boolean haveFromTable = !cols.isEmpty(); // Group By cols define src table.
-        for (String col : cols)
+        i = cols.iterator();
+        boolean haveFromTable = i.hasNext(); // Group By cols define src table.
+        while ( i.hasNext() )
         {
-            c.addGroupByColumn(col);
+            String col = (String) i.next();
+            c.addGroupByColumn( col );
             c.addSelectColumn(col);
         }
-        if (haveFromTable)
-        {
+        if ( haveFromTable )
             logger.debug("From table defined by Group By Cols");
-        }
 
         // Check if the from table is set via a where clause.
-        if (!haveFromTable && c.keys().hasMoreElements())
+        if ( ! haveFromTable && c.keys().hasMoreElements() )
         {
             haveFromTable = true;
             logger.debug("From table defined by a where clause");
         }
 
-        OrderedMap cMap = getAggregates();
+        ListOrderedMapCI cMap = getAggregates();
         OrderedMapIterator iMap = cMap.orderedMapIterator();
-        while (iMap.hasNext())
+        while ( iMap.hasNext() )
         {
             String key = (String) iMap.next();
             SQLFunction f = (SQLFunction) iMap.getValue();
-            c.addAsColumn(key, f.toSQL());
-            if (!haveFromTable)    // Last chance. Get it from the func.
+            c.addAsColumn( key, f.toSQL() );
+            if ( ! haveFromTable )    // Last chance. Get it from the func.
             {
                 String col =  f.getArgument(0).toString();
-                if (col.indexOf('.') >= 0)
+                if ( col.contains(".") )
                 {
                     // Kludgy Where table.col = table.col clause to force
                     // from table identification.
-                    c.add(col, (Object) (col + "=" + col), SqlEnum.CUSTOM);
+                    c.add( col,(Object)(col + "=" + col), SqlEnum.CUSTOM );
                     haveFromTable = true;
 
-                    String table = col.substring(0, col.indexOf('.'));
-                    logger.debug("From table, '" + table
-                            + "', defined from aggregate column");
+                    String table = col.substring(0,col.indexOf('.'));
+                    logger.debug("From table, '" + table +
+                                 "', defined from aggregate column");
                 }
             }
         }
-        if (!haveFromTable)
+        if ( ! haveFromTable )
         {
             throw new TorqueException(
-                    "No FROM table defined by the GroupBy set, "
-                    + "criteria.setAlias, or specified function column!");
+                         "No FROM table defined by the GroupBy set, " +
+                         "criteria.setAlias, or specified function column!");
         }
         return c;
     }
@@ -265,7 +269,7 @@ public class SummaryHelper
      *
      * @param column
      */
-    public void addGroupBy(String column)
+    public void addGroupBy( String column )
     {
         getGroupByColumns().add(column);
     }
@@ -277,9 +281,9 @@ public class SummaryHelper
      *               no key words, e.g. function names.
      * @param function One of the inner classes from the Aggregate class.
      */
-    public void addAggregate(String alias, SQLFunction function)
+    public void addAggregate( String alias, SQLFunction function )
     {
-        getAggregates().put(alias, function);
+        getAggregates().put( alias, function );
     }
 
     /**
@@ -293,11 +297,11 @@ public class SummaryHelper
         setExcludeExprColumns(false);
     }
 
-    public List<String> getGroupByColumns()
+    public List getGroupByColumns()
     {
-        if (groupByColumns == null)
+        if ( groupByColumns == null )
         {
-            groupByColumns = new Vector<String>();
+            groupByColumns = new Vector();
         }
         return groupByColumns;
     }
@@ -309,11 +313,11 @@ public class SummaryHelper
      *
      * @return the avgColumns.  Will always return a ListOrderedMap object.
      */
-    public OrderedMap getAggregates()
+    public ListOrderedMapCI getAggregates()
     {
-        if (aggregates == null)
+        if ( aggregates == null )
         {
-            aggregates = new ListOrderedMap();
+            aggregates = new ListOrderedMapCI();
         }
         return aggregates;
     }
@@ -328,44 +332,44 @@ public class SummaryHelper
      * @param includeHeader
      * @throws IOException
      */
-    public void dumpResults(Writer out, List<?> results, boolean includeHeader)
+    public void dumpResults(Writer out, List results, boolean includeHeader )
                                                             throws IOException
     {
-        Iterator<?> i = results.iterator();
+        Iterator i = results.iterator();
         boolean first = includeHeader;
 
-        while (i.hasNext())
+        while ( i.hasNext() )
         {
-            OrderedMap rec = (OrderedMap) i.next();
+            ListOrderedMapCI rec = (ListOrderedMapCI) i.next();
             OrderedMapIterator rI = rec.orderedMapIterator();
             String heading = "";
             String recString = "";
-            while (rI.hasNext())
+            while ( rI.hasNext() )
             {
                 String colId = (String) rI.next();
-                if (first)
+                if ( first )
                 {
                     heading += "\"" + colId + "\"";
-                    if (rI.hasNext())
+                    if ( rI.hasNext() )
                     {
                         heading += ", ";
                     }
                 }
                 Value v = (Value) rI.getValue();
-                if (v.isString())
+                if ( v.isString() )
                 {
                     recString += "\"" + v.toString() + "\"";
-                }
-                else
+                } 
+                else 
                 {
                     recString += v.toString();
                 }
-                if (rI.hasNext())
+                if ( rI.hasNext() )
                 {
                     recString += ", ";
                 }
             }
-            if (first)
+            if ( first )
             {
                 first = false;
                 out.write(heading);
@@ -400,5 +404,4 @@ public class SummaryHelper
     {
         this.excludeExprColumns = excludeExprColumns;
     }
-
 }

Modified: db/torque/torque4/trunk/torque-site/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-site/src/changes/changes.xml?rev=1041895&r1=1041894&r2=1041895&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-site/src/changes/changes.xml (original)
+++ db/torque/torque4/trunk/torque-site/src/changes/changes.xml Fri Dec  3 16:11:24 2010
@@ -24,6 +24,12 @@
 
   <body>
   <release version="4.0-alpha1-SNAPSHOT" date="in SVN">
+    <action type="update" dev="gmonroe">
+      Fixed SummaryHelper class issues caused by DB differences.
+      Added a ListOrderMapCI class to utils (case insensitive string keys).
+      Refactored the SummaryHelper class to use this.
+      Modified the SummaryHelperTest to work with all DB types.
+    </action>
     <action type="remove" dev="tfischer" issue="TORQUE-131">
       Remove support for value 'none' of the onUpdate and onDelete attributes
       of the foreign-key element in the schema XML.
@@ -35,7 +41,7 @@
       in schema XML files.
       This has not worked correctly in the past.
       Users who have set this attribute in old schema XMLs,
-      please define their indices using index elements. 
+      please define their indices using index elements.
     </action>
     <action type="remove" dev="gmonroe" issue="TORQUE-91">
       Remove the size attribute for the element index-column
@@ -57,7 +63,7 @@
       which allows easy customizing of templates.
     </action>
     <action type="update" dev="tv">
-      Made TorqueException and EngineException extend JDK-1.4-Exception 
+      Made TorqueException and EngineException extend JDK-1.4-Exception
       instead of commons-lang NestableException.
     </action>
     <action type="update" dev="tv">
@@ -77,7 +83,7 @@
       Added support for DB Adaptor specific SQL functions.
     </action>
     <action type="add" dev="gmonroe">
-      Add a SummaryHelper class which supports aggregate queries.  E.g. 
+      Add a SummaryHelper class which supports aggregate queries.  E.g.
       Select Sum(x) from table.
     </action>
   </release>
@@ -86,8 +92,8 @@
   <release version="3.3-RC3" date="2008-01-11">
     <action type="remove" dev="tfischer">
       maven2 plugin: removed the property idTableXmlFile from the sql and
-      id-table-init-sql goals. The property never was passed by the mojo and 
-      also does not work correctly in the generator. Use the goal 
+      id-table-init-sql goals. The property never was passed by the mojo and
+      also does not work correctly in the generator. Use the goal
       id-table-init-sql to create sql for id tables instead.
     </action>
     <action type="update" dev="tfischer">
@@ -102,7 +108,7 @@
     </action>
     <action type="add" dev="gmonroe">
       Removed Village meta data check for read only column status.  This is
-      not fully supported by a lot of JDBC drivers and causes Torque to 
+      not fully supported by a lot of JDBC drivers and causes Torque to
       fail with Derby's JDBC network driver.
     </action>
     <action type="add" dev="tfischer">
@@ -116,9 +122,9 @@
       sqlExec goal with default settings.
     </action>
     <action type="update" dev="tfischer" issue="TORQUE-105" due-to="Sylvain Benoist">
-      Sybase: Columns where the attribute &quot;required&quot; 
+      Sybase: Columns where the attribute &quot;required&quot;
       is not set or set to false are now created explicitly
-      with suffix &quot;NULL&quot;. 
+      with suffix &quot;NULL&quot;.
     </action>
     <action type="update" dev="tfischer">
       Changed Type Mappings for Sybase:
@@ -146,7 +152,7 @@
       the paperwork.
     </action>
     <action type="update" dev="gmonroe" issue="TORQUE-86" due-to="Will Glass-Husain">
-      The SQL statements generated for MS SQL by the torque:datasql target 
+      The SQL statements generated for MS SQL by the torque:datasql target
       will now be wrapped in SET IDENTITY_INSERT...ON /OFF statements if
       the idMethod is native and autogenerate is set on one or more fields.
     </action>
@@ -158,7 +164,7 @@
       Corrected invalid cast in TorqueRuntimeException.splitStackTrace.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-104" due-to="Sylvain Benoist">
-      Remove 'COMMENT ON...' output from generated SQL for Sybase 
+      Remove 'COMMENT ON...' output from generated SQL for Sybase
       as these commands do not exist in Sybase's sql.
     </action>
     <action type="update" dev="tfischer" issue="TORQUE-91">
@@ -176,11 +182,11 @@
       The suffix parameter to the Maven2-plugin's sql task now works.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-99" due-to="Tobias Hilka">
-      Added copy(..) and add&lt;ForeignKey&gt;(..) methods with a connection 
+      Added copy(..) and add&lt;ForeignKey&gt;(..) methods with a connection
       parameter.
     </action>
     <action type="update" dev="tv">
-      Updated JCS dependency to version 1.3 and fixed related deprecation 
+      Updated JCS dependency to version 1.3 and fixed related deprecation
       issues.
     </action>
     <action type="fix" dev="tv" issue="TORQUE-97" due-to="Markus Müller">
@@ -192,15 +198,15 @@
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-90" due-to="Sean Gilligan">
       Fixed Null Pointer Exceptions in Criteria.equals() and
-      Criteria.hashCode() if joins are null. 
+      Criteria.hashCode() if joins are null.
     </action>
     <action type="fix" dev="tfischer">
       Changed the maven2 plugin's datadump goal to accept only a single schema
-      xml. Multiple schema xmls produced illegal output. 
+      xml. Multiple schema xmls produced illegal output.
     </action>
     <action type="fix" dev="tfischer">
       Fixed the maven2 plugin's datasql goal to do the same as the ant and
-      maven1 datasql task. 
+      maven1 datasql task.
     </action>
     <action type="add" dev="tfischer">
       Added a datadtd goal to the maven2 plugin.
@@ -231,7 +237,7 @@
     </action>
     <action type="add" dev="gmonroe">
       Added torque.beanExtendsClass property that defines a fully qualified
-      class name (e.g. org.apache.struts.action.ActionForm) that the base 
+      class name (e.g. org.apache.struts.action.ActionForm) that the base
       bean classes will extend.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-88">
@@ -250,7 +256,7 @@
       Add documentation and test cases.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-80" due-to="Brian Telintelo">
-      In the JdbcTransformTask of the generator, the attribute 
+      In the JdbcTransformTask of the generator, the attribute
       &quot;default&quot; is only added to the generated schema if its value
       is not empty.
     </action>
@@ -297,7 +303,7 @@
     </action>
     <action type="fix" dev="gmonroe">
       Improved Derby generator platform implimentation to support correctly
-      sized BINARY and VARBINARY using the SizedAsBitDataDomain.  Also fixed 
+      sized BINARY and VARBINARY using the SizedAsBitDataDomain.  Also fixed
       problems with the BIT and TINYINT mappings.
     </action>
     <action type="add" dev="gmonroe">
@@ -306,35 +312,35 @@
     </action>
     <action type="fix" dev="gmonroe">
       Fixed template package references that caused bad code to be generated
-      if non-default packages were used.        
+      if non-default packages were used.
     </action>
   </release>
   <release version="3.3-RC1" date="2006-11-23">
     <action type="fix" dev="tfischer">
-      Fixed a synchronisation issue in the getDateString() method in 
-      the database adapter for postgresql.  
+      Fixed a synchronisation issue in the getDateString() method in
+      the database adapter for postgresql.
     </action>
     <action type="fix" dev="tv" issue="TORQUE-63" due-to="Ronny Völker">
-      Wrong caching of method calls with more than three arguments in MethodResultCache. 
+      Wrong caching of method calls with more than three arguments in MethodResultCache.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-44" due-to="Greg Monroe">
-      The Column names TABLE_NAME and DATABASE_NAME are now legal column names. 
+      The Column names TABLE_NAME and DATABASE_NAME are now legal column names.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-2" due-to="Raphael Pieroni">
-      Added a maven 2 plugin. 
+      Added a maven 2 plugin.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-57">
       Fixed handling of escaping (by backslashes) for LIKE clauses.
       This included fixing the general handling of backslashes
-      for several databases. 
+      for several databases.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-59">
       Booleanchar and Booleanint now work for chained (and'ed, or'ed)
-      Criterions. 
+      Criterions.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-27" due-to="Greg Monroe">
       Added support for option tags for most elements in the database.xml
-      for usage with custom templates. 
+      for usage with custom templates.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-10">
       Limit and Offset work now correctly if applied to joined
@@ -350,7 +356,7 @@
     <action type="add" dev="tv">
       Add a &quot;serialVersionUID&quot; to the generated classes that
       implement Serializable. The entry is generated if &quot;addTimeStamp&quot;
-      is true. This should remove quite a number of warnings when using 
+      is true. This should remove quite a number of warnings when using
       Torque generated classes.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-49">
@@ -362,7 +368,7 @@
       when torque.enableJava5Features is set to true.
     </action>
     <action type="update" dev="tfischer" issue="TORQUE-37" due-to="Greg Monroe">
-      The default package for generated classes was changed from 
+      The default package for generated classes was changed from
       org.apache.torque to torque.generated.
     </action>
     <action type="fix">
@@ -373,7 +379,7 @@
       Preserved case when generating the constants for column names
       in the Peers and the database maps. For example, for a table named book
       and a column namend author_id, the constant BaseBookPeer.AUTHOR_ID
-      is now set to book.author_id, whereas in former versions, this constant 
+      is now set to book.author_id, whereas in former versions, this constant
       would have been set to book.AUTHOR_ID.<br/>
       The old behaviour can be regained by setting the generator property
       torque.deprecated.uppercasePeer to true.
@@ -388,7 +394,7 @@
       Fixed MS-SQL failure in LargeSelect.
     </action>
     <action type="fix" dev="tv" issue="TORQUE-43" due-to="Thoralf Rickert">
-      Fixed several methods not using JavaName in Peer.vm. Thanks to 
+      Fixed several methods not using JavaName in Peer.vm. Thanks to
       Thoralf Rickert for the patch.
     </action>
     <action type="fix" dev="tv" issue="TORQUE-42" due-to="Federico Fissore">
@@ -397,25 +403,25 @@
       for the Criteria patch.
     </action>
     <action type="update" dev="tv">
-      Made DB an interface and changed all database adapters to extend 
+      Made DB an interface and changed all database adapters to extend
       AbstractDBAdapter. Moved generateLimits methods to the adapters and
       deprecated getLimitStyle and associated constants because this
       should be handled transparently for the user.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-41" due-to="Thoralf Rickert">
-      Caught SQL exception when foreign keys for a table or view 
+      Caught SQL exception when foreign keys for a table or view
       cannot be retrieved in the jdbc ant task in the generator.
       Now a warning is printed instead of stopping execution.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-33" due-to="Jacob Champlin">
       Refined guesswork for detecting column names out of functions, clauses
       etc. This is important e.g. for orderBy Statements like
-      &quot;order by table.column in (1,2,3)&quot; or 
+      &quot;order by table.column in (1,2,3)&quot; or
       &quot;order by 100 &lt; table.column&quot;.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-30" due-to="Patrick Carl">
       Added the CASCADE option to drop table statements for HSQLDB.
-      This will not work with HSQLDB 1.7. Consult the HSQLDB Howto for 
+      This will not work with HSQLDB 1.7. Consult the HSQLDB Howto for
       information about reverting to the old behaviour.
     </action>
     <action type="add" dev="tfischer" issue="TORQUE-26" due-to="Greg Monroe">
@@ -450,7 +456,7 @@
       Corrected datatype Mapping for MS-SQL:
       <ul>
         <li>
-          Torque type BLOB is now mapped to MS-SQL type IMAGE 
+          Torque type BLOB is now mapped to MS-SQL type IMAGE
           (was BLOB in Torque 3.2, not working)
         </li>
         <li>
@@ -460,7 +466,7 @@
       </ul>
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-21" due-to="Nicolas Le Griel">
-      Fixed bug in bean generation when a table has several references 
+      Fixed bug in bean generation when a table has several references
       to another table.
     </action>
     <action type="fix" dev="tfischer" issue="TORQUE-4" due-to="Joerg Friedrich">
@@ -481,11 +487,11 @@
           Torque type char is now mapped to firebird type char (was varchar)
         </li>
         <li>
-          Torque type double is now mapped to firebird type double precision 
+          Torque type double is now mapped to firebird type double precision
           (was double)
         </li>
         <li>
-          Torque type booleanchar is now mapped to firebird type char(1) 
+          Torque type booleanchar is now mapped to firebird type char(1)
           (was varchar(1))
         </li>
       </ul>
@@ -503,7 +509,7 @@
       Thanks to Joerg Friedrich for reporting the error.
     </action>
     <action type="add" dev="tfischer">
-      Added a new convenience method, Transaction.begin(), 
+      Added a new convenience method, Transaction.begin(),
       which is the same as Transaction.begin(Torque.getDefaultDb()).
     </action>
     <action type="update" dev="tfischer">
@@ -512,7 +518,7 @@
       decentralized methods to access information about the databases.
     </action>
     <action type="update" dev="tfischer">
-      The IdBroker is now only started for a database if the IdMethod 
+      The IdBroker is now only started for a database if the IdMethod
       idBroker is used in that database.
     </action>
     <action type="fix" dev="seade">
@@ -531,7 +537,7 @@
       Thanks to Patrick Carl for an early version of the patch.
     </action>
     <action type="fix" dev="tfischer" issue="TRQS345">
-      IgnoreCase in PsSelects now also takes into account 
+      IgnoreCase in PsSelects now also takes into account
       Criterion's setIgnoreCase().
       Thanks to Robert Dietrick for an early version of the patch.
     </action>
@@ -544,11 +550,11 @@
 	  Changed behaviour for a limit of zero: (criteria.setLimit(0))
       <ul>
         <li>
-          If the db supports native limit, 
+          If the db supports native limit,
           a limit of zero returns zero datasets.
         </li>
         <li>
-          if the db does not support native limit, a limit of zero 
+          if the db does not support native limit, a limit of zero
           causes a TorqueException (thanks to village :-()
         </li>
       </ul>
@@ -572,7 +578,7 @@
     </action>
     <action type="add" dev="tfischer" issue="TRQS305">
       Subqueries are now supported.
-      This has caused Criterion.appendTo(StringBuffer) to declare throwing 
+      This has caused Criterion.appendTo(StringBuffer) to declare throwing
       a Torque Exception.
     </action>
     <action type="fix" dev="tfischer" issue="TRQS133">
@@ -587,11 +593,11 @@
           IdMethod native is now supported
         </li>
         <li>
-          Added mappings for Torque types 
+          Added mappings for Torque types
           LONGVARCHAR, BINARY and VARBINARY
         </li>
         <li>
-          Implemented the methods getMaxColumnNameLength(), 
+          Implemented the methods getMaxColumnNameLength(),
           hasScale() and hasSize() in PlatformDerbyImpl
         </li>
         <li>
@@ -600,19 +606,19 @@
           tables in the schema.xml
         </li>
         <li>
-          The SQL for the creation of Indices is now generated correctly 
+          The SQL for the creation of Indices is now generated correctly
           (a CRLF was missing at the end)
         </li>
       </ul>
-      Thanks to Johnny Macchione for the patches. 
+      Thanks to Johnny Macchione for the patches.
     </action>
     <action type="fix" dev="tfischer">
       Fixed foreign key support in mysql to allow the referenced table to
       be declared before the referencing table.
-      This is done by defining the foreign keys in an extra 
-      &quot;CREATE TABLE&quot; statement instead of defining them in the 
-      &quot;CREATE TABLE&quot; statement. 
-      Note that foreign keys are ignored by mysql except in InnoDB tables. 
+      This is done by defining the foreign keys in an extra
+      &quot;CREATE TABLE&quot; statement instead of defining them in the
+      &quot;CREATE TABLE&quot; statement.
+      Note that foreign keys are ignored by mysql except in InnoDB tables.
       <br />
       Thanks to Thoralf Rickert for suggesting the patch.
       Fixes also TRQS278.
@@ -624,7 +630,7 @@
       Fixed support for limit and offset for Derby in the runtime.
     </action>
     <action type="add" dev="tfischer">
-      Added hyperlinks to foreign key in the documentation to point to 
+      Added hyperlinks to foreign key in the documentation to point to
       the referenced table.
       Thanks to Hilco Wijbenga for an early version of the patch.
     </action>
@@ -634,7 +640,7 @@
       Thanks to Martin Goulet for a very early version of the serialization fix.
     </action>
     <action type="add" dev="tfischer">
-      Added scale (i.e number of digits after the decimal point) support 
+      Added scale (i.e number of digits after the decimal point) support
       for the sql data types NUMERIC and DECIMAL in the JDBCTransformTask
       (creating schema.xml from the database). Only scales which are > 0
       are added as an extra attribute to the generated schema.xml.
@@ -646,15 +652,15 @@
       Thanks to Robert Dietrick for the patch.
     </action>
     <action type="update" dev="tfischer">
-      The default values of the generator options 
+      The default values of the generator options
       torque.subpackage.base.bean,
       torque.subpackage.bean,
       and torque.subpackage.map
-      are now defined in the property files plugin.properties (for maven) 
+      are now defined in the property files plugin.properties (for maven)
       and default.properties (for ant) instead of in the templates
     </action>
     <action type="fix" dev="tfischer" issue="TRQS322">
-      The DataSourceFactory with the name "default" is created 
+      The DataSourceFactory with the name "default" is created
       automatically again. This was removed when fixing TRQS308,
       but is required by Turbine.
     </action>
@@ -670,8 +676,8 @@
       native limit and offset
     </action>
     <action type="fix" dev="tfischer" issue="TRQS320">
-      Added necessary addJoin() statenments to the generated Methods 
-      XXXPeer.doSelectAllExceptYYY(). 
+      Added necessary addJoin() statenments to the generated Methods
+      XXXPeer.doSelectAllExceptYYY().
       Thanks to Thomas Vandahl for the patch.
     </action>
     <action type="add" dev="tfischer">
@@ -681,7 +687,7 @@
           to the BaseManager.vm template
         </li>
         <li>
-          Added the method getXXX(Connection) for associated objects 
+          Added the method getXXX(Connection) for associated objects
           to the ObjectWithManager.vm template
         </li>
       </ul>

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java?rev=1041895&r1=1041894&r2=1041895&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java Fri Dec  3 16:11:24 2010
@@ -22,11 +22,11 @@ package org.apache.torque.util;
 import java.io.StringWriter;
 import java.util.List;
 
-import org.apache.commons.collections.OrderedMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.BaseRuntimeTestCase;
 import org.apache.torque.Torque;
+import org.apache.torque.util.ListOrderedMapCI;
 import org.apache.torque.test.Summarize1;
 import org.apache.torque.test.Summarize1Peer;
 import org.apache.torque.util.functions.FunctionFactory;
@@ -146,26 +146,19 @@ public class SummaryHelperTest extends B
         assertTrue("Invalid number of records returned. Expected 4 but got " +
                        results.size(), results.size() == 4 );
 
-        OrderedMap rec = (OrderedMap) results.get(0);
+        ListOrderedMapCI rec = (ListOrderedMapCI) 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;
+        int expectedColumns = 10;
+
+        // Some DB server (Oracle) add an uppercased column when addAscendingOrderBY is used.
+        if ( rec.size() == expectedColumns + 1 ) {
+          expectedColumns++;
         }
-        assertEquals("Number of columns incorrect! Expected " 
+        assertEquals("Number of columns incorrect! Expected "
                         + expectedColumns
-                        + " but got " 
-                        + rec.size(), 
-                    expectedColumns, 
+                        + " but got "
+                        + rec.size(),
+                    expectedColumns,
                     rec.size());
         assertTrue( "GROUP_BY1 valued not correct",
                 "A1".equals(((Value) rec.get("GROUP_BY1")).asString()) );
@@ -180,12 +173,12 @@ public class SummaryHelperTest extends B
         assertTrue("SUM_INT1 not correct value",
                 ((Value) rec.get("SUM_INT1")).asInt() == 10 );
 
-        rec = (OrderedMap) results.get(3);
-        assertEquals("Number of columns incorrect! Expected " 
+        rec = (ListOrderedMapCI) results.get(3);
+        assertEquals("Number of columns incorrect! Expected "
                 + expectedColumns
-                + " but got " 
-                + rec.size(), 
-            expectedColumns, 
+                + " but got "
+                + rec.size(),
+            expectedColumns,
             rec.size());
         assertTrue( "GROUP_BY1 valued not correct",
                 "D1".equals(((Value) rec.get("GROUP_BY1")).asString()) );
@@ -241,7 +234,7 @@ public class SummaryHelperTest extends B
         assertTrue("Invalid number of records returned.  Expected 1 but got " +
                        results.size(), results.size() == 1 );
 
-        OrderedMap rec = (OrderedMap) results.get(0);
+        ListOrderedMapCI rec = (ListOrderedMapCI) results.get(0);
 
         assertTrue( "Number of columns incorrect! Did ExcludeExpColumns work? " +
                        "Expected 9 but got " + rec.size(), rec.size() == 9 );



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