db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r987316 - /db/torque/test/trunk/test-project/src/java/org/apache/torque/util/SummaryHelperTest.java
Date Thu, 19 Aug 2010 21:28:12 GMT
Author: tfischer
Date: Thu Aug 19 21:28:12 2010
New Revision: 987316

URL: http://svn.apache.org/viewvc?rev=987316&view=rev
Log:
Change test such that it also executes on Oracle:
- alter column names to upper case (because oracle will return upper case names anyway)
- check whether the adapter will add an extra select column

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=987316&r1=987315&r2=987316&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
Thu Aug 19 21:28:12 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