Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 87550 invoked from network); 19 Mar 2005 05:14:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Mar 2005 05:14:55 -0000 Received: (qmail 92725 invoked by uid 500); 19 Mar 2005 05:14:55 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Delivered-To: moderator for jdo-commits@db.apache.org Received: (qmail 92735 invoked by uid 99); 19 Mar 2005 01:16:31 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Message-ID: <20050319010944.29481.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Sat, 19 Mar 2005 01:09:44 -0000 Subject: svn commit: r158179 [5/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/ To: jdo-commits@db.apache.org From: mbo@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /IsPersistentNotPersistenceCapable.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/IsPersistentNotPersistenceCapable.java?view=3D= auto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= PersistentNotPersistenceCapable.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= PersistentNotPersistenceCapable.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,75 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.Point; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Is Persistent Not Persistence Capable + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.4.3-4 + *
+ *Assertion Description: + The jdohelper.isPersistent method returns false If the instance does not= implement PersistenceCapable + evaluating to true when =3D=3D is used.=20 + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/2/01 1.0 + */ +=20 +public class IsPersistentNotPersistenceCapable extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.4.3-4 (IsPersistentNotPersistenceCapable) failed: "; + =20 + /** + * The main 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(IsPersistentNotPersistenceCapable.class); + } + + /* test JDOHelper.isPersistent(Object pc) + * =20 + */ + public void testIsPersistentNotPersistenceCapable() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Point p1 =3D new Point(1,3); + boolean persistent =3D JDOHelper.isPersistent(p1); + tx.commit(); + if (persistent) + fail(ASSERTION_FAILED, + "JDOHelper.isPersistent returns false for instance of non= -pc class."); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /IsTransactional.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/IsTransactional.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= Transactional.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= Transactional.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,83 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Is Transactional + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.4.2-1 + *
+ *Assertion Description: + The jdohelper.isTransactional method returns true and delegates to the p= arameter instance=20 + and instances whose state is associated with the current transaction . = evaluating to true when =3D=3D is used.=20 + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/4/01 1.0 + */ +public class IsTransactional extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.4.2-1 (IsTransactional) failed: "; + =20 + /** + * The main 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(IsTransactional.class); + } +=20 + /* test JDOHelper.IsTransactional(Object pc) + * =20 + */ + public void testIsTransactional() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + boolean transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (!transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns false for P-NEW instan= ce"); + + tx.begin(); + // check transactional flag in new tx =20 + transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for P-HOLLOW/P-NO= NTX instance"); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /IsTransactionalFalse.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/IsTransactionalFalse.java?view=3Dauto&rev=3D15= 8179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalFalse.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalFalse.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,88 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Is Transactional False + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.4.2-2 + *
+ *Assertion Description: + The jdohelper.isTransactional method returns false and delegates to the = parameter +instance and instances whose state is not associated with the current tran= saction return false.=20 + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/4/01 1.0 + */ +public class IsTransactionalFalse extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.4.2-2 (IsTransactionalFalse) failed: "; + =20 + /** + * The main 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(IsTransactionalFalse.class); + } +=20 + /* test JDOHelper.IsTransactionalFalse(Object pc) + * =20 + */ + public void testIsTransactionalFalse() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + tx.commit(); + =20 + tx.begin(); + boolean transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for P-HOLLOW/P-NO= NTX instance"); + =20 + tx.begin(); + // access field to make sure the instance is P-CLEAN + p1.getX(); + transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (!transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns false for P-CLEAN inst= ance"); + + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /IsTransactionalForNull.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/IsTransactionalForNull.java?view=3Dauto&rev=3D= 158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalForNull.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalForNull.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,72 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Is Transactional For Null + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.4.2-5 + *
+ *Assertion Description: + The jdohelper.isTransactional method returns false, if the instance is n= ull. + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/4/01 1.0 + */ +public class IsTransactionalForNull extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.4.2-5 (IsTransactionalForNull) failed: "; + =20 + /** + * The main 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(IsTransactionalForNull.class); + } + + /* test JDOHelper.IsTransactionalForNull(Object pc) + * =20 + */ + public void testIsTransactionalForNull() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Object p1 =3D null; + boolean transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional with argument null returns tru= e=2E"); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /IsTransactionalForTransient.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/IsTransactionalForTransient.java?view=3Dauto&r= ev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalForTransient.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalForTransient.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,73 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Is Transactional For Transient + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.4.2-3 + *
+ *Assertion Description: + The jdohelper.isTransactional method returns false if the instance is tr= ansien . evaluating to true when =3D=3D is used.=20 + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/4/01 1.0 + */ +public class IsTransactionalForTransient extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.4.2-3 (IsTransactionalForTransient) failed: "; + =20 + /** + * The main 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(IsTransactionalForTransient.class); + } + + /* test JDOHelper.IsTransactionalForTransient(Object pc) + * =20 + */ + public void testIsTransactionalForTransient() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + boolean transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for transient ins= tance."); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /IsTransactionalNotPersistenceCapable.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/IsTransactionalNotPersistenceCapable.java?view= =3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalNotPersistenceCapable.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Is= TransactionalNotPersistenceCapable.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,74 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.Point; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Is Transactional Not Persistence Capable + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.4.2-4 + *
+ *Assertion Description: + The jdohelper.isTransactional method returns false If=20 + the instance does not implement PersistenceCapable . evaluating to true= when =3D=3D is used.=20 + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/4/01 1.0 + */ +public class IsTransactionalNotPersistenceCapable extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.4.2-4 (IsTransactionalNotPersistenceCapable) failed:= "; + =20 + /** + * The main 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(IsTransactionalNotPersistenceCapable.class); + } + + /* test JDOHelper.IsTransactionalNotPersistenceCapable(Object pc) + * =20 + */ + public void testIsTransactionalNotPersistenceCapable() { + pm =3D getPM();=20 + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Point p1 =3D new Point(1,3); + boolean transactional =3D JDOHelper.isTransactional(p1); + tx.commit(); + if (transactional) + fail(ASSERTION_FAILED, + "JDOHelper.isTransactional returns true for instance of n= on-pc class."); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /MakeDirty.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/MakeDirty.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirty.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirty.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,83 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Make Dirty=20 + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.2-1 + *
+ *Assertion Description: + The jdohelper.makeDirty method delegates to the parameter instance + and marks the specified field dirty if parameter is instance of Persis= tence + capable . evaluating to true when =3D=3D is used.=20 + */ + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/2/01 1.0 + */ +public class MakeDirty extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.2-1 (MakeDirty) failed: "; + =20 + /** + * The main 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(MakeDirty.class); + } + + /* test JDOHelper.MakeDirty(Object pc) + * =20 + */ + public void testMakeDirty() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + if (debug) logger.debug(" isDirty1:"+ JDOHelper.isDirty(p1)); =20 + tx.commit(); + if (debug) logger.debug(" isDirty2:" + JDOHelper.isDirty(p1)); + =20 + tx.begin(); + JDOHelper.makeDirty(p1,"x"); + boolean dirty =3D JDOHelper.isDirty(p1); + tx.commit(); + if (debug) logger.debug(" isDirty3:" + dirty); + if (!dirty) + fail(ASSERTION_FAILED, + "Instance is not dirty after calling JDOHelper.makeDirty"= ); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /MakeDirtyForNull.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/MakeDirtyForNull.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirtyForNull.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirtyForNull.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,75 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Make Dirty For Null + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.2-3 + *
+ *Assertion Description: + The JDOHelper.makeDirty method has no affect if the instance is null,=20 + evaluating to true when =3D=3D is used.=20 + */ + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 9/27/01 1.0 + */ +public class MakeDirtyForNull extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.2-3 (MakeDirtyForNull) failed: "; + =20 + /** + * The main 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(MakeDirtyForNull.class); + } +=20 + /* test JDOHelper.makeDirthy(Object pc) + * =20 + */ + public void testMakeDirtyForNull() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Object p1 =3D null; + JDOHelper.makeDirty(p1,"x"); + boolean dirty =3D JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "null instance is dirty after calling JDOHelper.makeDirty= ."); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /MakeDirtyForTransient.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/MakeDirtyForTransient.java?view=3Dauto&rev=3D1= 58179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirtyForTransient.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirtyForTransient.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,78 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Make Dirty For Transient + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.2-2 + *
+ *Assertion Description: + The JDOHelper.makeDirty method has no affect if the instance is transien= t,=20 + evaluating to true when =3D=3D is used.=20 + */ + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/3/01 1.0 + */ +public class MakeDirtyForTransient extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.2-2 (MakeDirtyForTransient) failed: "; + =20 + /** + * The main 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(MakeDirtyForTransient.class); + } + + /* test JDOHelper.makeDirthy(Object pc) + * =20 + */ + public void testMakeDirtyForTransient() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint p1 =3D new PCPoint(1,2); + if (debug) logger.debug(" isDirty1:"+ JDOHelper.isDirty(p1)); + JDOHelper.makeDirty(p1,"x"); + if (debug) logger.debug(" isDirty2:"+ JDOHelper.isDirty(p1)); + boolean dirty =3D JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "transient instance is dirty after calling JDOHelper.make= Dirty."); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper= /MakeDirtyNotPersistenceCapable.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/jdohelper/MakeDirtyNotPersistenceCapable.java?view=3Daut= o&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirtyNotPersistenceCapable.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/jdohelper/Ma= keDirtyNotPersistenceCapable.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,76 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.api.jdohelper; + +import javax.jdo.JDOHelper; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.Point; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Make Dirty Not Persistence Capable + *
+ *Keywords: jdohelper=20 + *
+ *Assertion ID: A8.2-4 + *
+ *Assertion Description: + The JDOHelper.makeDirty method has no affect if the instance is not pers= istence capable + evaluating to true when =3D=3D is used.=20 + */ + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/3/01 1.0 + */ +public class MakeDirtyNotPersistenceCapable extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A8.2-4 (MakeDirtyNotPersistenceCapable) failed: "; + =20 + /** + * The main 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(MakeDirtyNotPersistenceCapable.class); + } + + /* test JDOHelper.makeDirthy(Object pc) + * =20 + */ + public void testMakeDirtyNotPersistenceCapable() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Point p1 =3D new Point(1,2); + JDOHelper.makeDirty(p1,"x"); + boolean dirty =3D JDOHelper.isDirty(p1); + tx.commit(); + if (dirty) + fail(ASSERTION_FAILED, + "instance of non-pc class is dirty after calling JDOHelpe= r=2EmakeDirty."); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/AfterCloseAllMethodsThrowException.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/AfterCloseAllMethodsThrowException.ja= va?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/AfterCloseAllMethodsThrowException.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/AfterCloseAllMethodsThrowException.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,100 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + +package org.apache.jdo.tck.api.persistencemanager; + +import javax.jdo.JDOFatalUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: AfterCloseAllMethodsThrowException + *
+ *Keywords: exception + *
+ *Assertion IDs: A12.5-6 + *
+ *Assertion Description: +After the PersistenceManager.close method completes, +all methods on PersistenceManager except isClosed throw a +JDOFatalUserException. + + */ + +public class AfterCloseAllMethodsThrowException extends PersistenceManager= Test { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5-6 (AfterCloseAllMethodsThrowException) failed: "; + =20 + /** + * The main 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(AfterCloseAllMethodsThrowException.class); + } + =20 + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private Transaction tx; + + /** */ + public void testAfterCloseAllMethodsThrowException() { + pm =3D getPM(); + pm.close(); + runTestEvict(); + runTestRefresh(); + runTestIsClosed(); + pm =3D null; + } + + /** */ + private void runTestEvict() { + try { + pm.evictAll(); + fail(ASSERTION_FAILED,=20 + "pm.evictAll does not throw exception if pm is closed."); + } + catch (JDOFatalUserException ex) { + // caught expected exception + } + } + + /** */ + private void runTestRefresh() { + try { + pm.refreshAll(); + fail(ASSERTION_FAILED,=20 + "pm.refreshAll does not throw exception if pm is closed."= ); + } + catch (JDOFatalUserException ex) { + // caught expected exception + } + } + + /** */ + private void runTestIsClosed() { + if (!pm.isClosed()) + fail(ASSERTION_FAILED,=20 + "pm.isClosed returns false for closed pm."); + } +} + Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/CallingEvictAllWithCollectionContainingNulls.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/CallingEvictAllWithCollectionContaini= ngNulls.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CallingEvictAllWithCollectionContainingNulls.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CallingEvictAllWithCollectionContainingNulls.java Fri Mar 18 17:07:3= 9 2005 @@ -0,0 +1,137 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + + +package org.apache.jdo.tck.api.persistencemanager; + +import java.util.Collection; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Calling EvictAll With Collection Containing Nulls + *
+ *Keywords: cache + *
+ *Assertion IDs: A12.5-11 + *
+ *Assertion Description: +Passing a non-null Object[] or Collection arguments to evictAll that +contain null elements will have the documented behavior for non-null eleme= nts, and the null elements +will be ignored. + + */ + +public class CallingEvictAllWithCollectionContainingNulls extends Persiste= nceManagerTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5-11 (CallingEvictAllWithCollectionContainingNulls)= failed: "; + =20 + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingEvictAllWithCollectionContainingNulls.c= lass); + } + =20 + private PCPoint p1; + private PCPoint p2; + private PCPoint p3; + private PCPoint p4; + private PCPoint p5; + + /** */ + public void testCallingEvictAllWithCollectionContainingNulls() { + pm =3D getPM(); + createObjects(pm); + runTestEvictAll1(pm); + runTestEvictAll2(pm); + pm.close(); + pm =3D null; + } + =20 + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + p1 =3D new PCPoint (1,3); + p2 =3D new PCPoint (4,3); + p3 =3D new PCPoint (4,2); + p4 =3D new PCPoint (3,3); + =20 + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + =20 + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + =20 + /* test evictAll (Collection col1) */ + private void runTestEvictAll1(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + =20 + PCPoint p5 =3D null; + Collection col1 =3D new java.util.HashSet(); + col1.add (p1); + col1.add (p5); + col1.add (p2); + =20 + pm.evictAll(col1); + if (debug) logger.debug(" \nPASSED in testEvictAll1()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + =20 + /** test evictAll (Object[] objArray) */ + private void runTestEvictAll2(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + =20 + PCPoint p5 =3D null; + Collection col1 =3D new java.util.HashSet(); + col1.add (p3); + col1.add (p4); + col1.add (p5); + =20 + pm.evictAll(col1.toArray()); + if (debug) logger.debug(" \nPASSED in testEvictAll2()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/CallingRefreshAllWithCollectionContainingNulls.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/CallingRefreshAllWithCollectionContai= ningNulls.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CallingRefreshAllWithCollectionContainingNulls.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CallingRefreshAllWithCollectionContainingNulls.java Fri Mar 18 17:07= :39 2005 @@ -0,0 +1,140 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + + +package org.apache.jdo.tck.api.persistencemanager; + +import java.util.Collection; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Calling RefreshAll With Collection Containing Nulls + *
+ *Keywords: cache + *
+ *Assertion IDs: A12.5-12 + *
+ *Assertion Description: +Passing a non-null Object[] or Collection arguments to refreshAll that +contain null elements will have the documented behavior for non-null eleme= nts, and the null +elements will be ignored. + + */ + +public class CallingRefreshAllWithCollectionContainingNulls extends Persis= tenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5-12 (CallingRefreshAllWithCollectionContainingNull= s) failed: "; + =20 + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(CallingRefreshAllWithCollectionContainingNulls= .class); + } + =20 + private PCPoint p1; + private PCPoint p2; + private PCPoint p3; + private PCPoint p4; + private PCPoint p5; + + /** */ + public void testCallingRefreshAllWithCollectionContainingNulls() { + pm =3D getPM(); =20 + createObjects(pm); + runTestRefreshAll1(pm); + runTestRefreshAll2(pm); + pm.close(); + pm =3D null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + p1 =3D new PCPoint (1,3); + p2 =3D new PCPoint (2,3); + p3 =3D new PCPoint (4,2); + p4 =3D new PCPoint (3,3); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** test refreshAll (Collection col1) */ + private void runTestRefreshAll1(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p5 =3D null; + Collection col1 =3D new java.util.HashSet(); + col1.add (p1); + col1.add (p5); + col1.add (p2); + + pm.refreshAll(col1); + if (debug) logger.debug(" \nPASSED in testRefreshAll1()"); + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + + /* test refreshAll (Object[] objArray) */ + private void runTestRefreshAll2(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { =09 + tx.begin(); + + PCPoint p5 =3D null; + Collection col1 =3D new java.util.HashSet(); + col1.add (p3); + col1.add (p4); + col1.add (p5); + =20 + pm.refreshAll(col1.toArray()); + if (debug) logger.debug(" \nPASSED in testRefreshAll2()"); + tx.rollback(); + }=20 + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/ChangingObjectIdHasNoEffectOnInstance.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/ChangingObjectIdHasNoEffectOnInstance= .java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/ChangingObjectIdHasNoEffectOnInstance.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/ChangingObjectIdHasNoEffectOnInstance.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,67 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + + +package org.apache.jdo.tck.api.persistencemanager; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Changing ObjectId Has No Effect On Instance + *
+ *Keywords: identity + *
+ *Assertion ID: A12.5.6-13. + *
+ *Assertion Description: +If the application makes a change to the ObjectId instance +returned by PersistenceManager.getObjectId, there is no effect +on the instance from which the ObjectId was obtained. + + */ + +public class ChangingObjectIdHasNoEffectOnInstance extends PersistenceMana= gerTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-13 (ChangingObjectIdHasNoEffectOnInstance) fail= ed: "; + =20 + /** + * The main 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(ChangingObjectIdHasNoEffectOnInstance.class); + } + + /** */ + public void testChangingObjectIdHasNoEffectOnInstance() throws Excepti= on { + pm =3D getPM(); + Object oid =3D createPCPointInstance(pm); + Object p1 =3D pm.getObjectById(oid, false); + Object oid2 =3D pm.getObjectId(p1); + =20 + mangleObject(oid); + // now oid3 should equal oid2 even though we mangled oid + Object oid3 =3D getPM().getObjectId(p1); + if (!oid2.equals(oid3)) + fail(ASSERTION_FAILED, + "Changing the ObjectId returned by getObjectId has an effect= on ObjectId's returned by subsequent calls of getObjectId"); + pm.close(); + pm =3D null; + } =20 +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/CloseThrowsExceptionWhenActiveTx.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/CloseThrowsExceptionWhenActiveTx.java= ?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CloseThrowsExceptionWhenActiveTx.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CloseThrowsExceptionWhenActiveTx.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,68 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + +package org.apache.jdo.tck.api.persistencemanager; + +import javax.jdo.JDOUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Close Throws Exception + *
+ *Keywords: exception + *
+ *Assertion IDs: A12.6-2. + *
+ *Assertion Description: +In a non-managed environment, if the current transaction is active, close = throws JDOUserException. + */ + +public class CloseThrowsExceptionWhenActiveTx extends JDO_Test { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.6-2 (CloseThrowsExceptionWhenActiveTx) failed: "; + =20 + /** + * The main 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(CloseThrowsExceptionWhenActiveTx.class); + } + + /** */ + public void test() { + pm =3D getPM(); + pm.currentTransaction().begin(); + + try { + pm.close(); + fail(ASSERTION_FAILED, "JDOUserException was not thrown when closing Pe= rsistenceManager while transaction was open"); + } + catch (JDOUserException juex) { + // expected this exception + } + finally { + pm.currentTransaction().rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/ConcurrentPersistenceManagers.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagers.java?vi= ew=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/ConcurrentPersistenceManagers.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/ConcurrentPersistenceManagers.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,92 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + + +package org.apache.jdo.tck.api.persistencemanager; + +import java.util.Properties; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Concurrent Persistence Managers + *
+ *Keywords: concurrency multipleJDOimpls + *
+ *Assertion ID: A5.2-1. + *
+ *Assertion Description: +An implementation should support its own PersistenceManager +concurrently with another PersistenceManager. +A non-reference implementation will be tested concurrently +with the Reference Implementation. + + */ + +public class ConcurrentPersistenceManagers extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A5.2-1 (ConcurrentPersistenceManagers) failed: "; + =20 + /** + * The main 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(ConcurrentPersistenceManagers.class); + } + + /** */ + public void test() { + Properties pmfProperties =3D loadPMF2Properties(); + PersistenceManagerFactory pmf2 =3D JDOHelper.getPersistenceManagerFac= tory(pmfProperties); + PersistenceManager pm2 =3D pmf2.getPersistenceManager(); + Transaction tx2 =3D pm2.currentTransaction(); + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + tx2.begin(); + tx.commit(); + tx =3D null; + tx2.commit(); + tx2 =3D null; + } + finally { + cleanupPM(pm); + pm =3D null; + cleanupPM(pm2); + pm2 =3D null; + pmf2.close(); + } + } + + private Properties loadPMF2Properties() { + String PMF2 =3D System.getProperty ("PMF2Properties", "jdori2.propert= ies"); + if (debug) logger.debug("Got PMF2Properties file name:" + PMF2); + Properties ret =3D loadProperties (PMF2); + if (debug) logger.debug("Got PMF2Properties: " + ret); + return ret; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/ConcurrentPersistenceManagersSameClasses.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/ConcurrentPersistenceManagersSameClas= ses.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/ConcurrentPersistenceManagersSameClasses.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/ConcurrentPersistenceManagersSameClasses.java Fri Mar 18 17:07:39 20= 05 @@ -0,0 +1,137 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + + +package org.apache.jdo.tck.api.persistencemanager; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Properties; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.pc.mylib.PCRect; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Same Classes with Concurrent Persistence Managers + *
+ *Keywords: concurrency multipleJDOimpls + *
+ *Assertion ID: A5.2-2. + *
+ *Assertion Description: +The same classes must be supported concurrently by multiple +PersistenceManagers from different implementations. + + */ + +public class ConcurrentPersistenceManagersSameClasses extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A5.2-2 (ConcurrentPersistenceManagersSameClasses) faile= d: "; + =20 + /** + * The main 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(ConcurrentPersistenceManagersSameClasses.class= ); + } + =20 + /** */ + public void test() { + Properties pmfProperties =3D loadPMF2Properties(); + PersistenceManagerFactory pmf2 =3D JDOHelper.getPersistenceManager= Factory(pmfProperties); + PersistenceManager pm2 =3D pmf2.getPersistenceManager(); + Transaction tx2 =3D pm2.currentTransaction(); + =20 + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + tx2.begin(); + =20 + PCPoint p11 =3D new PCPoint(110, 120); + PCPoint p12 =3D new PCPoint(120, 140); + PCRect rect1 =3D new PCRect (0, p11, p12); + pm.makePersistent (rect1); + =20 + PCPoint p21 =3D new PCPoint(210, 220); + PCPoint p22 =3D new PCPoint(220, 240); + PCRect rect2 =3D new PCRect (0, p21, p22); + pm2.makePersistent (rect2); + =20 + tx.commit(); + tx2.commit(); + =20 + tx.begin(); + tx2.begin(); + =20 + PCPoint p11a =3D findPoint (pm, 110, 120); + if (p11a !=3D p11) { + fail(ASSERTION_FAILED,=20 + "unexpected PCPoint instance, expected: 110, 120, fou= nd: " + p11a.getX() + ", " + p11a.getY()); + } + =20 + PCPoint p21a =3D findPoint (pm2, 210, 220); + if (p21a !=3D p21) { + fail(ASSERTION_FAILED,=20 + "unexpected PCPoint instance, expected: 210, 220, fou= nd: " + p21a.getX() + ", " + p21a.getY()); + } + =20 + tx.commit(); + tx =3D null; + tx2.commit(); + tx2 =3D null; + } + finally { + cleanupPM(pm); + pm =3D null; + cleanupPM(pm2); + pm2 =3D null; + pmf2.close(); + } + } + + /** */ + private Properties loadPMF2Properties() { + String PMF2 =3D System.getProperty ("PMF2Properties", "jdori2.prop= erties"); + if (debug) logger.debug("Got PMF2Properties file name:" + PMF2); + Properties ret =3D loadProperties (PMF2); + if (debug) logger.debug("Got PMF2Properties: " + ret); + return ret; + } + + /** */ + private PCPoint findPoint (PersistenceManager pm, int x, int y) { + Query q =3D pm.newQuery (PCPoint.class); + q.declareParameters ("int px, int py"); + q.setFilter ("x =3D=3D px & y =3D=3D py"); + Collection results =3D (Collection)q.execute (new Integer(x), new = Integer(y)); + Iterator it =3D results.iterator(); + PCPoint ret =3D (PCPoint)it.next(); + return ret; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/CurrentTransaction.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/CurrentTransaction.java?view=3Dauto&r= ev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CurrentTransaction.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/CurrentTransaction.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,63 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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; + +/** + *Title: CurrentTransaction + *
+ *Keywords: + *
+ *Assertion ID: A12.5.2-1 + *
+ *Assertion Description: +The PersistenceManager.currentTransaction method returns the +Transaction instance associated with the PersistenceManager. + + */ + +public class CurrentTransaction extends PersistenceManagerTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.2-1 (CurrentTransaction) failed: "; + =20 + /** + * The main 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(CurrentTransaction.class); + } + =20 + /** */ + public void testCurrentTransaction() { + pm =3D getPM(); + PCPoint p1 =3D new PCPoint(); + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p1); + tx.commit(); + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/DeletePersistent.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/DeletePersistent.java?view=3Dauto&rev= =3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistent.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistent.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,254 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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; + +/** + *Title: Delete Persistent + *
+ *Keywords: + *
+ *Assertion IDs: A12.5.7-9 + *
+ *Assertion Description: +PersistenceManager.deletePersistent and deletePersistentAll delete a persi= stent instance(s) from the data store. It must be called in the context of = an active transaction, or a JDOUserExceptionis thrown. The representation i= n the data store will be deleted when this instance is flushed to the data = store (via commit, or evict). + + */ + +public class DeletePersistent extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.7-9 (DeletePersistent) failed: "; + =20 + /** + * The main 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(DeletePersistent.class); + } + =20 + private PCPoint p1 =3D null; + private PCPoint p2 =3D null; + private PCPoint p3 =3D null; + private PCPoint p4 =3D null; + private PCPoint p5 =3D null; + + /** */ + public void testDeletePersistent() { + pm =3D getPM(); =20 + createObjects(pm); + + /* positive tests */ + /* method called in the context of an active transaction */ + runTestDeletePersistent1(pm); + runTestDeletePersistent2(pm); + runTestDeletePersistent3(pm); + + /* negative tests */ + /* method called in the context of an non-active transaction */ + runTestDeletePersistent4(pm); + runTestDeletePersistent5(pm); + runTestDeletePersistent6(pm); + + pm.close(); + pm =3D null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + p1 =3D new PCPoint(1,3); + p2 =3D new PCPoint(2,4); + p3 =3D new PCPoint(3,5); + p4 =3D new PCPoint(4,6); + p5 =3D new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** test deletePersistent (Object pc) */ + private void runTestDeletePersistent1(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx =3D pm.currentTransaction(); + tx.begin(); + pm.deletePersistent(p1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent1()"= ); + } + finally { + if (tx.isActive()) + tx.rollback(); + } =20 + } + + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistent2(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 =3D new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + pm.deletePersistentAll(col1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent2()"= ); + }=20 + finally { + if (tx.isActive()) + tx.rollback(); + } =20 + } + + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistent3(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 =3D new HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1=3D col1.toArray(); + + pm.deletePersistentAll(obj1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent3()"= ); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistent (Object pc) */ + public void runTestDeletePersistent4(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint np1 =3D new PCPoint(1,3); + pm.makePersistent(np1); + tx.commit(); + =20 + try { + pm.deletePersistent(np1); + fail(ASSERTION_FAILED,=20 + "pm.deletePersistent(Object) outside of tx should thr= ow an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Collection pcs) */ + public void runTestDeletePersistent5(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint np1 =3D new PCPoint (3,3); + PCPoint np2 =3D new PCPoint (4,4); + pm.makePersistent(np1); + pm.makePersistent(np2); + tx.commit(); + + Collection col1 =3D new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED,=20 + "pm.deletePersistentAll(Collection) outside of tx sho= uld throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Object[] o) */ + public void runTestDeletePersistent6(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + =20 + PCPoint np1 =3D new PCPoint (3,3); + PCPoint np2 =3D new PCPoint (4,4); + =20 + pm.makePersistent(np1); + pm.makePersistent(np2); + tx.commit(); + =20 + Collection col1 =3D new java.util.HashSet(); + col1.add(np1); + col1.add(np2); + Object[] obj1=3Dcol1.toArray(); + =20 + try { + pm.deletePersistentAll(obj1); + fail(ASSERTION_FAILED,=20 + "pm.deletePersistentAll(Object[]) outside of tx shoul= d throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/DeletePersistentAllFails.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/DeletePersistentAllFails.java?view=3D= auto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentAllFails.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentAllFails.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,155 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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; + +/** + *Title: DeletePersistentAll Fails + *
+ *Keywords: exception + *
+ *Assertion IDs: A12.5.7-2. + *
+ *Assertion Description: +If a collection or array of instances is passed to PersistenceManager.dele= tePersistentAll, and one or more of the instances fail to complete the requ= ired operation, then all instances will be attempted, and a JDOUserExceptio= n will be thrown which contains nested exceptions, each of which contains o= ne of the failing instances. The succeeding instances will transition to th= e specified life cycle state, and the failing instances will remain in thei= r current state. + */ + +public class DeletePersistentAllFails extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.7-2 (DeletePersistentAllFails) failed: "; + =20 + /** + * The main 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(DeletePersistentAllFails.class); + } + =20 + private PCPoint p1 =3D null; + private PCPoint p2 =3D null; + private PCPoint p3 =3D null; + private PCPoint p4 =3D null; + private PCPoint p5 =3D null; + =20 + /** */ + public void testDeletePersistentAllFails() { + pm =3D getPM(); + createObjects(pm); + runTestDeletePersistentAllFails1(pm); + runTestDeletePersistentAllFails2(pm); + pm.close(); + pm =3D null; + } + + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + p1 =3D new PCPoint(1,3); + p2 =3D new PCPoint(2,4); + p3 =3D new PCPoint(3,5); + p4 =3D new PCPoint(4,6); + p5 =3D new PCPoint(5,7); + + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + =20 + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + =20 + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAllFails1(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + =20 + Point np3 =3D new Point (5,5); + =20 + Collection col1 =3D new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + col1.add(np3); + =20 + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistentAll(Collection) with non persiste= nt instances should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + =20 + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistentAllFails2(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Point np3 =3D new Point (5,5); + + Collection col1 =3D new java.util.HashSet(); + col1.add(p3); + col1.add(p4); + col1.add(np3); + =20 + Object[] obj1=3Dcol1.toArray(); + + try { + pm.deletePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.deletePersistentAll(Object[]) with non persistent= instances should throw an exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/DeletePersistentFailsIfInstanceIsTransient.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceIsTran= sient.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentFailsIfInstanceIsTransient.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentFailsIfInstanceIsTransient.java Fri Mar 18 17:07:39 = 2005 @@ -0,0 +1,146 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ + + +package org.apache.jdo.tck.api.persistencemanager; + +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; + +/** + *Title: DeletePersistent Fails If Instance Is Transient + *
+ *Keywords: exception + *
+ *Assertion IDs: A12.5.7-12. + *
+ *Assertion Description: +PersistenceManager.deletePersistent and deletePersistentAll will throw a J= DOUserException if the parameter instance is transient. + */ + +public class DeletePersistentFailsIfInstanceIsTransient extends Persistenc= eManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.7-12 (DeletePersistentFailsIfInstanceIsTransient)= failed: "; + =20 + /** + * The main 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(DeletePersistentFailsIfInstanceIsTransient.cla= ss); + } + =20 + /** */ + public void testDeletePersistentFailsIfInstanceIsTransient() { + pm =3D getPM(); + runTestDeletePersistent(); + runTestDeletePersistentAll1(); + runTestDeletePersistentAll2(); + pm.close(); + pm =3D null; + } + + /* test deletePersistent (Object pc) */ + private void runTestDeletePersistent() { + Transaction tx =3D pm.currentTransaction(); + try { + + tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint p1 =3D new PCPoint (3,3); + try { + pm.deletePersistent(p1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object) with transient instance sh= ould throw exception"); + } + catch (JDOUserException ex) { + // expected exception + }=20 + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAll1() { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + =20 + PCPoint p1 =3D new PCPoint (3,3); + PCPoint p2 =3D new PCPoint (4,4); + =20 + Collection col1 =3D new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + =20 + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Collection) with transient insta= nce(s) should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + }=20 + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistentAll2() { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 =3D new PCPoint (3,3); + PCPoint p2 =3D new PCPoint (4,4); + =20 + Collection col1 =3D new java.util.HashSet(); + col1.add(p1); + col1.add(p2); + + try { + pm.deletePersistentAll(col1.toArray()); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object[]) with transient instanc= e(s) should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + }=20 + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager= .java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/DeletePersistentFailsIfInstanceManage= dByAnotherPersistenceManager.java?view=3Dauto&rev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.ja= va (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentFailsIfInstanceManagedByAnotherPersistenceManager.ja= va Fri Mar 18 17:07:39 2005 @@ -0,0 +1,179 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * 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=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * 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; + +/** + *Title: DeletePersistent Fails If Instance Managed By Another Pers= istenceManager + *
+ *Keywords: exception + *
+ *Assertion IDs: A12.5.7-11. + *
+ *Assertion Description: + PersistenceManager.deletePersistent and deletePersistentAll will throw a = JDOUserException if the parameter instance is managed by a different Persis= tenceManager. + + */ + +public class DeletePersistentFailsIfInstanceManagedByAnotherPersistenceMan= ager extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.7-11 (DeletePersistentFailsIfInstanceManagedByAno= therPersistenceManager) failed: "; + =20 + /** + * The main 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(DeletePersistentFailsIfInstanceManagedByAnothe= rPersistenceManager.class); + } + + private PCPoint p1 =3D null; + private PCPoint p2 =3D null; + private PCPoint p3 =3D null; + private PCPoint p4 =3D null; + private PCPoint p5 =3D null; + + /** */ + public void testDeletePersistentFailsIfInstanceManagedByAnotherPersist= enceManager() { + pm =3D getPM(); + PersistenceManager pm2 =3D getPMF().getPersistenceManager(); + try { + createObjects(pm2); + =20 + /* positive tests */ + runTestDeletePersistent(pm); + runTestDeletePersistentAll1(pm); + runTestDeletePersistentAll2(pm); + } + finally { + cleanupPM(pm2); + pm =3D null; + cleanupPM(pm); + pm =3D null; + } + } + =20 + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + p1 =3D new PCPoint(1,3); + p2 =3D new PCPoint(2,4); + p3 =3D new PCPoint(3,5); + p4 =3D new PCPoint(4,6); + p5 =3D new PCPoint(5,7); + =20 + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + tx.commit(); + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistent (Object pc) */ + private void runTestDeletePersistent(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + try { + pm.deletePersistent(p1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object) with pc instance managed= by another pm should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + } + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + =20 + /* test deletePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAll1(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 =3D new HashSet(); + col1.add(p2); + col1.add(p3); + + try { + pm.deletePersistentAll(col1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Collection) with pc instance(s) = managed by another pm should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + }=20 + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test deletePersistentAll (Object[] o) */ + private void runTestDeletePersistentAll2(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 =3D new HashSet(); + col1.add(p4); + col1.add(p5); + Object[] obj1=3D col1.toArray(); + try { + pm.deletePersistentAll(obj1); + fail(ASSERTION_FAILED, + "pm.deletePersistent(Object[]) with pc instance(s) ma= naged by another pm should throw exception"); + } + catch (JDOUserException ex) { + // expected exception + }=20 + tx.rollback(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +}