svn commit: r160090 [6/63] - in incubator/jdo/trunk: ./ tck20/ tck20/assertions/ tck20/iut_jars/ tck20/test/ tck20/test/conf/ tck20/test/java/ tck20/test/java/org/ tck20/test/java/org/apache/ tck20/test/java/org/apache/jdo/ tck20/test/java/org/apache/jdo/tck/ tck20/test/java/org/apache/jdo/tck/api/ tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/api/jdohelper/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/close/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/extent/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/flags/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/getobject/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/ tck20/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ tck20/test/java/org/apache/jdo/tck/enhancement/ tck20/test/java/org/apache/jdo/tck/extents/ tck20/test/java/org/apache/jdo/tck/lifecycle/ tck20/test/java/org/apache/jdo/tck/lifecycle/nontransactional/ tck20/test/java/org/apache/jdo/tck/models/ tck20/test/java/org/apache/jdo/tck/models/embedded/ tck20/test/java/org/apache/jdo/tck/models/fieldtypes/ tck20/test/java/org/apache/jdo/tck/models/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/ tck20/test/java/org/apache/jdo/tck/pc/company/ tck20/test/java/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/java/org/apache/jdo/tck/pc/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/pc/lifecycle/ tck20/test/java/org/apache/jdo/tck/pc/mylib/ tck20/test/java/org/apache/jdo/tck/query/ tck20/test/java/org/apache/jdo/tck/query/operators/ tck20/test/java/org/apache/jdo/tck/transactions/ tck20/test/java/org/apache/jdo/tck/util/ tck20/test/jdo/ tck20/test/jdo/applicationidentity/ tck20/test/jdo/applicationidentity/org/ tck20/test/jdo/applicationidentity/org/apache/ tck20/test/jdo/applicationidentity/org/apache/jdo/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/jdo/datastoreidentity/ tck20/test/jdo/datastoreidentity/org/ tck20/test/jdo/datastoreidentity/org/apache/ tck20/test/jdo/datastoreidentity/org/apache/jdo/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/ tck20/test/orm/applicationidentity/ tck20/test/orm/applicationidentity/org/ tck20/test/orm/applicationidentity/org/apache/ tck20/test/orm/applicationidentity/org/apache/jdo/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/datastoreidentity/ tck20/test/orm/datastoreidentity/org/ tck20/test/orm/datastoreidentity/org/apache/ tck20/test/orm/datastoreidentity/org/apache/jdo/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/sql/ tck20/test/sql/derby/

4 Apr 2005 19:50:34 -0000

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,179 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> DeletePersistent Fails If Instance Managed By Another 
PersistenceManager
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-11.
+ *<BR>
+ *<B>Assertion Description: </B>
+ PersistenceManager.deletePersistent and deletePersistentAll will throw a 
JDOUserException if the parameter instance is managed by a different 
PersistenceManager.
+
+ */
+
+public class DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager 
extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-11 
(DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void 
testDeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager() {
+        pm = getPM();
+        PersistenceManager pm2 = getPMF().getPersistenceManager();
+        try {
+            createObjects(pm2);
+        
+            /* positive tests */
+            runTestDeletePersistent(pm);
+            runTestDeletePersistentAll1(pm);
+            runTestDeletePersistentAll2(pm);
+        }
+        finally {
+            cleanupPM(pm2);
+            pm = null;
+            cleanupPM(pm);
+            pm = null;
+        }
+    }
+    
+    /** */
+    private void  createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1 = new PCPoint(1,3);
+            p2 = new PCPoint(2,4);
+            p3 = new PCPoint(3,5);
+            p4 = new PCPoint(4,6);
+            p5 = new PCPoint(5,7);
+            
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+            pm.makePersistent(p5);
+            tx.commit();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test deletePersistent (Object pc) */
+    private void runTestDeletePersistent(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            try {
+                pm.deletePersistent(p1);
+                fail(ASSERTION_FAILED,
+                     "pm.deletePersistent(Object) with pc instance managed by 
another pm should throw exception");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /* test deletePersistentAll (Collection pcs) */
+    private void runTestDeletePersistentAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            try {
+                pm.deletePersistentAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.deletePersistent(Collection) with pc instance(s) 
managed by another pm should throw exception");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            } 
+            tx.rollback();
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test deletePersistentAll (Object[] o) */
+    private void runTestDeletePersistentAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p4);
+            col1.add(p5);
+            Object[] obj1= col1.toArray();
+            try {
+                pm.deletePersistentAll(obj1);
+                fail(ASSERTION_FAILED,
+                     "pm.deletePersistent(Object[]) with pc instance(s) 
managed by another pm should throw exception");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            } 
+            tx.rollback();
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> DeletePersistent Has No Effect On Deleted Instances
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+ PersistenceManager.deletePersistent and deletePersistentAll have no effect on 
parameter instances already deleted in the transaction.
+
+ */
+
+public class DeletePersistentHasNoEffectOnDeletedInstances extends 
PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-10 (DeletePersistentHasNoEffectOnDeletedInstances) 
failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(DeletePersistentHasNoEffectOnDeletedInstances.class);
+    }
+    
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testDeletePersistentHasNoEffectOnDeletedInstances() {
+        pm = getPM();
+        createObjects(pm);
+        runTestDeletePersistent(pm);
+        runTestDeletePersistentAll1(pm);
+        runTestDeletePersistentAll2(pm);
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1 = new PCPoint(1,3);
+            p2 = new PCPoint(2,4);
+            p3 = new PCPoint(3,5);
+            p4 = new PCPoint(4,6);
+            p5 = new PCPoint(5,7);
+            
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+            pm.makePersistent(p5);
+            
+            tx.commit();
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistent (Object pc) */
+    private void runTestDeletePersistent(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.deletePersistent(p1);
+            pm.deletePersistent(p1);
+            pm.deletePersistent(p1);
+            pm.deletePersistent(p1);
+            tx.commit();
+            if (debug) logger.debug(" \nPASSED in testDeletePersistent()");
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Collection pcs) */
+    private void runTestDeletePersistentAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            tx.begin();
+            pm.deletePersistentAll(col1);
+            pm.deletePersistentAll(col1);
+            pm.deletePersistentAll(col1);
+            pm.deletePersistentAll(col1);
+            tx.commit();
+            if (debug) logger.debug(" \nPASSED in testDeletePersistentAll1()");
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Object[] o) */
+    private void runTestDeletePersistentAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            Collection col1 = new java.util.HashSet();
+            col1.add(p4);
+            col1.add(p5);
+
+            Object[] obj1= col1.toArray();
+
+            tx.begin();
+            pm.deletePersistentAll(obj1);
+            pm.deletePersistentAll(obj1);
+            pm.deletePersistentAll(obj1);
+            pm.deletePersistentAll(obj1);
+            tx.commit();
+            if (debug) logger.debug(" \nPASSED in testDeletePersistentAll2()");
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedInstances.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get PersistenceManagerFactory
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion ID:</B> A12.9-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManagerFactory that created a
+PersistenceManager is returned by the method getPersistenceManagerFactory.
+
+
+ */
+
+public class GetPersistenceManagerFactory extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.9-1 (GetPersistenceManagerFactory) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(GetPersistenceManagerFactory.class);
+    }
+    
+    /** */
+    public void testGetPersistenceManagerFactory() {
+        PersistenceManagerFactory pmf = getPMF();
+        PersistenceManager pm = pmf.getPersistenceManager();
+        PersistenceManagerFactory pmf2 = pm.getPersistenceManagerFactory();
+        if (pmf2 != pmf) {
+            fail(ASSERTION_FAILED,
+                 "pm.getPMF() returned different pmf, expected " + pmf + ", 
got " + pmf2);
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetPersistenceManagerFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.Point;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get/Set User Object
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion ID:</B> A12.8-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.setUserObject method is used to store an object 
associated with the PersistenceManager. One uses the method getUserObject to 
later
+retrieve the object.
+
+
+ */
+
+public class GetSetUserObject extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.8-1 (GetSetUserObject) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(GetSetUserObject.class);
+    }
+
+    /** */
+    public void testGetSetUserObject() {
+        pm = getPM();
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Point p = new Point(10,10);
+            pm.setUserObject(p);
+            tx.commit();
+
+            tx.begin();
+            Object obj = pm.getUserObject();
+            
+            if (obj != p) {
+                fail(ASSERTION_FAILED,
+                     "Unexpected pm user object, expected " + p + ", got " + 
obj);
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get Transactional ObjectId When ObjectId Being Changed
+ *<BR>
+ *<B>Keywords:</B> identity applicationidentity
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.6-15.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the object identity is being changed in the transaction, by the application
+modifying one or more of the application key fields, then
+<code>PersistenceManager.getTransactionalObjectId</code> returns the current
+identity in the transaction.
+
+ */
+
+public class GetTransactionalObjectIdWhenObjectIdBeingChanged extends 
PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.6-15 
(GetTransactionalObjectIdWhenObjectIdBeingChanged) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(GetTransactionalObjectIdWhenObjectIdBeingChanged.class);
+    }
+
+    /** */
+    public void testGetObjectByIdWhenObjectIdBeingChanged() {
+        if (!isChangeApplicationIdentitySupported()) {
+            if (debug)
+                logger.debug("Implementation does not support chaning 
application identity");
+            return;
+        }
+
+
+        if (debug)
+            logger.debug("\nSTART 
GetTransactionalObjectIdWhenObjectIdBeingChanged");
+        pm = getPM();
+        Object oid = createPCPointInstance(pm);
+        PCPoint p1 = (PCPoint) pm.getObjectById (oid, false);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1.setX(10000); // this is the primary key
+            Object oid2 = pm.getTransactionalObjectId (p1); // should be 
different
+            tx.commit();
+            Object oid3 = pm.getObjectId (p1); // should be same as oid2
+            if (oid.equals(oid2)) {
+                fail(ASSERTION_FAILED,
+                     "Oid before is the same as transactional oid after 
modifying pk");
+            }
+
+            if (!oid2.equals(oid3)) {
+                fail(ASSERTION_FAILED,
+                     "Oid after is different from transactional oid after 
modifying pk");
+            }
+        }
+        finally {
+            if (debug)
+                logger.debug("END 
GetTransactionalObjectIdWhenObjectIdBeingChanged");
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWhenObjectIdBeingChanged.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get Transactional ObjectId With No Transaction
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.6-16
+ *<BR>
+ *<B>Assertion Description: </B>
+If there is no transaction in progress, or if none of the key fields is being
+modified, then PersistenceManager.getTransactionalObjectId has the same 
behavior as
+getObjectId.
+
+
+ */
+
+public class GetTransactionalObjectIdWithNoTransaction extends 
PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.6-16 (GetTransactionalObjectIdWithNoTransaction) 
failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(GetTransactionalObjectIdWithNoTransaction.class);
+    }
+
+    /** */
+    public void testGetTransactionalObjectIdWithNoTransaction() {
+        pm = getPM();
+        Transaction tx = pm.currentTransaction();
+        try {
+            PCPoint p1 = new PCPoint();
+
+            tx.begin();
+            pm.makePersistent(p1);
+            Object oid = pm.getObjectId(p1);
+            tx.commit();
+            
+            Object toid = pm.getTransactionalObjectId(p1);
+            if (!toid.equals(oid)) {
+                fail(ASSERTION_FAILED,
+                     "pm.getTransactionalObjectId(p1) returned unexpected 
ObjectId, expected " + 
+                     oid + ", got " + toid);
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> No PersistenceManager If Transient
+ *<BR>
+ *<B>Keywords:</B> transient
+ *<BR>
+ *<B>Assertion ID:</B> A12.5-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+A JDO Instance is associated with no <code>PersistenceManager</code>
+if and only if the instance is in the transient state.
+This is a duplicate of A8.1-2.
+
+ */
+
+public class NoPersistenceManagerIfTransient extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-1 (NoPersistenceManagerIfTransient) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(NoPersistenceManagerIfTransient.class);
+    }
+
+    /** */
+    public void test() {
+        if (debug)
+            
logger.debug("org.apache.jdo.tck.api.persistencemanager.NoPersistenceManagerIfTransient
 duplicate of A8.1-2.");
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> ObjectId Unique Among Instances
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.6-12.
+ *<BR>
+ *<B>Assertion Description: </B>
+Within a transaction, the <code>ObjectId</code> returned will compare equal
+to the <code>ObjectId</code> returned by only one among all JDO instances
+associated with the <code>PersistenceManager</code> regardless of the type of
+<code>ObjectId</code>.
+
+ */
+
+public class ObjectIdUniqueAmongInstances extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.6-12 (ObjectIdUniqueAmongInstances) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(ObjectIdUniqueAmongInstances.class);
+    }
+
+    /** */
+    public void test() {
+        final int count = 1000;
+    
+        HashSet instances = new HashSet(count);
+        HashSet oids = new HashSet(count);
+
+        pm = getPM();
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+    
+            // Construct "count" persistent instances, and save them in a
+            // hashset.
+            for (int i = 0; i < count; ++i) {
+                PCPoint p = new PCPoint (i, count-i);
+                pm.makePersistent(p);
+                instances.add(p);
+            }
+    
+            // For all new persistent instances, get the object ids and
+            // save them in another hashset.  There should be the same
+            // number if the ids  are all unique.
+            for (Iterator it = instances.iterator(); it.hasNext();) {
+                oids.add(pm.getObjectId(it.next()));
+            }
+    
+            tx.commit();
+            tx = null;
+    
+            if (oids.size() != instances.size()) {
+                fail(ASSERTION_FAILED,
+                     "Oids has size: " + oids.size() + "; expected: " + 
instances.size());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.pc.mylib.PCRect;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Only one instance of persistent object in cache per 
PersistenceManager
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion ID:</B> A5.4-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+JDO implementations must manage the cache of JDO Instances such that there is
+only one JDO Instance, associated with each JDO 
<code>PersistenceManager</code>,
+representing the persistent state of each corresponding data store object.
+(One needs a hashtable that uses <code>==</code> in order to test this).
+
+ */
+
+public class OneInstanceOfObjectPerPersistenceManager extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A5.4-2 (OneInstanceOfObjectPerPersistenceManager) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(OneInstanceOfObjectPerPersistenceManager.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+        Transaction tx = pm .currentTransaction();
+        try {
+            tx.setRetainValues(false);
+            tx.setRestoreValues(false);
+    
+            tx.begin();
+            PCPoint p1 = new PCPoint(10, 20);
+            PCPoint p2 = new PCPoint(20, 40);
+            PCRect rect = new PCRect(0, p1, p2);
+            pm.makePersistent(rect);
+            tx.commit();
+    
+            tx.begin();
+            Object p1Id = pm.getObjectId(p1);
+            PCPoint p1a = (PCPoint)pm.getObjectById(p1Id, true);
+            PCPoint p1b = rect.getUpperLeft();
+            PCPoint p1c = findPoint(10, 20);
+            tx.commit();
+            tx = null;
+    
+            if (p1 != p1a) {
+                fail(ASSERTION_FAILED, "getObjectById results differ");
+            }
+            if (p1 != p1b) {
+                fail(ASSERTION_FAILED, "navigation results differ");
+            }
+            if (p1 != p1c) {
+                fail(ASSERTION_FAILED, "query results differ");
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private PCPoint findPoint (int x, int y) {
+        Query q = getPM().newQuery (PCPoint.class);
+        q.declareParameters ("int px, int py");
+        q.setFilter ("x == px & y == py");
+        Collection results = (Collection)q.execute (new Integer(x), new 
Integer(y));
+        Iterator it = results.iterator();
+        PCPoint ret = (PCPoint)it.next();
+        return ret;
+    }
+    
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+/**
+ *<B>Title:</B> One PersistenceManager If Persistent or Transactional
+ *<BR>
+ *<B>Keywords:</B> 
+ *<BR>
+ *<B>Assertion ID:</B> A12.5-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+A JDO Instance is associated with exactly one <code>PersistenceManager</code>
+if the instance is persistent or transactional.
+This is a duplicate test.
+ */
+
+public class OnePersistenceManagerIfPersistentOrTransactional extends JDO_Test 
{
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-2 (OnePersistenceManagerIfPersistentOrTransactional) 
failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(OnePersistenceManagerIfPersistentOrTransactional.class);
+    }
+
+    /** */
+    public void test() {
+        if (debug)
+            
logger.debug("org.apache.jdo.tck.api.persistencemanager.OnePersistenceManagerIfPersistentOrTransactional.run
 duplicate");
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,232 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jdo.JDOException;
+import javax.jdo.JDOHelper;
+import javax.jdo.JDOOptimisticVerificationException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> OptimisticFailure
+ *<BR>
+ *<B>Keywords:</B> optimistic
+ *<BR>
+ *<B>Assertion IDs:</B> A13.5-1
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If any instance fails the verification, a 
JDOOptimisticVerificationException 
+ * is thrown which contains an array of JDOOptimisticVerificationException, 
+ * one for each instance that failed the verification. The optimistic 
+ * transaction is failed, and the transaction is rolled back. 
+ * The definition of "changed instance" is a JDO implementation choice, 
+ * but it is required that a field that has been changed to different 
+ * values in different transactions results in one of the transactions 
+ * failing. 
+ */
+
+public class OptimisticFailure extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A13.5-1 (OptimisticFailure) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(OptimisticFailure.class);
+    }
+
+    private PCPoint p1 = new PCPoint(1,1); // this will be updated in tx1, 
updated in tx2, verified in tx3
+    private PCPoint p2 = new PCPoint(2,2); // this will be updated in tx1, 
deleted in tx2, verified in tx3
+    private PCPoint p3 = new PCPoint(3,3); // this will be deleted in tx1, 
updated in tx2
+    private PCPoint p4 = new PCPoint(4,4); // this will be deleted in tx1, 
deleted in tx2
+    private PCPoint p5 = new PCPoint(5,5); // this will be unchanged in tx1, 
updated in tx2, verified in tx3
+    private Object p1oid = null;
+    private Object p2oid = null;
+    private Object p3oid = null;
+    private Object p4oid = null;
+    private Object p5oid = null;
+    
+    /** */
+    public void test() {
+        pm = getPM();
+        PersistenceManager pm2 = pmf.getPersistenceManager();
+        PersistenceManager pm3 = pmf.getPersistenceManager();
+
+        try {
+            runTestOptimistic(pm, pm2, pm3);
+        }
+        finally {
+            cleanupPM(pm3);
+            pm3 = null;    
+            cleanupPM(pm2);
+            pm2 = null;    
+            cleanupPM(pm);
+            pm = null;    
+        }
+    }
+    
+    /** */
+    private void runTestOptimistic(PersistenceManager pm1, 
+                                   PersistenceManager pm2, 
+                                   PersistenceManager pm3) {
+        if (!isOptimisticSupported()) {
+           if (debug)
+               logger.debug("OptimisticFailure tests not run; Optimistic not 
supported");
+           return;
+        }
+
+        Transaction tx1 = pm1.currentTransaction();
+        Transaction tx2 = pm2.currentTransaction();
+        Transaction tx3 = pm3.currentTransaction();
+        try {
+           tx1.setOptimistic(true);
+           tx2.setOptimistic(true);
+           
+           // create four instances to test
+           tx1.begin();
+           pm1.makePersistent(p1);
+           pm1.makePersistent(p2);
+           pm1.makePersistent(p3);
+           pm1.makePersistent(p4);
+           pm1.makePersistent(p5);
+           p1oid = pm1.getObjectId(p1);
+           p2oid = pm1.getObjectId(p2);
+           p3oid = pm1.getObjectId(p3);
+           p4oid = pm1.getObjectId(p4);
+           p5oid = pm1.getObjectId(p5);
+           tx1.commit();
+           
+           // update/delete the instances in tx1
+           tx1.begin();
+           PCPoint p1tx1 = (PCPoint)pm1.getObjectById(p1oid, true);
+           PCPoint p2tx1 = (PCPoint)pm1.getObjectById(p2oid, true);
+           PCPoint p3tx1 = (PCPoint)pm1.getObjectById(p3oid, true);
+           PCPoint p4tx1 = (PCPoint)pm1.getObjectById(p4oid, true);
+           p1tx1.setX(101);
+           p2tx1.setX(201);
+           pm1.deletePersistent(p3tx1);
+           pm1.deletePersistent(p4tx1);
+           
+           // update/delete the instances in tx2
+           tx2.begin();
+           PCPoint p1tx2 = (PCPoint)pm2.getObjectById(p1oid, true);
+           PCPoint p2tx2 = (PCPoint)pm2.getObjectById(p2oid, true);
+           PCPoint p3tx2 = (PCPoint)pm2.getObjectById(p3oid, true);
+           PCPoint p4tx2 = (PCPoint)pm2.getObjectById(p4oid, true);
+           PCPoint p5tx2 = (PCPoint)pm2.getObjectById(p5oid, true);
+           p1tx2.setX(102);
+//           pm2.deletePersistent(p2tx2); // this should fail but succeeds due 
to an RI bug
+           p3tx2.setX(202);
+           pm2.deletePersistent(p4tx2);
+           p5tx2.setX(502); // this change should not be committed
+           Set expectedFailedObjects = new HashSet();
+           expectedFailedObjects.add(p1tx2);
+//           expectedFailedObjects.add(p2tx2);
+           expectedFailedObjects.add(p3tx2);
+           expectedFailedObjects.add(p4tx2);
+           
+           // commit tx1 (should succeed)
+           tx1.commit();
+           tx1 = null;
+           
+           // commit tx2 (should fail)
+           try {
+               tx2.commit();
+               fail(ASSERTION_FAILED, "concurrent commit not detected");
+           } 
+           catch (JDOOptimisticVerificationException ex) {
+               // verify the correct information in the exception
+               Throwable[] ts = ex.getNestedExceptions();
+               int length = ts==null ? 0 : ts.length;
+               int expectedFailures = expectedFailedObjects.size();
+               if (length != expectedFailures) {
+                   fail(ASSERTION_FAILED,
+                        "Nested exceptions[] wrong size: expected " + 
+                        expectedFailures + ", got " + length);
+               }
+               for (int i = 0; i < length; ++i) {
+                   Throwable t = ts[i];
+                   if (t instanceof JDOOptimisticVerificationException) {
+                       if (debug)
+                           logger.debug("Expected exception caught " + 
t.toString());
+                       JDOException jex = (JDOException)t;
+                       Object failed = jex.getFailedObject();
+                       if (failed == null) {
+                           fail(ASSERTION_FAILED, 
+                                "Found unexpected null in failed object");
+                       }
+                       else {
+                           if (expectedFailedObjects.remove(failed)) {
+                               if (debug) 
+                                   logger.debug("Found expected failed 
instance, oid: " + 
+                                                JDOHelper.getObjectId(failed));
+                           } 
+                           else {
+                               fail(ASSERTION_FAILED,
+                                    "Unexpected failed instance: " + 
failed.toString());
+                           }
+                       }
+                   } 
+                   else {
+                       fail(ASSERTION_FAILED,
+                            "Unexpected nested exception: " + t.toString());
+                   }
+               }
+           }
+           tx2 = null;
+           
+           tx3.begin();
+           PCPoint p1tx3 = (PCPoint)pm3.getObjectById(p1oid, true);
+           PCPoint p2tx3 = (PCPoint)pm3.getObjectById(p2oid, true);
+           PCPoint p5tx3 = (PCPoint)pm3.getObjectById(p5oid, true);
+           verify(p1tx3, 101);
+           verify(p2tx3, 201);
+           verify(p5tx3, 5);
+           tx3.commit();
+           tx3 = null;
+        }
+        finally {
+            if ((tx3 != null) && tx3.isActive())
+                tx3.rollback();
+            if ((tx2 != null) && tx2.isActive())
+                tx2.rollback();
+            if ((tx1 != null) && tx1.isActive())
+                tx1.rollback();
+        }
+    }
+    
+    /** */
+    protected void verify(PCPoint p, int value) {
+        if (p.getX() != value) {
+            fail(ASSERTION_FAILED,
+                 "PCPoint has wrong value: expected " + value + ", got " + 
p.getX());
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+
+import java.util.Collection;
+import java.util.Vector;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.pc.mylib.PCPoint2;
+import org.apache.jdo.tck.pc.mylib.PCRect;
+
+public abstract class PersistenceManagerTest extends JDO_Test {
+    
+    /** */
+    protected PersistenceManagerTest() { }
+
+    /** */
+    protected void tearDown() {
+        try {
+            cleanup();
+            cleanupMylib();
+            closePMF();
+        }
+        catch (Throwable ex) {
+            if (debug) ex.printStackTrace();
+            if (testSucceeded) {
+                // runTest succeeded, but closePMF throws exception =>
+                // failure
+                fail("Exception during tearDown: " + ex);
+            }
+            else {
+                // runTest failed and closePMF throws exception =>
+                // just print the closePMF exception, otherwise the
+                // closePMF exception would swallow the test case failure
+                if (debug)
+                    logger.debug("Exception during tearDown: " + ex);
+            }
+        }
+    }
+    
+    /** */
+    protected void cleanupMylib() {
+        PersistenceManager pm = getPM();
+        Transaction tx = null;
+        try {
+            pm = pmf.getPersistenceManager();
+            tx = pm.currentTransaction();
+            tx.begin();
+            Collection c = getAllObjects(pm, PCPoint.class);
+            pm.deletePersistentAll(c);
+            tx.commit();
+        
+            tx.begin();
+            c = getAllObjects(pm, PCRect.class);
+            pm.deletePersistentAll(c);
+            tx.commit();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+            if ((pm != null) && pm.isClosed())
+                pm.close();
+        }
+    }
+  
+    /** */
+    protected Object createPCPointInstance(PersistenceManager pm) {
+        PCPoint p1 = new PCPoint(8,8);
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        pm.makePersistent(p1);
+        Object oid = pm.getObjectId(p1);
+        tx.commit();
+        return oid;
+    }
+  
+    /** */
+    public void deletePCPointInstance (PersistenceManager pm, Object oid) {
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        Object p1 = pm.getObjectById(oid, true);
+        pm.deletePersistent(p1);
+        tx.commit();
+    }
+
+    /** */
+    protected Collection getAllObjects(PersistenceManager pm, Class pcClass) {
+        Collection col = new Vector() ;
+        try {
+            Query query = pm.newQuery();
+            query.setClass(pcClass);
+            query.setCandidates(pm.getExtent(pcClass, false));
+            Object result = query.execute();
+            col = (Collection)result;
+        } catch (Exception e) {
+            fail("Exception in getAllObjects()" + e);
+        }
+        return col ;
+    }
+
+    /** */
+    public boolean testState(PCPoint obj, int expectState, String str) {
+        int actualState = currentState(obj);
+        if (actualState != expectState) {
+            if (debug) {
+                logger.debug(" Object not in " + str + " state for X = " +
+                             obj.getX());
+                logger.debug(" current state: " + actualState +
+                             " expected state: " + expectState);
+            }
+            return false;
+        }
+        return true;
+    }
+
+    /** */
+    public boolean testState(PCPoint2 obj, int expectState, String str) {
+        int actualState = currentState(obj);
+        if (actualState != expectState) {
+            if (debug) {
+                logger.debug(" Object not in " + str + " state for X = " +
+                             obj.getX() );
+                logger.debug(" current state: " + actualState +
+                             " expected state: " + expectState);
+            }
+            return false;
+        }
+        return true;
+    }
+    
+    /** */
+    public void assertGetX(PCPoint p, int value, String assertion, String 
label) {
+        if (p.getX() !=  value) {
+            fail(assertion, label);
+        }
+    }
+}
+
+

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+/**
+ *<B>Title:</B> Same Transaction Instance For All Calls To Current Transaction
+ *<BR>
+ *<B>Keywords:</B> 
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.2-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+The identical <code>Transaction</code> instance will be returned by all
+<code>currentTransaction</code> calls to the same 
<code>PersistenceManager</code>
+until <code>close</code>. 
+
+ */
+
+public class SameTransactionInstanceForAllCallsToCurrentTransaction extends 
JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.2-2 
(SameTransactionInstanceForAllCallsToCurrentTransaction) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(SameTransactionInstanceForAllCallsToCurrentTransaction.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        Transaction tx1 = getPM().currentTransaction();
+        tx1.begin();
+        Transaction tx2 = getPM().currentTransaction();
+        tx1.commit();
+        Transaction tx3 = getPM().currentTransaction();
+    
+        if (tx1 != tx2) {
+            fail(ASSERTION_FAILED,
+                 "tx1 before begin different from tx2 after begin");
+        }
+        if (tx2 != tx3) {
+            fail(ASSERTION_FAILED,
+                 "tx2 after begin different from tx3 after commit");
+        }
+
+        if (!pm.isClosed()) {
+            if (pm.currentTransaction().isActive()) {
+                pm.currentTransaction().rollback();
+            }
+            pm.close();
+        }
+        pm = null;
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/SameTransactionInstanceForAllCallsToCurrentTransaction.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,172 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.util.ThreadExceptionHandler;
+
+/**
+ *<B>Title:</B> Thread Safe
+ *<BR>
+ *<B>Keywords:</B> multithreaded
+ *<BR>
+ *<B>Assertion ID:</B> A12.4-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+It is a requirement for all JDO implementations to be thread-safe. That is, 
the behavior of the implementation must be predictable in the presence of 
multiple application threads.  This assertion will generate multiple test cases 
to be evaluated.
+
+ */
+
+
+public class ThreadSafe extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.4-1 (ThreadSafe) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(ThreadSafe.class);
+    }
+
+    private PersistenceManagerFactory   pmf;
+    PCPoint p1 = null;
+    private int totalThreadCount = 10;
+    private int completedThreadCount = 0;
+    private int succeeds = 0;
+    private int catchNumber = 0;
+
+    /** */
+    public void testThreadSafe() throws Exception  {
+        if(debug) logger.debug("\nSTART testThreadSafe");
+        pmf = getPMF();
+
+        p1 = new PCPoint(3,3);
+
+        ThreadExceptionHandler group = new ThreadExceptionHandler();
+        Thread[] threads = new Thread[totalThreadCount];
+        for (int i=0; i < totalThreadCount; i++) {
+            Thread t = new Thread(group, new PMThread(pmf, p1));
+            t.setName("ThreadSafeID-" + i);
+            threads[i] = t;
+            t.start();
+        }
+
+        for (int i = 0; i < totalThreadCount; i++) {
+            try {   
+                threads[i].join();
+            } 
+            catch (InterruptedException e) { 
+                // ignored
+            }
+       }
+        
+        checkResults(group);
+    }
+
+    /** */
+    protected synchronized void complete() {
+        completedThreadCount++;
+    }
+    
+    /** */
+    protected synchronized void winning(PCPoint pc) {
+        if (debug)
+            logger.debug("[" + Thread.currentThread().getName()  + "]: 
succeeds");
+        succeeds++;
+    }
+
+    /** */
+    public void checkResults(ThreadExceptionHandler group) {
+        // check unhandled exceptions
+        Set uncaught = group.getAllUncaughtExceptions();
+        if ((uncaught != null) && !uncaught.isEmpty()) {
+            for (Iterator i = uncaught.iterator(); i.hasNext();) {
+                Map.Entry next = (Map.Entry)i.next();
+                Thread thread = (Thread)next.getKey();
+                Throwable problem = (Throwable)next.getValue();
+                fail(ASSERTION_FAILED,
+                     "Uncaught exception " + problem + " in thread " + thread);
+            }
+        }
+
+        if (succeeds != 1) {
+            fail(ASSERTION_FAILED,
+                 "Only one thread should succeed, number of succeeded threads 
is " + succeeds);
+        }
+        
+        if (catchNumber != totalThreadCount - 1) {
+            fail(ASSERTION_FAILED,
+                 "All but one threads should throw exceptions, expected " + 
+                 (totalThreadCount - 1) + ", got " + catchNumber);
+        }
+    }
+
+/** */
+    class PMThread implements Runnable {
+        private final PersistenceManager pm;
+        private final Object pc;
+
+        /** */
+        PMThread(PersistenceManagerFactory pmf, PCPoint pc) {
+            this.pm = pmf.getPersistenceManager();
+            this.pc = pc;
+        }
+
+        /** */
+        public void run() {
+            String threadName = Thread.currentThread().getName();
+            Transaction tx = pm.currentTransaction();
+            try {
+                ThreadSafe.this.logger.debug("[" + threadName + "]: running");
+                tx.begin();
+                pm.makePersistent(pc);
+                tx.commit();
+                tx = null;
+                winning((PCPoint) pc);
+                complete();
+            } 
+            catch (JDOUserException ex) {
+                ThreadSafe.this.logger.debug("[" + threadName +
+                                             "]: throws expected " + ex);
+                catchNumber++;
+                complete();
+            } 
+            finally {
+                if ((tx != null) && tx.isActive()) {
+                    tx.rollback();
+                }
+                pm.close();
+            }
+        }              // run
+    }  // class PMThread
+}
+

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ThreadSafe.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Transient Transactional Instance Retains Values At Commit
+ *<BR>
+ *<B>Keywords:</B> transienttransactional
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.7-21
+ *<BR>
+ *<B>Assertion Description: </B>
+If the transaction in which an instance is made transactional (by calling 
PersistenceManager.makeTransactional or makeTransactionalAll) commits, then the 
transient instance retains its values.
+
+ */
+
+public class TransientTransactionalInstanceRetainsValuesAtCommit extends 
PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-21 
(TransientTransactionalInstanceRetainsValuesAtCommit) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(TransientTransactionalInstanceRetainsValuesAtCommit.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    private Collection col1 = new HashSet();
+    private Collection col2 = new HashSet();
+
+
+    /** */
+    public void testTransientTransactionalInstanceRetainsValuesAtCommit() {
+        pm = getPM();
+
+        createObjects(pm);
+        runTestTransientTransactional1(pm);
+        runTestTransientTransactional2(pm);
+        runTestTransientTransactional3(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        p1 = new PCPoint(1,3);
+        p2 = new PCPoint(2,4);
+        p3 = new PCPoint(3,5);
+        p4 = new PCPoint(4,6);
+        p5 = new PCPoint (5,7);
+        
+        col1.add(p2);
+        col1.add(p3);
+        
+        col2.add(p4);
+        col2.add(p5);
+    }
+
+    /** */
+    private void runTestTransientTransactional1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug(" ** in runTestTransientTransactional1() ");
+        try {
+            PCPoint p1 = new PCPoint(8,8);
+            p1.setX(100);
+            tx.begin();
+            p1.setX(200);
+            pm.makeTransactional(p1);
+            p1.setX(300);
+            tx.commit();
+            tx = null;
+
+            assertGetX (p1, 300, ASSERTION_FAILED, 
"runTestTransientTransactional1");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestTransientTransactional2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug(" ** in runTestTransientTransactional2() ");
+        try {
+            p2.setX(100);
+            p3.setX(100);
+            tx.begin();
+            p2.setX(201);
+            p3.setX(201);
+            pm.makeTransactionalAll(col1);
+            p2.setX(301);
+            p3.setX(301);
+            tx.commit();
+            tx = null;
+
+            assertGetX (p2, 301, ASSERTION_FAILED, 
"runTestTransientTransactional2");
+            assertGetX (p3, 301, ASSERTION_FAILED, 
"runTestTransientTransactional2");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestTransientTransactional3(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug(" ** in runTestTransientTransactional3() ");
+        try {
+            p4.setX(100);
+            p5.setX(100);
+            tx.begin();
+            p4.setX(201);
+            p5.setX(201);
+            pm.makeTransactionalAll(col2.toArray());
+            p4.setX(301);
+            p5.setX(301);
+            tx.commit();
+            tx = null;
+
+            assertGetX (p4, 301, ASSERTION_FAILED, 
"runTestTransientTransactional2");
+            assertGetX (p5, 301, ASSERTION_FAILED, 
"runTestTransientTransactional2");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/TransientTransactionalInstanceRetainsValuesAtCommit.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager.cache;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Calling EvictAll With Collection Containing Nulls
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-11
+ *<BR>
+ *<B>Assertion Description: </B>
+Passing a non-null Object[] or Collection arguments to evictAll that
+contain null elements will have the documented behavior for non-null elements, 
and the null elements
+will be ignored.
+
+ */
+
+public class CallingEvictAllWithCollectionContainingNulls extends 
PersistenceManagerTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-11 (CallingEvictAllWithCollectionContainingNulls) 
failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(CallingEvictAllWithCollectionContainingNulls.class);
+    }
+    
+    private PCPoint p1;
+    private PCPoint p2;
+    private PCPoint p3;
+    private PCPoint p4;
+    private PCPoint p5;
+
+    /** */
+    public void testCallingEvictAllWithCollectionContainingNulls() {
+        pm = getPM();
+        createObjects(pm);
+        runTestEvictAll1(pm);
+        runTestEvictAll2(pm);
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1 = new PCPoint (1,3);
+            p2 = new PCPoint (4,3);
+            p3 = new PCPoint (4,2);
+            p4 = new PCPoint (3,3);
+            
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+         
+            tx.commit();
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /* test evictAll (Collection col1) */
+    private void runTestEvictAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            PCPoint p5 = null;
+            Collection col1 = new java.util.HashSet();
+            col1.add (p1);
+            col1.add (p5);
+            col1.add (p2);
+            
+            pm.evictAll(col1);
+            if (debug) logger.debug(" \nPASSED in testEvictAll1()");
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /** test evictAll (Object[] objArray) */
+    private void runTestEvictAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            PCPoint p5 = null;
+            Collection col1 = new java.util.HashSet();
+            col1.add (p3);
+            col1.add (p4);
+            col1.add (p5);
+            
+            pm.evictAll(col1.toArray());
+            if (debug) logger.debug(" \nPASSED in testEvictAll2()");
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingEvictAllWithCollectionContainingNulls.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager.cache;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Calling RefreshAll With Collection Containing Nulls
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-12
+ *<BR>
+ *<B>Assertion Description: </B>
+Passing a non-null Object[] or Collection arguments to refreshAll that
+contain null elements will have the documented behavior for non-null elements, 
and the null
+elements will be ignored.
+
+ */
+
+public class CallingRefreshAllWithCollectionContainingNulls extends 
PersistenceManagerTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-12 (CallingRefreshAllWithCollectionContainingNulls) 
failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        
BatchTestRunner.run(CallingRefreshAllWithCollectionContainingNulls.class);
+    }
+    
+    private PCPoint p1;
+    private PCPoint p2;
+    private PCPoint p3;
+    private PCPoint p4;
+    private PCPoint p5;
+
+    /** */
+    public void testCallingRefreshAllWithCollectionContainingNulls() {
+       pm = getPM();  
+       createObjects(pm);
+       runTestRefreshAll1(pm);
+       runTestRefreshAll2(pm);
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+               tx.begin();
+               p1 = new PCPoint (1,3);
+               p2 = new PCPoint (2,3);
+               p3 = new PCPoint (4,2);
+               p4 = new PCPoint (3,3);
+
+               pm.makePersistent(p1);
+               pm.makePersistent(p2);
+               pm.makePersistent(p3);
+               pm.makePersistent(p4);
+
+               tx.commit();
+        }
+        finally {
+               if (tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /**  test refreshAll (Collection col1) */
+    private void runTestRefreshAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+               tx.begin();
+
+               PCPoint p5 = null;
+               Collection col1 = new java.util.HashSet();
+               col1.add (p1);
+               col1.add (p5);
+               col1.add (p2);
+
+               pm.refreshAll(col1);
+               if (debug) logger.debug(" \nPASSED in testRefreshAll1()");
+               tx.rollback();
+        }
+        finally {
+               if (tx.isActive())
+                       tx.rollback();
+        }
+    }
+
+
+    /* test refreshAll (Object[] objArray) */
+    private void runTestRefreshAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {                  
+               tx.begin();
+
+               PCPoint p5 = null;
+               Collection col1 = new java.util.HashSet();
+               col1.add (p3);
+               col1.add (p4);
+               col1.add (p5);
+          
+               pm.refreshAll(col1.toArray());
+               if (debug) logger.debug(" \nPASSED in testRefreshAll2()");
+               tx.rollback();
+        } 
+        finally {
+               if (tx.isActive())
+                       tx.rollback();
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/CallingRefreshAllWithCollectionContainingNulls.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java
URL: 
http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java?view=auto&rev=160090
==============================================================================
--- 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java
 (added)
+++ 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java
 Mon Apr  4 12:41:23 2005
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2005 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.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager.cache;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+import org.apache.jdo.tck.pc.mylib.PCPoint2;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> EvictAllWithNoParameters
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.1-2
+ *<BR>
+ *<B>Assertion Description: </B>
+ If PersistenceManager.evict is called with no parameter, then all referenced 
instances are evicted. For each instance evicted, it:
+ *<UL>
+ *<LI> calls the jdoPreClearmethod on each instance, if the class of the 
instance implements InstanceCallbacks </LI>
+ *<LI> clears persistent fields on each instance after the call to 
jdoPreClear()</LI>
+ *<LI> changes the state of instances to hollow or persistent-nontransactional 
(cannot distinguish between these two states) this is not directly testable. 
</LI>
+ *</UL>
+
+ */
+
+public class EvictAllWithNoParameters extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.1-2 (EvictAllWithNoParameters) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(EvictAllWithNoParameters.class);
+    }
+    
+    private PCPoint2 pnt1 = null;
+    private PCPoint2 p1 = null;
+
+    /** */
+    public void testEvictAllWithNoParameters() {
+        pm = getPM();
+        createObjects(pm);
+        runTestEvictAll(pm);
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pnt1 = new PCPoint2(1,3);
+            p1   = new PCPoint2 (3,5);
+            pm.makePersistent(pnt1);
+            pm.makePersistent(p1);
+            tx.commit();
+
+            // P-nontransactional instance
+            // Check whether pmf supported optimitic tx
+            tx.setOptimistic(isOptimisticSupported());
+            tx.begin();
+            pnt1.getX();
+            tx.commit();
+            
+            // P-clean instance 
+            tx.setOptimistic(false);
+            tx.begin();
+            p1.getX();
+            tx.commit();
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestEvictAll(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.evictAll();
+
+            if ( !p1.wasClearCalled()) {
+                fail(ASSERTION_FAILED,
+                     "missing call of p1.jdoPreClear during pm.evictAll");
+            }
+            if ( !pnt1.wasClearCalled()) {
+                fail(ASSERTION_FAILED,
+                     "missing call of pnt1.jdoPreClear during pm.evictAll");
+            }
+
+            if ( testState(p1, HOLLOW, "hollow") ||
+                 testState(p1, PERSISTENT_NONTRANSACTIONAL, 
"persistent_nontransaction")) {
+                ;  // expected result
+            } 
+            else {
+                fail(ASSERTION_FAILED,
+                     "p1 should be HOLLOW or P-NONTX after pm.evictAll.");
+            }
+
+            if ( testState(pnt1, HOLLOW, "hollow") ||
+                 testState(pnt1, PERSISTENT_NONTRANSACTIONAL, 
"persistent_nontransaction")) {
+                ;  // expected result
+            } 
+            else {
+                fail(ASSERTION_FAILED,
+                     "pnt1 should be HOLLOW or P-NONTX after pm.evictAll.");
+            }
+            tx.commit();
+            if (debug) logger.debug(" \nPASSED in testEvictAll()");
+        }
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Propchange: 
incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/EvictAllWithNoParameters.java
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to