db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r659938 - /db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
Date Sun, 25 May 2008 08:25:35 GMT
Author: tfischer
Date: Sun May 25 01:25:35 2008
New Revision: 659938

URL: http://svn.apache.org/viewvc?rev=659938&view=rev
Log:
added test case for inheritance

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/viewvc/db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java?rev=659938&r1=659937&r2=659938&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 Sun May 25
01:25:35 2008
@@ -70,6 +70,11 @@
 import org.apache.torque.test.IfcTable2;
 import org.apache.torque.test.IfcTable2Peer;
 import org.apache.torque.test.IfcTablePeer;
+import org.apache.torque.test.InheritanceChildB;
+import org.apache.torque.test.InheritanceChildC;
+import org.apache.torque.test.InheritanceChildD;
+import org.apache.torque.test.InheritanceTest;
+import org.apache.torque.test.InheritanceTestPeer;
 import org.apache.torque.test.IntegerPk;
 import org.apache.torque.test.IntegerPkPeer;
 import org.apache.torque.test.LargePk;
@@ -1905,7 +1910,66 @@
             assertTrue("IfcTable2Peer.doSelect should return instances of LocalTestInterface",

                     i.next() instanceof LocalTestInterface);
         }
+    }
+
+    public void testInheritance() throws Exception
+    {
+        // make sure that the InheritanceTest table is empty before the test
+        Criteria criteria = new Criteria();
+        criteria.add(
+                InheritanceTestPeer.INHERITANCE_TEST, 
+                (Object) null, 
+                Criteria.ISNOTNULL);
+        InheritanceTestPeer.doDelete(criteria);
+        criteria = new Criteria();
+        criteria.add(
+                InheritanceTestPeer.INHERITANCE_TEST, 
+                (Object) null, 
+                Criteria.ISNOTNULL);
+        assertEquals(0,
+                new CountHelper().count(criteria));
+
+        // create & save test data
+        InheritanceTest inheritanceTest = new InheritanceTest();
+        inheritanceTest.setPayloadParent("payload Parent 1");
+        inheritanceTest.save();
+        InheritanceChildB inheritanceChildB = new InheritanceChildB();
+        inheritanceChildB.setPayloadParent("payload Parent 2");
+        inheritanceChildB.save();
+        InheritanceChildC inheritanceChildC = new InheritanceChildC();
+        inheritanceChildC.setPayloadParent("payload Parent 3");
+        inheritanceChildC.save();
+        InheritanceChildD inheritanceChildD = new InheritanceChildD();
+        inheritanceChildD.setPayloadParent("payload Parent 4");
+        inheritanceChildD.save();
+        
+        // Check that all objects are saved into the InheritanceTest table
+        criteria = new Criteria();
+        criteria.add(
+                InheritanceTestPeer.INHERITANCE_TEST, 
+                (Object) null, 
+                Criteria.ISNOTNULL);
+        assertEquals("InheritanceTestTable should contain 4 rows",
+                4,
+                new CountHelper().count(criteria));
+        criteria = new Criteria();
+        criteria.addAscendingOrderByColumn(
+                InheritanceTestPeer.INHERITANCE_TEST);
         
+        // Check that the class of the object is retained when loading
+        List inheritanceObjects = InheritanceTestPeer.doSelect(criteria);
+        assertEquals(
+                InheritanceTest.class, 
+                inheritanceObjects.get(0).getClass());
+        assertEquals(
+                InheritanceChildB.class, 
+                inheritanceObjects.get(1).getClass());
+        assertEquals(
+                InheritanceChildC.class, 
+                inheritanceObjects.get(2).getClass());
+        assertEquals(
+                InheritanceChildD.class, 
+                inheritanceObjects.get(3).getClass());
     }
 
     public void testEscaping() throws Exception



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