roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gango...@apache.org
Subject svn commit: r724008 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java test/java/org/apache/roller/weblogger/business/TaskLockTest.java
Date Sat, 06 Dec 2008 16:53:11 GMT
Author: gangolli
Date: Sat Dec  6 08:53:11 2008
New Revision: 724008

URL: http://svn.apache.org/viewvc?rev=724008&view=rev
Log:
Flush within the registerLease() and unregisterLease() methods.  Correct TaskLockTest.  NOTE:
 this commit may expose ROL-1760 on unit tests run on Oracle and Postgres.

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java
    roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/TaskLockTest.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java?rev=724008&r1=724007&r2=724008&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAThreadManagerImpl.java
Sat Dec  6 08:53:11 2008
@@ -120,6 +120,7 @@
             int result = q.executeUpdate();
             
             if(result == 1) {
+                strategy.flush();
                 return true;
             }
 
@@ -166,6 +167,7 @@
             int result = q.executeUpdate();
             
             if(result == 1) {
+                strategy.flush();
                 return true;
             }
 

Modified: roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/TaskLockTest.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/TaskLockTest.java?rev=724008&r1=724007&r2=724008&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/TaskLockTest.java
(original)
+++ roller/trunk/apps/weblogger/test/java/org/apache/roller/weblogger/business/TaskLockTest.java
Sat Dec  6 08:53:11 2008
@@ -18,7 +18,6 @@
 
 package org.apache.roller.weblogger.business;
 
-import java.util.Date;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
@@ -26,7 +25,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.TestUtils;
 import org.apache.roller.weblogger.business.runnable.RollerTask;
-import org.apache.roller.weblogger.business.runnable.RollerTaskWithLeasing;
 import org.apache.roller.weblogger.business.runnable.ThreadManager;
 
 
@@ -59,6 +57,7 @@
     
     /**
      * Test basic persistence operations ... Create, Update, Delete.
+     * @throws Exception if one is raised
      */
     public void testTaskLockCRUD() throws Exception {
         
@@ -68,16 +67,23 @@
         RollerTask task = new TestTask();
         
         // try to acquire a lock
-        assertTrue(mgr.registerLease(task));
-        TestUtils.endSession(true);
+        assertTrue("Failed to acquire lease.",mgr.registerLease(task));
+        // We don't flush here because registerLease should flush on its own
+        TestUtils.endSession(false);
         
         // make sure task is locked
-        assertFalse(mgr.registerLease(task));
-        TestUtils.endSession(true);
+        assertFalse("Acquired lease a second time when we shouldn't have been able to.",mgr.registerLease(task));
+        TestUtils.endSession(false);
         
         // try to release a lock
-        assertTrue(mgr.unregisterLease(task));
-        TestUtils.endSession(true);
+        assertTrue("Release of lease failed.",mgr.unregisterLease(task));
+        // We don't flush here because unregisterLease should flush on its own
+        TestUtils.endSession(false);
+
+        // Current unregisterLease semantics are idempotent.  Double release should
+        // actually succeed.
+        assertTrue("Second release failed.", mgr.unregisterLease(task));
+        TestUtils.endSession(false);
     }
     
 }



Mime
View raw message