db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r488235 - /db/torque/test/trunk/test-project/src/java/org/apache/torque/DataTest.java
Date Mon, 18 Dec 2006 11:35:21 GMT
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: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message