db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r935677 - in /db/torque/torque4/trunk/torque-test/src: main/schema/test-schema.xml test/java/org/apache/torque/util/SummaryHelperTest.java
Date Mon, 19 Apr 2010 17:25:23 GMT
Author: tfischer
Date: Mon Apr 19 17:25:23 2010
New Revision: 935677

URL: http://svn.apache.org/viewvc?rev=935677&view=rev
Log:
Fixed test problem in Derby:
- For derby, an additional select column is added because an ignore case order by is added
to an already added column name
- Derby returns the column names in the result set in upper case. For this, all column namens
and the table name is changed to upper name for exact matches

Modified:
    db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/util/SummaryHelperTest.java

Modified: db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml?rev=935677&r1=935676&r2=935677&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml (original)
+++ db/torque/torque4/trunk/torque-test/src/main/schema/test-schema.xml Mon Apr 19 17:25:23
2010
@@ -486,14 +486,14 @@ Column.getJavaObject() not implimented f
   </table>
   
   <!--  Table to test SummaryHelper class  -->
-  <table name="summarize1" description="Test table for summaryHelper class" >
-    <column name="id" required="true" primaryKey="true" type="INTEGER" 
+  <table name="SUMMARIZE1" description="Test table for summaryHelper class" >
+    <column name="ID" required="true" primaryKey="true" type="INTEGER" 
             description="id column" autoIncrement="true" />
-    <column name="group_by1" type="VARCHAR" javaType="primitive" size="100" />
-    <column name="group_by2" type="VARCHAR" javaType="primitive" size="100" />
-    <column name="int_1" type="INTEGER" javaType="primitive" />
-    <column name="float1" type="FLOAT" javaType="primitive" />
-    <column name="type" type="INTEGER" javaType="primitive" />
+    <column name="GROUP_BY1" type="VARCHAR" javaType="primitive" size="100" />
+    <column name="GROUP_BY2" type="VARCHAR" javaType="primitive" size="100" />
+    <column name="INT_1" type="INTEGER" javaType="primitive" />
+    <column name="FLOAT1" type="FLOAT" javaType="primitive" />
+    <column name="TYPE" type="INTEGER" javaType="primitive" />
   </table>
   
 </database>

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=935677&r1=935676&r2=935677&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
Mon Apr 19 17:25:23 2010
@@ -26,6 +26,7 @@ import org.apache.commons.collections.Or
 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.test.Summarize1;
 import org.apache.torque.test.Summarize1Peer;
 import org.apache.torque.util.functions.FunctionFactory;
@@ -114,24 +115,24 @@ public class SummaryHelperTest extends B
 
         summary.setExcludeExprColumns(true);
         summary.addGroupBy ( Summarize1Peer.GROUP_BY1 );
-        summary.addAggregate("Count_recs",
+        summary.addAggregate("COUNT_RECS",
                                 FunctionFactory.count(Summarize1Peer.ID));
-        summary.addAggregate("Avg_int1",
+        summary.addAggregate("AVG_INT1",
                                 FunctionFactory.avg(Summarize1Peer.INT_1));
-        summary.addAggregate("Min_int1",
+        summary.addAggregate("MIN_INT1",
                                 FunctionFactory.min(Summarize1Peer.INT_1));
-        summary.addAggregate("Max_int1",
+        summary.addAggregate("MAX_INT1",
                                 FunctionFactory.max(Summarize1Peer.INT_1));
-        summary.addAggregate("Sum_int1",
+        summary.addAggregate("SUM_INT1",
                                 FunctionFactory.sum(Summarize1Peer.INT_1));
 
-        summary.addAggregate("Avg_float1",
+        summary.addAggregate("AVG_FLOAT1",
                                 FunctionFactory.avg(Summarize1Peer.FLOAT1));
-        summary.addAggregate("Min_float1",
+        summary.addAggregate("MIN_FLOAT1",
                                 FunctionFactory.min(Summarize1Peer.FLOAT1));
-        summary.addAggregate("Max_float1",
+        summary.addAggregate("MAX_FLOAT1",
                                 FunctionFactory.max(Summarize1Peer.FLOAT1));
-        summary.addAggregate("Sum_float1",
+        summary.addAggregate("SUM_FLOAT1",
                                 FunctionFactory.sum(Summarize1Peer.FLOAT1));
 
         List results = summary.summarize( c );
@@ -147,36 +148,57 @@ public class SummaryHelperTest extends B
 
         OrderedMap rec = (OrderedMap) results.get(0);
 
-        assertTrue( "Number of columns incorrect! Expected 10 but got " +
-                        rec.size(), rec.size() == 10 );
-        assertTrue( "group_by1 valued not correct",
-                "A1".equals(((Value) rec.get("group_by1")).asString()) );
-        assertTrue("Count_recs not correct value",
-                ((Value) rec.get("Count_recs")).asInt() == 4 );
-        assertTrue("Avg_int1 not correct value",
-                ((Value) rec.get("Avg_int1")).asInt() == 2 );
-        assertTrue("Min_int1 not correct value",
-                ((Value) rec.get("Min_int1")).asInt() == 1 );
-        assertTrue("Max_int1 not correct value",
-                ((Value) rec.get("Max_int1")).asInt() == 4 );
-        assertTrue("Sum_int1 not correct value",
-                ((Value) rec.get("Sum_int1")).asInt() == 10 );
+        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()) );
+        assertTrue("COUNT_RECS not correct value",
+                ((Value) rec.get("COUNT_RECS")).asInt() == 4 );
+        assertTrue("AVG_INT1 not correct value",
+                ((Value) rec.get("AVG_INT1")).asInt() == 2 );
+        assertTrue("MIN_INT1 not correct value",
+                ((Value) rec.get("MIN_INT1")).asInt() == 1 );
+        assertTrue("MAX_INT1 not correct value",
+                ((Value) rec.get("MAX_INT1")).asInt() == 4 );
+        assertTrue("SUM_INT1 not correct value",
+                ((Value) rec.get("SUM_INT1")).asInt() == 10 );
 
         rec = (OrderedMap) results.get(3);
-        assertTrue( "Number of columns incorrect! Expected 10 but got " +
-                        rec.size(), rec.size() == 10 );
-        assertTrue( "group_by1 valued not correct",
-                "D1".equals(((Value) rec.get("group_by1")).asString()) );
-        assertTrue("Count_recs not correct value",
-                ((Value) rec.get("Count_recs")).asInt() == 4 );
-        assertTrue("Avg_float1 not correct value",
-                ((Value) rec.get("Avg_float1")).asFloat() == 11.0f );
-        assertTrue("Min_float1 not correct value",
-                ((Value) rec.get("Min_float1")).asFloat() == 8.0f );
-        assertTrue("Max_float1 not correct value",
-                ((Value) rec.get("Max_float1")).asFloat() == 14.0f );
-        assertTrue("Sum_float1_recs not correct value",
-                ((Value) rec.get("Sum_float1")).asFloat() == 44.0f );
+        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()) );
+        assertTrue("COUNT_RECS not correct value",
+                ((Value) rec.get("COUNT_RECS")).asInt() == 4 );
+        assertTrue("AVG_FLOAT1 not correct value",
+                ((Value) rec.get("AVG_FLOAT1")).asFloat() == 11.0f );
+        assertTrue("MIN_FLOAT1 not correct value",
+                ((Value) rec.get("MIN_FLOAT1")).asFloat() == 8.0f );
+        assertTrue("MAX_FLOAT1 not correct value",
+                ((Value) rec.get("MAX_FLOAT1")).asFloat() == 14.0f );
+        assertTrue("SUM_FLOAT1 not correct value",
+                ((Value) rec.get("SUM_FLOAT1")).asFloat() == 44.0f );
 
     }
     /*
@@ -188,24 +210,24 @@ public class SummaryHelperTest extends B
         SummaryHelper summary = new SummaryHelper();
 
         summary.setExcludeExprColumns(true);
-        summary.addAggregate("Count_recs",
+        summary.addAggregate("COUNT_RECS",
                                 FunctionFactory.count(Summarize1Peer.ID));
-        summary.addAggregate("Avg_int1",
+        summary.addAggregate("AVG_INT1",
                                 FunctionFactory.avg(Summarize1Peer.INT_1));
-        summary.addAggregate("Min_int1",
+        summary.addAggregate("MIN_INT1",
                                 FunctionFactory.min(Summarize1Peer.INT_1));
-        summary.addAggregate("Max_int1",
+        summary.addAggregate("MAX_INT1",
                                 FunctionFactory.max(Summarize1Peer.INT_1));
-        summary.addAggregate("Sum_int1",
+        summary.addAggregate("SUM_INT1",
                                 FunctionFactory.sum(Summarize1Peer.INT_1));
 
-        summary.addAggregate("Avg_float1",
+        summary.addAggregate("AVG_FLOAT1",
                 FunctionFactory.avg(Summarize1Peer.FLOAT1));
-        summary.addAggregate("Min_float1",
+        summary.addAggregate("MIN_FLOAT1",
                 FunctionFactory.min(Summarize1Peer.FLOAT1));
-        summary.addAggregate("Max_float1",
+        summary.addAggregate("MAX_FLOAT1",
                 FunctionFactory.max(Summarize1Peer.FLOAT1));
-        summary.addAggregate("Sum_float1",
+        summary.addAggregate("SUM_FLOAT1",
                 FunctionFactory.sum(Summarize1Peer.FLOAT1));
 
         List results = summary.summarize(c);
@@ -223,25 +245,25 @@ 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 );
-        assertTrue("Avg_int1 not correct value",
-                ((Value) rec.get("Avg_int1")).asInt() == 4 );
-        assertTrue("Min_int1 not correct value",
-                ((Value) rec.get("Min_int1")).asInt() == 1 );
-        assertTrue("Max_int1 not correct value",
-                ((Value) rec.get("Max_int1")).asInt() == 7 );
-        assertTrue("Sum_int1 not correct value",
-                ((Value) rec.get("Sum_int1")).asInt() == 64 );
-
-        assertTrue("Avg_float1 not correct value",
-                ((Value) rec.get("Avg_float1")).asFloat() == 8.0f );
-        assertTrue("Min_float1 not correct value",
-                ((Value) rec.get("Min_float1")).asFloat() == 2.0f );
-        assertTrue("Max_float1 not correct value",
-                ((Value) rec.get("Max_float1")).asFloat() == 14.0f );
-        assertTrue("Sum_float1_recs not correct value",
-                ((Value) rec.get("Sum_float1")).asFloat() == 128.0f );
+        assertTrue("COUNT_RECS not correct value",
+                ((Value) rec.get("COUNT_RECS")).asInt() == 16 );
+        assertTrue("AVG_INT1 not correct value",
+                ((Value) rec.get("AVG_INT1")).asInt() == 4 );
+        assertTrue("MIN_INT1 not correct value",
+                ((Value) rec.get("MIN_INT1")).asInt() == 1 );
+        assertTrue("MAX_INT1 not correct value",
+                ((Value) rec.get("MAX_INT1")).asInt() == 7 );
+        assertTrue("SUM_INT1 not correct value",
+                ((Value) rec.get("SUM_INT1")).asInt() == 64 );
+
+        assertTrue("AVG_FLOAT1 not correct value",
+                ((Value) rec.get("AVG_FLOAT1")).asFloat() == 8.0f );
+        assertTrue("MIN_FLOAT1 not correct value",
+                ((Value) rec.get("MIN_FLOAT1")).asFloat() == 2.0f );
+        assertTrue("MAX_FLOAT1 not correct value",
+                ((Value) rec.get("MAX_FLOAT1")).asFloat() == 14.0f );
+        assertTrue("SUM_FLOAT1 not correct value",
+                ((Value) rec.get("SUM_FLOAT1")).asFloat() == 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