db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r374352 - /db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingTest.java
Date Thu, 02 Feb 2006 11:17:10 GMT
Author: arminw
Date: Thu Feb  2 03:17:04 2006
New Revision: 374352

URL: http://svn.apache.org/viewcvs?rev=374352&view=rev
Log:
add new test

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingTest.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingTest.java
URL: http://svn.apache.org/viewcvs/db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingTest.java?rev=374352&r1=374351&r2=374352&view=diff
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingTest.java (original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/test/org/apache/ojb/odmg/LockingTest.java Thu Feb
 2 03:17:04 2006
@@ -330,6 +330,45 @@
         }
     }
 
+    /**
+     * test proper treatment of Optimistic Locking in
+     * ODMG transactions
+     */
+    public void testOptimisticLockBasics_2() throws Exception
+    {
+        TransactionImpl tx1 = (TransactionImpl) odmg1.newTransaction();
+        TransactionImpl tx2 = (TransactionImpl) odmg2.newTransaction();
+
+        LockObjectOpt obj = new LockObjectOpt();
+
+
+        tx1.begin();
+
+        tx1.lock(obj, Transaction.WRITE);
+        obj.setValue("tx1");
+        tx1.commit();
+
+        obj.setVersion(obj.getVersion() - 1);
+        tx2.begin();
+        db2.deletePersistent(obj);
+        try
+        {
+            tx2.commit();
+// OL exceptions should be signalled as ODMG LockNotGrantedExceptions
+// so that users can react accordingly
+            fail("Optimistic locking exception expected");
+        }
+        catch(LockNotGrantedException ex)
+        {
+            assertTrue("expected that a OL exception is caught", true);
+        }
+        catch(Exception e)
+        {
+            e.printStackTrace();
+            fail("Wrong kind of exception thrown, expected 'LockNotGrantedException', but
was " + e.getMessage());
+        }
+    }
+
 
     /**
      * factory method that createa an PerformanceArticle



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


Mime
View raw message