Issue Details (XML | Word | Printable)

Key: JDO-394
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Michael Bouschen
Reporter: Christian Ernst
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JDO

org.apache.jdo.tck.api.persistencemanagerfactory.GetPersistenceManager.test() and org.apache.jdo.tck.api.persistencemanagerfactory.GetPersistenceManagerForUser.test() don't close PMF correctly

Created: 18/Jul/06 09:13 AM   Updated: 07/Aug/06 09:16 PM
Return to search
Component/s: tck2
Affects Version/s: JDO 2 final
Fix Version/s: JDO 2 maintenance release 1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works JDO-394-2.patch 2006-08-06 11:44 AM Michael Bouschen 52 kB
Text File Licensed for inclusion in ASF works JDO-394.patch 2006-07-30 08:06 PM Michael Bouschen 19 kB

Resolution Date: 07/Aug/06 09:16 PM


 Description  « Hide
org.apache.jdo.tck.api.persistencemanagerfactory.GetPersistenceManager.test() and
org.apache.jdo.tck.api.persistencemanagerfactory.GetPersistenceManagerForUser.test()
don't close PMF correctly and this can cause other Testcases to fail

Following should be added to the finally block of each test() Method

if (pmf != null) pmf.close();

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig Russell added a comment - 29/Jul/06 08:02 PM
Need to resolve these issues for maintenance release 1.

Craig Russell made changes - 29/Jul/06 08:02 PM
Field Original Value New Value
Fix Version/s JDO 2 maintenance release 1 [ 12310923 ]
Michael Bouschen made changes - 30/Jul/06 07:59 PM
Assignee Michael Bouschen [ mbo ]
Michael Bouschen added a comment - 30/Jul/06 08:06 PM
Attached you find a patch (JDO-394.patch) adding pmf.close to the finally block and does some more code cleanup.

I found a similar issue with the following test classes from the same package: SetIgnoreCache, SetMultithreaded, SetNonTransactionalRead, SetNonTransactionalWrite, and SetRetainValues. The patch adds a finally block closing the pmf.

Michael Bouschen made changes - 30/Jul/06 08:06 PM
Attachment JDO-394.patch [ 12337788 ]
Michael Bouschen added a comment - 06/Aug/06 11:44 AM
Attached you find a new patch (JDO-394-2.patch) for review.

The new patch fixes a problem I overlooked before: the old code creates a new PMF as part of the test method, but the setUp method
already created a PMF. This patch fixes this problem. It also makes sure that an existing PMF is closed, that might have been left open from a previous test. The test cases testing PMF setter method cannot use the getPMF method as implemented in the test super class JDO_Test, because this returns a non-configurable PMF.

Michael Bouschen made changes - 06/Aug/06 11:44 AM
Attachment JDO-394-2.patch [ 12338224 ]
Craig Russell added a comment - 07/Aug/06 05:39 PM
Looks great. It's good to clean up these tests. Just a few comments.

1. The pattern:

             if (pmf.getOptimistic() != true) {
- fail(ASSERTION_FAILED,
- "Optimistic set to true, value returned by PMF is " +
- pmf.getOptimistic());

hides the value that was returned by the pmf, and gets a new value for the error message. I'd prefer something like this:

boolean optimistic = pmf.getOptimistic();
             if (optimistic != true) {
- fail(ASSERTION_FAILED,
- "Optimistic set to true, value returned by PMF is " +
- optimistic;

2. In src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java you use the JDO_Test pmf instance but define your own pm and tx instances, which requires you to use your own finally block to close the pm. Couldn't you use the JDO_Test pm instance as well? Then the normal tearDown will close the pm.

3. This is really a nit, but I'd prefer the method getConfigurablePMF to be named getUnconfiguredPMF. From the name, I was expecting perhaps a PMF that was configured with all of the properties but was still configurable. Instead, it's simply an instance of PMF that had not been configured at all.

4. In src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java:
        username = props.getProperty(CONNECTION_USERNAME_PROP);
        password = props.getProperty(CONNECTION_PASSWORD_PROP);
        props.remove(CONNECTION_USERNAME_PROP);
        props.remove(CONNECTION_PASSWORD_PROP);

This could be simplified, since remove returns the present value in the Map:
        username = props.remove(CONNECTION_USERNAME_PROP);
        password = props.remove(CONNECTION_PASSWORD_PROP);

Craig

Repository Revision Date User Message
ASF #429480 Mon Aug 07 21:15:42 UTC 2006 mbo JDO-394: cleanup pmf test cases
Files Changed
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManager.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalRead.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetOptimistic.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerFactoryByPropertiesInstance.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/JDO_Test.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionPassword.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetNonTransactionalWrite.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/GetPersistenceManagerForUser.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetMultithreaded.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionURL.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetRetainValues.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetIgnoreCache.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanagerfactory/SetConnectionUserName.java

Michael Bouschen added a comment - 07/Aug/06 09:16 PM
I changed the patch according to the comments and checked it in (see revision 429480).

Michael Bouschen made changes - 07/Aug/06 09:16 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]