openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From allee8...@apache.org
Subject svn commit: r1073527 - in /openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr: LockEmployee.java TestNamedQueryLockMode.java TestOptimisticNamedQueryLockMode.java
Date Tue, 22 Feb 2011 22:02:48 GMT
Author: allee8285
Date: Tue Feb 22 22:02:48 2011
New Revision: 1073527

URL: http://svn.apache.org/viewvc?rev=1073527&view=rev
Log:
Fix test cases running in DB2 due to 1) dict.forUpdateClause must be obtained after emf is
created because specific dictionary may override the value of this attribute, 2) The forUpdateClause
in DB2 is LockMode type dependent, (i.e. WITH RR/RS) therefore can not depends on this attribute
for positive test case comparison, negative test ok.

Modified:
    openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java
    openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
    openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestOptimisticNamedQueryLockMode.java

Modified: openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java?rev=1073527&r1=1073526&r2=1073527&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/LockEmployee.java
Tue Feb 22 22:02:48 2011
@@ -34,7 +34,7 @@ import javax.persistence.Version;
     @NamedQuery(name = "findEmployeeById", 
         query = "SELECT c FROM LockEmployee c WHERE c.id = :id"),
     @NamedQuery(name = "findEmployeeByIdWithLock", 
-        query = "SELECT c FROM LockEmployee c WHERE c.id = :id", lockMode = LockModeType.PESSIMISTIC_READ),
+        query = "SELECT c FROM LockEmployee c WHERE c.id = :id", lockMode = LockModeType.PESSIMISTIC_WRITE),
     @NamedQuery(name = "findEmployeeByIdWithNoLock", 
         query = "SELECT c FROM LockEmployee c WHERE c.id = :id", lockMode = LockModeType.NONE)
})
 @Entity

Modified: openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java?rev=1073527&r1=1073526&r2=1073527&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestNamedQueryLockMode.java
Tue Feb 22 22:02:48 2011
@@ -44,12 +44,12 @@ public class TestNamedQueryLockMode exte
             "openjpa.LockManager", "pessimistic", 
             "openjpa.Optimistic", "false"
             );
-        lockClause = getForUpdateClause();
     }
 
     public void testForUpdateClausePresentInNamedQueryWithLockMode() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+        lockClause = getForUpdateClause();
         assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id",
0));
         em.getTransaction().rollback();
         em.getTransaction().begin();
@@ -75,8 +75,9 @@ public class TestNamedQueryLockMode exte
     public void testForUpdateClausePresentInQueryWithDefault() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
-        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
-        assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
+        lockClause = getForUpdateClause();
+        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
+        assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
         
         OpenJPAEntityManager oem = (OpenJPAEntityManager)em;
         OpenJPAQuery<?> q = oem.createNamedQuery("findEmployeeById").setParameter("id",
0); 
@@ -88,8 +89,8 @@ public class TestNamedQueryLockMode exte
     
     public void testForUpdateClauseAbsentInQueryWithFetchPlanNoneLockMode() {
         OpenJPAEntityManagerSPI em = emf.createEntityManager();
-        em.getTransaction().begin();
-        
+        em.getTransaction().begin();        
+        lockClause = getForUpdateClause();
         OpenJPAQuery<?> q = em.createNamedQuery("findEmployeeById").setParameter("id",
0); 
         FetchPlan fp = q.getFetchPlan();
         fp.setReadLockMode(LockModeType.NONE);
@@ -107,6 +108,7 @@ public class TestNamedQueryLockMode exte
     public void testForUpdateClauseAbsentInQueryWithExplictNoLock() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+        lockClause = getForUpdateClause();
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithNoLock").setParameter("id",
0));
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithNoLock").setParameter("id",
0));
         em.getTransaction().commit();

Modified: openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestOptimisticNamedQueryLockMode.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestOptimisticNamedQueryLockMode.java?rev=1073527&r1=1073526&r2=1073527&view=diff
==============================================================================
--- openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestOptimisticNamedQueryLockMode.java
(original)
+++ openjpa/branches/2.1.x/openjpa-persistence-locking/src/test/java/org/apache/openjpa/persistence/lockmgr/TestOptimisticNamedQueryLockMode.java
Tue Feb 22 22:02:48 2011
@@ -39,7 +39,6 @@ public class TestOptimisticNamedQueryLoc
         super.setUp(CLEAR_TABLES, LockEmployee.class, 
             "openjpa.LockManager", "pessimistic"
             );
-         lockClause = getForUpdateClause();
     }
 
     /*
@@ -47,6 +46,7 @@ public class TestOptimisticNamedQueryLoc
      */
     public void testForUpdateClausePresentInNamedQueryWithLockMode() {
         EntityManager em = emf.createEntityManager();
+        lockClause = getForUpdateClause();
         em.getTransaction().begin();
         assertClausePresentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithLock").setParameter("id",
0));
         em.getTransaction().rollback();
@@ -65,6 +65,7 @@ public class TestOptimisticNamedQueryLoc
     public void testForUpdateClausePresentInQueryWithDefault() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+        lockClause = getForUpdateClause();
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeById").setParameter("id",
0));
         
@@ -83,7 +84,7 @@ public class TestOptimisticNamedQueryLoc
     public void testForUpdateClauseAbsentInQueryWithFetchPlanNoneLockMode() {
         OpenJPAEntityManagerSPI em = emf.createEntityManager();
         em.getTransaction().begin();
-        
+        lockClause = getForUpdateClause();        
         OpenJPAQuery<?> q = em.createNamedQuery("findEmployeeById").setParameter("id",
0); 
         FetchPlan fp = q.getFetchPlan();
         fp.setReadLockMode(LockModeType.NONE);
@@ -104,6 +105,7 @@ public class TestOptimisticNamedQueryLoc
     public void testForUpdateClauseAbsentInQueryWithExplictNoLock() {
         EntityManager em = emf.createEntityManager();
         em.getTransaction().begin();
+        lockClause = getForUpdateClause();
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithNoLock").setParameter("id",
0));
         assertClauseAbsentInSQL(lockClause, em.createNamedQuery("findEmployeeByIdWithNoLock").setParameter("id",
0));
         em.getTransaction().commit();



Mime
View raw message