db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gmon...@apache.org
Subject svn commit: r1041878 - /db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java
Date Fri, 03 Dec 2010 15:30:30 GMT
Author: gmonroe
Date: Fri Dec  3 15:30:30 2010
New Revision: 1041878

URL: http://svn.apache.org/viewvc?rev=1041878&view=rev
Log:
Converted to case insensitive record class.  Modified the column count test to work with Oracle
and MSSql (Oracle fix broke MSSql).  Should work with all DB types now.

Modified:
    db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java

Modified: db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java
URL: http://svn.apache.org/viewvc/db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java?rev=1041878&r1=1041877&r2=1041878&view=diff
==============================================================================
--- db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java
(original)
+++ db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java
Fri Dec  3 15:30:30 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


Mime
View raw message