Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java (Arbeitskopie)
@@ -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 @@
*Assertion IDs: A11.1-1, A11.1-2.
*
*Assertion Description:
- 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,35 @@
BatchTestRunner.run(SetOptimistic.class);
}
- private PersistenceManagerFactory pmf;
- private PersistenceManager pm;
- private String pmfClass;
- private String url;
- private String username;
- private String password;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ pmf = getConfigurablePMF();
+ }
- 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 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());
+ 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());
+ 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);
+ } finally {
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java (Arbeitskopie)
@@ -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 @@
*Assertion IDs: A11.1-32
*
*Assertion Description:
- * 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,21 @@
/** */
public void test() {
- PMFPropertiesObject = loadProperties(PMFProperties);
- pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
- //Try to get a PersistenceManager and begin and commit a transaction
- pm = pmf.getPersistenceManager();
- Transaction tx = pm.currentTransaction();
- tx.begin();
- Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","",""));
- pm.makePersistent(comp);
- tx.commit();
+ Transaction tx = null;
+ try {
+ //Try to get a PersistenceManager and begin and commit a transaction
+ pm = pmf.getPersistenceManager();
+ tx = pm.currentTransaction();
+ tx.begin();
+ Company comp = new Company(1L, "Sun Microsystems", new Date(),
+ new Address(0,"","","","",""));
+ pm.makePersistent(comp);
+ tx.commit();
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ if ((pm != null) && !pm.isClosed())
+ pm.close();
+ }
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java (Arbeitskopie)
@@ -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,18 +30,11 @@
*Assertion IDs: A11.1-9,A11.1-10.
*
*Assertion Description:
- * PersistenceManagerFactory.setNontransactionalWrite(boolean flag) sets the value of the NontransactionalWrite property (the PersistenceManager mode that allows instances to be written outside a transaction).
+ * 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
- *
- */
-
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;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ pmf = getConfigurablePMF();
+ }
- 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 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 " +
+ 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 " +
+ 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);
+ } finally {
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java (Arbeitskopie)
@@ -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,18 +33,11 @@
*Assertion IDs: A11.1-11,A11.1-12.
*
*Assertion Description:
- *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.
+ * 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
- *
- */
-
public class SetMultithreaded extends JDO_Test {
/** */
@@ -60,45 +53,31 @@
BatchTestRunner.run(SetMultithreaded.class);
}
- private PersistenceManagerFactory pmf;
- private PersistenceManager pm;
- private String pmfClass;
- private String url;
- private String username;
- private String password;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ pmf = getConfigurablePMF();
+ }
- 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 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());
+ 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());
+ 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);
+ } finally {
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java (Arbeitskopie)
@@ -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,8 @@
package org.apache.jdo.tck.api.persistencemanagerfactory;
-import java.util.Properties;
+import javax.jdo.JDOException;
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
import org.apache.jdo.tck.JDO_Test;
import org.apache.jdo.tck.util.BatchTestRunner;
@@ -33,8 +30,9 @@
*Assertion IDs: A11.1-13,A11.1-14.
*
*Assertion Description:
-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 main 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 = getConfigurablePMF();
+ 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) {
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java (Arbeitskopie)
@@ -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,20 +29,13 @@
*Assertion IDs: A11.1-3,A11.1-4.
*
*Assertion Description:
- * 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.
+ * 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
- *
- */
-
public class SetRetainValues extends JDO_Test {
/** */
@@ -61,44 +51,31 @@
BatchTestRunner.run(SetRetainValues.class);
}
- private PersistenceManagerFactory pmf;
- private PersistenceManager pm;
- private String pmfClass;
- private String url;
- private String username;
- private String password;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ pmf = getConfigurablePMF();
+ }
- 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 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());
+ 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());
+ 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);
+ } finally {
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java (Arbeitskopie)
@@ -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,18 +31,10 @@
*
*Assertion Description:
* PersistenceManagerFactory.getPersistenceManager() returns a
-PersistenceManager instance with the configured properties and the
-default values for option settings.
+ * PersistenceManager instance with the configured properties and the
+ * default values for option settings.
*/
-/*
- * Revision History
- * ================
- * Author : Linga Neerathilingam
- * Date : 10/22/01
- *
- */
-
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;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ super.setUp();
+ }
- 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() {
- 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();
+ pm = pmf.getPersistenceManager();
+ if (pm == null) {
+ fail(ASSERTION_FAILED, "pmf.getPersistenceManager should " +
+ "return a non-null value.");
+ }
}
- catch (Exception ex) {
- fail(ASSERTION_FAILED,
- "unexpected exception " + ex);
- }
finally {
- if (debug) logger.debug("Persistence Manager obtained: " + pm);
- if (pm != null) pm.close();
+ if ((pm != null) && !pm.isClosed()) {
+ pm.close();
+ }
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java (Arbeitskopie)
@@ -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 @@
*Assertion IDs: A11.1-5.
*
*Assertion Description:
-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).
+ * 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
- *
- */
-
public class SetIgnoreCache extends JDO_Test {
/** */
@@ -59,30 +49,18 @@
BatchTestRunner.run(SetIgnoreCache.class);
}
- private PersistenceManagerFactory pmf;
- private PersistenceManager pm;
- private String pmfClass;
- private String url;
- private String username;
- private String password;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ pmf = getConfigurablePMF();
+ }
- 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 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,
@@ -95,9 +73,9 @@
"IgnoreCache set to true, value returned by PMF is " +
pmf.getIgnoreCache());
}
- } catch (Exception ex) {
- fail(ASSERTION_FAILED,
- "Failed in setting IgnoreCache" + ex);
+
+ } finally {
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java (Arbeitskopie)
@@ -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,24 +34,22 @@
*
*Assertion Description:
* PersistenceManagerFactory.getPersistenceManager(String userid,
-String password) returns a PersistenceManager instance with the
-configured properties and the default values for option settings.
+ * 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
- *
- */
-
public class GetPersistenceManagerForUser extends JDO_Test {
/** */
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 main is called when the class
* is directly executed from the command line.
@@ -60,39 +58,36 @@
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 = props.getProperty(CONNECTION_USERNAME_PROP);
+ password = props.getProperty(CONNECTION_PASSWORD_PROP);
+ props.remove(CONNECTION_USERNAME_PROP);
+ 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();
}
}
+
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java (Arbeitskopie)
@@ -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,18 +30,11 @@
*Assertion IDs: A11.1-7,A11.1-8.
*
*Assertion Description:
- *PersistenceManagerFactory.setNontransactionalRead(boolean flag) sets the value of the NontransactionalRead property (the PersistenceManager mode that allows instances to be read outside a transaction).
+ * 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
- *
- */
-
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;
+ /** */
+ protected void setUp() throws Exception {
+ // close pmf that might be left open from previous test
+ closePMF();
+ pmf = getConfigurablePMF();
+ }
- 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 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 " +
+ 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 " +
+ 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);
+ } finally {
+ closePMF();
}
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java (Arbeitskopie)
@@ -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 @@
*Assertion ID: A11.3-3.
*
*Assertion Description:
-After the first use of PersistenceManagerFactory.getPersistenceManager(),
-none of the set methods will succeed.
-
+ * After the first use of
+ * PersistenceManagerFactory.getPersistenceManager(),
+ * none of the set 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();) {
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java (Arbeitskopie)
@@ -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 @@
*Assertion IDs: A11.1-15.
*
*Assertion Description:
- * 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 main 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 = getConfigurablePMF();
+ 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();
+ }
}
}
Index: src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java
===================================================================
--- src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java (Arbeitskopie)
@@ -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,8 @@
package org.apache.jdo.tck.api.persistencemanagerfactory;
-import java.util.Properties;
+import javax.jdo.JDOException;
-import javax.jdo.PersistenceManager;
-import javax.jdo.PersistenceManagerFactory;
-
import org.apache.jdo.tck.JDO_Test;
import org.apache.jdo.tck.util.BatchTestRunner;
@@ -33,8 +30,10 @@
*Assertion IDs: A11.1-16,A11.1-17.
*
*Assertion Description:
- * 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 main 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 = getConfigurablePMF();
+ 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());
}
}
Index: src/java/org/apache/jdo/tck/JDO_Test.java
===================================================================
--- src/java/org/apache/jdo/tck/JDO_Test.java (Revision 429121)
+++ src/java/org/apache/jdo/tck/JDO_Test.java (Arbeitskopie)
@@ -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";
@@ -464,6 +480,40 @@
}
/**
+ * Get the PersistenceManagerFactory 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 pmf if it is not null,
+ * else sets field pmf to a new instance and returns that instance.
+ */
+ protected PersistenceManagerFactory getConfigurablePMF()
+ {
+ 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;
+ }
+
+ /**
* Get the PersistenceManager instance
* for the implementation under test.
*/