Author: tfischer
Date: Mon Dec 18 03:35:20 2006
New Revision: 488235

URL: http://svn.apache.org/viewvc?view=rev&rev=488235
Log:
Added a check to the dataTest in the test project whether updating an object 
with a primary key works.

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?view=diff&rev=488235&r1=488234&r2=488235
==============================================================================
--- 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 
Mon Dec 18 03:35:20 2006
@@ -607,6 +607,51 @@
     }
 
     /**
+     * Test whether an update works and whether it only affects the 
+     * specified record.
+     * @throws Exception if anything in the test goes wrong.
+     */
+    public void testUpdate() throws Exception
+    {
+        cleanBookstore();
+
+        Author otherAuthor = new Author();
+        otherAuthor.setName("OtherName");
+        otherAuthor.save();
+
+        Author author = new Author();
+        author.setName("Name");
+        author.save();
+        
+        Criteria criteria = new Criteria();
+        criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
+        
+        List authors = AuthorPeer.doSelect(criteria);
+        assertEquals("List should contain 2 authors", 2, authors.size());
+        assertEquals("First Author's name should be \"Name\"",
+                "Name",
+                ((Author) authors.get(0)).getName());
+        assertEquals("Second Author's name should be \"OtherName\"",
+                "OtherName",
+                ((Author) authors.get(1)).getName());
+         
+        author.setName("NewName");
+        author.save();
+        
+        criteria.clear();
+        criteria.addAscendingOrderByColumn(AuthorPeer.NAME);
+        
+        authors = AuthorPeer.doSelect(criteria);
+        assertEquals("List should contain 2 authors", 2, authors.size());
+        assertEquals("First Author's name should be \"NewName\"",
+                "NewName",
+                ((Author) authors.get(0)).getName());
+        assertEquals("Second Author's name should be \"OtherName\"",
+                "OtherName",
+                ((Author) authors.get(1)).getName());
+    }
+    
+    /**
      * test special cases in the select clause
      * @throws Exception if the test fails
      */



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to