openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r1128005 - /openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestQueryHints.java
Date Thu, 26 May 2011 17:52:24 GMT
Author: jrbauer
Date: Thu May 26 17:52:23 2011
New Revision: 1128005

URL: http://svn.apache.org/viewvc?rev=1128005&view=rev
Log:
OPENJPA-2007 jUnit for fetch plan isolation query hint validation.

Modified:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestQueryHints.java

Modified: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestQueryHints.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestQueryHints.java?rev=1128005&r1=1128004&r2=1128005&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestQueryHints.java
(original)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/conf/TestQueryHints.java
Thu May 26 17:52:23 2011
@@ -24,9 +24,10 @@ import javax.persistence.Query;
 import org.apache.openjpa.jdbc.sql.MySQLDictionary;
 import org.apache.openjpa.jdbc.sql.OracleDictionary;
 import org.apache.openjpa.kernel.QueryHints;
-import org.apache.openjpa.persistence.HintHandler;
 import org.apache.openjpa.persistence.OpenJPAPersistence;
 import org.apache.openjpa.persistence.OpenJPAQuery;
+import org.apache.openjpa.persistence.jdbc.IsolationLevel;
+import org.apache.openjpa.persistence.jdbc.JDBCFetchPlan;
 import org.apache.openjpa.persistence.test.SingleEMFTestCase;
 
 /**
@@ -38,7 +39,7 @@ import org.apache.openjpa.persistence.te
  */
 public class TestQueryHints extends SingleEMFTestCase {
     EntityManager em;
-    OpenJPAQuery query;
+    OpenJPAQuery<?> query;
     
     public void setUp() {
        super.setUp((Object[])null);
@@ -140,8 +141,6 @@ public class TestQueryHints extends Sing
         goodValue = "false";
         query.setHint(supportedKey, goodValue);
         assertTrue(query.getHints().containsKey(supportedKey));
-        assertEquals(false, query.getFetchPlan().getDelegate().getHint(
-                supportedKey));
     }
     
     public void testJPAHintSetsFetchPlan() {
@@ -169,6 +168,24 @@ public class TestQueryHints extends Sing
         }
     }
     
+    /**
+     * Verifies a valid fetchplan isolation level hint can be set and retrieved.
+     */
+    public void testFetchPlanIsolation() {
+        query.setHint("openjpa.FetchPlan.Isolation", "SERIALIZABLE");
+        assertTrue(query.getHints().containsKey("openjpa.FetchPlan.Isolation"));
+        assertEquals(IsolationLevel.SERIALIZABLE, ((JDBCFetchPlan)query.getFetchPlan()).getIsolation());
+    }
+
+    /**
+     * Verifies an invalid fetchplan isolation level hint is ignored.
+     */
+    public void testInvalidFetchPlanIsolation() {
+        query.setHint("openjpa.FetchPlan.TransactionIsolation", "SERIALIZABLE");
+        assertFalse(query.getHints().containsKey("openjpa.FetchPlan.TransactionIsolation"));
+        assertNotEquals(IsolationLevel.SERIALIZABLE, ((JDBCFetchPlan)query.getFetchPlan()).getIsolation());
       
+    }
+
     void assertSupportedHint(String hint, boolean contains) {
         if (contains)
             assertTrue("Expected supported hint [" + hint + "]",



Mime
View raw message