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 [7/61] - in incubator/jdo/trunk/tck11: ./ assertions/ iut_jars/ test/ test/conf/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/jdo/ test/java/org/apache/jdo/tck/ test/java/org/apache/jdo/tck/api/ test/java/org/apache/jdo/tck/api/instancecallbacks/ test/java/org/apache/jdo/tck/api/jdohelper/ test/java/org/apache/jdo/tck/api/persistencemanager/ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ test/java/org/apache/jdo/tck/enhancement/ test/java/org/apache/jdo/tck/extents/ test/java/org/apache/jdo/tck/lifecycle/ test/java/org/apache/jdo/tck/lifecycle/nontransactional/ test/java/org/apache/jdo/tck/models/ test/java/org/apache/jdo/tck/models/embedded/ test/java/org/apache/jdo/tck/models/fieldtypes/ test/java/org/apache/jdo/tck/models/inheritance/ test/java/org/apache/jdo/tck/pc/ test/java/org/apache/jdo/tck/pc/company/ test/java/org/apache/jdo/tck/pc/fieldtypes/ test/java/org/apache/jdo/tck/pc/inheritance/ test/java/org/apache/jdo/tck/pc/instancecallbacks/ test/java/org/apache/jdo/tck/pc/lifecycle/ test/java/org/apache/jdo/tck/pc/mylib/ test/java/org/apache/jdo/tck/query/ test/java/org/apache/jdo/tck/query/operators/ test/java/org/apache/jdo/tck/transactions/ test/java/org/apache/jdo/tck/util/ test/jdo/ test/jdo/applicationidentity/ test/jdo/applicationidentity/org/ test/jdo/applicationidentity/org/apache/ test/jdo/applicationidentity/org/apache/jdo/ test/jdo/applicationidentity/org/apache/jdo/tck/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ test/jdo/datastoreidentity/ test/jdo/datastoreidentity/org/ test/jdo/datastoreidentity/org/apache/ test/jdo/datastoreidentity/org/apache/jdo/ test/jdo/datastoreidentity/org/apache/jdo/tck/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/
Date Sat, 19 Mar 2005 01:09:44 GMT
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClass.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClass.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClass.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,100 @@
+/*
+ * 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 org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get ObjectId Class
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion IDs:</B> A12.10-1
+ *<BR>
+ *<B>Assertion Description: </B>
+The method PersistenceManager.getObjectIdClass returns the class of the
+object id for the given class.
+If the parameter class is not persistence-capable, or the parameter is null, 
+ null is returned. If the object-id class defined in the metadata for the 
+ parameter class is abstract then null is returned.
+If the implementation does not support application identity, and the class 
+ is defined in the jdo metadata to use application identity, 
+ then null is returned. 
+ */
+
+public class GetObjectIdClass extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.10-1 (GetObjectIdClass) 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(GetObjectIdClass.class);
+    }    
+
+    /** */
+    public void test() {
+        pm = getPM();
+        runTestGetObjectIdClassForNull(pm);
+        runTestGetObjectIdClassForNonPCClass(pm);
+        runTestGetObjectIdClassForAbstractClass(pm);
+        runTestGetObjectIdClass(pm);
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void runTestGetObjectIdClass(PersistenceManager pm) {
+        if (pm.getObjectIdClass(PCPoint.class) == null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectIdClass(PCPoint.class) returned null");
+        }
+    }
+
+    /** */
+    private void runTestGetObjectIdClassForNull(PersistenceManager pm) {
+        Class cl = pm.getObjectIdClass(null);
+        if (cl != null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectIdClass for null returned non-null class: " +
+                 cl.getName());
+        }
+    }
+
+    /** */
+    private void runTestGetObjectIdClassForNonPCClass(PersistenceManager pm) {
+        Class cl = pm.getObjectIdClass(java.lang.Throwable.class);
+        if (cl != null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectIdClass for non-PC class returned non-null class: " +
+                 cl.getName());
+        }
+    }
+
+    private void runTestGetObjectIdClassForAbstractClass(PersistenceManager pm) {
+        // not implemented; the tck contains no classes with which to test this.
+        // we need an abstract class whose object-id class is itself abstract.
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdClassForAbstractOrNonPersistenceCapableClass.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,77 @@
+/*
+ * 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 org.apache.jdo.tck.pc.mylib.Point;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get ObjectId Class For Abstract or Non-PersistenceCapable Class
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion IDs:</B> A12.10-2
+ *<BR>
+ *<B>Assertion Description: </B>
+A call to PersistenceManager.getObjectIdClass returns null if the class is abstract or not persistence-capable, or the parameter is null.
+ */
+
+public class GetObjectIdClassForAbstractOrNonPersistenceCapableClass extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.10-2 (GetObjectIdClassForAbstractOrNonPersistenceCapableClass) 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(GetObjectIdClassForAbstractOrNonPersistenceCapableClass.class);
+    }
+
+    /** */
+    public void testGetObjectIdClassForAbstractOrNonPersistenceCapableClass() {
+        pm = getPM();
+        runTestNonPcClass(pm);
+        runTestNullParam(pm);
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void runTestNonPcClass(PersistenceManager pm) {
+        Class c1 = pm.getObjectIdClass(Point.class);
+        if ( c1 != null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectIdClass returns non-null ObjectId class for non pc class");
+        }
+    }
+
+    /** */
+    private void runTestNullParam(PersistenceManager pm) {
+        Class c1 = pm.getObjectIdClass(null);
+        if (c1 != null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectIdClass for null returned non-null class: " +
+                 c1.getName());    
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdForNullOrNotPersistent.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdForNullOrNotPersistent.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdForNullOrNotPersistent.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdForNullOrNotPersistent.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.pc.mylib.Point;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> GetObjectIdForNullOrNotPersistent
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.6-14.
+ *<BR>
+ *<B>Assertion Description: </B>
+If a call is made to PersistenceManager.getObjectId and the
+parameter pc is not persistent, or is null, then null is returned.
+ */
+
+
+public class GetObjectIdForNullOrNotPersistent extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.6-14 (GetObjectIdForNullOrNotPersistent) 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(GetObjectIdForNullOrNotPersistent.class);
+    }
+
+    /** */
+    public void testGetObjectIdForNullOrNotPersistent() {
+        pm = getPM();
+        runTestNonPcClass(pm);
+        runTestNullParam(pm);
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void runTestNonPcClass(PersistenceManager pm) {
+        Point p = new Point(1,3);
+        Object oid = pm.getObjectId(p);
+        if (oid != null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectId returned non null ObjectId: " + oid + 
+                 " for instance of non-pc class");
+        }
+    }
+    
+    /** */
+    private void runTestNullParam(PersistenceManager pm) {
+        Object oid = pm.getObjectId(null);
+        if (oid != null) {
+            fail(ASSERTION_FAILED,
+                 "pm.getObjectId(null) returned non null ObjectId: " + oid);
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdWithApplicationModifyingIdentity.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdWithApplicationModifyingIdentity.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdWithApplicationModifyingIdentity.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetObjectIdWithApplicationModifyingIdentity.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get ObjectId With Application Modifying Identity
+ *<BR>
+ *<B>Keywords:</B> identity applicationidentity
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.6-11.
+ *<BR>
+ *<B>Assertion Description: </B>
+If the object identity is being changed in the transaction,
+by the application modifying one or more of the application key fields,
+then the method <code>PersistenceManager.getObjectId</code> returns the
+identity as of the beginning of the transaction. The value returned by
+<code>getObjectId</code> will be different following <code>afterCompletion</code>
+processing for successful transactions.
+
+ */
+
+public class GetObjectIdWithApplicationModifyingIdentity extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.6-11 (GetObjectIdWithApplicationModifyingIdentity) 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(GetObjectIdWithApplicationModifyingIdentity.class);
+    }
+
+    /** */
+    public void testGetObjectByIdWithApplicationModifyingIdentity() {
+        if (!isChangeApplicationIdentitySupported()) {
+            if (debug)
+                logger.debug("Implementation does not support chaning application identity");
+            return;
+        }
+        
+        if (debug)
+            logger.debug("\nSTART GetObjectIdWithApplicationModifyingIdentity");
+        pm = getPM();
+        Object oid = createPCPointInstance(pm);
+        PCPoint p1 = (PCPoint) pm.getObjectById(oid, false);
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            p1.setX(10000); // this is the primary key
+            Object oid2 = pm.getObjectId (p1); // should be the same
+            tx.commit();
+            
+            Object oid3 = pm.getObjectId (p1); // should be same as oid3
+            if (!oid.equals(oid2)) {
+                fail(ASSERTION_FAILED,
+                     "Oid before is different from oid after modifying pk");
+            }
+            
+            if (oid.equals(oid3)) {
+                fail(ASSERTION_FAILED,
+                     "Oid before is the same as oid after modifying pk");
+            }
+        }
+        finally {
+            if (debug)
+                logger.debug("END GetObjectIdWithApplicationModifyingIdentity");
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

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

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetSetUserObject.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.pc.mylib.Point;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get/Set User Object
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion ID:</B> A12.8-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.setUserObject method is used to store an object associated with the PersistenceManager. One uses the method getUserObject to later
+retrieve the object.
+
+
+ */
+
+public class GetSetUserObject extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.8-1 (GetSetUserObject) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(GetSetUserObject.class);
+    }
+
+    /** */
+    public void testGetSetUserObject() {
+        pm = getPM();
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Point p = new Point(10,10);
+            pm.setUserObject(p);
+            tx.commit();
+
+            tx.begin();
+            Object obj = pm.getUserObject();
+            
+            if (obj != p) {
+                fail(ASSERTION_FAILED,
+                     "Unexpected pm user object, expected " + p + ", got " + obj);
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

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

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/GetTransactionalObjectIdWithNoTransaction.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.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get Transactional ObjectId With No Transaction
+ *<BR>
+ *<B>Keywords:</B> identity
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.6-16
+ *<BR>
+ *<B>Assertion Description: </B>
+If there is no transaction in progress, or if none of the key fields is being
+modified, then PersistenceManager.getTransactionalObjectId has the same behavior as
+getObjectId.
+
+
+ */
+
+public class GetTransactionalObjectIdWithNoTransaction extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.6-16 (GetTransactionalObjectIdWithNoTransaction) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(GetTransactionalObjectIdWithNoTransaction.class);
+    }
+
+    /** */
+    public void testGetTransactionalObjectIdWithNoTransaction() {
+        pm = getPM();
+        Transaction tx = pm.currentTransaction();
+        try {
+            PCPoint p1 = new PCPoint();
+
+            tx.begin();
+            pm.makePersistent(p1);
+            Object oid = pm.getObjectId(p1);
+            tx.commit();
+            
+            Object toid = pm.getTransactionalObjectId(p1);
+            if (!toid.equals(oid)) {
+                fail(ASSERTION_FAILED,
+                     "pm.getTransactionalObjectId(p1) returned unexpected ObjectId, expected " + 
+                     oid + ", got " + toid);
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+        pm.close();
+        pm = null;
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponConstruction.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponConstruction.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponConstruction.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponConstruction.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Is Closed returns false Upon Construction
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-3
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.isClosed method returns false upon construction of
+the PersistenceManager instance.
+*/
+
+public class IsClosedIsFalseUponConstruction extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-3 (IsClosedIsFalseUponConstruction) 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(IsClosedIsFalseUponConstruction.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        if (pm.isClosed()) {
+            fail(ASSERTION_FAILED,
+                 "pm is closed after creation");
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponRetrievalFromPool.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponRetrievalFromPool.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponRetrievalFromPool.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsFalseUponRetrievalFromPool.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Is Closed Is False Upon Retrieval From a Pool
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-4
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.isClosed method returns false upon retrieval
+of a PersistenceManager from a pool.
+*/
+
+public class IsClosedIsFalseUponRetrievalFromPool extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-4 (IsClosedIsFalseUponRetrievalFromPool) 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(IsClosedIsFalseUponRetrievalFromPool.class);
+    }
+
+    /** */
+    public void testIsClosed() {
+        String sname="Jojo";
+        String spswd="mypswd";
+
+        pmf = getPMF();
+        pm = pmf.getPersistenceManager(sname,spswd);
+
+        if (pm.isClosed()) {
+            fail(ASSERTION_FAILED,
+                 "pm is closed after creation");
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsTrueAfterClose.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsTrueAfterClose.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsTrueAfterClose.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/IsClosedIsTrueAfterClose.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,61 @@
+/*
+ * 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.PersistenceManagerFactory;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Is Closed Is True After Close
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5-5
+ *<BR>
+ *<B>Assertion Description: </B>
+The PersistenceManager.isClosed method returns true only after the
+closemethod completes successfully, meaning the PersistenceManager has been closed. (same as A35-01).
+*/
+
+public class IsClosedIsTrueAfterClose extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5-5 (IsClosedIsTrueAfterClose) 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(IsClosedIsTrueAfterClose.class);
+    }
+
+    /** */
+    public void test() {
+        PersistenceManagerFactory pmf = getPMF();
+        pm = pmf.getPersistenceManager();
+        pm.close();
+        
+        if (!pm.isClosed()) {
+            fail(ASSERTION_FAILED,
+                 "pm.isClosed returns false after pm.close");
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalAllFails.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalAllFails.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalAllFails.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalAllFails.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,173 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+
+import javax.jdo.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;
+
+/**
+ *<B>Title:</B> MakeNontransactionalAllFails
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion ID:</B> A12.5.7-5
+ *<BR>
+ *<B>Assertion Description: </B>
+If a collection or array of instances is passed to PersistenceManager.makeNontransactionalAll, 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 MakeNontransactionalAllFails extends PersistenceManagerTest {
+       
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-5 (MakeNontransactionalAllFails) 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(MakeNontransactionalAllFails.class);
+    }
+    
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private Point p5 = null;
+
+    /** */
+    public void testTransactionalInst() {
+        pm = getPM();
+
+        createObjects(pm);
+        runTestMakeNontransactional1(pm);
+        runTestMakeNontransactionalAll1(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);
+    }
+    
+    /* test makeNontransactional (Object pc) */
+    private void runTestMakeNontransactional1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makePersistent(p1);
+            try {
+                pm.makeNontransactional(p1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeNontransactional should throw a JDOUserException when called for a P-NEW instance.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /* test makeNontransactionalAll (Collection pcs) */
+    private void runTestMakeNontransactionalAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makePersistent(p2);
+            tx.commit();
+
+            tx.begin();
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+            col1.add(p4);
+            
+            try {
+                pm.makeNontransactionalAll(col1);
+                fail(ASSERTION_FAILED,
+                     "pm.makeNontransactionalAll(Collection) should throw a JDOUserException when called for collection including P-NEW instances.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makeNontransactionalAll (Object[] pcs) */
+    private void testMakeNontransactionalAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+            pm.makePersistent(p2);
+            tx.commit();
+            
+            tx.begin();
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+            
+            Collection col1 = new java.util.HashSet();
+            col1.add(p2);
+            col1.add(p3);
+            col1.add(p4);
+            
+            try {
+                pm.makeNontransactionalAll(col1.toArray());
+                fail(ASSERTION_FAILED,
+                     "pm.makeNontransactionalAll(Object []) should throw a JDOUserException when called for an array including P-NEW instances.");
+            }
+            catch (JDOUserException ex) {
+                // expected exception
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalDirtyInstance.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalDirtyInstance.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalDirtyInstance.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalDirtyInstance.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,304 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+/**
+ *<B>Title:</B> Make Nontransactional a Dirty Instance
+ *<BR>
+ *<B>Keywords:</B> exception
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-28
+ *<BR>
+ *<B>Assertion Description: </B>
+If PersistenceManager.makeNontransactional or makeNontransactionalAll is called with an explicit dirty parameter instance, a JDOUserException is thrown.
+
+ */
+
+public class MakeNontransactionalDirtyInstance extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-28 (MakeNontransactionalDirtyInstance) 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(MakeNontransactionalDirtyInstance.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 PCPoint c1 = null;
+    private PCPoint c2 = null;
+    private PCPoint c3 = null;
+    private PCPoint c4 = null;
+    private PCPoint c5 = null;
+    private PCPoint c6 = null;
+    private PCPoint c7 = null;
+
+    private Collection pcol1 = new HashSet();
+    private Collection pcol2 = new HashSet();
+    private Collection ccol1 = new HashSet();
+    private Collection ccol2 = new HashSet();
+
+    /** */
+    public void testMakeNontransactional() {
+        pm = getPM();
+        /*  call with an explicit persistent dirty parameter instance */
+        String pstate="persistent";
+        createPersistentObjects(pm);
+        if (debug)
+            logger.debug(" -- testing with persistent dirty instance -- ");
+        runTestMakeNontransactionalDirtyInstance(pm, p1,pstate);
+        runTestMakeNontransactionalDirtyInstanceAll1(pm, pcol1, pstate);
+        runTestMakeNontransactionalDirtyInstanceAll2(pm, pcol2, pstate);
+        
+        /*  call with an explicit transient dirty parameter instance */
+        pstate="transient";
+        createTcleanObjects(pm);
+        if (debug)
+            logger.debug (" -- testing with transient dirty instance -- ");
+        runTestMakeNontransactionalDirtyInstance(pm, c1,pstate);
+        runTestMakeNontransactionalDirtyInstanceAll1(pm, ccol1, pstate);
+        runTestMakeNontransactionalDirtyInstanceAll2(pm, ccol2, pstate);
+        
+        pm.close();
+        pm = null;
+    }
+    
+    /** */
+    private void createTcleanObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            c1 = new PCPoint(1,3);
+            c2 = new PCPoint(2,4);
+            c3 = new PCPoint(3,5);
+            c4 = new PCPoint(4,6);
+            c5 = new PCPoint (5,7);
+            c6 = new PCPoint (6,8);
+            c7 = new PCPoint (7,9);
+            
+            ccol1.add(c2);
+            ccol1.add(c3);
+            ccol1.add(c4);
+            
+            ccol2.add(c5);
+            ccol2.add(c6);
+            ccol2.add(c7);
+            
+            pm.makeTransactional(c1);
+            pm.makeTransactional(c2);
+            pm.makeTransactional(c3);
+            pm.makeTransactional(c4);
+            pm.makeTransactional(c5);
+            pm.makeTransactional(c6);
+            pm.makeTransactional(c7);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    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);
+            p6 = new PCPoint (6,8);
+            p7 = new PCPoint (7,9);
+
+            pm.makePersistent(p1);
+            pm.makePersistent(p2);
+            pm.makePersistent(p3);
+            pm.makePersistent(p4);
+            pm.makePersistent(p5);
+            pm.makePersistent(p6);
+            pm.makePersistent(p7);
+
+            pcol1.add(p2);
+            pcol1.add(p3);
+            pcol1.add(p4);
+
+            pcol2.add(p5);
+            pcol2.add(p6);
+            pcol2.add(p7);
+            tx.commit();
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /** */
+    private void runTestMakeNontransactionalDirtyInstance(PersistenceManager pm, PCPoint obj, String state) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalDirtyInstance()");
+            int curr;
+            tx.begin();
+            if (makeAndTestDirtyInstance(obj,state)) {
+                try {
+                    pm.makeNontransactional(obj);
+                    fail (ASSERTION_FAILED, 
+                          "pm.makeNontransactional should throw a JDOUserException when called for P-DIRTY instance.");
+                }
+                catch (JDOUserException ex) {
+                    // expected exception
+                }
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalDirtyInstanceAll1(PersistenceManager pm, Collection tcol, String state) {
+        Transaction tx = pm.currentTransaction();
+        boolean stopFlag = false;
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalDirtyInstanceAll1()");
+            int curr;
+            tx.begin();
+
+            Iterator iter = tcol.iterator();
+            while (iter.hasNext()) {
+                PCPoint p = (PCPoint) iter.next();
+                if (makeAndTestDirtyInstance(p,state))
+                    stopFlag = true;
+            }
+
+            if (! stopFlag) {
+                try {
+                    pm.makeNontransactionalAll(tcol);
+                    fail (ASSERTION_FAILED, 
+                          "pm.makeNontransactionalAll(Collection) should throw a JDOUserException when called for a collection including P-DIRTY instances.");
+                }
+                catch (JDOUserException ex) {
+                    // expected exception
+                }
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalDirtyInstanceAll2(PersistenceManager pm, 
+                                                              Collection tcol, 
+                                                              String state) {
+        Transaction tx = pm.currentTransaction();
+        boolean stopFlag = false;
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalDirtyInstanceAll2()");
+            tx.begin();
+
+            Iterator iter = tcol.iterator();
+            while (iter.hasNext()) {
+                PCPoint p = (PCPoint) iter.next();
+                if (makeAndTestDirtyInstance(p,state))
+                    stopFlag = true;
+            }
+
+            Object[] objArray = tcol.toArray();
+
+            if (! stopFlag) {
+                try {
+                    pm.makeNontransactionalAll(objArray);
+                    fail (ASSERTION_FAILED, 
+                          "pm.makeNontransactionalAll(Object []) should throw a JDOUserException when called for an arry including P-DIRTY instances.");
+                }
+                catch (JDOUserException ex) {
+                    // expected exception
+                }
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private boolean makeAndTestDirtyInstance (PCPoint obj, String state) {
+        int i = obj.getX();
+        i = i*10;
+
+        obj.setX(i);
+        int curr = currentState(obj);
+
+        if (state.equals("persistent")) {
+            if ( curr != PERSISTENT_DIRTY ) {
+                fail(ASSERTION_FAILED,
+                     " Object not in persistent dirty state " +
+                     " for " + obj.getX() + " current state: " + curr);
+                return false;
+            }
+        }
+        else if (state.equals("transient")) {
+            if ( curr != TRANSIENT_DIRTY ) {
+                fail(ASSERTION_FAILED,
+                     " Object not in transient dirty state " +
+                     " for " + obj.getX() + " current state: " + curr);
+                return false;
+            }
+        }
+        return true;
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalIsImmediate.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalIsImmediate.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalIsImmediate.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalIsImmediate.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Make Nontransactional is immediate
+ *<BR>
+ *<B>Keywords:</B>
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-29
+ *<BR>
+ *<B>Assertion Description: </B>
+The effect of PersistenceManager.makeNontransactional or
+makeNontransactionalAll is immediate and not subject to rollback.
+ */
+
+public class MakeNontransactionalIsImmediate extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-29 (MakeNontransactionalIsImmediate) 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(MakeNontransactionalIsImmediate.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();
+        runTestMakeNontransactionalIsImmediate(pm);
+        runTestMakeNontransactionalIsImmediateAll1(pm);
+        runTestMakeNontransactionalIsImmediateAll2(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createTcleanObjects() {
+        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);
+            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);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalIsImmediate(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug (" ** in runTestMakeNontransactionalIsImmediate()");
+            int curr;
+            tx.begin();
+            
+            if (testState(p1, TRANSIENT_CLEAN, "transient clean")) {
+                pm.makeNontransactional(p1);
+                if (! testState(p1, TRANSIENT, "transient")) {
+                    fail(ASSERTION_FAILED,
+                         "transient clean instance shoud become transient immediately after pm.makeNontransactional");
+                }
+            }
+            tx.rollback();
+            tx = null;
+            
+            if (! testState(p1, TRANSIENT, "transient")) {
+                fail(ASSERTION_FAILED,
+                     "tx.rollback should rollback effect of pm.makeNontransactional");
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalIsImmediateAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeNontransactionalIsImmediateAll1()");
+            int curr;
+            tx.begin();
+
+            if (testState (p2, TRANSIENT_CLEAN, "transient clean") &&
+                testState (p3, TRANSIENT_CLEAN, "transient clean") &&
+                testState (p4, TRANSIENT_CLEAN, "transient clean")) {
+
+                pm.makeNontransactionalAll(col1);
+                if (! navigateAndTestTransientCol(col1)) {
+                    fail(ASSERTION_FAILED, 
+                         "transient clean instances shoud become transient immediately after pm.makeNontransactionalAll(Collection)");
+                }
+            }
+            
+            tx.rollback();
+
+            tx.begin();
+            if (! navigateAndTestTransientCol(col1)) {
+                fail(ASSERTION_FAILED, 
+                     "tx.rollback should rollback effect of pm.makeNontransactionalAll(Collection)");
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalIsImmediateAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in runTestMakeNontransactionalIsImmediateAll2()");
+            int curr;
+            tx.begin();
+            Object[] objArray = col2.toArray();
+
+            if (testState (p5, TRANSIENT_CLEAN, "transient clean") &&
+                testState (p6, TRANSIENT_CLEAN, "transient clean") &&
+                testState (p7, TRANSIENT_CLEAN, "transient clean")) {
+                
+                pm.makeNontransactionalAll(objArray);
+                if (! navigateAndTestTransientArray(objArray)) {
+                    fail(ASSERTION_FAILED, 
+                         "transient clean instances shoud become transient immediately after pm.makeNontransactionalAll(Object[])");
+                }
+            }
+            tx.rollback();
+            
+            tx.begin();
+            if (! navigateAndTestTransientArray(objArray)) { 
+                fail(ASSERTION_FAILED, 
+                     "tx.rollback should rollback effect of pm.makeNontransactionalAll(Object[])");
+            }
+            tx.rollback();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /** */
+    private boolean navigateAndTestTransientCol (Collection col) {
+        boolean noError = true;
+        Iterator iter = col1.iterator();
+        while (iter.hasNext() ) {
+            PCPoint p = (PCPoint) iter.next();
+            if (! testState(p, TRANSIENT, "transient")) {
+                noError = false;
+            }
+        }
+        return noError;
+    }
+    
+    /** */
+    private boolean navigateAndTestTransientArray (Object[] objArray) {
+        boolean noError = true;
+        for (int i=0; i < objArray.length; i++) {
+            PCPoint p = (PCPoint) objArray[i];
+            if (! testState(p, TRANSIENT, "transient")) {
+                noError = false;
+            }
+        }
+        return noError;
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalPersistentCleanInstance.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalPersistentCleanInstance.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalPersistentCleanInstance.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalPersistentCleanInstance.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,239 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Make Nontransactional a Persistent-Clean Instance
+ *<BR>
+ *<B>Keywords:</B> lifecycle
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-27
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeNontransactional and makeNontransactionalAll makes a
+ *persistent-clean instance nontransactional and causes a state transition to
+ *persistent-nontransactional.
+ */
+
+public class MakeNontransactionalPersistentCleanInstance
+    extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-27 (MakeNontransactionalPersistentCleanInstance) 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(MakeNontransactionalPersistentCleanInstance.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() {
+        pm = getPM();
+        
+        createObjects(pm);
+        runTestMakeNontransactionalPersistentCleanInstance(pm);
+        runTestMakeNontransactionalPersistentCleanInstanceAll1(pm);
+        runTestMakeNontransactionalPersistentCleanInstanceAll2(pm);
+
+        pm.close();
+        pm = null;
+   }
+
+    /** */
+    private void createObjects(PersistenceManager pm) {
+        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();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalPersistentCleanInstance(
+        PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalPersistentCleanInstance()");
+            int curr;
+            tx.setOptimistic(false);
+            tx.begin();
+
+            if (makePersistentCleanInstance(p1)) {
+                pm.makeNontransactional(p1);
+                curr = currentState(p1);
+
+                if (curr == HOLLOW ||
+                    curr == PERSISTENT_NONTRANSACTIONAL) {
+                }
+                else {
+                    fail(ASSERTION_FAILED,
+                         "Excpected P-HOLLOW or P-NONTX instance, instance is " + 
+                         getStateOfInstance(p1));
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalPersistentCleanInstanceAll1(
+        PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalPersistentCleanInstanceAll1()");
+            int curr;
+
+            tx.setOptimistic(false);
+            tx.begin();
+            
+            if ( makePersistentCleanInstance(p2) &&
+                 makePersistentCleanInstance(p3) &&
+                 makePersistentCleanInstance(p4)) {
+                
+                pm.makeNontransactionalAll(col1);
+                Iterator iter = col1.iterator();
+                while (iter.hasNext() ) {
+                    PCPoint p = (PCPoint) iter.next();
+                    curr = currentState(p);
+                    if (curr == HOLLOW ||
+                        curr == PERSISTENT_NONTRANSACTIONAL) {
+                    }
+                    else {
+                        fail(ASSERTION_FAILED,
+                             "Expected persistent-nontransactional or hollow; got " + 
+                             getStateOfInstance(p));
+                    }
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+
+    }
+
+    /** */
+    private void runTestMakeNontransactionalPersistentCleanInstanceAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalPersistentCleanInstanceAll2()");
+            int curr;
+            if (tx.getOptimistic())
+                if (debug) logger.debug (" opt flag set to true");
+            tx.begin();
+
+            Object[] objArray = col2.toArray();
+
+            if ( makePersistentCleanInstance(p5) &&
+                 makePersistentCleanInstance(p6) &&
+                 makePersistentCleanInstance(p7)) {
+                
+                pm.makeNontransactionalAll(objArray);
+
+                for (int i=0; i < objArray.length; i++) {
+                    PCPoint p = (PCPoint) objArray[i];
+                    curr = currentState(p);
+                    if (curr == HOLLOW ||
+                        curr == PERSISTENT_NONTRANSACTIONAL) {
+                    }
+                    else {
+                        fail(ASSERTION_FAILED,
+                             "Expected persistent-nontransactional or hollow; got " + 
+                             getStateOfInstance(p));
+                    }
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private boolean makePersistentCleanInstance (PCPoint obj) {
+        int val = obj.getX();
+        return (testState(obj, PERSISTENT_CLEAN, "persistent clean"));
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalTransientCleanInstance.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalTransientCleanInstance.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalTransientCleanInstance.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakeNontransactionalTransientCleanInstance.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+/**
+ *<B>Title:</B> MakeNontransactionalTransientCleanInstance
+ *<BR>
+ *<B>Keywords:</B> lifecycle
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-26
+ *<BR>
+ *<B>Assertion Description: </B>
+PersistenceManager.makeNontransactional and makeNontransactionalAll makes a transient-clean instance nontransactional and causes a state transition to transient. After the method completes, the instance does not observe transaction boundaries.
+ */
+
+public class MakeNontransactionalTransientCleanInstance extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-26 (MakeNontransactionalTransientCleanInstance) 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(MakeNontransactionalTransientCleanInstance.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();
+
+        createTcleanObjects(pm);
+        runTestMakeNontransactionalTransientCleanInstance(pm);
+        runTestMakeNontransactionalTransientCleanInstanceAll1(pm);
+        runTestMakeNontransactionalTransientCleanInstanceAll2(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    private void createTcleanObjects(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+            p1 = new PCPoint(1,3);
+            p2 = new PCPoint(2,4);
+            p3 = new PCPoint(3,5);
+            p4 = new PCPoint(4,6);
+            p5 = new PCPoint (5,7);
+            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);
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalTransientCleanInstance(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalTransientCleanInstance()");
+            int curr;
+            tx.begin();
+            
+            if (testState(p1, TRANSIENT_CLEAN, "transient clean")) {
+                pm.makeNontransactional(p1);
+                
+                if (testState(p1, TRANSIENT, "transient")) {
+                    // expected result
+                }
+                else {
+                    fail(ASSERTION_FAILED, 
+                         "expected transient instance after pm.makeNontransactional, instance is " +
+                         getStateOfInstance(p1));
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /** */
+    private void runTestMakeNontransactionalTransientCleanInstanceAll1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug(" ** in testMakeNontransactionalTransientCleanInstanceAll1()");
+            int curr;
+            tx.begin();
+
+            if (testState(p2, TRANSIENT_CLEAN, "transient clean") &&
+                testState(p3, TRANSIENT_CLEAN, "transient clean") &&
+                testState(p4, TRANSIENT_CLEAN, "transient clean")) {
+                
+                pm.makeNontransactionalAll(col1);
+                Iterator iter = col1.iterator();
+                while (iter.hasNext() ) {
+                    PCPoint p = (PCPoint) iter.next();
+                    if (testState(p, TRANSIENT, "transient")) {
+                        // expected result
+                    }
+                    else {
+                    fail(ASSERTION_FAILED, 
+                         "expected transient instance after pm.makeNontransactionalAll, instance is " +
+                         getStateOfInstance(p));
+                    }
+                }
+            }
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    private void runTestMakeNontransactionalTransientCleanInstanceAll2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            if (debug)
+                logger.debug (" ** in testMakeNontransactionalTransientCleanInstanceAll2()");
+            int curr;
+            tx.begin();
+
+            Object[] objArray = col2.toArray();
+            
+            if (testState(p5, TRANSIENT_CLEAN, "transient clean") &&
+                testState(p6, TRANSIENT_CLEAN, "transient clean") &&
+                testState(p7, TRANSIENT_CLEAN, "transient clean")) {
+                
+                pm.makeNontransactionalAll(objArray);
+                
+                for (int i=0; i < objArray.length; i++) {
+                    PCPoint p = (PCPoint) objArray[i];
+                    if (testState(p, TRANSIENT, "transient")) {
+                        // expected result
+                    }
+                    else {
+                        fail(ASSERTION_FAILED, 
+                             "expected transient instance after pm.makeNontransactionalAll, instance is " +
+                             getStateOfInstance(p));
+                    }
+                }
+            }
+            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/MakePersistent.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakePersistent.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakePersistent.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencemanager/MakePersistent.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.api.persistencemanager;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> make instance persistent
+ *<BR>
+ *<B>Keywords:</B> persistencemanager
+ *<BR>
+ *<B>Assertion IDs:</B> A12.5.7-6A
+ *<BR>
+ *<B>Assertion Description: </B>
+The method <code>PersistenceManager.makePersistent</code> and
+<code>makePersistentAll</code> makes a transient instance(s) persistent directly.
+It must be called in the context of an active transaction,
+or a <code>JDOUserException</code> is thrown.
+
+ */
+
+public class MakePersistent extends PersistenceManagerTest {
+    
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A12.5.7-6A (MakePersistent) 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(MakePersistent.class);
+    }
+
+    private PCPoint p1 = null;
+    private PCPoint p2 = null;
+    private PCPoint p3 = null;
+    private PCPoint p4 = null;
+    private PCPoint p5 = null;
+
+    /** */
+    public void testMakePersistent() {
+        pm = getPM();
+        
+        createObjects();
+        
+        /* positive tests */
+        runTestMakePersistent1(pm);
+        runTestMakePersistent2(pm);
+        runTestMakePersistent3(pm);
+        
+        /* negative tests */
+        runTestMakePersistent4(pm);
+        runTestMakePersistent5(pm);
+        runTestMakePersistent6(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 runTestMakePersistent1(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            pm.makePersistent(p1);
+            tx.commit();
+            tx = null;
+            if (debug) logger.debug(" \nPASSED in runTestMakePersistent1()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /* test makePersistentAll (Collection pcs) */
+    private void runTestMakePersistent2(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Collection col1 = new HashSet();
+            col1.add(p2);
+            col1.add(p3);
+            
+            pm.makePersistentAll(col1);
+            tx.commit();
+            tx = null;
+            if (debug) logger.debug(" \nPASSED in runTestMakePersistent2()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /* test makePersistentAll (Object[] o) */
+    private void runTestMakePersistent3(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx = pm.currentTransaction();
+            tx.begin();
+            
+            Collection col1 = new HashSet();
+            col1.add(p1);
+            col1.add(p2);
+            
+            Object[] obj1= col1.toArray();
+            
+            pm.makePersistentAll(obj1);
+            tx.commit();
+            tx = null;
+            if (debug) logger.debug (" \nPASSED in runTestMakePersistent3()");
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+    /* test makePersistent (Object pc) */
+    private void runTestMakePersistent4(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (tx.isActive())
+            tx.rollback();
+
+        PCPoint np1 = new PCPoint(1,3);
+        try {
+            pm.makePersistent(np1);
+            fail(ASSERTION_FAILED,
+                 "pm.makePersistent outside of a tx should throw a JDOUserException");
+        }
+        catch (JDOUserException ex) {
+            // expected expected
+        }
+    }
+
+    /* test makePersistentAll (Collection pcs) */
+    private void runTestMakePersistent5(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (tx.isActive())
+            tx.rollback();
+
+        PCPoint np1 = new PCPoint (3,3);
+        PCPoint np2 = new PCPoint (4,4);
+        
+        Collection col1 = new HashSet();
+        col1.add(np1);
+        col1.add(np2);
+        
+        try {
+            pm.makePersistentAll(col1);
+            fail(ASSERTION_FAILED,
+                 "pm.makePersistentAll(Collection) outside of a tx should throw a JDOUserException");
+        }
+        catch (JDOUserException ex) {
+            // expected expected
+        }
+    }
+
+    /* test makePersistentAll (Object[] o) */
+    private void runTestMakePersistent6(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        if (tx.isActive())
+            tx.rollback();
+
+        PCPoint np1 = new PCPoint (3,3);
+        PCPoint np2 = new PCPoint (4,4);
+        
+        Collection col1 = new HashSet();
+        col1.add(np1);
+        col1.add(np2);
+        
+        Object[] obj1=col1.toArray();
+        
+        try {
+            pm.makePersistentAll(obj1);  
+            fail(ASSERTION_FAILED,
+                 "pm.makePersistentAll(Object[]) outside of a tx should throw a JDOUserException");
+        }
+        catch (JDOUserException ex) {
+            // expected expected
+        }
+    }
+}



Mime
View raw message