db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r695064 - in /db/jdo/trunk: api2/src/java/javax/jdo/Constants.java tck2/src/java/org/apache/jdo/tck/JDO_Test.java tck2/src/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java
Date Sat, 13 Sep 2008 23:27:36 GMT
Author: clr
Date: Sat Sep 13 16:27:36 2008
New Revision: 695064

URL: http://svn.apache.org/viewvc?rev=695064&view=rev
Log:
JDO-590 Prepare JDO_Test for isolation level

Modified:
    db/jdo/trunk/api2/src/java/javax/jdo/Constants.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java
    db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java

Modified: db/jdo/trunk/api2/src/java/javax/jdo/Constants.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/src/java/javax/jdo/Constants.java?rev=695064&r1=695063&r2=695064&view=diff
==============================================================================
--- db/jdo/trunk/api2/src/java/javax/jdo/Constants.java (original)
+++ db/jdo/trunk/api2/src/java/javax/jdo/Constants.java Sat Sep 13 16:27:36 2008
@@ -21,6 +21,7 @@
  * Constant values used in JDO.
  *
  * @since 2.1
+ * @version 2.2
  */
 public interface Constants {
 
@@ -611,6 +612,53 @@
     static String PROPERTY_MULTITHREADED
         = "javax.jdo.option.Multithreaded";
     /**
+     * "javax.jdo.option.TransactionIsolationLevel"
+     *
+     * @since 2.2
+     */
+    static String PROPERTY_TRANSACTION_ISOLATION_LEVEL
+        = "javax.jdo.option.TransactionIsolationLevel";
+    /**
+     * "javax.jdo.option.TransactionIsolationLevel.read-uncommitted"
+     *
+     * @see PersistenceManagerFactory#supportedOptions()
+     * @since 2.2
+     */
+    static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_UNCOMMITTED
+        = "javax.jdo.option.TransactionIsolationLevel.read-uncommitted";
+    /**
+     * "javax.jdo.option.TransactionIsolationLevel.read-committed"
+     *
+     * @see PersistenceManagerFactory#supportedOptions()
+     * @since 2.2
+     */
+    static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_READ_COMMITTED
+        = "javax.jdo.option.TransactionIsolationLevel.read-committed";
+    /**
+     * "javax.jdo.option.TransactionIsolationLevel.repeatable-read"
+     *
+     * @see PersistenceManagerFactory#supportedOptions()
+     * @since 2.2
+     */
+    static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_REPEATABLE_READ
+        = "javax.jdo.option.TransactionIsolationLevel.repeatable-read";
+    /**
+     * "javax.jdo.option.TransactionIsolationLevel.snapshot"
+     *
+     * @see PersistenceManagerFactory#supportedOptions()
+     * @since 2.2
+     */
+    static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_SNAPSHOT
+        = "javax.jdo.option.TransactionIsolationLevel.snapshot";
+    /**
+     * "javax.jdo.option.TransactionIsolationLevel.serializable"
+     *
+     * @see PersistenceManagerFactory#supportedOptions()
+     * @since 2.2
+     */
+    static String PROPERTY_TRANSACTION_ISOLATION_LEVEL_SERIALIZABLE
+        = "javax.jdo.option.TransactionIsolationLevel.serializable";
+    /**
      * "javax.jdo.option.DetachAllOnCommit"
      *
      * @see PersistenceManagerFactory#getDetachAllOnCommit()
@@ -877,5 +925,50 @@
      */
     static String ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME
         = "";
-}
 
+    /**
+     * Transaction isolation level representing the ability to read
+     * uncommitted data.
+     * @see PersistenceManagerFactory#getTransactionIsolationLevel()
+     * @see Transaction#getIsolationLevel()
+     * @since 2.2
+     */
+    public static final String TX_READ_UNCOMMITTED = "read-uncommitted"; 
+
+    /**
+     * Transaction isolation level representing the requirement to read
+     * committed data only.
+     * @see PersistenceManagerFactory#getTransactionIsolationLevel()
+     * @see Transaction#getIsolationLevel()
+     * @since 2.2
+     */
+    public static final String TX_READ_COMMITTED = "read-committed"; 
+
+    /**
+     * Transaction isolation level representing the requirement to read
+     * the same data in the same transaction.
+     * @see PersistenceManagerFactory#getTransactionIsolationLevel()
+     * @see Transaction#getIsolationLevel()
+     * @since 2.2
+     */
+    public static final String TX_REPEATABLE_READ = "repeatable-read"; 
+
+    /**
+     * Transaction isolation level representing the requirement to keep
+     * a snapshot for reading data.
+     * @see PersistenceManagerFactory#getTransactionIsolationLevel()
+     * @see Transaction#getIsolationLevel()
+     * @since 2.2
+     */
+    public static final String TX_SNAPSHOT = "snapshot"; 
+
+    /**
+     * Transaction isolation level representing the requirement to serialize
+     * transactions.
+     * @see PersistenceManagerFactory#getTransactionIsolationLevel()
+     * @see Transaction#getIsolationLevel()
+     * @since 2.2
+     */
+    public static final String TX_SERIALIZABLE = "serializable"; 
+
+}

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java?rev=695064&r1=695063&r2=695064&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/JDO_Test.java Sat Sep 13 16:27:36 2008
@@ -34,13 +34,16 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
+import javax.jdo.Constants;
 import javax.jdo.Extent;
 import javax.jdo.JDOException;
 import javax.jdo.JDOFatalException;
@@ -166,6 +169,16 @@
     /** identitytype value for datastoreidentity. */
     public static final String DATASTORE_IDENTITY = "datastoreidentity";
 
+    /** Map of transaction isolation String values to Integer */
+    protected final static Map levelValues = new HashMap();
+    static {
+        levelValues.put(Constants.TX_READ_UNCOMMITTED, 0);
+        levelValues.put(Constants.TX_READ_COMMITTED, 1);
+        levelValues.put(Constants.TX_REPEATABLE_READ, 2);
+        levelValues.put(Constants.TX_SNAPSHOT, 3);
+        levelValues.put(Constants.TX_SERIALIZABLE, 4);
+    }
+
     /** 
      * String indicating the type of identity used for the current test case.
      * The value is either "applicationidentity" or "datastoreidentity".
@@ -200,7 +213,7 @@
     protected static PersistenceManagerFactory pmf;
     
     /** The collection of supported options of the pmf. */
-    private static Collection supportedOptions;
+    protected static Collection supportedOptions;
 
     /** The name of the pmf supported options summary file. */
     private static final String PMF_SUPPORTED_OPTIONS_FILE_NAME = "pmf_supported_options.txt";
@@ -716,152 +729,152 @@
 
     /** Reports whether TransientTransactional is supported. */
     public boolean isTransientTransactionalSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.TransientTransactional");
     }
     
     /** Reports whether NontransactionalRead is supported. */
     public boolean isNontransactionalReadSupported(){
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.NontransactionalRead");
     }
     
     /** Reports whether NontransactionalWrite is supported. */
     public boolean isNontransactionalWriteSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.NontransactionalWrite");
     }
 
     /** Reports whether RetainValues is supported. */
     public boolean isRetainValuesSupported()
     {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.RetainValues");
     }
 
     /** Reports whether Optimistic is supported. */
     public boolean isOptimisticSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.Optimistic");
     }
 
     /** Reports whether Application Identity is supported. */
     public boolean isApplicationIdentitySupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.ApplicationIdentity");
     }
 
     /** Reports whether Datastore Identity is supported. */
     public boolean isDatastoreIdentitySupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.DatastoreIdentity");
     }
 
     /** Reports whether Non-Durable Identity is supported. */
     public boolean isNonDurableIdentitySupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.NonDurableIdentity");
     }
 
     /** Reports whether an <code>ArrayList</code> collection is supported. */
     public boolean isArrayListSupported() {        
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.ArrayList");
     }
 
     /** Reports whether a <code>HashMap</code> collection is supported. */
     public boolean isHashMapSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.HashMap");
     }
 
     /** Reports whether a <code>Hashtable</code> collection is supported. */
     public boolean isHashtableSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.Hashtable");
     }
 
     /** Reports whether a <code>LinkedList</code> collection is supported. */
     public boolean isLinkedListSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.LinkedList");
     }
 
     /** Reports whether a <code>TreeMap</code> collection is supported. */
     public boolean isTreeMapSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.TreeMap");
     }
 
     /** Reports whether a <code>TreeSet</code> collection is supported. */
     public boolean isTreeSetSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.TreeSet");
     }
 
     /** Reports whether a <code>Vector</code> collection is supported. */
     public boolean isVectorSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.Vector");
     }
 
     /** Reports whether a <code>Map</code> collection is supported. */
     public boolean isMapSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.Map");
     }
 
     /** Reports whether a <code>List</code> collection is supported. */
     public boolean isListSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.List");
     }
 
     /** Reports whether arrays are supported. */
     public boolean isArraySupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.Array");
     }
 
     /** Reports whether a null collection is supported. */
     public boolean isNullCollectionSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.NullCollection");
     }
 
     /** Reports whether Changing Application Identity is supported. */
     public boolean isChangeApplicationIdentitySupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.ChangeApplicationIdentity");
     }
 
     /** Reports whether Binary Compatibility is supported. */
     public boolean isBinaryCompatibilitySupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.BinaryCompatibility");
     }
 
     /** Reports whether UnconstrainedVariables is supported. */
     public boolean isUnconstrainedVariablesSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.UnconstrainedVariables");
     }
     
     /** Reports whether SQL queries are supported. */
     public boolean isSQLSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.query.SQL");
     }
     
     /** Reports whether getting the DataStoreConnection is supported. */
     public boolean isDataStoreConnectionSupported() {
-        return getPMF().supportedOptions().contains(
+        return supportedOptions.contains(
             "javax.jdo.option.GetDataStoreConnection");
     }
 
     /** Reports whether a feature is supported */
     public boolean isSupported(String option) {
-        return getPMF().supportedOptions().contains(option);
+        return supportedOptions.contains(option);
     }
 
     /**
@@ -1082,7 +1095,7 @@
     protected boolean isTestToBePerformed() {
         boolean isTestToBePerformed = true;
         String requiredOptions = System.getProperty("jdo.tck.requiredOptions");
-        Collection supportedOptions = getPMF().supportedOptions();
+//        Collection supportedOptions = supportedOptions;
         StringTokenizer tokenizer = new StringTokenizer(
                 requiredOptions, " ,;\n\r\t");
         while (tokenizer.hasMoreTokens()) {
@@ -1147,4 +1160,12 @@
             fail (errors);
         }
     }
+
+    /** Validate an actual isolation level against the requested level. */
+    protected boolean validLevelSubstitution(String requested, String actual) {
+        int requestedLevel = ((Integer)levelValues.get(requested)).intValue();
+        int actualLevel = ((Integer)levelValues.get(actual)).intValue();
+        return actualLevel >= requestedLevel;
+    }
+
 }

Modified: db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java?rev=695064&r1=695063&r2=695064&view=diff
==============================================================================
--- db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java
(original)
+++ db/jdo/trunk/tck2/src/java/org/apache/jdo/tck/query/jdoql/ComparingCollectionFieldToNull.java
Sat Sep 13 16:27:36 2008
@@ -69,12 +69,7 @@
     /** 
      * The expected results of valid queries.
      */
-    private Object[] expectedResult = {
-        // emp1 should be in the query result set,
-        // if the JDO Implentation supports null values for Collections
-        getTransientCompanyModelInstancesAsList(
-            isNullCollectionSupported() ? new String[]{"emp1"} : new String[]{})
-    };
+    private Object[] expectedResult;
     
     /**
      * The <code>main</code> is called when the class
@@ -102,6 +97,13 @@
         addTearDownClass(CompanyModelReader.getTearDownClasses());
         loadAndPersistCompanyModel(getPM());
         Employee employee = (Employee) getPersistentCompanyModelInstance("emp1");
+        expectedResult = new Object[] {
+            // emp1 should be in the query result set,
+            // if the JDO Implentation supports null values for Collections
+            getTransientCompanyModelInstancesAsList(
+                isNullCollectionSupported() ? 
+                    new String[]{"emp1"} : new String[]{})
+        };
         if (isNullCollectionSupported()) {
             getPM().currentTransaction().begin();
             employee.setProjects(null);



Mime
View raw message