db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r365720 - /db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
Date Tue, 03 Jan 2006 19:37:40 GMT
Author: tfischer
Date: Tue Jan  3 11:37:26 2006
New Revision: 365720

URL: http://svn.apache.org/viewcvs?rev=365720&view=rev
Log:
added a test case checking for correct handling of null values in selects

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

Modified: db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewcvs/db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java?rev=365720&r1=365719&r2=365720&view=diff
==============================================================================
--- db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java (original)
+++ db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java Tue Jan  3
11:37:26 2006
@@ -57,6 +57,7 @@
 import org.apache.torque.test.MultiPkForeignKeyPeer;
 import org.apache.torque.test.MultiPkPeer;
 import org.apache.torque.test.NullValueTable;
+import org.apache.torque.test.NullValueTablePeer;
 import org.apache.torque.util.BasePeer;
 import org.apache.torque.util.CountHelper;
 import org.apache.torque.util.Criteria;
@@ -235,6 +236,68 @@
         }
     }
 
+    /**
+     * Tests whether selects work correctly if the value <code>null</code> 
+     * is used. 
+     * @throws Exception if the test fails
+     */
+    public void testNullSelects() throws Exception
+    {
+        // clean table
+        Criteria criteria = new Criteria();
+        criteria.add(
+                NullValueTablePeer.NULL_VALUE_TABLE_ID,
+                -1, 
+                Criteria.NOT_EQUAL);
+        NullValueTablePeer.doDelete(criteria);
+
+        // add test data
+        NullValueTable nvt = new NullValueTable();
+        nvt.setText1("text");
+        nvt.save();
+        nvt = new NullValueTable();
+        nvt.setText2("text");
+        nvt.save();
+        
+        // do check for comparison NOT_EQUAL and value null 
+        criteria.clear();
+        criteria.add(
+                NullValueTablePeer.TEXT1, 
+                (Integer)null, 
+                Criteria.NOT_EQUAL);
+        List result = NullValueTablePeer.doSelect(criteria);
+        assertEquals("testNullSelects()" 
+                + "Result size should be 1 but is " 
+                + result.size(),
+                result.size(),
+                1);
+        nvt = (NullValueTable) result.get(0);
+        assertEquals("testNullSelects()"
+                + "Text1 should be \"text\" but is"
+                + nvt.getText1(),
+                nvt.getText1(),
+                "text");
+        
+        // do check for comparison EQUAL and value null 
+        criteria.clear();
+        criteria.add(
+                NullValueTablePeer.TEXT1, 
+                (Integer)null, 
+                Criteria.EQUAL);
+        result = NullValueTablePeer.doSelect(criteria);
+        assertEquals("testNullSelects()" 
+                + "Result size should be 1 but is " 
+                + result.size(),
+                result.size(),
+                1);
+        nvt = (NullValueTable) result.get(0);
+        assertEquals("testNullSelects()"
+                + "Text2 should be \"text\" but is"
+                + nvt.getText2(),
+                nvt.getText2(),
+                "text");
+    }
+    
     /**
      * tests whether null values can be processed successfully by datadump
      * For this, a row containing null values is inserted here,



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