You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2010/10/28 20:19:35 UTC

svn commit: r1028411 - /db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java

Author: tfischer
Date: Thu Oct 28 18:19:35 2010
New Revision: 1028411

URL: http://svn.apache.org/viewvc?rev=1028411&view=rev
Log:
reactivate testNullConnection test

Modified:
    db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java

Modified: db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java?rev=1028411&r1=1028410&r2=1028411&view=diff
==============================================================================
--- db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java (original)
+++ db/torque/torque4/branches/trunk-without-village/torque-test/src/test/java/org/apache/torque/DataTest.java Thu Oct 28 18:19:35 2010
@@ -946,23 +946,51 @@ public class DataTest extends BaseRuntim
     }
 
     /**
-     * test the behaviour if a connection is supplied to access the database,
-     * but it is null. All methods on the user level should be able to
-     * handle this.
+     * Test the behaviour if a connection is supplied to access the database,
+     * but it is null. All methods on the user level should be fail
+     * because these methods will be only needed if a method should be executed
+     * in a transaction context. If one assumes that a transaction is open
+     * (connection is not null), but it is not (connection == null),
+     * it is a bad idea to silently start one as this behaviour is very
+     * difficult to tell from the correct one. A clean failure is much easier
+     * to test for.
      */
-    // ignored connection handling has changed
-    public void ignoredTestNullConnection() throws Exception
+    public void testNullConnection() throws Exception
     {
-        Criteria criteria = new Criteria();
-        BasePeer.doSelect(criteria, new IntegerMapper(), null, null);
+        try
+        {
+            Criteria criteria = new Criteria();
+            BasePeer.doSelect(criteria, new IntegerMapper(), null, null);
+            fail("NullPointerException expected");
+        }
+        catch (NullPointerException e)
+        {
+            //expected
+        }
 
-        criteria = new Criteria();
-        criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
-        BookPeer.doDelete(criteria, null);
+        try
+        {
+            Criteria criteria = new Criteria();
+            criteria.add(BookPeer.BOOK_ID, (Long) null, Criteria.NOT_EQUAL);
+            BookPeer.doDelete(criteria, null);
+            fail("NullPointerException expected");
+        }
+        catch (NullPointerException e)
+        {
+            //expected
+        }
 
-        Author author = new Author();
-        author.setName("name");
-        author.save((Connection) null);
+        try
+        {
+            Author author = new Author();
+            author.setName("name");
+            author.save((Connection) null);
+            fail("NullPointerException expected");
+        }
+        catch (NullPointerException e)
+        {
+            //expected
+        }
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org