db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r160090 [10/63] - in incubator/jdo/trunk: ./ tck20/ tck20/assertions/ tck20/iut_jars/ tck20/test/ tck20/test/conf/ tck20/test/java/ tck20/test/java/org/ tck20/test/java/org/apache/ tck20/test/java/org/apache/jdo/ tck20/test/java/org/apache/jdo/tck/ tck20/test/java/org/apache/jdo/tck/api/ tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/api/jdohelper/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/close/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/extent/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/flags/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/getobject/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/ tck20/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ tck20/test/java/org/apache/jdo/tck/enhancement/ tck20/test/java/org/apache/jdo/tck/extents/ tck20/test/java/org/apache/jdo/tck/lifecycle/ tck20/test/java/org/apache/jdo/tck/lifecycle/nontransactional/ tck20/test/java/org/apache/jdo/tck/models/ tck20/test/java/org/apache/jdo/tck/models/embedded/ tck20/test/java/org/apache/jdo/tck/models/fieldtypes/ tck20/test/java/org/apache/jdo/tck/models/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/ tck20/test/java/org/apache/jdo/tck/pc/company/ tck20/test/java/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/java/org/apache/jdo/tck/pc/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/pc/lifecycle/ tck20/test/java/org/apache/jdo/tck/pc/mylib/ tck20/test/java/org/apache/jdo/tck/query/ tck20/test/java/org/apache/jdo/tck/query/operators/ tck20/test/java/org/apache/jdo/tck/transactions/ tck20/test/java/org/apache/jdo/tck/util/ tck20/test/jdo/ tck20/test/jdo/applicationidentity/ tck20/test/jdo/applicationidentity/org/ tck20/test/jdo/applicationidentity/org/apache/ tck20/test/jdo/applicationidentity/org/apache/jdo/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/jdo/datastoreidentity/ tck20/test/jdo/datastoreidentity/org/ tck20/test/jdo/datastoreidentity/org/apache/ tck20/test/jdo/datastoreidentity/org/apache/jdo/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/ tck20/test/orm/applicationidentity/ tck20/test/orm/applicationidentity/org/ tck20/test/orm/applicationidentity/org/apache/ tck20/test/orm/applicationidentity/org/apache/jdo/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/datastoreidentity/ tck20/test/orm/datastoreidentity/org/ tck20/test/orm/datastoreidentity/org/apache/ tck20/test/orm/datastoreidentity/org/apache/jdo/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/sql/ tck20/test/sql/derby/
Date Mon, 04 Apr 2005 19:43:46 GMT
Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentAssignsObjectId.java Mon Apr  4 12:41:23 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.lifecycle;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.jdo.Transaction;
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> make instance persistent
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-6B
+ *<BR>
+ *<B>Assertion Description: </B>
+The method PersistenceManager.makePersistent and
+makePersistentAll will assign an object identity to the instance
+and transitions it to persistent-new.
+
+ */
+
+public class MakePersistentAssignsObjectId extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-6B (MakePersistentAssignsObjectId) 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(MakePersistentAssignsObjectId.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakePersistentAssignsObjectId() {
+        pm = getPM();
+
+        createObjects();
+        
+        /* positive tests */
+        runTestMakePersistentAssignsObjectId1(pm);
+        runTestMakePersistentAssignsObjectId2(pm);
+        runTestMakePersistentAssignsObjectId3(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void  createObjects() {
+        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 makePersistent (Object pc) */
+    private void runTestMakePersistentAssignsObjectId1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makePersistent(p1);
+            
+            if (!testState(p1, PERSISTENT_NEW, "persistent_new")) {
+                fail(ASSERTION_FAILED,
+                     "expected P-NEW instance, instance is " + getStateOfInstance(p1) + ".");
+            }
+            if (pm.getObjectId(p1) == null) {
+                fail(ASSERTION_FAILED,
+                     "pm.makePersistent should assign non-null oid.");
+            }
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Collection pcs) */
+    private void runTestMakePersistentAssignsObjectId2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            Collection col1 = new HashSet();
+            col1.add(p2);
+            col1.add(p3);
+            
+            pm.makePersistentAll(col1);
+
+            for (Iterator i = col1.iterator(); i.hasNext();) {
+                PCPoint p = (PCPoint)i.next();
+                if (!testState(p, PERSISTENT_NEW, "persistent_new")) {
+                    fail(ASSERTION_FAILED,
+                         "expected P-NEW instance, instance is " + getStateOfInstance(p) + ".");
+                }
+                
+                if (pm.getObjectId(p) == null) {
+                    fail(ASSERTION_FAILED,
+                         "pm.makePersistentAll should assign non-null oid.");
+                }
+            }
+            
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+   /* test makePersistentAll (Object[] o) */
+    private void runTestMakePersistentAssignsObjectId3(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.makePersistentAll(obj1);
+            for (int i = 0; i < NUM_OBJS; i++) {
+                PCPoint p = (PCPoint)obj1[i];
+                if (!testState(p, PERSISTENT_NEW, "persistent_new")) {
+                    fail(ASSERTION_FAILED,
+                         "expected P-NEW instance, instance is " + getStateOfInstance(p) + ".");
+                }
+                
+                if (pm.getObjectId(p) == null) {
+                    fail(ASSERTION_FAILED,
+                         "pm.makePersistentAll should assign non-null oid.");
+                }
+            }
+            
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,185 @@
+/*
+ * 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.lifecycle;
+
+import java.util.Collection;
+
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakePersistent Fails If Instance Managed By Another PersistenceManager
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-8.
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makePersistent and makePersistentAll will throw a JDOUserException if the parameter instance is managed by a different PersistenceManager.
+
+ */
+
+public class MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-8 (MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager) 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(MakePersistentFailsIfInstanceManagedByAnotherPersistenceManager.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakePersistentFailsIfInstanceManagedByAnotherPersistenceManager() {
+        pm = getPM();
+
+        PersistenceManager pm2 = getPMF().getPersistenceManager();
+        try {
+            createObjects(pm2);
+        
+            /* positive tests */
+            runTestMakePersistent(pm);
+            runTestMakePersistentAll1(pm);
+            runTestMakePersistentAll2(pm);
+        }
+        finally {
+            cleanupPM(pm2);
+            pm2 = null;
+            cleanupPM(pm);
+            pm = null;
+        }
+    }
+
+    /** */
+    private void  createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1 = new PCPoint(1,3);
+            p2 = new PCPoint(2,4);
+            p3 = new PCPoint(3,5);
+            p4 = new PCPoint(4,6);
+            p5 = new PCPoint(5,7);
+            
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+            pm.makePersistent(p5);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistent (Object pc) */
+    private void runTestMakePersistent(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            try {
+                pm.makePersistent(p1);
+                fail(ASSERTION_FAILED,
+                     "pm.makePersistent should throw JDOUserException if instance is already made persistence by different pm.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Collection pcs) */
+    private void runTestMakePersistentAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+            
+            try {
+                pm.makePersistentAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.makePersistentAll(Collection) should throw JDOUserException if instance is already made persistence by different pm.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Object[] o) */
+    private void runTestMakePersistentAll2(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();
+
+            try {
+                pm.makePersistentAll(obj1);
+                fail(ASSERTION_FAILED,
+                     "pm.makePersistentAll(Object[]) should throw JDOUserException if instance is already made persistence by different pm.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakePersistentHasNoEffectOnPersistentInstances.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,166 @@
+/*
+ * 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.lifecycle;
+
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakePersistent Has No Effect On Persistent Instances
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-7.
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makePersistent and makePersistentAll have no effect on
+ *parameter persistent instances already managed by the same PersistenceManager.
+
+ */
+
+public class MakePersistentHasNoEffectOnPersistentInstances
+    extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-7 (MakePersistentHasNoEffectOnPersistentInstances) 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(MakePersistentHasNoEffectOnPersistentInstances.class);
+    }
+       
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakePersistentHasNoEffectOnPersistentInstances() {
+        pm = getPM();
+        
+        createObjects(pm);
+        
+        runTestMakePersistent(pm);
+        runTestMakePersistentAll1(pm);
+        runTestMakePersistentAll2(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void  createObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1 = new PCPoint(1,3);
+            p2 = new PCPoint(2,4);
+            p3 = new PCPoint(3,5);
+            p4 = new PCPoint(4,6);
+            p5 = new PCPoint(5,7);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistent (Object pc) */
+    private void runTestMakePersistent(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+            pm.makePersistent(p1);
+            pm.makePersistent(p1);
+            pm.makePersistent(p1);
+            pm.makePersistent(p1);
+            tx.commit();
+            tx = null;
+            if (debug) logger.debug (" \nPASSED in runTestMakePersistent()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Collection pcs) */
+    private void runTestMakePersistentAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            pm.makePersistentAll(col1);
+            pm.makePersistentAll(col1);
+            pm.makePersistentAll(col1);
+            pm.makePersistentAll(col1);
+            tx.commit();
+            tx = null;
+            if (debug) logger.debug (" \nPASSED in runTestMakePersistentAll1()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Object[] o) */
+    private void runTestMakePersistentAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+          tx.begin();
+
+          Collection col1 = new java.util.HashSet();
+          col1.add(p1);
+          col1.add(p2);
+          
+          Object[] obj1= col1.toArray();
+
+          pm.makePersistentAll(obj1);
+          pm.makePersistentAll(obj1);
+          pm.makePersistentAll(obj1);
+          pm.makePersistentAll(obj1);
+          tx.commit();
+          tx = null;
+          if (debug) logger.debug (" \nPASSED in runTestMakePersistentAll2()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactional.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager.lifecycle;
+
+import java.util.Collection;
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakeTransactional
+ *<BR>
+ *<B>Keywords:</B> transienttransactional lifecycle
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-20
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeTransactional and makeTransactionalAll makes a transient instance transactional and causes a state transition to transient-clean. After the method completes, the instance observes transaction boundaries.
+
+ */
+
+
+public class MakeTransactional extends PersistenceManagerTest{
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-20 (MakeTransactional) 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(MakeTransactional.class);
+    }
+ 
+    private PCPoint p = null;
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+
+    /** */  
+    public void testTransactionalInst() {
+    	pm = getPM();
+    	
+        createObjects();
+        testMakeTransactional(pm);
+        testMakeTransactionalAll1(pm);
+        testMakeTransactionalAll2(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createObjects() {
+    	p1 = new PCPoint(1,3);
+        p2 = new PCPoint(2,4);
+        p3 = new PCPoint(3,5);
+        p4 = new PCPoint(4,6);
+    }
+
+    /** */
+    public void testMakeTransactional(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            pm.makeTransactional(p1);
+            if (currentState(p1) != TRANSIENT_CLEAN) {
+                fail(ASSERTION_FAILED,
+                     "Expected T-CLEAN instance, instance is " + 
+                     getStateOfInstance(p1) + ".");
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void testMakeTransactionalAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            Collection col1 = new java.util.HashSet();
+            col1.add(p1);
+            col1.add(p2);
+            col1.add(p3);
+            col1.add(p4);
+            
+            pm.makeTransactionalAll(col1);
+            Iterator iter = col1.iterator();
+            while (iter.hasNext() ) {
+                PCPoint p = (PCPoint) iter.next();
+                if (currentState(p) != TRANSIENT_CLEAN) {
+                    fail(ASSERTION_FAILED,
+                         "Expected T-CLEAN instance, instance " + p + " is " + 
+                         getStateOfInstance(p1) + ".");
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void testMakeTransactionalAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            
+            Object[] objArray = {p1,p2,p3,p4};
+            pm.makeTransactionalAll(objArray);
+            
+            for ( int i=0; i < objArray.length; i++) {
+                p = (PCPoint) objArray[i];
+                if (currentState(p) != TRANSIENT_CLEAN) {
+                    fail(ASSERTION_FAILED,
+                         "Expected T-CLEAN instance, instance " + p + " is " + 
+                         getStateOfInstance(p1) + ".");
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalANontransactionalPersistentInstance.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,311 @@
+/*
+ * 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.lifecycle;
+
+import java.util.Collection;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+/**
+ *<B>Title:</B> Make Transactional A Persistent Nontransactional Instance
+ *<BR>
+ *<B>Keywords:</B> persistentnontransactional
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-24
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeTransactional and makeTransactionalAll can be used to mark a nontransactional persistent instance as being part of the read-consistency set of the transaction. In this case, the call must be made in the context of an active transaction, or a JDOUserException is thrown. To test this, get an instance in the persistence-nontransactional state, make it transactional, then in a
+different transaction commit a change to the instance. An exception should then be thrown when the first transaction commits.
+
+ */
+
+public class MakeTransactionalANontransactionalPersistentInstance extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-24 (MakeTransactionalANontransactionalPersistentInstance) 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(MakeTransactionalANontransactionalPersistentInstance.class);
+    }
+    
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+    private PCPoint p6 = null;
+    private PCPoint p7 = null;
+
+    private Collection col1 = new java.util.HashSet();
+    private Collection col2 = new java.util.HashSet();
+
+    /** */
+    public void testTransactionalInstance() {
+        if (isOptimisticSupported()) {
+            pm = getPM();
+
+            createPNonTranObjects();
+            
+            /* Positive cases */
+            runTestMakeTransactional();
+            runTestMakeTransactionalAll1();
+            runTestMakeTransactionalAll2();
+            
+            /* Negative cases */
+            runTestMakeTransactionalNeg();
+            runTestMakeTransactionalAll1Neg();
+            runTestMakeTransactionalAll2Neg();
+            
+            pm.close();
+            pm = null;
+        }
+    }
+
+    /** */
+    private void createPNonTranObjects() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            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);
+            p6 = new PCPoint (6,8);
+            p7 = new PCPoint (7,9);
+
+            col1.add(p2);
+            col1.add(p3);
+            col1.add(p4);
+
+            col2.add(p5);
+            col2.add(p6);
+            col2.add(p7);
+
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+            pm.makePersistent(p5);
+            pm.makePersistent(p6);
+            pm.makePersistent(p7);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactional() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug) logger.debug(" ** in runTestMakeTransactional()");
+            int curr;
+
+            tx.setOptimistic(true);
+            tx.begin();
+
+            if (makePersistentNonTranInstance(p1)) {
+                pm.makeTransactional(p1);
+            }
+            tx.commit();
+            tx = null;
+            if (debug) logger.debug(" \nPASSED in runTestMakeTransactional()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactionalNeg() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug) logger.debug(" ** in runTestMakeTransactionalNeg()");
+            int curr;
+
+            tx.setOptimistic(true);
+            tx.begin();
+
+            if (makePersistentNonTranInstance(p1)) {
+                ; // expected result
+            }
+            tx.commit();
+            tx = null;
+
+            try {
+                pm.makeTransactional(p1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransactional should throw JDOUserException outside of tx");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactionalAll1() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug) logger.debug(" ** in runTestMakeTransactionalAll1()");
+            int curr;
+            tx.setOptimistic(true);
+            tx.begin();
+
+            if ( makePersistentNonTranInstance(p2) &&
+                 makePersistentNonTranInstance(p3) &&
+                 makePersistentNonTranInstance(p4)) {
+
+                pm.makeTransactionalAll(col1);
+            }
+
+            tx.commit();
+            tx = null;
+            if (debug)
+                logger.debug(" \nPASSED in runTestMakeTransactionalAll1()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactionalAll1Neg() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug) logger.debug(" ** in runTestMakeTransactionalAll1Neg()");
+            int curr;
+            tx.setOptimistic(true);
+            tx.begin();
+
+            if ( makePersistentNonTranInstance(p2) &&
+                 makePersistentNonTranInstance(p3) &&
+                 makePersistentNonTranInstance(p4)) {
+                ;  // expected result
+            }
+            tx.commit();
+
+            try {
+                pm.makeTransactionalAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransactionalAll(Collection) should throw JDOUserException outside of tx");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactionalAll2() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug) logger.debug(" ** in runTestMakeTransactionalAll2()");
+            int curr;
+            tx.setOptimistic(true);
+            tx.begin();
+
+            Object[] objArray = col2.toArray();
+
+            if ( makePersistentNonTranInstance(p5) &&
+                 makePersistentNonTranInstance(p6) &&
+                 makePersistentNonTranInstance(p7)) {
+
+                pm.makeTransactionalAll(objArray);
+
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactionalAll2Neg() {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug) logger.debug(" ** in runTestMakeTransactionalAll2Neg()");
+            int curr;
+            tx = pm.currentTransaction();
+            tx.setOptimistic(true);
+            tx.begin();
+
+            Object[] objArray = col2.toArray();
+            if ( makePersistentNonTranInstance(p5) &&
+                 makePersistentNonTranInstance(p6) &&
+                 makePersistentNonTranInstance(p7)) {
+                ;  // expected result
+            }
+            tx.commit();
+
+            try {
+                pm.makeTransactionalAll(objArray);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransactionalAll(Object[]) should throw JDOUserException outside of tx");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public boolean makePersistentNonTranInstance (PCPoint obj) {
+        int val = obj.getX();
+        int curr = currentState(obj);
+        if ( curr != PERSISTENT_NONTRANSACTIONAL &&
+             curr != HOLLOW) {
+            fail(ASSERTION_FAILED,
+                 "expected P-HOLLOW or P-NONTX instance, instance " + obj + 
+                 " is " + getStateOfInstance(obj) + ".");
+            return false;
+        }
+        return true;
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalAllFails.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,134 @@
+/*
+ * 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.lifecycle;
+
+import java.util.Collection;
+
+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.pc.mylib.Point;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakeTransactionalAllFails
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.7-4
+ *<BR>
+ *<B>Assertion Description: </B>
+If a collection or array of instances is passed to
+ *PersistenceManager.makeTransactionalAll, and one or more of the instances
+ *fail to complete the required o peration, then all instances will be
+ *attempted, and a JDOUserException will be thrown which contains a nested
+ *exception array, each exception of which conta ins one of the failing
+ *instances. The succeeding instances will transition to the specified life
+ *cycle state, and the failing instances will remain in their current state.
+
+ */
+
+public class MakeTransactionalAllFails extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-4 (MakeTransactionalAllFails) 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(MakeTransactionalAllFails.class);
+    }
+ 
+    private PCPoint p1 = null;
+    private Point p2 = null;
+    private Collection col1 = new java.util.HashSet();
+
+    /** */
+    public void testTransactionalInst() {
+        pm = getPM();
+
+        createObjects();
+        runTestMakeTransactionalAll1(pm);
+        runTestMakeTransactionalAll2(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createObjects() {
+        p1 = new PCPoint(1,3);
+        p2 = new Point(2,4);
+        col1 = new java.util.HashSet();
+        col1.add(p1);
+        col1.add(p2);
+    }
+
+    /* test makeTransactional (Collection pcs) */
+    private void runTestMakeTransactionalAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug(" in runTestMakeTransactionalAll2() ");
+        try {
+            tx.begin();
+            
+            col1.add(p1);
+            col1.add(p2);
+            try {
+                pm.makeTransactionalAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransactionalAll(Collection) should throw JDOUserException when called for collection icnluding instance of non-pc class");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransactionalAll (Object[] pcs) */
+    private void runTestMakeTransactionalAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (debug) logger.debug(" in runTestMakeTransactionalAll2() ");
+        try {
+            tx.begin();
+            try {
+                pm.makeTransactionalAll(col1.toArray());
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransactionalAll(Object[]) should throw JDOUserException when called for collection icnluding instance of non-pc class");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalIsImmediate.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,185 @@
+/*
+ * 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.lifecycle;
+
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+/**
+ *<B>Title:</B> Make Nontransactional is immediate
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-25
+ *<BR>
+ *<B>Assertion Description: </B>
+The effect of PersistenceManager.makeTransactional or
+makeTransactionalAll is immediate and not subject to rollback.
+ */
+
+
+public class MakeTransactionalIsImmediate extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-25 (MakeTransactionalIsImmediate) 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(MakeTransactionalIsImmediate.class);
+    }
+    
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+    private PCPoint p6 = null;
+    private PCPoint p7 = null;
+
+    private Collection col1 = new HashSet();
+    private Collection col2 = new HashSet();
+
+    /** */
+    public void testTransactionalInst() {
+        pm = getPM();
+
+        createTcleanObjects(pm);
+        runTestMakeTransactionalIsImmediate(pm);
+        runTestMakeTransactionalIsImmediateAll1(pm);
+        runTestMakeTransactionalIsImmediateAll2(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createTcleanObjects(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);
+        p6 = new PCPoint (6,8);
+        p7 = new PCPoint (7,9);
+        
+        col1.add(p2);
+        col1.add(p3);
+        col1.add(p4);
+        
+        col2.add(p5);
+        col2.add(p6);
+        col2.add(p7);
+        
+        pm.makeTransactional(p1);
+        pm.makeTransactional(p2);
+        pm.makeTransactional(p3);
+        pm.makeTransactional(p4);
+        pm.makeTransactional(p5);
+        pm.makeTransactional(p6);
+        pm.makeTransactional(p7);
+    }
+
+    /** */
+    private void runTestMakeTransactionalIsImmediate(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalIsImmediate()");
+
+            tx.begin();
+            pm.makeTransactional(p1);
+            tx.rollback();
+            
+            if (!testState (p1, TRANSIENT_CLEAN, "transient_clean")) {
+                fail(ASSERTION_FAILED,
+                     "expected T-CLEAN instance, instance " + p1 + 
+                     " is " + getStateOfInstance(p1));
+            }
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeTransactionalIsImmediateAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalIsImmediateAll1()");
+            tx = pm.currentTransaction();
+            tx.begin();
+            pm.makeTransactionalAll(col1);
+            tx.rollback();
+
+            for (Iterator iter = col1.iterator(); iter.hasNext();) {
+                PCPoint p = (PCPoint) iter.next();
+                if (!testState(p, TRANSIENT_CLEAN, "transient_clean")) {
+                    fail(ASSERTION_FAILED,
+                         "expected T-CLEAN instance, instance " + p1 + 
+                         " is " + getStateOfInstance(p));
+                }
+            }
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeTransactionalIsImmediateAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalIsImmediateAll2()");
+            tx.begin();
+            Object[] objArray = col2.toArray();
+            pm.makeTransactionalAll(objArray);
+            tx.rollback();
+            
+            for (int i=0; i < objArray.length; i++) {
+                PCPoint p = (PCPoint) objArray[i];
+                if (!testState(p, TRANSIENT_CLEAN, "transient_clean")) {
+                    fail(ASSERTION_FAILED,
+                         "expected T-CLEAN instance, instance " + p1 + 
+                         " is " + getStateOfInstance(p));
+                }
+            }
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalPriorToTransactionRolledback.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,214 @@
+/*
+ * 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.lifecycle;
+
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakeTransactional Prior To a Transaction Rolledback
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-23
+ *<BR>
+ *<B>Assertion Description: </B>
+If the transaction in which an instance is made transactional (by
+calling PersistenceManager.makeTransactional or makeTransactionalAll) is
+rolled back, then the transient instance takes its values as of the beginning of the
+transaction, if the call to makeTransactional was made prior to the beginning of the
+current transaction.
+
+ */
+
+public class MakeTransactionalPriorToTransactionRolledback extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-23 (MakeTransactionalPriorToTransactionRolledback) 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(MakeTransactionalPriorToTransactionRolledback.class);
+    }
+    
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+    private PCPoint p6 = null;
+    private PCPoint p7 = null;
+
+    private Collection col1 = new HashSet();
+    private Collection col2 = new HashSet();
+
+    /** */
+    public void testTransactionalInst() {
+       pm = getPM();
+       pm.currentTransaction().setRestoreValues(true);
+
+       createObjects();
+       runTestMakeTransactionalPriorToTransactionRolledback(pm);
+       runTestMakeTransactionalPriorToTransactionRolledbackAll1(pm);
+       runTestMakeTransactionalPriorToTransactionRolledbackAll2(pm);
+
+       pm.close();
+       pm = null;
+   }
+
+    /** */
+    private void createObjects() {
+        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);
+    }
+    
+    
+    public void runTestMakeTransactionalPriorToTransactionRolledback(
+        PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledback()");
+            p1.setY(new Integer(50));
+
+            tx.begin();
+            p1.setY(new Integer(100));
+            pm.makeTransactional(p1);
+            p1.setY(new Integer(200));
+            tx.rollback();
+
+            p1.setY(new Integer(300));
+            tx.begin();
+            p1.setY(new Integer(400));
+            tx.rollback();
+
+            if (p1.getY().intValue() != 300) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p1.y, expected: 300, actual: " +
+                     p1.getY().intValue());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeTransactionalPriorToTransactionRolledbackAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalPriorToTransactionRolledbackAll1()");
+            p2.setY(new Integer(50));
+            p3.setY(new Integer(50));
+            tx.begin();
+            p2.setY(new Integer(100));
+            p3.setY(new Integer(100));
+            pm.makeTransactionalAll(col1);
+            p2.setY(new Integer(200));
+            p3.setY(new Integer(200));
+            tx.rollback();
+
+            p2.setY(new Integer(300));
+            p3.setY(new Integer(300));
+            tx.begin();
+            p2.setY(new Integer(400));
+            p3.setY(new Integer(400));
+            tx.rollback();
+
+            if (p2.getY().intValue() != 300) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p2.y, expected: 300, actual: " +
+                     p2.getY().intValue());
+            }
+            if (p3.getY().intValue() != 300) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p3.y, expected: 300, actual: " +
+                     p3.getY().intValue());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    public void runTestMakeTransactionalPriorToTransactionRolledbackAll2(
+        PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug (" ** in runTestMakeTransactionalPriorToTransactionRolledbackAll2()");
+            p2.setY(new Integer(50));
+            p3.setY(new Integer(50));
+            tx.begin();
+            p2.setY(new Integer(100));
+            p3.setY(new Integer(100));
+
+            Object[] objArray = col2.toArray();
+            pm.makeTransactionalAll(objArray);
+            p2.setY(new Integer(200));
+            p3.setY(new Integer(200));
+            tx.rollback();
+
+            p2.setY(new Integer(300));
+            p3.setY(new Integer(300));
+            tx.begin();
+            p2.setY(new Integer(400));
+            p3.setY(new Integer(400));
+            tx.rollback();
+
+            if (p2.getY().intValue() != 300) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p2.y, expected: 300, actual: " +
+                     p2.getY().intValue());
+            }
+            if (p3.getY().intValue() != 300) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p3.y, expected: 300, actual: " +
+                     p3.getY().intValue());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransactionalWithinTransactionRolledback.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,186 @@
+/*
+ * 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.lifecycle;
+
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+/**
+ *<B>Title:</B> MakeTransactionalWithinTransactionRolledback
+ *<BR>
+ *<B>Keywords:</B> transienttransactional
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-22
+ *<BR>
+ *<B>Assertion Description: </B>
+If the transaction in which an instance is made transactional (by
+calling PersistenceManager.makeTransactional or makeTransactionalAll) is
+rolled back, then the transient instance takes its values as of the call to
+makeTransactional if the call was made within the current transaction.
+
+ */
+
+public class MakeTransactionalWithinTransactionRolledback extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-22 (MakeTransactionalWithinTransactionRolledback) 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(MakeTransactionalWithinTransactionRolledback.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+    private PCPoint p6 = null;
+    private PCPoint p7 = null;
+
+    private Collection col1 = new java.util.HashSet();
+    private Collection col2 = new java.util.HashSet();
+
+    /** */
+    public void testTransactionalInst() {
+        pm = getPM();
+        pm.currentTransaction().setRestoreValues(true);
+        
+        createObjects();
+        runTestMakeTransactionalWithinTransactionRolledback(pm);
+        runTestMakeTransactionalWithinTransactionRolledbackAll1(pm);
+        runTestMakeTransactionalWithinTransactionRolledbackAll2(pm);
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void createObjects() {
+        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);
+    }
+    
+    /** */
+    public void runTestMakeTransactionalWithinTransactionRolledback(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledback()");
+
+            p1.setY(new Integer(100));
+            tx.begin();
+            p1.setY(new Integer(200));
+            pm.makeTransactional(p1);
+            p1.setY(new Integer(300));
+            tx.rollback();
+
+            if (p1.getY().intValue() != 200) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p1.y, expected: 200, actual: " + p1.getY().intValue());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeTransactionalWithinTransactionRolledbackAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledbackAll1()");
+            p2.setY(new Integer(100));
+            p3.setY(new Integer(100));
+            tx.begin();
+            p2.setY(new Integer(200));
+            p3.setY(new Integer(200));
+            pm.makeTransactionalAll(col1);
+            p2.setY(new Integer(300));
+            p3.setY(new Integer(300));
+            tx.rollback();
+            
+            if (p2.getY().intValue() != 200) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p2.y expected: 200, actual: " + p2.getY().intValue());
+            }
+
+            if (p3.getY().intValue() != 200) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p3.y, expected: 200, actual: " + p3.getY().intValue());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeTransactionalWithinTransactionRolledbackAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeTransactionalWithinTransactionRolledbackAll2()");
+
+            p4.setY(new Integer(100));
+            p5.setY(new Integer(100));
+            tx.begin();
+            p4.setY(new Integer(200));
+            p5.setY(new Integer(200));
+            Object[] objArray = col2.toArray();
+            pm.makeTransactionalAll(objArray);
+            p4.setY(new Integer(300));
+            p5.setY(new Integer(300));
+            tx.rollback();
+            
+            if (p4.getY().intValue() != 200) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p4, expected: 200, actual: " + p4.getY().intValue());
+            }
+            
+            if (p5.getY().intValue() != 200) {
+                fail(ASSERTION_FAILED,
+                     "wrong value of p5.y, expected: 200, actual: " + p5.getY().intValue());
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransient.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,178 @@
+/*
+ * 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.lifecycle;
+
+import java.util.Collection;
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakeTransient
+ *<BR>
+ *<B>Keywords:</B> transient
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-13
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeTransient and makeTransientAll make a persistent instance transient, so it is not associated with the PersistenceManager instance. It does not affect the persistent state in the data store.
+
+ */
+
+public class MakeTransient extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-13 (MakeTransient) 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(MakeTransient.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakeTransient() {
+        pm = getPM();
+
+        createPersistentObjects(pm);
+        runTestMakeTransient1(pm);
+        runTestMakeTransientAll1(pm);
+        runTestMakeTransientAll2(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 runTestMakeTransient1(PersistenceManager pm) {
+      Transaction tx = pm.currentTransaction();
+      try {
+          tx.begin();
+          pm.makeTransient(p1);
+          tx.commit();
+          tx = null;
+
+          if (!testState(p1, TRANSIENT, "transient")) {
+              fail("expected TRANSIENT instance, instance " + p1 + 
+                   " is " + getStateOfInstance(p1));
+          }
+      }
+      finally {
+          if ((tx != null) && tx.isActive())
+              tx.rollback();
+      }
+    }
+    
+    /* test makeTransientAll (Collection pcs) */
+    private void runTestMakeTransientAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new java.util.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("expected TRANSIENT instance, instance " + p1 + 
+                         " is " + getStateOfInstance(p));
+                }
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            int NUM_OBJS = 2;
+            tx.begin();
+            
+            Collection col1 = new java.util.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("expected TRANSIENT instance, instance " + p1 + 
+                         " is " + getStateOfInstance(p));
+                }
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}
+

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientAllFails.java Mon Apr  4 12:41:23 2005
@@ -0,0 +1,135 @@
+/*
+ * 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.lifecycle;
+
+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.pc.mylib.Point;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B>MakeTransientAll Fail
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-3
+ *<BR>
+ *<B>Assertion Description: </B>
+If a collection or array of instances is passed to PersistenceManager.makeTransientAll, and one or more of the instances fail to complete the required operation, then all instances will be attempted, and a JDOUserException will be thrown which contains a nested exception array, each exception of which contains one of the failing instances. The succeeding instances will transition to the specified life cycle state, and the failing instances will remain in their current state.
+
+ */
+
+public class MakeTransientAllFails extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-3 (MakeTransientAllFails) 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(MakeTransientAllFails.class);
+    }
+
+    /** */
+    public void testMakeTransientAllFails() {
+        pm = getPM();
+
+        runTestMakeTransientAllFails1(pm);
+        runTestMakeTransientAllFails2(pm);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /* test makeTansientAll (Collection pcs) */
+    private void runTestMakeTransientAllFails1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            PCPoint np1 = new PCPoint (3,3);
+            PCPoint np2 = new PCPoint (4,4);
+            Point np3 =  new Point (5,5);
+
+            Collection col1 = new HashSet();
+            col1.add(np1);
+            col1.add(np2);
+            col1.add(np3);
+
+            try {
+                pm.makeTransientAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransientAll(Collection) should throw JDOUserException when called for a collection including an instance of a non-pc class");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            
+            tx.rollback();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientAllFails2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            PCPoint np1 = new PCPoint (3,3);
+            PCPoint np2 = new PCPoint (4,4);
+            Point np3 =  new Point (5,5);
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(np1);
+            col1.add(np2);
+            col1.add(np3);
+
+            Object[] obj1=col1.toArray();
+            
+            try {
+                pm.makeTransientAll(obj1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeTransientAll(Object[]) should throw JDOUserException when called for an array including an instance of a non-pc class");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            
+            tx.rollback();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java?view=auto&rev=160090
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/MakeTransientCausesLossOfIdentity.java Mon Apr  4 12:41:23 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.lifecycle;
+
+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;
+import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest;
+
+/**
+ *<B>Title:</B> MakeTransientCausesLossOfIdentity
+ *<BR>
+ *<B>Keywords:</B> transient identity
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-14
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeTransient and makeTransientAll transition an instance to transient, causing it to lose its JDO identity.
+
+ */
+
+public class MakeTransientCausesLossOfIdentity extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-14 (MakeTransientCausesLossOfIdentity) 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(MakeTransientCausesLossOfIdentity.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakeTransientCausesLossOfIdentity() {
+        pm = getPM();
+
+        createPersistentObjects(pm);
+        runTestMakeTransientCausesLossOfIdentity1(pm);
+        runTestMakeTransientCausesLossOfIdentityAll1(pm);
+        runTestMakeTransientCausesLossOfIdentityAll2(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 runTestMakeTransientCausesLossOfIdentity1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+            pm.makeTransient(p1);
+            tx.commit();
+
+            Object oid = pm.getObjectId(p1);
+            if (oid != null) {
+                fail(ASSERTION_FAILED,
+                     "pm.getObjectId(p1) returned non null ObjectId " + oid + " for transient instance");
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Collection pcs) */
+    private void runTestMakeTransientCausesLossOfIdentityAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+
+            pm.makeTransientAll(col1);
+            tx.commit();
+
+            Object oid1 = pm.getObjectId(p2);
+            if (oid1 != null) {
+                fail(ASSERTION_FAILED,
+                     "pm.getObjectId(p2) returned non null ObjectId " + oid1 + " for transient instance");
+            }
+            Object oid2 = pm.getObjectId(p3);
+            if (oid2 != null) {
+                fail(ASSERTION_FAILED,
+                     "pm.getObjectId(p3) returned non null ObjectId " + oid2 + " for transient instance");
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeTransientAll (Object[] o) */
+    private void runTestMakeTransientCausesLossOfIdentityAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p4);
+            col1.add(p5);
+
+            Object[] obj1= col1.toArray();
+
+            pm.makeTransientAll(obj1);
+            tx.commit();
+
+            Object oid1 = pm.getObjectId(p4);
+            if (oid1 != null) {
+                fail(ASSERTION_FAILED,
+                     "pm.getObjectId(p4) returned non null ObjectId " + oid1 + " for transient instance");
+            }
+            Object oid2 = pm.getObjectId(p5);
+            if (oid2 != null) {
+                fail(ASSERTION_FAILED,
+                     "pm.getObjectId(p5) returned non null ObjectId " + oid2 + " for transient instance");
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

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



Mime
View raw message