db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r429480 - in /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck: ./ api/persistencemanagerfactory/
Date Mon, 07 Aug 2006 21:15:43 GMT
Author: mbo
Date: Mon Aug  7 14:15:42 2006
New Revision: 429480

URL: http://svn.apache.org/viewvc?rev=429480&view=rev
Log:
JDO-394: cleanup pmf test cases

Modified:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java Mon Aug  7 14:15:42 2006
@@ -143,6 +143,22 @@
         {   false,          false,              true,       false,      false,        true}
     };
   
+    /** Name of the PersistenceManagerFactoryClass PMF property. */
+    public static final String PMF_CLASS_PROP = 
+        "javax.jdo.PersistenceManagerFactoryClass";
+
+    /** Name of the ConnectionURL PMF property. */
+    public static final String CONNECTION_URL_PROP = 
+        "javax.jdo.option.ConnectionURL";
+
+    /** Name of the ConnectionUserName PMF property. */
+    public static final String CONNECTION_USERNAME_PROP = 
+        "javax.jdo.option.ConnectionUserName";
+
+    /** Name of the ConnectionPassword PMF property. */
+    public static final String CONNECTION_PASSWORD_PROP = 
+        "javax.jdo.option.ConnectionPassword";
+
     /** identitytype value for applicationidentity. */
     public static final String APPLICATION_IDENTITY = "applicationidentity";
 
@@ -458,6 +474,40 @@
             pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
             if (supportedOptions == null) {
                 supportedOptions = pmf.supportedOptions();
+            }
+        }
+        return pmf;
+    }
+
+    /**
+     * Get the <code>PersistenceManagerFactory</code> instance 
+     * for the implementation under test. This method does NOT use the
+     * JDOHelper method to retrieve the PMF, instead it creates an instance of
+     * the class specified as javax.jdo.PersistenceManagerFactoryClass
+     * property. The returned PMF is not configured. 
+     * @return field <code>pmf</code> if it is not <code>null</code>, 
+     * else sets field <code>pmf</code> to a new instance and returns that instance.
+     */
+    protected PersistenceManagerFactory getUnconfiguredPMF()
+    {
+        if (pmf == null) {
+            PMFPropertiesObject = loadProperties(PMFProperties); // will exit here if no properties
+            String name = PMFPropertiesObject.getProperty(PMF_CLASS_PROP);
+            try {
+                Class pmfClass = Class.forName(name);
+                pmf = (PersistenceManagerFactory) pmfClass.newInstance();
+                if (supportedOptions == null) {
+                    supportedOptions = pmf.supportedOptions();
+                }
+            } catch (ClassNotFoundException ex) {
+                throw new JDOException("Cannot find PMF class '" + name + "'.",
+                                       ex);
+            } catch (InstantiationException ex) {
+                throw new JDOException("Cannot instantiate PMF class '" + 
+                                       name + "'.", ex);
+            } catch (IllegalAccessException ex) {
+                throw new JDOException("Cannot access PMF class '" + name + 
+                                       "' or its no-arg constructor.", ex);
             }
         }
         return pmf;

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,17 +38,15 @@
  *<B>Assertion ID:</B> A11.3-3.
  *<BR>
  *<B>Assertion Description: </B>
-After the first use of <code>PersistenceManagerFactory.getPersistenceManager()</code>,
-none of the <code>set</code> methods will succeed.
-
+ * After the first use of
+ * <code>PersistenceManagerFactory.getPersistenceManager()</code>, 
+ * none of the <code>set</code> methods will succeed.
  */
 
 public class AfterGetPersistenceManagerNoSetMethodsSucceed extends JDO_Test {
 
     private String username;
     private String password;
-    private static final String USERNAME_PROPERTY = "javax.jdo.option.ConnectionUserName";
-    private static final String PASSWORD_PROPERTY = "javax.jdo.option.ConnectionPassword";
 
     private Class[] stringParameters = null;
     private Class[] booleanParameters = null;
@@ -72,7 +70,7 @@
 
     /** */
     public AfterGetPersistenceManagerNoSetMethodsSucceed() {
-		super();
+        super();
         initVariables();
     }
 
@@ -123,19 +121,19 @@
     /** */
     public void testGetPersistenceManagerWithParameters() {
         Properties props = loadProperties(PMFProperties);
-        username = props.getProperty(USERNAME_PROPERTY);  
-        password = props.getProperty(PASSWORD_PROPERTY);  
+        username = props.getProperty(CONNECTION_USERNAME_PROP);  
+        password = props.getProperty(CONNECTION_PASSWORD_PROP);  
         runTest(true);
     }
 
-	/** */
+    /** */
     public void runTest(boolean bUserAndPasswd) {       
         pmf = getPMF();
         if (!bUserAndPasswd)
             pm = getPM();
         else
-            pm = getPMF().getPersistenceManager(username,password);	
-	
+            pm = getPMF().getPersistenceManager(username,password);
+
         // each set method should throw an exception
         Collection setCollection = Arrays.asList(setMethods);
         for (Iterator it = setCollection.iterator(); it.hasNext();) {

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,10 +16,7 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
 import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.util.BatchTestRunner;
@@ -34,16 +31,8 @@
  *<BR>
  *<B>Assertion Description: </B>
  * PersistenceManagerFactory.getPersistenceManager() returns a
-PersistenceManager instance with the configured properties and the
-default values for option settings. 
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/22/01
- *
+ * PersistenceManager instance with the configured properties and the
+ * default values for option settings. 
  */
 
 public class GetPersistenceManager extends JDO_Test {
@@ -61,41 +50,28 @@
         BatchTestRunner.run(GetPersistenceManager.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        super.setUp();
+    }
 
+    /** */
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-        
+        PersistenceManager pm = null;
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setConnectionURL(url);
-            pmf.setConnectionUserName(username);
-            pmf.setConnectionPassword(password);
-            pm  = pmf.getPersistenceManager();
-        }
-        catch (Exception ex) {
-        	fail(ASSERTION_FAILED,
-                 "unexpected exception " + ex);
+            pm = pmf.getPersistenceManager();
+            if (pm == null) {
+                fail(ASSERTION_FAILED, "pmf.getPersistenceManager should " + 
+                     "return a non-null value.");
+            }
         }
         finally { 
-            if (debug) logger.debug("Persistence Manager obtained: " + pm); 
-            if (pm != null) pm.close();
+            if ((pm != null) && !pm.isClosed()) {
+                pm.close();
+            }
+            closePMF();
         }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -34,8 +34,10 @@
  *<B>Assertion IDs:</B> A11.1-32
  *<BR>
  *<B>Assertion Description: </B>
- * An implementation must provide a method to construct a PersistenceManagerFactory by a Properties instance.
- * This static method is called by the JDOHelper method getPersistenceManagerFactory (Properties props).
+ * An implementation must provide a method to construct a
+ * PersistenceManagerFactory by a Properties instance. This static method is
+ * called by the JDOHelper method getPersistenceManagerFactory (Properties
+ * props). 
  */
 
 
@@ -54,6 +56,15 @@
         BatchTestRunner.run(GetPersistenceManagerFactoryByPropertiesInstance.class);
     }
 
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        PMFPropertiesObject = loadProperties(PMFProperties);
+        pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
+        localSetUp();
+    }
+
     /**
      * @see JDO_Test#localSetUp()
      */
@@ -63,14 +74,15 @@
 
     /** */
     public void test() {
-        PMFPropertiesObject = loadProperties(PMFProperties);
-        pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
         //Try to get a PersistenceManager and begin and commit a transaction
-        pm = pmf.getPersistenceManager();
+        pm = getPM();
         Transaction tx = pm.currentTransaction();
         tx.begin();
-        Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","",""));
+        Company comp = new Company(1L, "Sun Microsystems", new Date(), 
+                                   new Address(0,"","","","",""));
         pm.makePersistent(comp);
         tx.commit();
+        pm.close();
+        pm = null;
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,8 +18,8 @@
 
 import java.util.Properties;
 
+import javax.jdo.JDOHelper;
 import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.util.BatchTestRunner;
@@ -34,16 +34,8 @@
  *<BR>
  *<B>Assertion Description: </B>
  * PersistenceManagerFactory.getPersistenceManager(String userid,
-String password) returns a PersistenceManager instance with the
-configured properties and the default values for option settings. 
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/22/01
- *
+ * String password) returns a PersistenceManager instance with the
+ * configured properties and the default values for option settings. 
  */
 
 public class GetPersistenceManagerForUser extends JDO_Test {
@@ -52,6 +44,12 @@
     private static final String ASSERTION_FAILED = 
         "Assertion A11.3-2 (GetPersistenceManagerForUser) failed: ";
     
+    /** The value of the ConnectionUserName property. */
+    private String username;
+
+    /** The value of the ConnectionPassword property. */
+    private String password;
+
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -60,39 +58,34 @@
     public static void main(String[] args) {
         BatchTestRunner.run(GetPersistenceManagerForUser.class);
     }
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
 
     /** */
-    public void test() {
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
         Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
+        username = (String)props.remove(CONNECTION_USERNAME_PROP);
+        password = (String)props.remove(CONNECTION_PASSWORD_PROP);
+        pmf = JDOHelper.getPersistenceManagerFactory(props);
+    }
 
+    /** */
+    public void test() {
+        PersistenceManager pm = null;
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setConnectionURL(url);
-            pm  = pmf.getPersistenceManager(username, password);
-        } 
-        catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "unexpected exception " + ex);
+            pm = pmf.getPersistenceManager(username, password);
+            if (pm == null) {
+                fail(ASSERTION_FAILED, 
+                     "pmf.getPersistenceManager(user, password) should " + 
+                     "return a non-null value.");
+            }
         }
         finally { 
-            if (debug) logger.debug("Persistence Manager obtained: " + pm); 
-            if (pm != null) pm.close();
+            if ((pm != null) && !pm.isClosed()) {
+                pm.close();
+            }
+            closePMF();
         }
     }
+    
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,11 +16,6 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
@@ -33,8 +28,8 @@
  *<B>Assertion IDs:</B> A11.1-15.
  *<BR>
  *<B>Assertion Description: </B>
- * PersistenceManagerFactory.setConnectionPassword(String
-password) sets the value of the ConnectionPassword property (the password for the user)
+ * PersistenceManagerFactory.setConnectionPassword(String password) sets the
+ * value of the ConnectionPassword property (the password for the user) 
  */
 
 public class SetConnectionPassword extends JDO_Test {
@@ -43,6 +38,9 @@
     private static final String ASSERTION_FAILED = 
         "Assertion A11.1-15 (SetConnectionPassword) failed: ";
     
+    /** The value of the ConnectionPassword property. */
+    private String password;
+
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -52,33 +50,22 @@
         BatchTestRunner.run(SetConnectionPassword.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
-    /** set ConnectionPassword */ 
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+        password = getPMFProperty(CONNECTION_PASSWORD_PROP);
+    }
+    
+    /** 
+     * Set ConnectionPassword.
+     */
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-        
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
             pmf.setConnectionPassword(password);
-        } catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting ConnectionPassword " + ex);
-        } 
+        } finally {
+            closePMF();
+        }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,10 +16,7 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.JDOException;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.util.BatchTestRunner;
@@ -33,8 +30,10 @@
  *<B>Assertion IDs:</B> A11.1-16,A11.1-17.
  *<BR>
  *<B>Assertion Description: </B>
- * PersistenceManagerFactory.setConnectionURL(String URL) sets the value of the ConnectionURL property (the URL for the data source).
- * PersistenceManagerFactory.getConnectionURL() returns the value of the ConnectionURL property. 
+ * PersistenceManagerFactory.setConnectionURL(String URL) sets the value of
+ * the ConnectionURL property (the URL for the data source). 
+ * PersistenceManagerFactory.getConnectionURL() returns the value of the
+ * ConnectionURL property.
  */
 
 public class SetConnectionURL extends JDO_Test {
@@ -43,6 +42,9 @@
     private static final String ASSERTION_FAILED = 
         "Assertion A11.1-16,A11.1-17 (SetConnectionURL) failed: ";
     
+    /** The value of the ConnectionURL property. */
+    private String url;
+
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -52,42 +54,30 @@
         BatchTestRunner.run(SetConnectionURL.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
- 
-    /** set ConnectionURL value and get ConnectionURL value to verify */ 
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+        url = getPMFProperty(CONNECTION_URL_PROP);
+    }
+    
+    /** Set ConnectionURL value and get ConnectionURL value to verify. */ 
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
+            if (url == null) {
+                throw new JDOException(
+                    "Missing PMF property " + CONNECTION_URL_PROP);
+            }
             pmf.setConnectionURL(url);
             if (!url.equals(pmf.getConnectionURL())) {
                 fail(ASSERTION_FAILED,
-                     "ConnectionURL " + url + 
-                     " not equal to value returned by PMF " +
-                     pmf.getConnectionURL());
+                     "ConnectionURL set to '" + url + "' ," +
+                     "value returned by PMF is '" +
+                     pmf.getConnectionURL() + "'.");
             }
+        } finally {
+            closePMF();
         }
-        catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting ConnectionURL" + ex);
-        }
-        if (debug) logger.debug("ConnectionURL: " + pmf.getConnectionURL()); 
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,10 +16,7 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.JDOException;
 
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.util.BatchTestRunner;
@@ -33,8 +30,9 @@
  *<B>Assertion IDs:</B> A11.1-13,A11.1-14.
  *<BR>
  *<B>Assertion Description: </B>
-PersistenceManagerFactory.setConnectionUserName(String name) sets the
-value of the ConnectionUserName property (the name of the user establishing the connection). 
+ * PersistenceManagerFactory.setConnectionUserName(String name) sets the value
+ * of the ConnectionUserName property (the name of the user establishing the
+ * connection).
  */
 
 public class SetConnectionUserName extends JDO_Test {
@@ -43,6 +41,9 @@
     private static final String ASSERTION_FAILED = 
         "Assertions A11.1-13,A11.1-14 (SetConnectionUserName) failed: ";
     
+    /** The value of the ConnectionUserName property. */
+    private String username;
+
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -52,36 +53,29 @@
         BatchTestRunner.run(SetConnectionUserName.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
-
-    /** set ConnectionUserName value and get ConnectionUserName value to verify */ 
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+        username = getPMFProperty(CONNECTION_USERNAME_PROP);
+    }
+    
+    /** 
+     * Set ConnectionUserName value and get ConnectionUserName value to verify.
+     */ 
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
+            if (username == null) {
+                throw new JDOException(
+                    "Missing PMF property " + CONNECTION_USERNAME_PROP);
+            }
             pmf.setConnectionUserName(username);
             if (!username.equals(pmf.getConnectionUserName())) {
                 fail(ASSERTION_FAILED,
-                     "ConnectionUserName " + username + 
-                     " not equal to value returned by PMF " +
-                     pmf.getConnectionUserName());
+                     "ConnectionUserName set to '" + username + "' ," + 
+                     "value returned by PMF is '" + 
+                     pmf.getConnectionUserName() + "'.");
             }
         } 
         catch (Exception ex) {

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.jdo.tck.JDO_Test;
@@ -32,16 +29,9 @@
  *<B>Assertion IDs:</B> A11.1-5.
  *<BR>
  *<B>Assertion Description: </B>
-PersistenceManagerFactory.setIgnoreCache(boolean flag) sets the value of the IgnoreCache property (the query mode that specifies whether cached instances are considered when evaluating the filter expression). 
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/15/01
- * Version  :     1.0
- *
+ * PersistenceManagerFactory.setIgnoreCache(boolean flag) sets the value of
+ * the IgnoreCache property (the query mode that specifies whether cached
+ * instances are considered when evaluating the filter expression).
  */
 
 public class SetIgnoreCache extends JDO_Test {
@@ -59,45 +49,32 @@
         BatchTestRunner.run(SetIgnoreCache.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+    }
 
-    /** set IgnoreCache to true or false and use getIgnoreCache value to verify */ 
+    /** 
+     * Set IgnoreCache to true or false and use getIgnoreCache value to verify.
+     */ 
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setIgnoreCache(false);
-            if (pmf.getIgnoreCache() != false) {
-                fail(ASSERTION_FAILED,
-                     "IgnoreCache set to false, value returned by PMF is " +
-                     pmf.getIgnoreCache());
-            }
-            pmf.setIgnoreCache(true);
-            if (pmf.getIgnoreCache() != true) {
-                fail(ASSERTION_FAILED,
-                     "IgnoreCache set to true, value returned by PMF is " +
-                     pmf.getIgnoreCache());
-            }
-        } catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting IgnoreCache" + ex);
+            setIgnoreCache(false);
+            setIgnoreCache(true);
+        } finally {
+            closePMF();
+        }
+    }
+
+    /** */
+    private void setIgnoreCache(boolean newValue) {
+        pmf.setIgnoreCache(newValue);
+        boolean current = pmf.getIgnoreCache();
+        if (current != newValue) {
+            fail(ASSERTION_FAILED, "IgnoreCache set to " + newValue + 
+                 ", value returned by PMF is " + current);
         }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,16 +33,9 @@
  *<B>Assertion IDs:</B> A11.1-11,A11.1-12.
  *<BR>
  *<B>Assertion Description: </B>
- *PersistenceManagerFactory.setMultithreaded(boolean flag) sets the value of the Multithreaded flag that indicates that the application will invoke methods or access fields of managed instances from multiple threads. 
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/15/01
- * Version  :     1.0
- *
+ * PersistenceManagerFactory.setMultithreaded(boolean flag) sets the value of
+ * the Multithreaded flag that indicates that the application will invoke
+ * methods or access fields of managed instances from multiple threads.
  */
 
 public class SetMultithreaded extends JDO_Test {
@@ -60,45 +53,33 @@
         BatchTestRunner.run(SetMultithreaded.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+    }
 
-    /** set Multithreaded to true or false and use getMultithreaded value to verify */ 
+    /** 
+     * Set Multithreaded to true or false and use getMultithreaded value to
+     * verify.
+     */ 
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setMultithreaded(true);
-            if (pmf.getMultithreaded() != true) {
-                fail(ASSERTION_FAILED,
-                     "Multithreaded set to true, value returned by PMF is " +
-                     pmf.getMultithreaded());
-            }
-            pmf.setMultithreaded(false);
-            if (pmf.getMultithreaded() != false) {
-                fail(ASSERTION_FAILED,
-                     "Multithreaded set to false, value returned by PMF is " +
-                     pmf.getMultithreaded());
-            }
-        } 
-        catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting Multithreaded " + ex);
+            setMultithreaded(false);
+            setMultithreaded(true);
+        } finally {
+            closePMF();
+        }
+    }
+
+    /** */
+    private void setMultithreaded(boolean newValue) {
+        pmf.setMultithreaded(newValue);
+        boolean current = pmf.getMultithreaded();
+        if (current != newValue) {
+            fail(ASSERTION_FAILED, "Multithreaded set to " + newValue + 
+                 ", value returned by PMF is " + current);
         }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.jdo.tck.JDO_Test;
@@ -33,16 +30,9 @@
  *<B>Assertion IDs:</B> A11.1-7,A11.1-8.
  *<BR>
  *<B>Assertion Description: </B>
- *PersistenceManagerFactory.setNontransactionalRead(boolean flag) sets the value of the NontransactionalRead property (the PersistenceManager mode that allows instances to be read outside a transaction). 
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/15/01
- * Version  :     1.0
- *
+ * PersistenceManagerFactory.setNontransactionalRead(boolean flag) sets the
+ * value of the NontransactionalRead property (the PersistenceManager mode
+ * that allows instances to be read outside a transaction).
  */
 
 public class SetNonTransactionalRead extends JDO_Test {
@@ -60,46 +50,33 @@
         BatchTestRunner.run(SetNonTransactionalRead.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+    }
 
-    /** set NonTransactionalRead to true or false and use getNonTransactionalRead value to verify */ 
+    /** 
+     * Set NonTransactionalRead to true or false and use
+     * getNonTransactionalRead value to verify.
+     */
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setNontransactionalRead(false);
-            if (pmf.getNontransactionalRead() != false) {
-                fail(ASSERTION_FAILED,
-                     "NonTransactionalRead set to false, value returned by PMF is " +
-                     pmf.getNontransactionalRead());
-            }
-            pmf.setNontransactionalRead(true);
-            if (pmf.getNontransactionalRead() != true) {
-                fail(ASSERTION_FAILED,
-                     "NonTransactionalRead set to true, value returned by PMF is " +
-                     pmf.getNontransactionalRead());
-            }
-        } 
-        catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting NonTransactionalRead " + ex);
+            setNontransactionalRead(false);
+            setNontransactionalRead(true);
+        } finally {
+            closePMF();
+        }
+    }
+
+    /** */
+    private void setNontransactionalRead(boolean newValue) {
+        pmf.setNontransactionalRead(newValue);
+        boolean current = pmf.getNontransactionalRead();
+        if (current != newValue) {
+            fail(ASSERTION_FAILED, "NonTransactionalRead set to " + newValue + 
+                 ", value returned by PMF is " + current);
         }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.jdo.tck.JDO_Test;
@@ -33,16 +30,9 @@
  *<B>Assertion IDs:</B> A11.1-9,A11.1-10.
  *<BR>
  *<B>Assertion Description: </B>
- * PersistenceManagerFactory.setNontransactionalWrite(boolean flag) sets the value of the NontransactionalWrite property (the PersistenceManager mode that allows instances to be written outside a transaction).
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/15/01
- * Version  :     1.0
- *
+ * PersistenceManagerFactory.setNontransactionalWrite(boolean flag) sets the
+ * value of the NontransactionalWrite property (the PersistenceManager mode
+ * that allows instances to be written outside a transaction).
  */
 
 public class SetNonTransactionalWrite extends JDO_Test {
@@ -60,51 +50,39 @@
         BatchTestRunner.run(SetNonTransactionalWrite.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
-
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+    }
 
-    /** set NonTransactionalWrite to true or false and use getNonTransactionalWrite value to verify */ 
+    /** Set NonTransactionalWrite to true or false and use
+     * getNonTransactionalWrite value to verify.
+     */
     public void test () {
         if (!isNontransactionalWriteSupported()) {
-            if (debug)
-                logger.debug("\n SetNonTransactionalWrite() passed: this implementation does not support NontransactionalWrite.");
+            printUnsupportedOptionalFeatureNotTested(
+                "org.apache.jdo.tck.api.persistencemanagerfactory.SetNonTransactionalWrite", 
+                "javax.jdo.option.NontransactionalWrite");
             return;
         }
        
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setNontransactionalWrite(false);
-            if (pmf.getNontransactionalWrite() != false) {
-                fail(ASSERTION_FAILED,
-                     "NonTransactionalWrite set to false, value returned by PMF is " +
-                     pmf.getNontransactionalWrite());
-            }
-            pmf.setNontransactionalWrite(true);
-            if (pmf.getNontransactionalWrite() != true) {
-                fail(ASSERTION_FAILED,
-                     "NonTransactionalWrite set to true, value returned by PMF is " +
-                     pmf.getNontransactionalWrite());
-            }
-        } catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting NonTransactionalWrite " + ex);
+            setNontransactionalWrite(false);
+            setNontransactionalWrite(true);
+        } finally {
+            closePMF();
+        }
+    }
+
+    /** */
+    private void setNontransactionalWrite(boolean newValue) {
+        pmf.setNontransactionalWrite(newValue);
+        boolean current = pmf.getNontransactionalWrite();
+        if (current != newValue) {
+            fail(ASSERTION_FAILED, "NonTransactionalWrite set to " + newValue + 
+                 ", value returned by PMF is " + current);
         }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,11 +16,6 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
 import org.apache.jdo.tck.JDO_Test;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
@@ -33,8 +28,10 @@
  *<B>Assertion IDs:</B> A11.1-1, A11.1-2.
  *<BR>
  *<B>Assertion Description: </B>
-  PersistenceManagerFactory.getOptimistic() returns Value of the Optimistic property,persistenceManagerFactory.setOptimistic(boolean flag) sets
-the value of the Optimistic property (the transaction mode that specifies concurrency control 
+ * PersistenceManagerFactory.getOptimistic() returns Value of the Optimistic
+ * property,persistenceManagerFactory.setOptimistic(boolean flag) sets the
+ * value of the Optimistic property (the transaction mode that specifies
+ * concurrency control.
  */
 
 public class SetOptimistic extends JDO_Test {
@@ -52,51 +49,37 @@
         BatchTestRunner.run(SetOptimistic.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+    }
 
-    /** set Optimistic to true or false and use getOptimistic value to verify */ 
+    /** Set Optimistic to true or false and use getOptimistic value to verify. */ 
     public void test() {
         if (!isOptimisticSupported()) {
-            if (debug)
-                logger.debug("\n SetOptimistic() passed: this implementation does not support Optimistic.");
+            printUnsupportedOptionalFeatureNotTested(
+                "org.apache.jdo.tck.api.persistencemanagerfactory.SetOptimistic", 
+                "javax.jdo.option.Optimistic");
             return;
         }
        
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setOptimistic(false);
-            if (pmf.getOptimistic() != false) {
-                fail(ASSERTION_FAILED,
-                     "Optimistic set to false, value returned by PMF is " +
-                     pmf.getOptimistic());
-            }
-            pmf.setOptimistic(true);
-            if (pmf.getOptimistic() != true) {
-                fail(ASSERTION_FAILED,
-                     "Optimistic set to true, value returned by PMF is " +
-                     pmf.getOptimistic());
-            }
-        } 
-        catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting Optimistic " + ex);
+            setOptimistic(false);
+            setOptimistic(true);
+        } finally {
+            closePMF();
+        }
+    }
+
+    /** */
+    private void setOptimistic(boolean newValue) {
+        pmf.setOptimistic(newValue);
+        boolean optimistic = pmf.getOptimistic();
+        if (optimistic != newValue) {
+            fail(ASSERTION_FAILED, "Optimistic set to " + newValue + 
+                 ", value returned by PMF is " + optimistic);
         }
     }
 }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java?rev=429480&r1=429479&r2=429480&view=diff
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java Mon Aug  7 14:15:42 2006
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005 The Apache Software Foundation.
+ * Copyright 2005-2006 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,9 +16,6 @@
  
 package org.apache.jdo.tck.api.persistencemanagerfactory;
 
-import java.util.Properties;
-
-import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
 
 import org.apache.jdo.tck.JDO_Test;
@@ -32,18 +29,11 @@
  *<B>Assertion IDs:</B> A11.1-3,A11.1-4.
  *<BR>
  *<B>Assertion Description: </B>
- * PersistenceManagerFactory.setRetainValues(boolean flag) sets the value of the RetainValues property (the transaction mode that specifies the treatment of persistent instances after commit),
-PersistenceManagerFactory.getRetainValues() returns the value of the
-RetainValues property.
- */
-
-/* 
- * Revision History
- * ================
- * Author         :   Linga Neerathilingam
- * Date   :  10/18/01
- * Version  :     1.0
- *
+ * PersistenceManagerFactory.setRetainValues(boolean flag) sets the value of
+ * the RetainValues property (the transaction mode that specifies the
+ * treatment of persistent instances after commit),
+ * PersistenceManagerFactory.getRetainValues() returns the value of the
+ * RetainValues property. 
  */
 
 public class SetRetainValues extends JDO_Test {
@@ -61,44 +51,33 @@
         BatchTestRunner.run(SetRetainValues.class);
     }
 
-    private PersistenceManagerFactory   pmf;
-    private PersistenceManager          pm;
-    private String 			pmfClass;
-    private String                      url;
-    private String 			username;
-    private String 			password;
-
-    private static  String  		PMFCLASS = "javax.jdo.PersistenceManagerFactoryClass";
-    private static  String  		URL      = "javax.jdo.option.ConnectionURL";
-    private static  String  		USERNAME = "javax.jdo.option.ConnectionUserName";
-    private static  String  		PASSWORD = "javax.jdo.option.ConnectionPassword";
+    /** */
+    protected void setUp() throws Exception {
+        // close pmf that might be left open from previous test
+        closePMF();
+        pmf = getUnconfiguredPMF();
+    }
 
-    /** set RetainValues to true or false and use getRetainValues value to verify */ 
+    /** 
+     * Set RetainValues to true or false and use getRetainValues value to
+     * verify.
+     */ 
     public void test() {
-        Properties props = loadProperties(PMFProperties);
-        pmfClass = props.getProperty(PMFCLASS);  
-        url      = props.getProperty(URL);
-        username = props.getProperty(USERNAME);  
-        password = props.getProperty(PASSWORD);  
-
         try {
-            Class cl = Class.forName(pmfClass);
-            pmf = (PersistenceManagerFactory) cl.newInstance();
-            pmf.setRetainValues(false);
-            if (pmf.getRetainValues() != false) {
-                fail(ASSERTION_FAILED,
-                     "RetainValues set to false, value returned by PMF is " +
-                     pmf.getRetainValues());
-            }
-            pmf.setRetainValues(true);
-            if (pmf.getRetainValues() != true) {
-                fail(ASSERTION_FAILED,
-                     "RetainValues set to true, value returned by PMF is " +
-                     pmf.getRetainValues());
-            }
-        } catch (Exception ex) {
-            fail(ASSERTION_FAILED,
-                 "Failed in setting RetainValues " + ex);
+            setRetainValues(false);
+            setRetainValues(true);
+        } finally {
+            closePMF();
+        }
+    }
+
+    /** */
+    private void setRetainValues(boolean newValue) {
+        pmf.setRetainValues(newValue);
+        boolean current = pmf.getRetainValues();
+        if (current != newValue) {
+            fail(ASSERTION_FAILED, "RetainValues set to " + newValue + 
+                 ", value returned by PMF is " + current);
         }
     }
 }



Mime
View raw message