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 [10/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:45 GMT
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithCollectionSideEffects.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithCollectionSideEffects.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithCollectionSideEffects.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithCollectionSideEffects.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,252 @@
+/*
+ * 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 Collection Side Effects
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.1-5C
+ *<BR>
+ *<B>Assertion Description: </B>
+The refreshAll(Collection 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 RefreshAllWithCollectionSideEffects extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.1-5C (RefreshAllWithCollectionSideEffects) 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(RefreshAllWithCollectionSideEffects.class);
+    }
+    
+    /** */
+    public void test () throws Exception {
+        PersistenceManagerFactory pmf = getPMF();
+        PersistenceManager pm1 = pmf.getPersistenceManager();
+        PersistenceManager pm2 = pmf.getPersistenceManager();
+        
+        try {
+            runTestRefreshAllWithCollectionSideEffects(pm1, pm2);
+        }
+        finally {
+            cleanupPM(pm2);
+            pm2 = null;
+            cleanupPM(pm1);
+            pm1 = null;
+        }
+    }
+
+    /** */
+    public void runTestRefreshAllWithCollectionSideEffects(PersistenceManager pm1, 
+                                                           PersistenceManager pm2) throws Exception {
+        if (debug) logger.debug("\nSTART RefreshAllWithCollectionSideEffects");
+
+        ThreadExceptionHandler group = new ThreadExceptionHandler();
+        RefreshColThreadT1 thread1 = new RefreshColThreadT1(pm1);
+        Thread  T1 = new Thread(group, thread1);
+        RefreshColThreadT2 thread2 = new RefreshColThreadT2(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("RefreshAllWithCollectionSideEffects 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("RefreshAllWithCollectionSideEffects ThreadT2 results in uncaught exception");
+                t2Problem.printStackTrace();
+            }
+            fail(ASSERTION_FAILED,
+                 "ThreadT2 results in exception " + t2Problem);
+        }
+
+        if (debug) logger.debug("END RefreshAllWithCollectionSideEffects");
+    }
+
+    /** */
+    class RefreshColThreadT1 implements Runnable{
+
+        PersistenceManager pm;
+        RefreshColThreadT2 other;
+        boolean commitDone;
+    
+        /** */
+        RefreshColThreadT1(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.commitDone = false;
+        }
+        
+        /** */
+        void setOther(RefreshColThreadT2 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);
+                RefreshAllWithCollectionSideEffects.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;
+                RefreshAllWithCollectionSideEffects.this.logger.debug(
+                    "  ThreadT1: commit finished.");
+            } 
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+        }
+    }
+
+    /** */
+    class RefreshColThreadT2 implements Runnable{
+
+        PersistenceManager pm = null;
+        RefreshColThreadT1 other = null;
+        boolean done = false;
+    
+        /** */
+        RefreshColThreadT2(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.done = false;
+        }
+
+        /** */
+        boolean isDone() {
+            return done;
+        }
+        
+
+        /** */
+        void setOther(RefreshColThreadT1 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);
+                done = true;
+
+                RefreshAllWithCollectionSideEffects.this.logger.debug(
+                    "  ThreadT2: waiting for commit of ThreadT1");
+                while (!other.isCommitDone()) {
+                    try {
+                        Thread.sleep(DELAY);
+                    }
+                    catch (InterruptedException ex) {
+                        // ignore
+                    }
+                }
+                tx.commit();
+                tx = null;
+                RefreshAllWithCollectionSideEffects.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/RefreshAllWithNoParameters.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithNoParameters.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithNoParameters.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshAllWithNoParameters.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,102 @@
+/*
+ * 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.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Refresh All With No Parameters
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.1-6.
+ *<BR>
+ *<B>Assertion Description: </B>
+ The <code>PersistenceManager.refreshAll</code> method with no parameters
+ causes all transactional instances to be refreshed. Note that this method
+ will cause loss of changes made to affected instances by the application
+ due to refreshing the contents from the data store.
+ The JDO <code>PersistenceManager</code>:
+ <UL>
+ <LI>loads persistent values from the data store;</LI>
+ <LI>loads persistent fields into the instance;</LI>
+ <LI>calls the <code>jdoPostLoad</code> method on each persistent instance,
+ if the class of the instance implements <code>InstanceCallbacks</code>; and</LI>
+ <LI>changes the state of persistent-dirty instances to persistent-clean.</LI>
+ </UL>
+
+ */
+
+public class RefreshAllWithNoParameters extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.1-6 (RefreshAllWithNoParameters) 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(RefreshAllWithNoParameters.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTestRefreshAll(pm);
+
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void runTestRefreshAll(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            PCPoint p = new PCPoint (100, 200);
+            pm.makePersistent(p);
+            tx.commit();
+            
+            tx.begin();
+            p.setX(500);
+            p.setY(new Integer(800));
+            pm.refreshAll();
+            int currentX = p.getX();
+            Integer currentY = p.getY();
+            if ((currentX != 100) || !currentY.equals(new Integer(200))) {
+                fail(ASSERTION_FAILED,
+                     "RefreshAll expected 100, 200; got " + currentX + ", " + currentY);
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshSideEffects.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshSideEffects.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshSideEffects.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/RefreshSideEffects.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,237 @@
+/*
+ * 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 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 Side Effects
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.1-5A
+ *<BR>
+ *<B>Assertion Description: </B>
+ The refresh method 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 RefreshSideEffects extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.1-5A (RefreshSideEffects) 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(RefreshSideEffects.class);
+    }
+
+    /** */
+    public void test () throws Exception {
+        PersistenceManagerFactory pmf = getPMF();
+        PersistenceManager pm1 = pmf.getPersistenceManager();
+        PersistenceManager pm2 = pmf.getPersistenceManager();
+        
+        try {
+            runTestRefreshSideEffects(pm1, pm2);
+        }
+        finally {
+            cleanupPM(pm2);
+            pm2 = null;
+            cleanupPM(pm1);
+            pm1 = null;
+        }
+    }
+
+    /** */
+    private void runTestRefreshSideEffects(PersistenceManager pm1, 
+                                           PersistenceManager pm2) throws Exception {
+        if (debug) logger.debug ("\nSTART RefreshSideEffects");
+
+        ThreadExceptionHandler group = new ThreadExceptionHandler();
+        RefreshThreadT1 thread1 = new RefreshThreadT1(pm1);
+        Thread T1 = new Thread(group, thread1);
+        RefreshThreadT2 thread2 = new RefreshThreadT2(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 RefreshSideEffects");
+    }
+
+    /** */
+    class RefreshThreadT1 implements Runnable {
+
+        PersistenceManager pm;
+        RefreshThreadT2 other;
+        boolean commitDone;
+
+        /** */
+        RefreshThreadT1(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.commitDone = false;
+        }
+
+        /** */
+        void setOther(RefreshThreadT2 other) {
+            this.other = other;
+        }
+
+        /** */
+        boolean isCommitDone() {
+            return commitDone;
+        }
+        
+        /** */
+        synchronized public void run() {
+            PCPoint n1 = new PCPoint (5,1);
+            Transaction tx = pm.currentTransaction();
+            try {
+                RefreshSideEffects.this.logger.debug("  ThreadT1: START");
+                tx.begin();
+                n1.setX(500);
+                pm.makePersistent(n1);
+                pm.refresh(n1);
+
+                RefreshSideEffects.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;
+                RefreshSideEffects.this.logger.debug(
+                    "  ThreadT1: commit finished.");
+            }
+            finally {
+                if ((tx != null) && tx.isActive())
+                    tx.rollback();
+            }
+        }
+    }
+
+    /** */
+    class RefreshThreadT2 implements Runnable {
+
+        PersistenceManager pm;
+        RefreshThreadT1 other;
+        boolean done;
+    
+        /** */
+        RefreshThreadT2(PersistenceManager pm) {
+            this.pm = pm;
+            this.other = null;
+            this.done = false;
+        }
+
+        /** */
+        boolean isDone() {
+            return done;
+        }
+        
+
+        /** */
+        void setOther(RefreshThreadT1 other) {
+            this.other = other;
+        }
+
+        /* test refresh() */
+        synchronized public void run() {
+            PCPoint p1 = new PCPoint (5,1);
+            Transaction tx = pm.currentTransaction();
+            try {
+                RefreshSideEffects.this.logger.debug("  ThreadT2: START");
+                tx.begin();
+                p1.setX(201);
+                pm.makePersistent(p1);
+                pm.refresh(p1);
+                done = true;
+
+                RefreshSideEffects.this.logger.debug(
+                    "  ThreadT2: waiting for commit of ThreadT1");
+                while (!other.isCommitDone()) {
+                    try {  
+                        Thread.sleep(DELAY);
+                    }
+                    catch (InterruptedException ex) {
+                        // ignore
+                    }
+                }
+                tx.commit();
+                tx = null;
+                RefreshSideEffects.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/Retrieve.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/Retrieve.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/Retrieve.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/Retrieve.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,336 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+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;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Retrieve
+ *<BR>
+ *<B>Keywords:</B> cache
+ *<BR>
+ *<B>Assertion IDs:</B> A12.6.1-2, A12.6.1-5
+ *<BR>
+ *<B>Assertion Description: </B>
+These methods request the PersistenceManager to load all persistent fields into 
+the parameter instances. Subsequent to this call, the application might 
+call makeTransient on the parameter instances, and the fields can no 
+longer be touched by the PersistenceManager. The PersistenceManager 
+might also retrieve related instances according to a pre-read policy 
+(not specified by JDO).
+The JDO PersistenceManager loads persistent values from the datastore into the instance
+and if the class of the instance implements InstanceCallbacks calls jdoPostLoad.
+ */
+
+public class Retrieve extends JDO_Test {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertions A12.6.1-2, A12.6.1-5 (Retrieve) 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(Retrieve.class);
+    }
+
+    private PCPoint p1 = null;
+    private String p1print = null;
+    private PCPoint p2 = null;
+    private PCPoint2 p3 = null;
+    private PCRect rect = null;
+
+    private static final Integer one = new Integer(1);
+    private static final Integer three = new Integer(3);
+
+    /** */
+    public void test () {
+        pm = getPM();
+
+        runTestRetrieve(pm);
+        runTestRetrieveAllWithCollection(pm);
+        runTestRetrieveAllWithArray(pm);
+        runTestRetrieveAllWithCollectionDFGtrue(pm);
+        runTestRetrieveAllWithArrayDFGtrue(pm);
+        runTestRetrieveAllWithCollectionDFGfalse(pm);
+        runTestRetrieveAllWithArrayDFGfalse(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void runTestRetrieve(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.retrieve(p1);
+            pm.retrieve(p3);
+            pm.retrieve(rect);
+            pm.makeTransient(p1);
+            pm.makeTransient(rect);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            checkRectP1();
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestRetrieveAllWithCollection(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Collection coll = new ArrayList();
+            coll.add(p1);
+            coll.add(p3);
+            coll.add(rect);
+            pm.retrieveAll(coll);
+            pm.makeTransientAll(coll);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            checkRectP1();
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestRetrieveAllWithCollectionDFGtrue(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Collection coll = new ArrayList();
+            coll.add(p1);
+            coll.add(p3);
+            coll.add(rect);
+            pm.retrieveAll(coll, true);
+            pm.makeTransientAll(coll);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            // checkRectP1(); p1 is not in the default fetch group by default
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestRetrieveAllWithCollectionDFGfalse(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Collection coll = new ArrayList();
+            coll.add(p1);
+            coll.add(p3);
+            coll.add(rect);
+            pm.retrieveAll(coll, true);
+            pm.makeTransientAll(coll);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            checkRectP1();
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestRetrieveAllWithArray(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Object[] objs = new Object[3];
+            objs[0] = p1;
+            objs[1] = p3;
+            objs[2] = rect;
+            pm.retrieveAll(objs);
+            pm.makeTransientAll(objs);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            checkRectP1();
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestRetrieveAllWithArrayDFGtrue(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Object[] objs = new Object[3];
+            objs[0] = p1;
+            objs[1] = p3;
+            objs[2] = rect;
+            pm.retrieveAll(objs, true);
+            pm.makeTransientAll(objs);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            // checkRectP1(); p1 is not in the default fetch group by default
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestRetrieveAllWithArrayDFGfalse(PersistenceManager pm) {
+        createObjects(pm);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Object[] objs = new Object[3];
+            objs[0] = p1;
+            objs[1] = p3;
+            objs[2] = rect;
+            pm.retrieveAll(objs, true);
+            pm.makeTransientAll(objs);
+            tx.commit();
+            tx = null;
+            checkP1();
+            checkP3();
+            checkRectP1();
+            checkRectId();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.setRetainValues(false);
+            tx.begin();
+            p1   = new PCPoint(1,1);
+            p1print = p1.toString();
+            p2   = new PCPoint(2,2);
+            p3   = new PCPoint2(3,3);
+            rect = new PCRect(100, p1, p2);
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(rect);
+            if (debug) {
+                logger.debug("p1: " + p1.name());
+                logger.debug("p2: " + p2.name());
+                logger.debug("p3: " + p3.name());
+                logger.debug("rect id: " + rect.getId() + 
+                             ", upperLeft: " + rect.getUpperLeft().name() + 
+                             ", lowerRight: " + rect.getLowerRight().name());
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void checkP1() {
+        if (((p1.getX() != 1) || (!one.equals(p1.getY())))) {
+            fail(ASSERTION_FAILED,
+                 "Error in p1 fields. Expected x:1, y:1; got x:" + p1.getX() +
+                 ", y:" + p1.getY());
+        }
+    }
+
+    /** */
+    private void checkP3() {
+        if ((p3.getX() != 3) || (!three.equals(p3.getY()))) {
+            fail(ASSERTION_FAILED,
+                 "Error in p3 fields. Expected x:3, y:3; got x:" + p3.getX() +
+                 ", y:" + p3.getY());
+        }
+
+        if (!p3.wasPostLoadCalled()) {
+            fail(ASSERTION_FAILED,
+                 "missing call of jdoPostLoad for p3");
+        }
+    }
+
+    /** */
+    private void checkRectId() {
+        if (rect.getId() == 0) {
+            fail(ASSERTION_FAILED,
+                 "Error in rect field id. Expected id!= 0; got id:0");
+        }
+    }
+
+    /** */
+    private void checkRectP1() {
+        if (rect.getUpperLeft()!= p1) {
+            fail(ASSERTION_FAILED,
+	         "Error in rect field upperLeft. Expected:" + p1print +
+                 ", got:" + rect.getUpperLeft());
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToFalse.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToFalse.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToFalse.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToFalse.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,83 @@
+/*
+ * 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> Set IgnoreCache To False
+ *<BR>
+ *<B>Keywords:cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.3-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.setIgnoreCache method called with a value of false instructs the
+query engine that the user expects queries to return results that reflect changed values in the cache.
+
+
+ */
+
+public class SetIgnoreCacheToFalse extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.3-3 (SetIgnoreCacheToFalse) 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(SetIgnoreCacheToFalse.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+    
+        runTestSetIgnoreCacheToFalse(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void runTestSetIgnoreCacheToFalse(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            PCPoint p1 = new PCPoint();
+            tx.begin();
+            pm.setIgnoreCache(false);
+            if (pm.getIgnoreCache()) {
+                fail(ASSERTION_FAILED,
+                     "pm.getIgnoreCache() should return false after setting the flag to false.");
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToTrue.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToTrue.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToTrue.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetIgnoreCacheToTrue.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,84 @@
+/*
+ * 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> Set IgnoreCache To True
+ *<BR>
+ *<B>Keywords:cache
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.3-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.setIgnoreCache method called with a value of true is a hint to the
+query engine that the user expects queries to be optimized to return approximate results by ignoring changed values in the
+cache. This is not testable, except to see whether the get/set works.
+
+
+ */
+
+public class SetIgnoreCacheToTrue extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.3-2 (SetIgnoreCacheToTrue) 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(SetIgnoreCacheToTrue.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+    
+        runTestSetIgnoreCacheToTrue(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    public void runTestSetIgnoreCacheToTrue(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            PCPoint p1 = new PCPoint();
+            tx.begin();
+            pm.setIgnoreCache(true);
+            if (!pm.getIgnoreCache()) {
+                fail(ASSERTION_FAILED,
+                     "pm.getIgnoreCache() should return true after setting the flag to true.");
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedFalse.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedFalse.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedFalse.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedFalse.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,82 @@
+/*
+ * 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> Set Multithreaded False
+ *<BR>
+ *<B>Keywords:</B> multithreaded
+ *<BR>
+ *<B>Assertion ID:</B> A12.7-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+If PersistenceManager.setMultithreaded is called with a value of false, a value of false
+will be returned when getMultithreaded is called.
+
+ */
+
+public class SetMultithreadedFalse extends PersistenceManagerTest{
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.7-2 (SetMultithreadedFalse) 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(SetMultithreadedFalse.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        runTestSetMultithreadedFalse(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void runTestSetMultithreadedFalse(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            PCPoint p1 = new PCPoint();
+            tx.begin();
+            pm.setMultithreaded(false);
+            if (pm.getMultithreaded()) {
+                fail(ASSERTION_FAILED,
+                     "pm.getMultithreaded() should false true after setting the flag to false.");
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedTrue.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedTrue.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedTrue.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SetMultithreadedTrue.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,81 @@
+/*
+ * 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> Set Multithreaded True
+ *<BR>
+ *<B>Keywords:</B> multithreaded
+ *<BR>
+ *<B>Assertion ID:</B> A12.7-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+If PersistenceManager.setMultithreaded is called with a value of true, then the JDO
+implementation must perform synchronizations to support multiple application threads. A value of true will be returned
+when getMultithreaded is called. In testing, multi-threading should be turned on and then multi-threading tests should
+be run.
+ */
+
+public class SetMultithreadedTrue extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.7-1 (SetMultithreadedTrue) 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(SetMultithreadedTrue.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        runTestSetMultithreadedTrue(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    public void runTestSetMultithreadedTrue(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.setMultithreaded(true);
+            if (!pm.getMultithreaded()) {
+                fail(ASSERTION_FAILED,
+                     "pm.getMultithreaded() should true true after setting the flag to true.");
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SettingFlagsWithTransactionInstance.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SettingFlagsWithTransactionInstance.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SettingFlagsWithTransactionInstance.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/SettingFlagsWithTransactionInstance.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,71 @@
+/*
+ * 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> Setting Flags With Transaction instance
+ *<BR>
+ *<B>Keywords:
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.2-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+Even if the Transaction instance returned by PersistenceManager.currentTransaction
+cannot be used for transaction completion (due to external transaction management), it still can be used to set flags.
+
+ */
+
+public class SettingFlagsWithTransactionInstance extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.2-3 (SettingFlagsWithTransactionInstance) 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(SettingFlagsWithTransactionInstance.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        runTestSettingFlagsWithTransactionInstance(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+
+    /** */
+    private void runTestSettingFlagsWithTransactionInstance(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        tx.setNontransactionalRead(false);
+        tx.setNontransactionalWrite(false);
+        tx.setRetainValues(false);
+        tx.setOptimistic(false);
+    }
+}

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

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

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseGetPMThrowsException.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,76 @@
+/*
+ * 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.persistencemanagerfactory;
+
+import javax.jdo.JDOUserException;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B>AfterCloseGetPMThrowsException of PersistenceManagerFactory  
+ *<BR>
+ *<B>Keywords:</B> persistencemanagerfactory
+ *<BR>
+ *<B>Assertion IDs:</B> A11.4-9B.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * PersistenceManagerFactory.getPersistenceManager() throws
+ * JDOUserException after the PersistenceManagerFactory is closed.
+ */
+
+/* 
+ * Revision History
+ * ================
+ * Author :  Craig Russell
+ * Date   :  05/16/03
+ *
+ */
+
+public class AfterCloseGetPMThrowsException extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A11.4-9B (AfterCloseGetPMThrowsException) 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(AfterCloseGetPMThrowsException.class);
+    }
+
+    /** */
+    public void test() {
+        try {
+            pmf = getPMF();
+            pmf.close();
+            pm = pmf.getPersistenceManager();
+            fail(ASSERTION_FAILED,
+                 "pmf.getPersistenceManager should throw JDOUserException if pmf is closed.");
+        } catch (JDOUserException ex) {
+            // expected exception
+            if (debug)
+                logger.debug("caught expected exception " + ex.toString());
+        } finally { 
+            if (pm != null) 
+                pm.close();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterCloseSetMethodsThrowException.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,196 @@
+/*
+ * 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.persistencemanagerfactory;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.JDOException;
+import javax.jdo.JDOFatalInternalException;
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManagerFactory;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B>AfterCloseSetMethodsThrowException  
+ *<BR>
+ *<B>Keywords:</B> persistencemanagerfactory
+ *<BR>
+ *<B>Assertion IDs:</B> A11.4-9A.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If a set method is called after close, then JDOUserException is thrown.
+ */
+
+/* 
+ * Revision History
+ * ================
+ * Author :   Craig Russell
+ * Date   :  05/16/03
+ *
+ */
+
+public class AfterCloseSetMethodsThrowException extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A11.4-9A (AfterCloseSetMethodsThrowException) 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(AfterCloseSetMethodsThrowException.class);
+    }
+
+    /** */
+    public void test() {
+        Class[] stringParameters = new Class[]{String.class};
+        Class[] booleanParameters = new Class[]{boolean.class};
+        Object[] stringParameter = new Object[]{"Nobody knows the trouble"};
+        Object[] booleanParameter = new Object[]{new Boolean(false)};
+        
+        SetProperty[] setMethods = new SetProperty[] {
+            new SetProperty("setConnectionDriverName", stringParameters, stringParameter),
+            new SetProperty("setConnectionFactoryName", stringParameters, stringParameter),
+            new SetProperty("setConnectionFactory2Name", stringParameters, stringParameter),
+            new SetProperty("setConnectionURL", stringParameters, stringParameter),
+            new SetProperty("setConnectionUserName", stringParameters, stringParameter),
+            new SetProperty("setConnectionPassword", stringParameters, stringParameter),
+            new SetProperty("setIgnoreCache", booleanParameters, booleanParameter),
+            new SetProperty("setMultithreaded", booleanParameters, booleanParameter),
+            new SetProperty("setNontransactionalRead", booleanParameters, booleanParameter),
+            new SetProperty("setNontransactionalWrite", booleanParameters, booleanParameter),
+            new SetProperty("setOptimistic", booleanParameters, booleanParameter),
+            new SetProperty("setRestoreValues", booleanParameters, booleanParameter),
+            new SetProperty("setRetainValues", booleanParameters, booleanParameter)
+        };
+       
+        GetProperty[] getMethods = new GetProperty[] {
+            new GetProperty("getConnectionDriverName"),
+            new GetProperty("getConnectionFactoryName"),
+            new GetProperty("getConnectionFactory2Name"),
+            new GetProperty("getConnectionURL"),
+            new GetProperty("getConnectionUserName"),
+            new GetProperty("getIgnoreCache"),
+            new GetProperty("getMultithreaded"),
+            new GetProperty("getNontransactionalRead"),
+            new GetProperty("getNontransactionalWrite"),
+            new GetProperty("getOptimistic"),
+            new GetProperty("getRestoreValues"),
+            new GetProperty("getRetainValues")
+        };
+       
+        pmf = getPMF();
+        pmf.close();
+        // each set method should throw an exception
+        Collection setCollection = Arrays.asList(setMethods);
+        for (Iterator it = setCollection.iterator(); it.hasNext();) {
+            SetProperty sp = (SetProperty)it.next();
+            String where = sp.getMethodName();
+            try {
+                sp.execute(pmf);
+                fail(ASSERTION_FAILED,
+                     "pmf method " + where + " shoudl throw JDOUserException when called for closed pmf");
+            } catch (JDOUserException ex) {
+                if (debug)
+                    logger.debug("Caught expected exception " + ex.toString() +
+                                 " from " + where);
+            }
+        }
+        // each get method should succeed
+        Collection getCollection = Arrays.asList(getMethods);
+        for (Iterator it = getCollection.iterator(); it.hasNext();) {
+            GetProperty gp = (GetProperty)it.next();
+            String where = gp.getMethodName();
+            try {
+                gp.execute(pmf);
+            } catch (JDOUserException ex) {
+                fail(ASSERTION_FAILED,
+                     "Caught unexpected exception " + ex.toString() + " from " +
+                     where);
+            }
+        }
+    }
+   
+    /** */
+    class SetProperty {
+        
+        java.lang.reflect.Method method;
+        String methodName;
+        Class[] parameters;
+        Object[] parameter;
+       
+        SetProperty(String methodName, Class[] parameters, Object[] parameter) {
+            this.methodName = methodName;
+            this.parameters = parameters;
+            this.parameter = parameter;
+            try {
+                method = PersistenceManagerFactory.class.getMethod(methodName, parameters);
+            } catch (NoSuchMethodException ex) {
+                throw new JDOFatalInternalException("Method not defined: " + methodName);
+            }
+        }
+        void execute(PersistenceManagerFactory pmf) {
+            try {
+                method.invoke(pmf, parameter);
+            } catch (IllegalAccessException ex) {
+                throw new JDOFatalInternalException("IllegalAccessException", ex);
+            } catch (java.lang.reflect.InvocationTargetException ex) {
+                throw (JDOException)ex.getTargetException();
+            }
+        }
+       
+        String getMethodName() {
+            return methodName;
+        }
+    }
+   
+    /** */
+    class GetProperty {
+       
+        java.lang.reflect.Method method;
+        String methodName;
+       
+        GetProperty(String methodName) {
+            this.methodName = methodName;
+            try {
+                method = PersistenceManagerFactory.class.getMethod(methodName, null);
+            } catch (NoSuchMethodException ex) {
+                throw new JDOFatalInternalException("Method not defined: " + methodName);
+            }
+        }
+        void execute(PersistenceManagerFactory pmf) {
+            try {
+                method.invoke(pmf, null);
+            } catch (IllegalAccessException ex) {
+                throw new JDOFatalInternalException("IllegalAccessException", ex);
+            } catch (java.lang.reflect.InvocationTargetException ex) {
+                throw (JDOException)ex.getTargetException();
+            }
+        }
+       
+        String getMethodName() {
+            return methodName;
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/AfterGetPersistenceManagerNoSetMethodsSucceed.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,231 @@
+/*
+ * 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.persistencemanagerfactory;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.PersistenceManager;
+import javax.jdo.JDOException;
+import javax.jdo.JDOFatalInternalException;
+import javax.jdo.JDOUserException;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> After GetPersistenceManager No Set Methods Succeed
+ *<BR>
+ *<B>Keywords:</B> 
+ *<BR>
+ *<B>Assertion ID:</B> A11.3-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+After the first use of <code>PersistenceManagerFactory.getPersistenceManager()</code>,
+none of the <code>set</code> methods will succeed.
+
+ */
+
+public class AfterGetPersistenceManagerNoSetMethodsSucceed extends JDO_Test {
+
+    private String username;
+    private String password;
+    private static final String USERNAME_PROPERTY = "javax.jdo.option.ConnectionUserName";
+    private static final String PASSWORD_PROPERTY = "javax.jdo.option.ConnectionPassword";
+
+    private Class[] stringParameters = null;
+    private Class[] booleanParameters = null;
+    private Object[] stringParameter = null;
+    private Object[] booleanParameter = null;
+    private SetProperty[] setMethods = null;
+    private GetProperty[] getMethods = null;
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A11.3-3 (AfterGetPersistenceManagerNoSetMethodsSucceed) 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(AfterGetPersistenceManagerNoSetMethodsSucceed.class);
+    }
+
+    /** */
+    public AfterGetPersistenceManagerNoSetMethodsSucceed() {
+		super();
+        initVariables();
+    }
+
+    /** */
+    public void initVariables() {
+        stringParameters = new Class[]{String.class};
+        booleanParameters = new Class[]{boolean.class};
+        stringParameter = new Object[]{"Nobody knows the trouble"};
+        booleanParameter = new Object[]{Boolean.FALSE};
+
+        setMethods = new SetProperty[] {
+            new SetProperty("setConnectionDriverName", stringParameters, stringParameter),
+            new SetProperty("setConnectionFactoryName", stringParameters, stringParameter),
+            new SetProperty("setConnectionFactory2Name", stringParameters, stringParameter),
+            new SetProperty("setConnectionURL", stringParameters, stringParameter),
+            new SetProperty("setConnectionUserName", stringParameters, stringParameter),
+            new SetProperty("setConnectionPassword", stringParameters, stringParameter),
+            new SetProperty("setIgnoreCache", booleanParameters, booleanParameter),
+            new SetProperty("setMultithreaded", booleanParameters, booleanParameter),
+            new SetProperty("setNontransactionalRead", booleanParameters, booleanParameter),
+            new SetProperty("setNontransactionalWrite", booleanParameters, booleanParameter),
+            new SetProperty("setOptimistic", booleanParameters, booleanParameter),
+            new SetProperty("setRestoreValues", booleanParameters, booleanParameter),
+            new SetProperty("setRetainValues", booleanParameters, booleanParameter)
+        };
+
+        getMethods = new GetProperty[] {
+            new GetProperty("getConnectionDriverName"),
+            new GetProperty("getConnectionFactoryName"),
+            new GetProperty("getConnectionFactory2Name"),
+            new GetProperty("getConnectionURL"),
+            new GetProperty("getConnectionUserName"),
+            new GetProperty("getIgnoreCache"),
+            new GetProperty("getMultithreaded"),
+            new GetProperty("getNontransactionalRead"),
+            new GetProperty("getNontransactionalWrite"),
+            new GetProperty("getOptimistic"),
+            new GetProperty("getRestoreValues"),
+            new GetProperty("getRetainValues")
+        };
+    }
+
+    /** */
+    public void testGetPersistenceManagerWithNoParametes() {
+        runTest(false);
+    }
+
+    /** */
+    public void testGetPersistenceManagerWithParameters() {
+        Properties props = loadProperties(PMFProperties);
+        username = props.getProperty(USERNAME_PROPERTY);  
+        password = props.getProperty(PASSWORD_PROPERTY);  
+        runTest(true);
+    }
+
+	/** */
+    public void runTest(boolean bUserAndPasswd) {       
+        pmf = getPMF();
+        if (!bUserAndPasswd)
+            pm = getPM();
+        else
+            pm = getPMF().getPersistenceManager(username,password);	
+	
+        // each set method should throw an exception
+        Collection setCollection = Arrays.asList(setMethods);
+        for (Iterator it = setCollection.iterator(); it.hasNext();) {
+            SetProperty sp = (SetProperty)it.next();
+            String where = sp.getMethodName();
+            try {
+                sp.execute(pmf);
+                fail(ASSERTION_FAILED,
+                     "pmf method " + where + 
+                     " should throw JDOUserException when called after getPersistenceManager");
+            } catch (JDOUserException ex) {
+                if (debug)
+                    logger.debug("Caught expected exception " + ex.toString() + " from " + where);
+            }
+        }
+        // each get method should succeed
+        Collection getCollection = Arrays.asList(getMethods);
+        for (Iterator it = getCollection.iterator(); it.hasNext();) {
+            GetProperty gp = (GetProperty)it.next();
+            String where = gp.getMethodName();
+            try {
+                gp.execute(pmf);
+            } catch (JDOUserException ex) {
+                fail(ASSERTION_FAILED,
+                     "Caught unexpected exception " + ex.toString() + " from " + where);
+            }
+        }
+    }
+   
+    /** */
+    static class SetProperty {
+        
+        java.lang.reflect.Method method;
+        String methodName;
+        Class[] parameters;
+        Object[] parameter;
+       
+        SetProperty(String methodName, Class[] parameters, Object[] parameter) {
+            this.methodName = methodName;
+            this.parameters = parameters;
+            this.parameter = parameter;
+            try {
+                method = PersistenceManagerFactory.class.getMethod(methodName, parameters);
+            } catch (NoSuchMethodException ex) {
+                throw new JDOFatalInternalException("Method not defined: " + methodName);
+            }
+        }
+        void execute(PersistenceManagerFactory pmf) {
+            try {
+                method.invoke(pmf, parameter);
+            } catch (IllegalAccessException ex) {
+                throw new JDOFatalInternalException("IllegalAccessException", ex);
+            } catch (java.lang.reflect.InvocationTargetException ex) {
+                throw (JDOException)ex.getTargetException();
+            }
+        }
+       
+        String getMethodName() {
+            return methodName;
+        }
+    }
+   
+    /** */
+    static class GetProperty {
+       
+        java.lang.reflect.Method method;
+        String methodName;
+       
+        GetProperty(String methodName) {
+            this.methodName = methodName;
+            try {
+                method = PersistenceManagerFactory.class.getMethod(methodName, null);
+            } catch (NoSuchMethodException ex) {
+                throw new JDOFatalInternalException(
+                    "Method not defined: " + methodName);
+            }
+        }
+        void execute(PersistenceManagerFactory pmf) {
+            try {
+                method.invoke(pmf, null);
+            } catch (IllegalAccessException ex) {
+                throw new JDOFatalInternalException("IllegalAccessException", ex);
+            } catch (java.lang.reflect.InvocationTargetException ex) {
+                throw (JDOException)ex.getTargetException();
+            }
+        }
+       
+        String getMethodName() {
+            return methodName;
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/Close.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,66 @@
+/*
+ * 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.persistencemanagerfactory;
+
+import javax.jdo.JDOUserException;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B>Close of PersistenceManagerFactory  
+ *<BR>
+ *<B>Keywords:</B> persistencemanagerfactory
+ *<BR>
+ *<B>Assertion IDs:</B> A11.4-2
+ *<BR>
+ *<B>Assertion Description: </B>
+ * PersistenceManagerFactory.close() closes this PersistenceManagerFactory.
+ */
+
+
+public class Close extends JDO_Test {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertions A11.4-2 (Close) 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(Close.class);
+    }
+
+    /** */
+    public void test() {
+        pmf = getPMF();
+        pmf.close();
+        //check that pmf is really closed by trying to get a getPersistenceManager
+        try {
+            pm = pmf.getPersistenceManager();
+            fail(ASSERTION_FAILED,
+                "JDOUserException was not thrown when calling pmf.getPersistenceManager() after pmf was closed");
+        } catch (JDOUserException ex) {
+            // expected exception
+            if (debug)
+                logger.debug("caught expected exception " + ex.toString());
+        }
+    }
+}



Mime
View raw message