db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r158179 [9/61] - in incubator/jdo/trunk/tck11: ./ assertions/ iut_jars/ test/ test/conf/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/jdo/ test/java/org/apache/jdo/tck/ test/java/org/apache/jdo/tck/api/ test/java/org/apache/jdo/tck/api/instancecallbacks/ test/java/org/apache/jdo/tck/api/jdohelper/ test/java/org/apache/jdo/tck/api/persistencemanager/ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ test/java/org/apache/jdo/tck/enhancement/ test/java/org/apache/jdo/tck/extents/ test/java/org/apache/jdo/tck/lifecycle/ test/java/org/apache/jdo/tck/lifecycle/nontransactional/ test/java/org/apache/jdo/tck/models/ test/java/org/apache/jdo/tck/models/embedded/ test/java/org/apache/jdo/tck/models/fieldtypes/ test/java/org/apache/jdo/tck/models/inheritance/ test/java/org/apache/jdo/tck/pc/ test/java/org/apache/jdo/tck/pc/company/ test/java/org/apache/jdo/tck/pc/fieldtypes/ test/java/org/apache/jdo/tck/pc/inheritance/ test/java/org/apache/jdo/tck/pc/instancecallbacks/ test/java/org/apache/jdo/tck/pc/lifecycle/ test/java/org/apache/jdo/tck/pc/mylib/ test/java/org/apache/jdo/tck/query/ test/java/org/apache/jdo/tck/query/operators/ test/java/org/apache/jdo/tck/transactions/ test/java/org/apache/jdo/tck/util/ test/jdo/ test/jdo/applicationidentity/ test/jdo/applicationidentity/org/ test/jdo/applicationidentity/org/apache/ test/jdo/applicationidentity/org/apache/jdo/ test/jdo/applicationidentity/org/apache/jdo/tck/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ test/jdo/datastoreidentity/ test/jdo/datastoreidentity/org/ test/jdo/datastoreidentity/org/apache/ test/jdo/datastoreidentity/org/apache/jdo/ test/jdo/datastoreidentity/org/apache/jdo/tck/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/
Date Sat, 19 Mar 2005 01:09:44 GMT
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFailsWithDirtyInstance.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFailsWithDirtyInstance.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFailsWithDirtyInstance.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFailsWithDirtyInstance.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,190 @@
+/*
+ * 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>MakeTransientFailsWithDirtyInstance
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-16
+ *<BR>
+ *<B>Assertion Description: </B>
+If the instance passed to PersistenceManager.makeTransient or makeTransientAll is dirty, a JDOUserException is thrown.
+
+ */
+
+public class MakeTransientFailsWithDirtyInstance extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-16 (MakeTransientFailsWithDirtyInstance) 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(MakeTransientFailsWithDirtyInstance.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakeTransientFailsWithDirtyInstance() {
+        pm = getPM();
+
+        createObjects(pm);
+        runTestMakeTransient(pm);
+        runTestMakeTransientAll1(pm);
+        runTestMakeTransientAll2(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void  createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            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();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTansient (Object pc) */
+    private void runTestMakeTransient(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            // make instance dirty
+            p1.setX(100);
+            
+            try {
+                pm.makeTransient(p1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransient should throw JDOUserException when called for P-DIRTY instance.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTansientAll (Collection pcs) */
+    private void runTestMakeTransientAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+
+            tx = pm.currentTransaction();
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            p2.setX(200);
+            p3.setX(201);
+
+            try {
+                pm.makeTransientAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransientAll(Collection) should throw JDOUserException when called for a collection including P-DIRTY instances.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+        	tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p4);
+            col1.add(p5);
+
+            p4.setX(300);
+            p5.setX(301);
+
+            Object[] obj1=col1.toArray();
+            
+            try {
+                pm.makeTransientAll(obj1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransientAll(Object[]) should throw JDOUserException when called for an array including P-DIRTY instances.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFieldsPreservedUnchanged.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFieldsPreservedUnchanged.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFieldsPreservedUnchanged.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientFieldsPreservedUnchanged.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,243 @@
+/*
+ * 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 java.util.Iterator;
+
+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> MakeTransient Fields Preserved Unchanged
+ *<BR>
+ *<B>Keywords:</B> transient
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-15, A12.5.7-18
+ *<BR>
+ *<B>Assertion Description: </B>
+If the instance passed to PersistenceManager.makeTransient or makeTransientAll has field values (persistent-nontransactional or persistent-clean), the fields in the cache are preserved unchanged. The instance(s) are not modified in any way.
+ */
+
+public class MakeTransientFieldsPreservedUnchanged extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-15, A12.5.7-18 (MakeTransientFieldsPreservedUnchanged) 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(MakeTransientFieldsPreservedUnchanged.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    private PCPoint np1 = null;
+    private PCPoint np2 = null;
+    private PCPoint np3 = null;
+    private PCPoint np4 = null;
+    private PCPoint np5 = null;
+
+    /** */
+    public void testMakeTransientFieldsPreservedUnchanged() {
+        pm = getPM();
+
+        createObjects(pm);
+        runTestMakeTransientFieldsPreservedUnchanged1(pm);
+        runTestMakeTransientFieldsPreservedUnchangedAll1(pm);
+        runTestMakeTransientFieldsPreservedUnchangedAll2(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        createPCleanObjects(pm);
+        createPNonTransactionalObjects(pm);
+    }
+    
+    /** */
+    private void  createPCleanObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            // create P-clean instances
+            tx.setOptimistic(false);
+            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();
+
+            tx.begin();
+            p1.getX();
+            p2.getX();
+            p3.getX();
+            p4.getX();
+            p5.getX();
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void createPNonTransactionalObjects(PersistenceManager pm) {
+        if (isOptimisticSupported()) {
+            Transaction tx = pm.currentTransaction();
+            try {
+                tx.setOptimistic(true);
+                tx.begin();
+                
+                np1 = new PCPoint(1,3);
+                np2 = new PCPoint(2,4);
+                np3 = new PCPoint(3,5);
+                np4 = new PCPoint(4,6);
+                np5 = new PCPoint(5,7);
+                
+                pm.makePersistent(np1);
+                pm.makePersistent(np2);
+                pm.makePersistent(np3);
+                pm.makePersistent(np4);
+                pm.makePersistent(np5);
+                tx.commit();
+                
+                tx.begin();
+                np1.getX();
+                np2.getX();
+                np3.getX();
+                np4.getX();
+                np5.getX();
+                tx.commit();
+                tx = null;
+            }
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+        }
+    }
+    
+    /* test makeTransient (Object pc)
+     * instance passed has field values and is P-nontransactional *
+     */
+    private void runTestMakeTransientFieldsPreservedUnchanged1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makeTransient(p1);
+            tx.commit();
+            tx = null;
+
+            if (!testState(p1, TRANSIENT, "transient")) {
+                fail(ASSERTION_FAILED,
+                     "expected TRANSIENT instance, instance " + p1 + 
+                     " is " + getStateOfInstance(p1));
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Collection pcs) */
+    private void runTestMakeTransientFieldsPreservedUnchangedAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            pm.makeTransientAll(col1);
+            tx.commit();
+            tx = null;
+            
+            for (Iterator iter = col1.iterator(); iter.hasNext();) {
+                PCPoint p = (PCPoint) iter.next();
+                if (!testState(p, TRANSIENT, "transient")) {
+                    fail(ASSERTION_FAILED,
+                         "expected TRANSIENT instance, instance " + p + 
+                         " is " + getStateOfInstance(p));
+                }
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientFieldsPreservedUnchangedAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            int NUM_OBJS = 2;
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p4);
+            col1.add(p5);
+
+            Object[] obj1= col1.toArray();
+
+            pm.makeTransientAll(obj1);
+            tx.commit();
+            tx = null;
+            
+            for (int i=0; i < NUM_OBJS; ++i ) {
+                PCPoint p = (PCPoint) obj1[i];
+                if (!testState(p, TRANSIENT, "transient")) {
+                    fail(ASSERTION_FAILED,
+                         "expected TRANSIENT instance, instance " + p + 
+                         " is " + getStateOfInstance(p));
+                }
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientHasNoEffectOnTransientInstances.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientHasNoEffectOnTransientInstances.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientHasNoEffectOnTransientInstances.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientHasNoEffectOnTransientInstances.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,150 @@
+/*
+ * 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> MakeTransientHasNoEffectOnTransientInstances
+ *<BR>
+ *<B>Keywords:</B> transient
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-19
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeTransient and
+makeTransientAll have no effect if the parameter instance is transient.
+
+ */
+
+public class MakeTransientHasNoEffectOnTransientInstances
+    extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-19 (MakeTransientHasNoEffectOnTransientInstances) 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(MakeTransientHasNoEffectOnTransientInstances.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakeTransientHasNoEffectOnTransientInstances() {
+        pm = getPM();
+
+        createTransientObjects();
+        runTestMakeTransientHasNoEffectOnTransientInstances1(pm);
+        runTestMakeTransientHasNoEffectOnTransientInstancesAll1(pm);
+        runTestMakeTransientHasNoEffectOnTransientInstancesAll2(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void  createTransientObjects() {
+        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);
+    }
+
+    /* test makeTransient (Object pc) */
+    private void runTestMakeTransientHasNoEffectOnTransientInstances1(
+        PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makeTransient(p1);
+            tx.commit();
+            tx = null;
+            if (debug)
+                logger.debug (" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstances()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Collection pcs) */
+    private void runTestMakeTransientHasNoEffectOnTransientInstancesAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            pm.makeTransientAll(col1);
+            tx.commit();
+            tx = null;
+            if (debug)
+                logger.debug(" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstancesAll1()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientHasNoEffectOnTransientInstancesAll2(
+        PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p4);
+            col1.add(p5);
+
+            Object[] obj1= col1.toArray();
+
+            pm.makeTransientAll(obj1);
+            tx.commit();
+            tx = null;
+            if (debug)
+                logger.debug (" \nPASSED in runTestMakeTransientHasNoEffectOnTransientInstancesAll2()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientNotSubjectToRollback.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientNotSubjectToRollback.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientNotSubjectToRollback.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeTransientNotSubjectToRollback.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,184 @@
+/*
+ * 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> MakeTransientNotSubjectToRollback
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-17
+ *<BR>
+ *<B>Assertion Description: </B>
+The effect of PersistenceManager.makeTransient or makeTransientAll is immediate and not subject to rollback.
+
+ */
+
+public class MakeTransientNotSubjectToRollback extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-17 (MakeTransientNotSubjectToRollback) 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(MakeTransientNotSubjectToRollback.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakeTransientNotSubjectToRollback() {
+        pm = getPM();
+
+        createPersistentObjects(pm);
+        runTestMakeTransientNotSubjectToRollback1(pm);
+        runTestMakeTransientNotSubjectToRollbackAll1(pm);
+        runTestMakeTransientNotSubjectToRollbackAll2(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void  createPersistentObjects(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();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransient (Object pc) */
+    private void runTestMakeTransientNotSubjectToRollback1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makeTransient(p1);
+            int curr1 = currentState(p1);
+            tx.rollback();
+
+            if (curr1 != currentState(p1)) {
+                fail(ASSERTION_FAILED,
+                     "expected TRANSIENT instancew, instance " + p1 + 
+                     " is " + getStateOfInstance(p1));
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Collection pcs) */
+    private void runTestMakeTransientNotSubjectToRollbackAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+            pm.makeTransientAll(col1);
+            int p2_curr = currentState(p2);
+            int p3_curr = currentState(p3);
+            tx.rollback();
+
+            if (p2_curr != currentState(p2)) {
+                fail(ASSERTION_FAILED,
+                     "expected TRANSIENT instancew, instance " + p2 + 
+                     " is " + getStateOfInstance(p2));
+            }
+            if (p3_curr != currentState(p3)) {
+                fail(ASSERTION_FAILED,
+                     "expected TRANSIENT instancew, instance " + p3 + 
+                     " is " + getStateOfInstance(p3));
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientNotSubjectToRollbackAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p4);
+            col1.add(p5);
+
+            Object[] obj1= col1.toArray();
+
+            pm.makeTransientAll(obj1);
+            int p4_curr = currentState(p4);
+            int p5_curr = currentState(p5);
+            tx.rollback();
+
+            if (p4_curr != currentState(p4)) {
+                fail(ASSERTION_FAILED,
+                     "expected TRANSIENT instancew, instance " + p4 + 
+                     " is " + getStateOfInstance(p2));
+            }
+            if (p5_curr != currentState(p5)) {
+                fail(ASSERTION_FAILED,
+                     "expected TRANSIENT instancew, instance " + p5 + 
+                     " is " + getStateOfInstance(p5));
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/NoPersistenceManagerIfTransient.java Fri Mar 18 17:07:39 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.");
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/ObjectIdUniqueAmongInstances.java Fri Mar 18 17:07:39 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;
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OneInstanceOfObjectPerPersistenceManager.java Fri Mar 18 17:07:39 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;
+    }
+    
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OnePersistenceManagerIfPersistentOrTransactional.java Fri Mar 18 17:07:39 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");
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/OptimisticFailure.java Fri Mar 18 17:07:39 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());
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictAllThrowsException.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictAllThrowsException.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictAllThrowsException.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictAllThrowsException.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,112 @@
+/*
+ * 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.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> PassingNullToEvictAllThrowsException
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-9
+ *<BR>
+ *<B>Assertion Description: </B>
+Passing a null valued argument to evictAll will throw a NullPointerException.
+
+ */
+
+public class PassingNullToEvictAllThrowsException extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-9 (PassingNullToEvictAllThrowsException) 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(PassingNullToEvictAllThrowsException.class);
+    }
+
+    /** */
+    public void testPassingNullToEvictAllThrowsException() {
+        pm = getPM();
+
+        runTestEvictAll1(pm);
+        runTestEvictAll2(pm);
+       
+        pm.close();
+        pm = null;
+    }
+
+    /* test evictAll (Collection pcs) */
+    private void runTestEvictAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug ("**  in runTestEvictAll1() ");
+        try {
+            tx.begin();
+            Collection col1 = null;
+            try {
+                pm.evictAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.evictAll should throw NullPointerException when called with argument null");
+            }
+            catch (NullPointerException ex) {
+                // expected exception
+            }
+            tx .rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test evictAll (Object[] objArray) */
+    private void runTestEvictAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug ("**  in runTestEvictAll1() ");
+        try {
+            tx.begin();
+            Object[] arr = null;
+            try {
+                pm.evictAll(arr); 
+                fail(ASSERTION_FAILED,
+                     "pm.evictAll should throw NullPointerException when called with argument null");
+            }
+            catch (NullPointerException ex) {
+                // expected exception
+            }
+            tx .rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictHasNoEffect.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictHasNoEffect.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictHasNoEffect.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToEvictHasNoEffect.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,79 @@
+/*
+ * 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.Transaction;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> PassingNullToEvictHasNoEffect
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-7
+ *<BR>
+ *<B>Assertion Description: </B>
+Passing a null value to PersistenceManager.evict will have no effect. A
+NullPointerException should NOT be thrown.
+
+ */
+
+public class PassingNullToEvictHasNoEffect extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-7 (PassingNullToEvictHasNoEffect) 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(PassingNullToEvictHasNoEffect.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTestPassingNullToEvictHasNoEffect(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /* test evict (object pc) */
+    public void runTestPassingNullToEvictHasNoEffect(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.evict(null);
+            if (debug)
+                logger.debug (" \nPASSED in testPassingNullToEvictHasNoEffect()");
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshAllThrowsException.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshAllThrowsException.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshAllThrowsException.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshAllThrowsException.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,115 @@
+/*
+ * 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.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Passing Null to RefreshAll Throws Exception
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-10.
+ *<BR>
+ *<B>Assertion Description: </B>
+Passing a null valued argument to refreshAll will throw a
+NullPointerException.
+
+ */
+
+public class PassingNullToRefreshAllThrowsException
+    extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-10 (PassingNullToRefreshAllThrowsException) 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(PassingNullToRefreshAllThrowsException.class);
+    }
+
+    /** */
+    public void testPassingNullToRefreshAllThrowsException() {
+        pm = getPM();
+ 
+        runTestRefreshAll1(pm);
+        runTestRefreshAll2(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /* test refreshAll (Collection pcs) */
+    public void runTestRefreshAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug("**  in runTestRefreshAll1() ");
+        try {
+            tx.begin();
+            Collection col1 = null;
+            try {
+                pm.refreshAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.refreshAll should throw NullPointerException when called with argument null");
+            }
+            catch (NullPointerException ex) {
+                // expected exception
+            }
+            tx .rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test refreshAll (Object[] objArray) */
+    public void runTestRefreshAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug ("**  in runTestRefreshAll1() ");
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+            Object[] arr = null;
+            try {
+                pm.refreshAll(arr);
+                fail(ASSERTION_FAILED,
+                     "pm.refreshAll should throw NullPointerException when called with argument null");
+            }
+            catch (NullPointerException ex) {
+                // expected exception
+            }
+            tx .rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshHasNoEffect.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshHasNoEffect.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshHasNoEffect.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PassingNullToRefreshHasNoEffect.java Fri Mar 18 17:07:39 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.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Passing Null to Refresh has no Effect
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-8
+ *<BR>
+ *<B>Assertion Description: </B>
+Passing a null value to PersistenceManager.refresh will have no effect. A NullPointerException should NOT be thrown.
+
+ */
+
+public class PassingNullToRefreshHasNoEffect extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-8 (PassingNullToRefreshHasNoEffect) 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(PassingNullToRefreshHasNoEffect.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTestPassingNullToRefreshHasNoEffect(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /* test evict (object pc) */
+    private void runTestPassingNullToRefreshHasNoEffect(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            PCPoint p1 = null;
+            pm.refresh(p1);
+            if (debug)
+                logger.debug (" \nPASSED in testPassingNullToRefreshHasNoEffect()");
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/PersistenceManagerTest.java Fri Mar 18 17:07:39 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);
+        }
+    }
+}
+
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllNoParameterSideEffects.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllNoParameterSideEffects.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllNoParameterSideEffects.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllNoParameterSideEffects.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,261 @@
+/*
+ * 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.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> Refresh All No Parameters Side Effects
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.1-5B
+ *<BR>
+ *<B>Assertion Description: </B>
+The refreshAll() updates the values in the parameter
+instance[s] from the data in the data store. ((The intended use is for optimistic transactions where the state of
+the JDO Instance is not guaranteed to reflect the state in the data store. This method can be used to minimize
+the occurrence of commit failures due to mismatch between the state of cached instances and the state of
+data in the data store.)) This can be tested by using 2 PersistenceManagers, independently change an object,
+then refresh.
+ */
+
+/** */
+public class RefreshAllNoParameterSideEffects extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.1-5B (RefreshAllNoParameterSideEffects) failed: ";
+    
+    /** */
+    static final int DELAY = 100;
+
+    /**
+     * 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(RefreshAllNoParameterSideEffects.class);
+    }
+
+    /** */
+    public void test () throws Exception {
+        PersistenceManagerFactory pmf = getPMF();
+        PersistenceManager pm1 = pmf.getPersistenceManager();
+        PersistenceManager pm2 = pmf.getPersistenceManager();
+        
+        try {
+            runTestRefreshAllNoParameterSideEffects(pm1, pm2);
+        }
+        finally {
+            cleanupPM(pm2);
+            pm2 = null;
+            cleanupPM(pm1);
+            pm1 = null;
+        }
+    }
+    
+    /** */
+    private void runTestRefreshAllNoParameterSideEffects(PersistenceManager pm1, 
+                                                         PersistenceManager pm2) throws Exception {
+        if (!isOptimisticSupported()) {
+            if (debug)
+                logger.debug("Optimistic not supported => skip RefreshAllNoParameterSideEffects");
+            return;
+        }
+        
+        if (debug) logger.debug ("\nSTART RefreshAllNoParameterSideEffects");
+        
+        ThreadExceptionHandler group = new ThreadExceptionHandler();
+        ThreadT1 thread1 = new ThreadT1(pm1);
+        Thread  T1 = new Thread(group, thread1);
+        ThreadT2 thread2 = new ThreadT2(pm2);
+        Thread  T2 = new Thread(group, thread2);
+        thread1.setOther(thread2);
+        thread2.setOther(thread1);
+        
+        T1.start();
+        T2.start();
+
+        T1.join();
+        T2.join();
+        
+        Throwable t1Problem = group.getUncaughtException(T1);
+        if (t1Problem != null) {
+            if (debug) {
+                logger.debug("RefreshAllNoParameterSideEffects ThreadT1 results in uncaught exception");
+                t1Problem.printStackTrace();
+            }
+            fail(ASSERTION_FAILED,
+                 "ThreadT1 results in exception " + t1Problem);
+        }
+        Throwable t2Problem = group.getUncaughtException(T2);
+        if (t2Problem != null) {
+            if (debug) {
+                logger.debug("RefreshAllNoParameterSideEffects ThreadT2 results in uncaught exception");
+                t2Problem.printStackTrace();
+            }
+            fail(ASSERTION_FAILED,
+                 "ThreadT2 results in exception " + t2Problem);
+        }
+        
+        if (debug) logger.debug ("END RefreshAllNoParameterSideEffects");
+    }
+
+    /** */
+    class ThreadT1 implements Runnable {
+
+        PersistenceManager pm;
+        ThreadT2 other;
+        boolean commitDone;
+
+        /** */
+        public ThreadT1(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.commitDone = false;
+        }
+
+        /** */
+        void setOther(ThreadT2 other) {
+            this.other = other;
+        }
+
+        /** */
+        boolean isCommitDone() {
+            return commitDone;
+        }
+        
+        /** */
+        synchronized public void run() {
+            PCPoint n1 = new PCPoint (5,1);
+            PCPoint n2 = new PCPoint (5,2);
+            Transaction tx = pm.currentTransaction();
+            tx.setOptimistic(true);
+            try {
+                tx.begin();
+                n1.setX(500);
+                n2.setX(501);
+
+                Collection col1 = new HashSet();
+                col1.add(n1);
+                col1.add(n2);
+
+                pm.makePersistentAll(col1);
+                pm.refreshAll();
+
+                RefreshAllNoParameterSideEffects.this.logger.debug(
+                    "  ThreadT1: waiting for ThreadT2.done");
+                while (!other.isDone()) {
+                    try {
+                        Thread.sleep(DELAY);
+                    }
+                    catch (InterruptedException ex) {
+                        // ignore
+                    }
+                }
+
+                tx.commit();
+                tx = null;
+                commitDone = true;
+                RefreshAllNoParameterSideEffects.this.logger.debug(
+                    "  ThreadT1: commit finished.");
+            }
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+        }
+    }
+
+    /** */
+    class ThreadT2 implements Runnable {
+
+        PersistenceManager pm = null;
+        ThreadT1 other = null;
+        boolean done = false;
+
+        /** */
+        public ThreadT2(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.done = false;
+        }
+
+        /** */
+        boolean isDone() {
+            return done;
+        }
+        
+
+        /** */
+        void setOther(ThreadT1 other) {
+            this.other = other;
+        }
+
+        /** */
+        synchronized public void run() {
+            PCPoint p1 = new PCPoint (5,1);
+            PCPoint p2 = new PCPoint (5,2);
+            Transaction tx = pm.currentTransaction();
+            tx.setOptimistic(true);
+            try {
+                tx.begin();
+                p1.setX(200);
+                p2.setX(201);
+
+                Collection col1 = new HashSet();
+                col1.add(p1);
+                col1.add(p2);
+                pm.makePersistentAll(col1);
+                pm.refreshAll();
+                done = true; 
+
+                RefreshAllNoParameterSideEffects.this.logger.debug(
+                    "  ThreadT2: waiting for commit of ThreadT1");
+                while (! other.isCommitDone()) {
+                    try {
+                        Thread.sleep(DELAY);
+                    }
+                    catch (InterruptedException ex) {
+                        // ignore
+                    }
+                }
+
+                tx.commit();
+                tx = null;
+                RefreshAllNoParameterSideEffects.this.logger.debug(
+                    "  ThreadT2: commit finished.");
+            }
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithArraySideEffects.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithArraySideEffects.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithArraySideEffects.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithArraySideEffects.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,254 @@
+/*
+ * 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.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> Refresh All With Array Side Effects
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.1-5D
+ *<BR>
+ *<B>Assertion Description: </B>
+The refreshAll(Object[] pcs) updates the values in the parameter
+instance[s] from the data in the data store. ((The intended use is for optimistic transactions where the state of
+the JDO Instance is not guaranteed to reflect the state in the data store. This method can be used to minimize
+the occurrence of commit failures due to mismatch between the state of cached instances and the state of
+data in the data store.)) This can be tested by using 2 PersistenceManagers, independently change an object,
+then refresh.
+ */
+
+
+/** */
+public class RefreshAllWithArraySideEffects extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.1-5D (RefreshAllWithArraySideEffects) failed: ";
+    
+    /** */
+    static final int DELAY = 100;
+
+    /**
+     * 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(RefreshAllWithArraySideEffects.class);
+    }
+
+    /** */
+    public void test () throws Exception {
+        PersistenceManagerFactory pmf = getPMF();
+        PersistenceManager pm1 = pmf.getPersistenceManager();
+        PersistenceManager pm2 = pmf.getPersistenceManager();
+        
+        try {
+            runTestRefreshAllWithArraySideEffects(pm1, pm2);
+        }
+        finally {
+            cleanupPM(pm2);
+            pm2 = null;
+            cleanupPM(pm1);
+            pm1 = null;
+        }
+    }
+
+    /** */
+    private void runTestRefreshAllWithArraySideEffects(
+        PersistenceManager pm1, PersistenceManager pm2) throws Exception {
+        if (debug) logger.debug("\nSTART RefreshAllWithArraySideEffects");
+
+        ThreadExceptionHandler group = new ThreadExceptionHandler();
+        RefreshArrThreadT1 thread1 = new RefreshArrThreadT1(pm1);
+        Thread  T1 = new Thread(group, thread1);
+        RefreshArrThreadT2 thread2 = new RefreshArrThreadT2(pm2);
+        Thread  T2 = new Thread(group, thread2);
+        thread1.setOther(thread2);
+        thread2.setOther(thread1);
+        
+        T1.start();
+        T2.start();
+        
+        T1.join();
+        T2.join();
+        
+        Throwable t1Problem = group.getUncaughtException(T1);
+        if (t1Problem != null) {
+            if (debug) {
+                logger.debug("RefreshAllWithArraySideEffects ThreadT1 results in uncaught exception");
+                t1Problem.printStackTrace();
+            }
+            fail(ASSERTION_FAILED,
+                 "ThreadT1 results in exception " + t1Problem);
+        }
+        Throwable t2Problem = group.getUncaughtException(T2);
+        if (t2Problem != null) {
+            if (debug) {
+                logger.debug("RefreshAllWithArraySideEffects ThreadT2 results in uncaught exception");
+                t2Problem.printStackTrace();
+            }
+            fail(ASSERTION_FAILED,
+                 "ThreadT2 results in exception " + t2Problem);
+        }
+
+        if (debug) logger.debug ("END RefreshAllWithArraySideEffects");
+    }
+
+    /** */
+    class RefreshArrThreadT1 implements Runnable {
+
+        PersistenceManager pm;
+        RefreshArrThreadT2 other;
+        boolean commitDone;
+
+        /** */
+        RefreshArrThreadT1(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.commitDone = false;
+        }
+
+        /** */
+        void setOther(RefreshArrThreadT2 other) {
+            this.other = other;
+        }
+
+        /** */
+        boolean isCommitDone() {
+            return commitDone;
+        }
+        
+        /** */
+        synchronized public void run() {
+            PCPoint n1 = new PCPoint (5,1);
+            PCPoint n2 = new PCPoint (5,2);
+            Transaction tx = pm.currentTransaction();
+            try {
+                tx.begin();
+                n1.setX(500);
+                n2.setX(501);
+
+                Collection col1 = new HashSet();
+                col1.add(n1);
+                col1.add(n2);
+
+                pm.makePersistentAll(col1);
+                pm.refreshAll(col1.toArray());
+                RefreshAllWithArraySideEffects.this.logger.debug(
+                    "  ThreadT1: waiting for ThreadT2.done");
+
+                while (!other.isDone()) {
+                    try {
+                        Thread.sleep(DELAY);
+                    }
+                    catch (InterruptedException ex) {
+                        // ignore
+                    }
+                }
+
+                tx.commit();
+                tx = null;
+                commitDone = true;
+                RefreshAllWithArraySideEffects.this.logger.debug(
+                    "  ThreadT1: commit finished.");
+            } 
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+        }
+    }
+
+    /** */
+    class RefreshArrThreadT2 implements Runnable{
+
+
+        PersistenceManager pm;
+        RefreshArrThreadT1 other;
+        boolean done;
+
+        /** */
+        public RefreshArrThreadT2(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.done = false;
+        }
+
+        /** */
+        boolean isDone() {
+            return done;
+        }
+        
+
+        /** */
+        void setOther(RefreshArrThreadT1 other) {
+            this.other = other;
+        }
+
+        /** */
+        synchronized public void run() {
+            PCPoint p1 = new PCPoint (5,1);
+            PCPoint p2 = new PCPoint (5,2);
+            Transaction tx = pm.currentTransaction();
+            try {
+                tx.begin();
+                p1.setX(200);
+                p2.setX(201);
+
+                Collection col1 = new HashSet();
+                col1.add(p1);
+                col1.add(p2);
+                pm.makePersistentAll(col1);
+                pm.refreshAll(col1.toArray());
+                done = true;
+
+                RefreshAllWithArraySideEffects.this.logger.debug(
+                    "  ThreadT2: waiting for commit of ThreadT1");
+                while (!other.isCommitDone()) {
+                    try {
+                        Thread.sleep(DELAY);
+                    }
+                    catch (InterruptedException ex) {
+                        // ignore
+                    }
+                }
+                tx.commit();
+                tx = null;
+                RefreshAllWithArraySideEffects.this.logger.debug(
+                    "  ThreadT2: commit finished.");
+            } 
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+
+        }
+    }
+}



Mime
View raw message