openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r752306 [1/3] - in /openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/ openjpa-per...
Date Tue, 10 Mar 2009 23:41:04 GMT
Author: allee8285
Date: Tue Mar 10 23:41:03 2009
New Revision: 752306

URL: http://svn.apache.org/viewvc?rev=752306&view=rev
Log:
OPENJPA-891 - Complete new LockModeType supports in EntityManager. Manual updated. Build and TCK passed. Code reviewed by Pinaki P. and Mike D.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerGenericTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockPermutationTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerRefreshBasicTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerRefreshExceptionTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerRefreshPermutationTest.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/SequencedActionsTest.java   (with props)
Removed:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockManagerTestBase.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockStory.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockTask.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestJPA2LockManager.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestOptimisticLockManager.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/TestPessimisticLockManager.java
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/NoneLockManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/JPA2LockManager.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    openjpa/trunk/openjpa-persistence/src/main/resources/org/apache/openjpa/persistence/localizer.properties
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_conf.xml
    openjpa/trunk/openjpa-project/src/doc/manual/ref_guide_runtime.xml

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java?rev=752306&r1=752305&r2=752306&view=diff
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java Tue Mar 10 23:41:03 2009
@@ -90,7 +90,7 @@
     }
 
     protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
-        Object sdata) {
+        Object sdata, boolean postVersionCheck) {
         // we can skip any already-locked instance regardless of level because
         // we treat all locks the same (though super doesn't)
         if (getLockLevel(sm) == LOCK_NONE) {
@@ -99,7 +99,7 @@
             if (info == null || info.result == null || !info.result.isLocking())
                 lockRow(sm, timeout, level);
         }
-        optimisticLockInternal(sm, level, timeout, sdata);
+        optimisticLockInternal(sm, level, timeout, sdata, postVersionCheck);
     }
 
     /**

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=752306&r1=752305&r2=752306&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Tue Mar 10 23:41:03 2009
@@ -2933,6 +2933,10 @@
                         		load = new ArrayList(objs.size());
                             load.add(sm);
                         }
+                        int level = _fc.getReadLockLevel();
+                        int timeout = _fc.getLockTimeout();
+                        _lm.lock(sm, level, timeout, null, false);
+                        sm.readLocked(level, level);
                     } else if (assertPersistenceCapable(obj).pcIsDetached()
                         == Boolean.TRUE)
                         throw newDetachedException(obj, "refresh");
@@ -3001,6 +3005,10 @@
                     sm.load(_fc, StateManagerImpl.LOAD_FGS, null, null, false);
                     sm.afterRefresh();
                 }
+                int level = _fc.getReadLockLevel();
+                int timeout = _fc.getLockTimeout();
+                _lm.lock(sm, level, timeout, null, false);
+                sm.readLocked(level, level);
                 fireLifecycleEvent(sm.getManagedInstance(), null,
                     sm.getMetaData(), LifecycleEvent.AFTER_REFRESH);
             } else if (assertPersistenceCapable(obj).pcIsDetached()

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockManager.java?rev=752306&r1=752305&r2=752306&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/LockManager.java Tue Mar 10 23:41:03 2009
@@ -71,6 +71,13 @@
         Object sdata);
 
     /**
+     * Perform the same function as previous lock method and has the option
+     * to perform a version check after the lock function has completed. 
+     */
+    public void lock(OpenJPAStateManager sm, int level, int timeout,
+        Object sdata, boolean postLockVersionCheck);
+    
+    /**
      * Obtain locks on the specified objects.
      *
      * @see #lock

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/NoneLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/NoneLockManager.java?rev=752306&r1=752305&r2=752306&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/NoneLockManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/NoneLockManager.java Tue Mar 10 23:41:03 2009
@@ -28,6 +28,13 @@
 
     public void lock(OpenJPAStateManager sm, int level, int timeout,
         Object context) {
+        // Duplicate code in the 2 lock methods to enforce proper action
+        // and avoid unexpected behavior due to method override.
+        sm.setLock(Boolean.TRUE);
+    }
+
+    public void lock(OpenJPAStateManager sm, int level, int timeout,
+        Object context, boolean postLockVersionCheck) {
         sm.setLock(Boolean.TRUE);
     }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java?rev=752306&r1=752305&r2=752306&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java Tue Mar 10 23:41:03 2009
@@ -68,6 +68,11 @@
      */
     public void lock(OpenJPAStateManager sm, int level, int timeout,
         Object sdata) {
+        lock(sm, level, timeout, sdata, true);
+    }
+    
+    public void lock(OpenJPAStateManager sm, int level, int timeout,
+            Object sdata, boolean postLockVersionCheck) {
         if (level == LOCK_NONE)
             return;
         while (sm.getOwner() != null)
@@ -77,7 +82,7 @@
             return;
 
         try {
-            lockInternal(sm, level, timeout, sdata);
+            lockInternal(sm, level, timeout, sdata, postLockVersionCheck);
         } catch (RuntimeException re) {
             // revert lock
             setLockLevel(sm, oldLevel);
@@ -94,12 +99,12 @@
      * @see StoreContext#transactional
      */
     protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
-        Object sdata) {
-        optimisticLockInternal(sm, level, timeout, sdata);
+        Object sdata, boolean postLockVersionCheck) {
+        optimisticLockInternal(sm, level, timeout, sdata, postLockVersionCheck);
     }
 
     protected void optimisticLockInternal(OpenJPAStateManager sm, int level,
-        int timeout, Object sdata) {
+        int timeout, Object sdata, boolean postLockVersionCheck) {
         // Set lock level first to prevent infinite recursion with
         // transactional(..) call
         setLockLevel(sm, level);

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java?rev=752306&r1=752305&r2=752306&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java Tue Mar 10 23:41:03 2009
@@ -18,16 +18,19 @@
  */
 package org.apache.openjpa.persistence.lockmgr;
 
-import java.util.Collection;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 
-import javax.persistence.CascadeType;
 import javax.persistence.Entity;
 import javax.persistence.Id;
-import javax.persistence.OneToMany;
 import javax.persistence.Version;
 
 @Entity
-public class LockEmployee {
+public class LockEmployee implements Externalizable {
+
+    private static final long serialVersionUID = 1200290394382760086L;
 
     @Id
     private int id;
@@ -38,11 +41,6 @@
     private String firstName;
     private String lastName;
 
-    @OneToMany(mappedBy = "employee"
-        , cascade = { CascadeType.ALL }
-        )     
-    private Collection<LockTask> tasks;
-
     public int getId() {
         return id;
     }
@@ -67,21 +65,29 @@
         this.lastName = lastName;
     }
 
-    public Collection<LockTask> getTasks() {
-        return tasks;
-    }
-
-    public void setTasks(Collection<LockTask> tasks) {
-        this.tasks = tasks;
-    }
-
     public int getVersion() {
         return version;
     }
-    
+
     public String toString() {
-        return this.getClass().getName() + "[id=" + getId() + ", ver="
-            + getVersion() + "] first=" + getFirstName() + ", last="
-            + getLastName() + ", tasks={" + getTasks() + "}";
+        return this.getClass().getName() + '@'
+            + Integer.toHexString(System.identityHashCode(this)) + "[id="
+            + getId() + ", ver=" + getVersion() + "] first=" + getFirstName()
+            + ", last=" + getLastName();
+    }
+
+    public void readExternal(ObjectInput in) throws IOException,
+        ClassNotFoundException {
+        id = in.readInt();
+        version = in.readInt();
+        firstName = (String) in.readObject();
+        lastName = (String) in.readObject();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException {
+        out.writeInt(id);
+        out.writeInt(version);
+        out.writeObject(firstName);
+        out.writeObject(lastName);
     }
 }

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java?rev=752306&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java Tue Mar 10 23:41:03 2009
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.lockmgr;
+
+import javax.persistence.LockModeType;
+
+/**
+ * Test JPA 2.0 em.find(LockMode) behaviors with "mixed" lock manager.
+ */
+public class MixedLockManagerFindBasicTest extends SequencedActionsTest {
+    public void setUp() {
+        setUp(LockEmployee.class
+            , "openjpa.LockManager", "mixed"
+            );
+        commonSetUp();
+    }
+
+    public void testFindRead() {
+        testCommon("testFindRead",
+            LockModeType.READ, 0, 1);
+    }
+
+    public void testFindWrite() {
+        testCommon("testFindWrite",
+            LockModeType.WRITE, 1, 1);
+    }
+
+    public void testFindOptimistic() {
+        testCommon("testFindOptimistic",
+            LockModeType.OPTIMISTIC, 0, 1);
+    }
+
+    public void testFindOptimisticForceInc() {
+        testCommon("testFindOptimisticForceInc",
+            LockModeType.OPTIMISTIC_FORCE_INCREMENT, 1, 1);
+    }
+
+    public void testFindPessimisticRead() {
+        testCommon("testFindPessimisticRead",
+            LockModeType.PESSIMISTIC/* _READ */, 0, 1);
+    }
+
+    public void testFindPessimisticWrite() {
+        testCommon("testFindPessimisticWrite",
+            LockModeType.PESSIMISTIC/* _WRITE */, 0, 1);
+    }
+
+    public void testFindPessimisticForceInc() {
+        testCommon("testFindPessimisticForceInc",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, 1, 1);
+    }
+
+    public void testCommon(String testName, LockModeType lockMode,
+        int commitVersionIncrement, int updateCommitVersionIncrement) {
+        Object[][] threadMain = {
+            // Find entity, no transaction, no update.
+            { Act.CreateEm },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, Default_FirstName},
+
+            // Find entity with lLock, no update and commit.
+            { Act.StartTx },
+            { Act.Clear },
+            { Act.FindWithLock, 1, lockMode },
+            { Act.TestEmployee, 1, Default_FirstName},
+            { Act.SaveVersion },
+            { Act.CommitTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, Default_FirstName,
+                commitVersionIncrement },
+
+            // Find entity with lock, update and commit.
+            { Act.StartTx },
+            { Act.Clear },
+            { Act.FindWithLock, 1, lockMode },
+            { Act.SaveVersion },
+            { Act.TestEmployee, 1, Default_FirstName},
+            { Act.UpdateEmployee, 1, lockMode.toString() },
+            { Act.CommitTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, lockMode.toString(),
+                updateCommitVersionIncrement },
+
+            // Find entity with lock, update but rollback.
+            { Act.StartTx },
+            { Act.Clear },
+            { Act.FindWithLock, 1, lockMode },
+            { Act.SaveVersion },
+            { Act.TestEmployee, 1, lockMode.toString()},
+            { Act.UpdateEmployee, 1, lockMode.toString() + " Again" },
+            { Act.RollbackTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, lockMode.toString(), 0 },
+        };
+
+        launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
+    }
+}
\ No newline at end of file

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindBasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java?rev=752306&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java Tue Mar 10 23:41:03 2009
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.lockmgr;
+
+import javax.persistence.EntityNotFoundException;
+import javax.persistence.LockModeType;
+import javax.persistence.OptimisticLockException;
+import javax.persistence.TransactionRequiredException;
+
+/**
+ * Test JPA 2.0 em.find(LockMode) exception behaviors with "mixed" lock manager.
+ */
+public class MixedLockManagerFindExceptionTest extends SequencedActionsTest {
+    public void setUp() {
+        setUp(LockEmployee.class
+            , "openjpa.LockManager", "mixed"
+        );
+        commonSetUp();
+    }
+
+    /**
+     * TransactionRequiredException if there is no transaction
+     */
+    public void testFindTxReqExceptions() {
+        Object[][] threadMainTxReqTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            
+            {Act.FindWithLock, 1, LockModeType.NONE },
+            {Act.TestException},
+            
+            {Act.FindWithLock, 1, LockModeType.READ },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.FindWithLock, 1, LockModeType.WRITE },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.FindWithLock, 1, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.FindWithLock, 1, LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.FindWithLock, 1, LockModeType.PESSIMISTIC/*_READ*/},
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.FindWithLock, 1, LockModeType.PESSIMISTIC/*_WRITE*/},
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.FindWithLock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, TransactionRequiredException.class },
+        };
+        launchActionSequence("testLockTxReqExceptions()",
+            null, threadMainTxReqTest);
+    }
+
+    /*
+     * IllegalArgumentException if the instance is not an entity or is a
+     *      detached entity
+     */
+    public void testFindIllegalArgrumentExceptions() {
+        // Test invalid entity argument throws IllegalArgumentException.
+        Object[][] threadMainInvEntityIllegalArgTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.StartTx},
+      
+            {Act.FindObject, null, 0, LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0, LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null, LockModeType.NONE },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.FindObject, null, 0, LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0, LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null, LockModeType.READ },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.FindObject, null, 0, LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0, LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null, LockModeType.WRITE },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.FindObject, null, 0, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null,
+                LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.FindObject, null, 0,
+                LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0, 
+                LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null,
+                LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.FindObject, null, 0,
+                LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0,
+                LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null,
+                LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.FindObject, null, 0,
+                LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0,
+                    IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0,
+                LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0,
+                    IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null,
+                LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0,
+                    EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE,
+                LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.FindObject, null, 0,
+                LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0,
+                IllegalArgumentException.class },
+            {Act.FindObject, Object.class, 0,
+                LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0,
+                IllegalArgumentException.class },
+            {Act.FindObject, LockEmployee.class, null,
+                LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, EntityNotFoundException.class },
+            {Act.FindObject, LockEmployee.class, Boolean.TRUE, 
+                LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+        };
+        launchActionSequence("testLockIllegalArgrumentExceptions()",
+            "Test invalid entity.", threadMainInvEntityIllegalArgTest);
+    }
+    
+    /*
+     * If a pessimistic lock mode type is specified and the entity
+     * contains a version attribute, the persistence provider must
+     * also perform optimistic version checks when obtaining the
+     * database lock. If these checks fail, the
+     * OptimisticLockException will be thrown.
+     */
+    public void testLockOptimisticLockExceptions() {
+        commonLockOptimisticLockExceptions(
+            LockModeType.NONE, true, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.READ, true, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.WRITE, true, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.OPTIMISTIC, true, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.OPTIMISTIC_FORCE_INCREMENT, true, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.PESSIMISTIC/* _READ */, false, true);
+        commonLockOptimisticLockExceptions(
+            LockModeType.PESSIMISTIC/* _WRITE */, false, true);
+        commonLockOptimisticLockExceptions(
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, false, true);
+    }
+    
+    public void commonLockOptimisticLockExceptions(LockModeType lockMode,
+        boolean expectingOptLockException1, 
+        boolean expectingOptLockException2) {
+        Object[][] threadMainOptLockExTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.Clear},
+            
+            {Act.NewThread, 1 },
+            {Act.StartThread, 1 },
+            {Act.Wait},
+            
+            {Act.StartTx},
+            {Act.FindWithLock, 1, lockMode},
+            {Act.UpdateEmployee},
+            {Act.Notify, 1},
+            {Act.Wait},
+            {Act.CommitTx},
+            
+            {Act.WaitAllChildren},
+            {Act.TestException, 0, expectingOptLockException1
+                ? OptimisticLockException.class : null},
+            {Act.TestException, 1, expectingOptLockException2
+                    ? OptimisticLockException.class : null},
+        };
+        Object[][] thread1OptLockExTest = {
+            {Act.CreateEm},
+            {Act.StartTx},
+            {Act.FindWithLock, 1, LockModeType.OPTIMISTIC},
+            {Act.SaveVersion},
+            {Act.UpdateEmployee},
+            
+            {Act.Notify, 0},
+            {Act.Wait},
+            
+            {Act.CommitTx},
+            {Act.Notify, 0},
+        };        
+        launchActionSequence("testLockOptimisticLockExceptions()", null,
+            threadMainOptLockExTest, thread1OptLockExTest);
+    }
+}
\ No newline at end of file

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java?rev=752306&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java Tue Mar 10 23:41:03 2009
@@ -0,0 +1,384 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.lockmgr;
+
+import java.util.Arrays;
+
+import javax.persistence.LockModeType;
+
+/**
+ * Test JPA 2.0 LockMode type permutation behaviors with "mixed" lock manager.
+ */
+public class MixedLockManagerFindPermutationTest extends SequencedActionsTest {
+    public void setUp() {
+        setUp(LockEmployee.class
+            , "openjpa.LockManager", "mixed"
+        );
+        commonSetUp();
+    }
+
+    /* ======== Thread 1 : Read Lock ============*/
+    public void testFindReadRead() {
+        commonFindTest(
+            "testFind(Read,Commit/Read,Commit)",
+            LockModeType.READ, Act.CommitTx, 1, null, 
+            LockModeType.READ, Act.CommitTx, 0, ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(Read,Commit/Read,Rollback)",
+            LockModeType.READ, Act.CommitTx, 1, null,
+            LockModeType.READ, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindReadWrite() {
+        commonFindTest(
+            "testFind(Read,Commit/Write,Commit)",
+            LockModeType.READ, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.CommitTx, 0,
+                ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(Read,Commit/Write,Rollback)",
+            LockModeType.READ, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindReadPessimisticRead() {
+        commonFindTest(
+            "testFind(Read,Commit/PessimisticRead,Commit)",
+            LockModeType.READ, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 0, null);
+        commonFindTest(
+            "testFind(Read,Commit/PessimisticRead,Rollback)",
+            LockModeType.READ, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_READ*/, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindReadPessimisticWrite() {
+        commonFindTest(
+            "testFind(Read,Commit/PessimisticWrite,Commit)",
+            LockModeType.READ, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 0, null);
+        commonFindTest(
+            "testFind(Read,Commit/PessimisticWrite,Rollback)",
+            LockModeType.READ, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindReadPessimisticForceInc() {
+        commonFindTest(
+            "testFind(Read,Commit/PessimisticForceInc,Commit)",
+            LockModeType.READ, Act.CommitTx, 1, ExpectingOptimisticLockExClass, 
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null);
+        commonFindTest(
+            "testFind(Read,Commit/PessimisticForceInc,Rollback)",
+            LockModeType.READ, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, null);
+    }
+    
+    /* ======== Thread 1 : Write Lock ============*/
+    public void testFindWriteRead() {
+        commonFindTest(
+            "testFind(Write,Commit/Read,Commit)",
+            LockModeType.WRITE, Act.CommitTx, 1, null, 
+            LockModeType.READ, Act.CommitTx, 0, ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(Write,Commit/Read,Rollback)",
+            LockModeType.WRITE, Act.CommitTx, 1, null,
+            LockModeType.READ, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindWriteWrite() {
+        commonFindTest(
+            "testFind(Write,Commit/Write,Commit)",
+            LockModeType.WRITE, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.CommitTx, 0,
+                ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(Write,Commit/Write,Rollback)",
+            LockModeType.WRITE, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindWritePessimisticRead() {
+        commonFindTest(
+            "testFind(Write,Commit/PessimisticRead,Commit)",
+            LockModeType.WRITE, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 0, null);
+        commonFindTest(
+            "testFind(Write,Commit/PessimisticRead,Rollback)",
+            LockModeType.WRITE, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_READ*/, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindWritePessimisticWrite() {
+        commonFindTest(
+            "testFind(Write,Commit/PessimisticWrite,Commit)",
+            LockModeType.WRITE, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 0, null);
+        commonFindTest(
+            "testFind(Write,Commit/PessimisticWrite,Rollback)",
+            LockModeType.WRITE, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindWritePessimisticForceInc() {
+        commonFindTest(
+            "testFind(Write,Commit/PessimisticForceInc,Commit)",
+            LockModeType.WRITE, Act.CommitTx, 1, ExpectingOptimisticLockExClass, 
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null);
+        commonFindTest(
+            "testFind(Write,Commit/PessimisticForceInc,Rollback)",
+            LockModeType.WRITE, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 1, null);
+    }
+    
+    /* ======== Thread 1 : PessimisticRead Lock ============*/
+    public void testFindPessimisticReadRead() {
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/Read,Commit)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null, 
+            LockModeType.READ, Act.CommitTx, 0, ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/Read,Rollback)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null,
+            LockModeType.READ, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindPessimisticReadWrite() {
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/Write,Commit)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.CommitTx, 0, 
+                ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/Write,Rollback)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindPessimisticReadPessimisticRead() {
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/PessimisticRead,Commit)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 0, null);
+//                ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/PessimisticRead,Rollback)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_READ*/, Act.RollbackTx, 0, null); 
+//                ExpectingOptimisticLockExClass);
+    }
+    
+    public void testFindPessimisticReadPessimisticWrite() {
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/PessimisticWrite,Commit)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 0, null); 
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/PessimisticWrite,Rollback)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.RollbackTx, 0, null);
+    }
+    
+    public void testFindPessimisticReadPessimisticForceInc() {
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/PessimisticForceInc,Commit)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null);
+        commonFindTest(
+            "testFind(PessimisticRead,Commit/PessimisticForceInc,Rollback)",
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 0, null);
+    }
+    
+    /* ======== Thread 1 : Pessimsitic Write Lock ============*/
+    public void testFindPessimsiticWriteRead() {
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/Read,Commit)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null, 
+            LockModeType.READ, Act.CommitTx, 0, ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/Read,Rollback)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null,
+            LockModeType.READ, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindPessimsiticWriteWrite() {
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/Write,Commit)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.CommitTx, 0, 
+                ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/Write,Rollback)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindPessimsiticWritePessimisticRead() {
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/PessimisticRead,Commit)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 0, null); 
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/PessimisticRead,Rollback)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_READ*/, Act.RollbackTx, 0, null); 
+    }
+    
+    public void testFindPessimsiticWritePessimisticWrite() {
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/PessimisticWrite,Commit)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 0, null); 
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/PessimisticWrite,Rollback)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.RollbackTx, 0, null); 
+    }
+    
+    public void testFindPessimsiticWritePessimisticForceInc() {
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/PessimisticForceInc,Commit)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null); 
+        commonFindTest(
+            "testFind(PessimsiticWrite,Commit/PessimisticForceInc,Rollback)",
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 0, null);
+    }
+    
+    /* ======== Thread 1 : Pessimsitic Force Increment Lock ============*/
+    public void testFindPessimsiticForceIncRead() {
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/Read,Commit)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null, 
+            LockModeType.READ, Act.CommitTx, 0, ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/Read,Rollback)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
+            LockModeType.READ, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindPessimsiticForceIncWrite() {
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/Write,Commit)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.CommitTx, 0,
+                ExpectingOptimisticLockExClass);
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/Write,Rollback)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
+            LockModeType.WRITE, Act.RollbackTx, 1, null);
+    }
+    
+    public void testFindPessimsiticForceIncPessimisticRead() {
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/PessimisticRead,Commit)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_READ*/, Act.CommitTx, 0, null); 
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/PessimisticRead,Rollback)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_READ*/, Act.RollbackTx, 0, null); 
+    }
+    
+    public void testFindPessimsiticForceIncPessimisticWrite() {
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/PessimisticWrite,Commit)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.CommitTx, 0, null);
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/PessimisticWrite,Rollback)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC/*_WRITE*/, Act.RollbackTx, 0, null); 
+    }
+    
+    public void testFindPessimsiticForceIncPessimisticForceInc() {
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/PessimisticForceInc,Commit)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null, 
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null); 
+        commonFindTest(
+            "testFind(PessimsiticForceInc,Commit/PessimisticForceInc,Rollback)",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.CommitTx, 1, null,
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, Act.RollbackTx, 0, null);
+    }
+
+    private void commonFindTest( String testName, 
+        LockModeType t1Lock, Act t1IsCommit, int t1VersionInc, 
+            Class<?>[] t1Exceptions, 
+        LockModeType t2Lock, Act t2IsCommit, int t2VersionInc,
+            Class<?>[] t2Exceptions ) {
+        String[] parameters = new String[] {
+            "Thread 1: lock= " + t1Lock + ", isCommit= " + t1IsCommit +
+                ", versionInc= +" + t1VersionInc +
+                ", expectedEx= " + Arrays.toString(t1Exceptions),
+            "Thread 2: lock= " + t2Lock + ", isCommit= " + t2IsCommit + 
+                ", versionInc= +" + t2VersionInc +
+                ", expectedEx= " + Arrays.toString(t2Exceptions)};
+            
+        Object[][] threadMain = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            
+            {Act.NewThread, 1 },
+            {Act.NewThread, 2 },
+            {Act.StartThread, 1 },
+            {Act.Wait},
+            {Act.StartThread, 2 },
+            {Act.Notify, 1, 1000 },
+            {Act.Notify, 2, 1000 },
+            {Act.WaitAllChildren},
+            {Act.Find},
+            {Act.TestEmployee, 1},
+            {Act.TestException, 1, t1Exceptions },
+            {Act.TestException, 2, t2Exceptions },
+        };
+        Object[][] thread1 = {
+            {Act.CreateEm},
+            {Act.StartTx},
+            {Act.FindWithLock, 1, t1Lock},
+            {Act.SaveVersion},
+            {Act.TestException},
+            {Act.Notify, 0},
+            {Act.Wait},
+            {Act.UpdateEmployee},
+            
+            {t1IsCommit},
+            {Act.Find},
+            {Act.TestEmployee, 1, null, t1VersionInc}
+        };
+        Object[][] thread2 = {
+            {Act.CreateEm},
+            {Act.StartTx},
+            {Act.FindWithLock, 1, t2Lock},
+            {Act.SaveVersion},
+            {Act.Notify, 0},
+            {Act.Wait},
+            
+            {t2IsCommit},
+            {Act.Find},
+            {Act.TestEmployee, 1, null, t2VersionInc}
+        };
+        launchActionSequence(testName, parameters, threadMain, thread1,
+            thread2);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerFindPermutationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerGenericTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerGenericTest.java?rev=752306&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerGenericTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerGenericTest.java Tue Mar 10 23:41:03 2009
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.lockmgr;
+
+import javax.persistence.LockModeType;
+
+/**
+ * Test JPA 2.0 em.lock(LockMode) behaviors with "mixed" lock manager.
+ */
+public class MixedLockManagerGenericTest extends SequencedActionsTest {
+    public void setUp() {
+        setUp(LockEmployee.class
+            , "openjpa.LockManager", "mixed"
+            );
+        commonSetUp();
+    }
+
+    public void testRefreshRead() {
+        testCommon("testRefreshRead",
+            LockModeType.READ, 0, 1);
+    }
+
+    public void testRefreshWrite() {
+        testCommon("testRefreshWrite",
+            LockModeType.WRITE, 1, 1);
+    }
+
+    public void testRefreshOptimistic() {
+        testCommon("testRefreshOptimistic",
+            LockModeType.OPTIMISTIC, 0, 1);
+    }
+
+    public void testRefreshOptimisticForceInc() {
+        testCommon("testRefreshOptimisticForceInc",
+            LockModeType.OPTIMISTIC_FORCE_INCREMENT, 1, 1);
+    }
+
+    public void testRefreshPessimisticRead() {
+        testCommon("testRefreshPessimisticRead",
+            LockModeType.PESSIMISTIC/* _READ */, 0, 1);
+    }
+
+    public void testRefreshPessimisticWrite() {
+        testCommon("testRefreshPessimisticWrite",
+            LockModeType.PESSIMISTIC/* _WRITE */, 0, 1);
+    }
+
+    public void testRefreshPessimisticForceInc() {
+        testCommon("testRefreshPessimisticForceInc",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, 1, 1);
+    }
+
+    public void testCommon(String testName, LockModeType lockMode,
+        int commitVersionIncrement, int updateCommitVersionIncrement) {
+        
+        Object[][] threadTest = {
+          { Act.CreateEm },
+          { Act.StartTx },
+          { Act.Test},
+        };
+
+        launchActionSequence(testName, "LockMode=" + lockMode, threadTest);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerGenericTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java?rev=752306&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java Tue Mar 10 23:41:03 2009
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.lockmgr;
+
+import javax.persistence.LockModeType;
+
+/**
+ * Test JPA 2.0 em.lock(LockMode) basic behaviors with "mixed" lock manager.
+ */
+public class MixedLockManagerLockBasicTest extends SequencedActionsTest {
+    public void setUp() {
+        setUp(LockEmployee.class
+            , "openjpa.LockManager", "mixed"
+            );
+        commonSetUp();
+    }
+
+    public void testLockRead() {
+        testCommon("testLockRead",
+            LockModeType.READ, 0, 1);
+    }
+
+    public void testLockWrite() {
+        testCommon("testLockWrite",
+            LockModeType.WRITE, 1, 1);
+    }
+
+    public void testLockOptimistic() {
+        testCommon("testLockOptimistic",
+            LockModeType.OPTIMISTIC, 0, 1);
+    }
+
+    public void testLockOptimisticForceInc() {
+        testCommon("testLockOptimisticForceInc",
+            LockModeType.OPTIMISTIC_FORCE_INCREMENT, 1, 1);
+    }
+
+    public void testLockPessimisticRead() {
+        testCommon("testLockPessimisticRead",
+            LockModeType.PESSIMISTIC/*_READ */, 0, 1);
+    }
+
+    public void testLockPessimisticWrite() {
+        testCommon("testLockPessimisticWrite",
+            LockModeType.PESSIMISTIC/*_WRITE */, 0, 1);
+    }
+
+    public void testLockPessimisticForceInc() {
+        testCommon("testLockPessimisticForceInc",
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, 1, 1);
+    }
+
+    public void testCommon(String testName, LockModeType lockMode,
+        int commitVersionIncrement, int updateCommitVersionIncrement) {
+        Object[][] threadMain = {
+            // Find entity, lock, no update and commit.
+            { Act.CreateEm },
+            { Act.StartTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, Default_FirstName},
+            { Act.SaveVersion },
+            { Act.Lock, 1, lockMode },
+            { Act.CommitTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, Default_FirstName,
+                commitVersionIncrement },
+
+            // Find entity, lock, update and commit.
+            { Act.StartTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, Default_FirstName},
+            { Act.SaveVersion },
+            { Act.Lock, 1, lockMode },
+            { Act.UpdateEmployee, 1, lockMode.toString() },
+            { Act.CommitTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, lockMode.toString(),
+                updateCommitVersionIncrement },
+
+            // Find entity, lock, update but rollback.
+            { Act.StartTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, lockMode.toString()},
+            { Act.SaveVersion },
+            { Act.Lock, 1, lockMode },
+            { Act.UpdateEmployee, 1, lockMode.toString() + " Again" },
+            { Act.RollbackTx },
+            { Act.Clear },
+            { Act.Find, 1 },
+            { Act.TestEmployee, 1, lockMode.toString(), 0 },
+        };
+        launchActionSequence(testName, "LockMode=" + lockMode, threadMain);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockBasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java?rev=752306&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java Tue Mar 10 23:41:03 2009
@@ -0,0 +1,316 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openjpa.persistence.lockmgr;
+
+import javax.persistence.LockModeType;
+import javax.persistence.OptimisticLockException;
+import javax.persistence.TransactionRequiredException;
+
+/**
+ * Test JPA 2.0 em.lock(LockMode) exception behaviors with "mixed" lock manager.
+ */
+public class MixedLockManagerLockExceptionTest extends SequencedActionsTest {
+    public void setUp() {
+        setUp(LockEmployee.class
+            , "openjpa.LockManager", "mixed"
+        );
+        commonSetUp();
+    }
+
+    /**
+     * TransactionRequiredException if there is no transaction
+     */
+    public void testLockTxReqExceptions() {
+        Object[][] threadMainTxReqTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            
+            {Act.Lock, 1, LockModeType.NONE },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.READ },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.WRITE },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.PESSIMISTIC/*_READ*/},
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.PESSIMISTIC/*_WRITE*/},
+            {Act.TestException, 0, TransactionRequiredException.class },
+            
+            {Act.Lock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, TransactionRequiredException.class },
+        };
+        
+        launchActionSequence("testLockTxReqExceptions()",
+            null, threadMainTxReqTest);
+    }
+
+    /*
+     * IllegalArgumentException if the instance is not an entity or is a
+     *      detached entity
+     */
+    public void testLockIllegalArgrumentExceptions() {
+        // Test invalid entity argument throws IllegalArgumentException.
+        Object[][] threadMainInvEntityIllegalArgTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.StartTx},
+      
+            {Act.LockObject, null, LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.LockObject, null, LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.LockObject, null, LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.LockObject, null, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.LockObject, null, LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.LockObject, null, LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.LockObject, null, LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.LockObject, null, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            {Act.LockObject, "null", LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+        };
+        launchActionSequence("testLockIllegalArgrumentExceptions()",
+            "Test invalid entity.", threadMainInvEntityIllegalArgTest);
+        
+        // Test detached entity argument throws IllegalArgumentException.
+        Object[][] threadMainDetachEntityIllegalArgTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.StartTx},
+            {Act.Detach, 1, 2},
+            
+            {Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+            
+            {Act.Lock, 2, LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+          
+            {Act.Lock, 2, LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+        };
+        launchActionSequence("testLockIllegalArgrumentExceptions()",
+            "Test detached entity.", threadMainDetachEntityIllegalArgTest);
+
+        // Test detached argument from serialized entity throws 
+        //  IllegalArgumentException.
+        Object[][] threadMainDetachSerializeIllegalArgTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.StartTx},
+            {Act.DetachSerialize, 1, 2},
+            
+            {Act.Lock, 2, LockModeType.NONE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+        
+            {Act.Lock, 2, LockModeType.READ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.WRITE },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.OPTIMISTIC },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException, 0, IllegalArgumentException.class },
+
+            {Act.Lock, 2, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException, 0, IllegalArgumentException.class },
+        };        
+        launchActionSequence("testLockIllegalArgrumentExceptions()",
+            "Test detached entity using serialization.",
+            threadMainDetachSerializeIllegalArgTest);
+        
+        Object[][] threadMainRemoveIllegalArgTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.StartTx},
+            {Act.Remove},
+
+            {Act.Lock, 1, LockModeType.NONE },
+            {Act.TestException},
+      
+            {Act.Lock, 1, LockModeType.READ },
+            {Act.TestException},
+
+            {Act.Lock, 1, LockModeType.WRITE },
+            {Act.TestException},
+
+            {Act.Lock, 1, LockModeType.OPTIMISTIC },
+            {Act.TestException},
+
+            {Act.Lock, 1, LockModeType.OPTIMISTIC_FORCE_INCREMENT },
+            {Act.TestException},
+
+            {Act.Lock, 1, LockModeType.PESSIMISTIC/*_READ*/ },
+            {Act.TestException},
+
+            {Act.Lock, 1, LockModeType.PESSIMISTIC/*_WRITE*/ },
+            {Act.TestException},
+
+            {Act.Lock, 1, LockModeType.PESSIMISTIC_FORCE_INCREMENT },
+            {Act.TestException},
+            
+            {Act.RollbackTx},
+        };
+        launchActionSequence(
+            "testLockIllegalArgrumentExceptions()",
+            "Test removed entity - no exception since it is still "
+                +"in the context.",
+            threadMainRemoveIllegalArgTest);
+    }
+    
+    /*
+     * If a pessimistic lock mode type is specified and the entity
+     * contains a version attribute, the persistence provider must
+     * also perform optimistic version checks when obtaining the
+     * database lock. If these checks fail, the
+     * OptimisticLockException will be thrown.
+     */
+    public void testLockOptimisticLockExceptions() {
+        commonLockOptimisticLockExceptions(
+            LockModeType.NONE, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.READ, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.WRITE, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.OPTIMISTIC, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.OPTIMISTIC_FORCE_INCREMENT, false);
+        commonLockOptimisticLockExceptions(
+            LockModeType.PESSIMISTIC/*_READ*/, true);
+        commonLockOptimisticLockExceptions(
+            LockModeType.PESSIMISTIC/*_WRITE*/, true);
+        commonLockOptimisticLockExceptions(
+            LockModeType.PESSIMISTIC_FORCE_INCREMENT, true);
+    }
+    
+    public void commonLockOptimisticLockExceptions(LockModeType lockMode,
+        boolean expectingOptLockException) {
+        Object[][] threadMainOptLockExTest = {
+            {Act.CreateEm},
+            {Act.Find},
+            {Act.SaveVersion},
+            {Act.TestEmployee, 1, Default_FirstName},
+            {Act.Clear},
+            
+            {Act.NewThread, 1 },
+            {Act.StartThread, 1 },
+            {Act.Wait},
+            
+            {Act.StartTx},
+            {Act.Find},
+            {Act.Notify, 1},
+            
+            {Act.Wait},
+            {Act.Lock, 1, lockMode},
+            {Act.WaitAllChildren},
+            {Act.TestException, 0, expectingOptLockException
+                ? OptimisticLockException.class : null},
+            
+            {Act.RollbackTx},
+        };
+        Object[][] thread1OptLockExTest = {
+            {Act.CreateEm},
+            {Act.StartTx},
+            {Act.Find},
+            {Act.SaveVersion},
+            
+            {Act.Notify, 0},
+            {Act.Wait},
+            {Act.UpdateEmployee},
+            
+            {Act.CommitTx},
+            {Act.Notify, 0},
+        };        
+        launchActionSequence("testLockOptimisticLockExceptions()", null,
+            threadMainOptLockExTest, thread1OptLockExTest);
+    }
+}

Propchange: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lockmgr/MixedLockManagerLockExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message