Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 87445 invoked from network); 19 Mar 2005 05:14:31 -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:31 -0000 Received: (qmail 92396 invoked by uid 500); 19 Mar 2005 05:14:31 -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 92765 invoked by uid 99); 19 Mar 2005 01:16:31 -0000 X-ASF-Spam-Status: No, hits=-7.9 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME,WEIRD_QUOTING X-Spam-Check-By: apache.org Message-ID: <20050319010944.29484.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 [6/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/persisten= cemanager/DeletePersistentHasNoEffectOnDeletedInstances.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/DeletePersistentHasNoEffectOnDeletedI= nstances.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/DeletePersistentHasNoEffectOnDeletedInstances.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/DeletePersistentHasNoEffectOnDeletedInstances.java Fri Mar 18 17:07:= 39 2005 @@ -0,0 +1,161 @@ +/* + * 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: DeletePersistent Has No Effect On Deleted Instances + *
+ *Keywords: + *
+ *Assertion IDs: A12.5.7-10. + *
+ *Assertion Description: + PersistenceManager.deletePersistent and deletePersistentAll have no effec= t on parameter instances already deleted in the transaction. + + */ + +public class DeletePersistentHasNoEffectOnDeletedInstances extends Persist= enceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.7-10 (DeletePersistentHasNoEffectOnDeletedInstanc= es) 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(DeletePersistentHasNoEffectOnDeletedInstances.= 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 testDeletePersistentHasNoEffectOnDeletedInstances() { + pm =3D getPM(); + createObjects(pm); + runTestDeletePersistent(pm); + runTestDeletePersistentAll1(pm); + runTestDeletePersistentAll2(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); + =20 + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + pm.makePersistent(p5); + =20 + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test makePersistent (Object pc) */ + private void runTestDeletePersistent(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + pm.deletePersistent(p1); + pm.deletePersistent(p1); + pm.deletePersistent(p1); + pm.deletePersistent(p1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistent()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test makePersistentAll (Collection pcs) */ + private void runTestDeletePersistentAll1(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx =3D pm.currentTransaction(); + + Collection col1 =3D new java.util.HashSet(); + col1.add(p2); + col1.add(p3); + + tx.begin(); + pm.deletePersistentAll(col1); + pm.deletePersistentAll(col1); + pm.deletePersistentAll(col1); + pm.deletePersistentAll(col1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistentAll1= ()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /* test makePersistentAll (Object[] o) */ + private void runTestDeletePersistentAll2(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + Collection col1 =3D new java.util.HashSet(); + col1.add(p4); + col1.add(p5); + + Object[] obj1=3D col1.toArray(); + + tx.begin(); + pm.deletePersistentAll(obj1); + pm.deletePersistentAll(obj1); + pm.deletePersistentAll(obj1); + pm.deletePersistentAll(obj1); + tx.commit(); + if (debug) logger.debug(" \nPASSED in testDeletePersistentAll2= ()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/EvictAllWithNoParameters.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/EvictAllWithNoParameters.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/EvictAllWithNoParameters.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/EvictAllWithNoParameters.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,141 @@ +/* + * 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.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint2; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: EvictAllWithNoParameters + *
+ *Keywords: cache + *
+ *Assertion IDs: A12.5.1-2 + *
+ *Assertion Description: + If PersistenceManager.evict is called with no parameter, then all referen= ced instances are evicted. For each instance evicted, it: + *
    + *
  • calls the jdoPreClearmethod on each instance, if the class of the i= nstance implements InstanceCallbacks
  • + *
  • clears persistent fields on each instance after the call to jdoPreC= lear()
  • + *
  • changes the state of instances to hollow or persistent-nontransacti= onal (cannot distinguish between these two states) this is not directly tes= table.
  • + *
+ + */ + +public class EvictAllWithNoParameters extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.1-2 (EvictAllWithNoParameters) 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(EvictAllWithNoParameters.class); + } + =20 + private PCPoint2 pnt1 =3D null; + private PCPoint2 p1 =3D null; + + /** */ + public void testEvictAllWithNoParameters() { + pm =3D getPM(); + createObjects(pm); + runTestEvictAll(pm); + pm.close(); + pm =3D null; + } + =20 + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + pnt1 =3D new PCPoint2(1,3); + p1 =3D new PCPoint2 (3,5); + pm.makePersistent(pnt1); + pm.makePersistent(p1); + tx.commit(); + + // P-nontransactional instance + // Check whether pmf supported optimitic tx + tx.setOptimistic(isOptimisticSupported()); + tx.begin(); + pnt1.getX(); + tx.commit(); + =20 + // P-clean instance=20 + tx.setOptimistic(false); + tx.begin(); + p1.getX(); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestEvictAll(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + pm.evictAll(); + + if ( !p1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of p1.jdoPreClear during pm.evictAll"); + } + if ( !pnt1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of pnt1.jdoPreClear during pm.evictAll"= ); + } + + if ( testState(p1, HOLLOW, "hollow") || + testState(p1, PERSISTENT_NONTRANSACTIONAL, "persistent_no= ntransaction")) { + ; // expected result + }=20 + else { + fail(ASSERTION_FAILED, + "p1 should be HOLLOW or P-NONTX after pm.evictAll."); + } + + if ( testState(pnt1, HOLLOW, "hollow") || + testState(pnt1, PERSISTENT_NONTRANSACTIONAL, "persistent_= nontransaction")) { + ; // expected result + }=20 + else { + fail(ASSERTION_FAILED, + "pnt1 should be HOLLOW or P-NONTX after pm.evictAll."= ); + } + tx.commit(); + if (debug) logger.debug(" \nPASSED in testEvictAll()"); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/EvictingCollectionOfInstancesSideEffects.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/EvictingCollectionOfInstancesSideEffe= cts.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/EvictingCollectionOfInstancesSideEffects.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/EvictingCollectionOfInstancesSideEffects.java Fri Mar 18 17:07:39 20= 05 @@ -0,0 +1,201 @@ +/* + * 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.PCPoint2; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: EvictingCollectionOfInstancesSideEffects + *
+ *Keywords: cache + *
+ *Assertion IDs: A12.5.1-4 + *
+ *Assertion Description: + If PersistenceManager.evict is called with no parameter, then all referen= ced instances are evicted. For each instance evicted, it: + *
    + *
  • calls the jdoPreClearmethod on each instance, if the class of the i= nstance implements InstanceCallbacks
  • + *
  • clears persistent fields on each instance after the call to jdoPreC= lear()
  • + *
  • changes the state of instances to hollow or persistent-nontransacti= onal (cannot distinguish between these two states) this is not directly tes= table.
  • + *
+ + */ + +public class EvictingCollectionOfInstancesSideEffects extends PersistenceM= anagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.1-4 (EvictingCollectionOfInstancesSideEffects) fa= iled: "; + =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(EvictingCollectionOfInstancesSideEffects.class= ); + } + =20 + private PCPoint2 pnt1 =3D null; + private PCPoint2 pnt2 =3D null; + private PCPoint2 p1 =3D null; + private PCPoint2 p2 =3D null; + + /** */ + public void testEvictingCollectionOfInstancesSideEffects() { + pm =3D getPM(); + createObjects(pm); + runTestEvictAllCollection(pm); + runTestEvictAllArray(pm); + pm.close(); + pm =3D null; + } + =20 + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + pnt1 =3D new PCPoint2(1,2); + pnt2 =3D new PCPoint2(2,3); + p1 =3D new PCPoint2 (3,1); + p2 =3D new PCPoint2 (4,2); + pm.makePersistent(pnt1); + pm.makePersistent(pnt2); + pm.makePersistent(p1); + pm.makePersistent(p2); + tx.commit(); + + // P-nontransactional instance + // Check whether pmf supported optimitic tx + tx.setOptimistic(isOptimisticSupported()); + tx.begin(); + pnt1.getX(); + pnt2.getX(); + tx.commit(); + + /* P-clean instance */ + tx.setOptimistic(false); + tx.begin(); + p1.getX(); + p2.getX(); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestEvictAllCollection(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 =3D new java.util.HashSet(); + col1.add(pnt1); + col1.add(p1); + + pm.evictAll(col1); + + if ( !p1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of p1.jdoPreClear during pm.evictAll(Co= llection)"); + } + if ( !pnt1.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of pnt1.jdoPreClear during pm.evictAll(= Collection)"); + } + + if ( testState(p1, HOLLOW, "hollow") || + testState(p1, PERSISTENT_NONTRANSACTIONAL, "persistent_no= ntransactional")) { + ; // expected result + }=20 + else {=20 + fail(ASSERTION_FAILED, + "p1 should be HOLLOW or P-NONTX after pm.evictAll(Col= lection)."); + } + + if ( testState(pnt1, HOLLOW, "hollow") || + testState(pnt1, PERSISTENT_NONTRANSACTIONAL, "persistent_= nontransactional")) { + ; // expected result + } else { + fail(ASSERTION_FAILED, + "pnt1 should be HOLLOW or P-NONTX after pm.evictAll(C= ollection)."); + } + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + =20 + /** */ + private void runTestEvictAllArray(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + Collection col1 =3D new java.util.HashSet(); + col1.add(pnt2); + col1.add(p2); + + pm.evictAll(col1.toArray()); + + if ( !p2.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of p2.jdoPreClear during pm.evictAll(Ob= ject[])"); + } + if ( !pnt2.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of pnt2.jdoPreClear during pm.evictAll(= Object[])"); + } + + if ( testState(p2, HOLLOW, "hollow") || + testState(p2, PERSISTENT_NONTRANSACTIONAL, "persistent_no= ntransactional")) { + ; // expected result + } else { + fail(ASSERTION_FAILED, + "p2 should be HOLLOW or P-NONTX after pm.evictAll(Obj= ect[])."); + } + + if ( testState(pnt2, HOLLOW, "hollow") || + testState(pnt2, PERSISTENT_NONTRANSACTIONAL, "persistent_= nontransactional")) { + ; // expected result + } else { + fail(ASSERTION_FAILED, + "pnt2 should be HOLLOW or P-NONTX after pm.evictAll(O= bject[])."); + } + + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/EvictingWithRestoreValuesFalse.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/EvictingWithRestoreValuesFalse.java?v= iew=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/EvictingWithRestoreValuesFalse.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/EvictingWithRestoreValuesFalse.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,128 @@ +/* + * 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.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint2; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Evicting With RestoreValues False + *
+ *Keywords: cache + *
+ *Assertion ID: A12.6.1-1. + *
+ *Assertion Description: +If users wish to automatically evict transactional instances = at transaction +rollback time, then they should set RestoreValues to false. +For each persistent-clean instance that the +JDO PersistenceManager evicts, it: +
    +
  • calls the jdoPreClear method on each instance, +if the class of the instance implements InstanceCallbacks
  • +
  • clears persistent fields on each instance (sets the value of the field= to its Java default value)
  • +
  • changes the state of instances to hollow
  • +
+ + */ + +public class EvictingWithRestoreValuesFalse extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.6.1-1 (EvictingWithRestoreValuesFalse) 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(EvictingWithRestoreValuesFalse.class); + }=09 + + /** */ + public void test() { + pm =3D getPM(); + PCPoint2 pt =3D getHollowInstance(); + + Transaction tx =3D pm.currentTransaction(); + tx.setRestoreValues(false); //This should cause eviction of transactiona= l instances when transaction is later rolled back. + =09 + //Test + tx.begin(); + makePersistentClean(pt); + tx.rollback(); // This should evict pt + verify(pt); + } + + /** */ + private PCPoint2 getHollowInstance() { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint2 pt =3D new PCPoint2(1,2); + pm.makePersistent(pt); + tx.commit(); + + int curr =3D currentState(pt); + if (curr !=3D HOLLOW){ + fail(ASSERTION_FAILED, + "Unable to create HOLLOW instance, state is " + states[curr]); + } + return pt; + } + + /** */ + private void makePersistentClean(PCPoint2 pt) { + pm.makeTransactional(pt); + int curr =3D currentState(pt); + if (curr !=3D PERSISTENT_CLEAN){ + fail(ASSERTION_FAILED, + "Unable to create PERSISTENT_CLEAN instance, state is " + st= ates[curr]); + } + } + + /** */ + private void verify(PCPoint2 pt) { + // When PersistenceManager evicts instances, it: calls the jdoPreClear m= ethod on each instance + if ( !pt.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of jdoPreClear"); + } + + // When PersistenceManager evicts instances, it: changes the state of th= e instances to hollow + int curr =3D currentState(pt); + if ( (curr !=3D HOLLOW) && (curr !=3D PERSISTENT_NONTRANSACTIONAL)= ) { + fail(ASSERTION_FAILED, + "Instance should be HOLLOW after tx.rollback(), state is = " + states[curr]); + } + =09 + pm.makeTransient(pt); + // When PersistenceManager evicts instances, it: clears persistent= fields on each instance (sets the value of the field to its Java default v= alue) + int x=3Dpt.getX(); + Integer y=3Dpt.getY(); + if ((x !=3D 0) || (y !=3D null)) { + fail(ASSERTION_FAILED, + "persistent fields not cleared, pt.getX()=3D=3D"+x+" and pt.= getY()=3D=3D"+y); + } + }=09 +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/EvictingWithRetainValuesFalse.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/EvictingWithRetainValuesFalse.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/EvictingWithRetainValuesFalse.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/EvictingWithRetainValuesFalse.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,135 @@ +/* + * 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.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint2; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Evicting With RetainValues False + *
+ *Keywords: cache + *
+ *Assertion ID: A12.5.1-3. + *
+ *Assertion Description: +If users wish to automatically evict transactional instances = at transaction +commit time, then they should set RetainValues t= o false. +For each persistent-clean instance that the +JDO PersistenceManager evicts, it: +
    +
  • calls the jdoPreClear method on each instance, +if the class of the instance implements InstanceCallbacks
  • +
  • clears persistent fields on each instance (sets the value of the field= to its Java default value)
  • +
  • changes the state of instances to hollow
  • +
+ + */ + +public class EvictingWithRetainValuesFalse extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.1-3 (EvictingWithRetainValuesFalse) 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(EvictingWithRetainValuesFalse.class); + }=09 + + /** */ + public void test() { + + if (!isRetainValuesSupported()) { + printUnsupportedOptionalFeatureNotTested("EvictingWithRetainValuesFa= lse", "javax.jdo.option.RetainValues"); + } + else + { + pm =3D getPM(); + PCPoint2 pt =3D getHollowInstance(); + + Transaction tx =3D pm.currentTransaction(); + tx.setRetainValues(false); //This should cause eviction of transactiona= l instances when transaction is later commited. + =09 + //Test + tx.begin(); + makePersistentClean(pt); + tx.commit(); // This should evict pt + verify(pt); + } + } + + /** */ + private PCPoint2 getHollowInstance() { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + PCPoint2 pt =3D new PCPoint2(1,2); + pm.makePersistent(pt); + tx.commit(); + + int curr =3D currentState(pt); + if (curr !=3D HOLLOW){ + fail(ASSERTION_FAILED, + "Unable to create HOLLOW instance, state is " + states[curr]); + } + return pt; + } + + /** */ + private void makePersistentClean(PCPoint2 pt) { + pm.makeTransactional(pt); + int curr =3D currentState(pt); + if (curr !=3D PERSISTENT_CLEAN){ + fail(ASSERTION_FAILED, + "Unable to create PERSISTENT_CLEAN instance, state is " + st= ates[curr]); + } + } + + /** */ + private void verify(PCPoint2 pt) { + // When PersistenceManager evicts instances, it: calls the jdoPreClear m= ethod on each instance + if ( !pt.wasClearCalled()) { + fail(ASSERTION_FAILED, + "missing call of jdoPreClear"); + } + + // When PersistenceManager evicts instances, it: changes the state of th= e instances to hollow + int curr =3D currentState(pt); + if ( (curr !=3D HOLLOW) && (curr !=3D PERSISTENT_NONTRANSACTIONAL)= ) { + fail(ASSERTION_FAILED, + "Instance should be HOLLOW after tx.commit(), state is " = + states[curr]); + } + =09 + pm.makeTransient(pt); + // When PersistenceManager evicts instances, it: clears persistent= fields on each instance (sets the value of the field to its Java default v= alue) + int x=3Dpt.getX(); + Integer y=3Dpt.getY(); + if ((x !=3D 0) || (y !=3D null)) { + fail(ASSERTION_FAILED, + "persistent fields not cleared, pt.getX()=3D=3D"+x+" and pt.= getY()=3D=3D"+y); + } + }=09 +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetExtentWithInstancesMadePersistentViaReachability.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetExtentWithInstancesMadePersistentV= iaReachability.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/GetExtentWithInstancesMadePersistentViaReachability.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetExtentWithInstancesMadePersistentViaReachability.java Fri Mar 18 = 17:07:39 2005 @@ -0,0 +1,115 @@ +/* + * 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.Iterator; +import java.util.Date; + +import javax.jdo.Extent; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.company.Company; +import org.apache.jdo.tck.pc.company.Department; +import org.apache.jdo.tck.pc.company.Address; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: GetExtentWithInstancesMadePersistentViaReachability + *
+ *Keywords: inheritance extent + *
+ *Assertion ID: A12.5.4-1. + *
+ *Assertion Description: +If an instance of a class or interface that has a managed extent is made p= ersistent via reachability, the instance is put into the extent implicitly. + */ + +public class GetExtentWithInstancesMadePersistentViaReachability extends J= DO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.4-3 (GetExtentWithInstancesMadePersistentViaReach= ability) failed: "; + + /** + * 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(GetExtentWithInstancesMadePersistentViaReachab= ility.class); + } + + /** */ + public void test() { + pm =3D getPM(); + createObjects(pm); + runTest(pm); + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Company comp =3D new Company(1L, "Sun Microsystems", new Date(), n= ew Address(0,"","","","","")); + pm.makePersistent(comp); + //Add transient departments + comp.addDepartment(new Department(1L, "Department 1")); + comp.addDepartment(new Department(2L, "Department 2")); + comp.addDepartment(new Department(3L, "Department 3")); + tx.commit(); //Now the transient departments should be made persis= tent via reachability + } + + /** */ + private void runTest(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Extent e =3D pm.getExtent(Department.class, false); + + boolean foundDep1 =3D false; + boolean foundDep2 =3D false; + boolean foundDep3 =3D false; + + for (Iterator i =3D e.iterator(); i.hasNext();) { + Department dep =3D (Department) i.next(); + if (dep.getName().equals("Department 1")) + foundDep1=3Dtrue; + else if (dep.getName().equals("Department 2")) + foundDep2=3Dtrue; + else if (dep.getName().equals("Department 3")) + foundDep3=3Dtrue; =09 + } + + if (!foundDep1) { + fail(ASSERTION_FAILED, + "Extent of class " + Department.class.getName() + " does n= ot include instance with deptid 1L"); + } + if (!foundDep2) { + fail(ASSERTION_FAILED, + "Extent of class " + Department.class.getName() + " does n= ot include instance with deptid 2L"); + } + if (!foundDep3) { + fail(ASSERTION_FAILED, + "Extent of class " + Department.class.getName() + " does n= ot include instance with deptid 3L"); + } + + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetExtentWithNoSubclasses.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetExtentWithNoSubclasses.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/GetExtentWithNoSubclasses.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetExtentWithNoSubclasses.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,111 @@ +/* + * 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.Iterator; + +import javax.jdo.Extent; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: GetExtentWithNoSubclasses + *
+ *Keywords: inheritance extent + *
+ *Assertion ID: A12.5.4-2. + *
+ *Assertion Description: +The getExtent method returns an Extent that contains all of the instances = in the parameter class. With the subclasses parameter false, only instances= of the specified class are returned. + + */ + +public class GetExtentWithNoSubclasses extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.4-2 (GetExtentWithNoSubclasses) 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(GetExtentWithNoSubclasses.class); + } + + private PCPoint p1 =3D null; + private PCPoint p2 =3D null; + + /** */ + public void testGetExtentWithNoSubclasses() { + pm =3D getPM(); + createObjects(pm); + runTestGetExtent(pm); + pm.close(); + pm =3D null; + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint (1,3); + PCPoint p2 =3D new PCPoint (3,5); + pm.makePersistent(p1); + pm.makePersistent(p2); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } + + /** */ + private void runTestGetExtent(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + Extent e =3D pm.getExtent(PCPoint.class, false); + =20 + int c =3D 0; + for (Iterator i =3D e.iterator(); i.hasNext();) { + PCPoint p =3D (PCPoint) i.next(); + if (debug) logger.debug("p.getX() =3D " + p.getX()); + if ((p.getX() =3D=3D 1) || (p.getX() =3D=3D 3)) { + // OK + } + else { + fail(ASSERTION_FAILED,=20 + "Extent of class " + PCPoint.class.getName() +=20 + " includes unexpected instance, p.getX():" + p.ge= tX()); + } + } + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetExtentWithSubclasses.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetExtentWithSubclasses.java?view=3Da= uto&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/GetExtentWithSubclasses.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetExtentWithSubclasses.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,130 @@ +/* + * 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.Iterator; +import java.util.Date; + +import javax.jdo.Extent; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; + +import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.pc.company.PartTimeEmployee; +import org.apache.jdo.tck.pc.company.FullTimeEmployee; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: GetExtentWithSubclasses + *
+ *Keywords: inheritance extent + *
+ *Assertion ID: A12.5.4-3. + *
+ *Assertion Description: +The getExtent method returns an Extent that contains all of the instances = in the parameter class or interface, and if the subclasses flag is true, al= l of the instances of the parameter class and its subclasses. + */ + +public class GetExtentWithSubclasses extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.4-3 (GetExtentWithSubclasses) 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(GetExtentWithSubclasses.class); + } + + /** */ + public void test() { + pm =3D getPM(); + createObjects(pm); + runTest(pm); + } + + /** */ + private void createObjects(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Date date =3D new Date(); + Person p1 =3D new Person(1L, "Craig", "Russell", null, date, null); + Employee p2 =3D new FullTimeEmployee(2L, "Michael", "Bouschen", nu= ll, date, null, date, 0.0); + Employee p3 =3D new PartTimeEmployee(3L, "Michelle", "Caisse", nul= l, date, null, date, 0.0); + Employee p4 =3D new FullTimeEmployee(4L, "Victor", "Kirkebo", null= , date, null, date, 0.0); + pm.makePersistent(p1); + pm.makePersistent(p2); + pm.makePersistent(p3); + pm.makePersistent(p4); + tx.commit(); + } + + /** */ + private void runTest(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + Extent e =3D pm.getExtent(Person.class, true); + + boolean foundCraig =3D false; + boolean foundMichael =3D false; + boolean foundMichelle =3D false; + boolean foundVictor =3D false; + + for (Iterator i =3D e.iterator(); i.hasNext();) { + Person p =3D (Person) i.next(); + if ((p.getFirstname().equals("Craig")) && (p.getLastname().equ= als("Russell"))) + foundCraig=3Dtrue; + else if ((p.getFirstname().equals("Michael")) && (p.getLastnam= e().equals("Bouschen"))) + foundMichael=3Dtrue; + else if ((p.getFirstname().equals("Michelle")) && (p.getLastna= me().equals("Caisse"))) + foundMichelle=3Dtrue; + else if ((p.getFirstname().equals("Victor")) && (p.getLastname= ().equals("Kirkebo"))) + foundVictor=3Dtrue; + } + + if (!foundCraig) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() +=20 + " does not include instance of class " + Person.class.getN= ame() + " with personid 1L"); + } + if (!foundMichael) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() +=20 + " does not include instance of class " + Employee.class.ge= tName() + " with personid 2L"); + } + if (!foundMichelle) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() +=20 + " does not include instance of class " + PartTimeEmployee.= class.getName() + " with personid 3L"); + } + if (!foundVictor) { + fail(ASSERTION_FAILED, + "Extent of class " + Person.class.getName() +=20 + " does not include instance of class " + FullTimeEmployee.= class.getName() + " with personid 4L"); + } + + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetIgnoreCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetIgnoreCache.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/GetIgnoreCache.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetIgnoreCache.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. + */ + +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: Get IgnoreCache Value from PersistenceManager + *
+ *Keywords: + *
+ *Assertion ID: A12.5.3-1. + *
+ *Assertion Description: + The PersistenceManager.getIgnoreCache method returns the current value of= the + IgnoreCache option. + + */ + +public class GetIgnoreCache extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.3-1 (GetIgnoreCache) 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(GetIgnoreCache.class); + } + + /** */ + public void testGetIgnoreCache() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + PCPoint p1 =3D new PCPoint(); + tx.begin(); + pm.setIgnoreCache(true); + boolean returnValue =3D pm.getIgnoreCache(); + + if (!returnValue) + fail(ASSERTION_FAILED, + "pm.getIgnoreCache() returns false after setting the = falg to true"); + tx.commit(); + } + finally { + if (tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectById.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectById.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/persistencem= anager/GetObjectById.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectById.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 javax.jdo.Transaction; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Get Object By Id + *
+ *Keywords: identity cache + *
+ *Assertion ID: A12.5.6-9. + *
+ *Assertion Description: + If PersistenceManager.getObjectById is called with a value of + true for the second parameter named validate, + and there is not an instance already in the cache with the same JDO ident= ity + as the oid parameter, then this method creates an instance with the speci= fied + JDO identity, verifies that it exists in the data store, and returns it. +
    +
  1. If there is no transaction in progress, the returned instance will be + hollow or persistent-nontransactional, at the choice of the implementatio= n=2E
  2. +
  3. If there is a data store transaction in progress, + the returned instance will be persistent-clean.
  4. +
  5. If there is an optimistic transaction in progress, + the returned instance will be persistent-nontransactional.
  6. +
+ + */ + +public class GetObjectById extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-9 (GetObjectById) 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(GetObjectById.class); + } + + /** */ + public void testGetObjectById() { + if (debug) logger.debug ("\nSTART GetObjectById"); + + Transaction tx =3D null; + try { + pm =3D getPM(); + Object oid =3D createPCPointInstance(pm); + if (pm !=3D null) { + pm.close(); + pm =3D null; // make sure to get a different pm so obj is = not in cache + } + =20 + Object obj =3D null; + int state =3D 0; + =20 + // nontransactional access + if (isNontransactionalReadSupported()) { + if (debug) logger.debug("nontransactional"); + pm =3D getPM(); + tx =3D pm.currentTransaction(); + tx.setNontransactionalRead(true); + obj =3D pm.getObjectById(oid, true); + state =3D currentState (obj); + if (state !=3D PERSISTENT_NONTRANSACTIONAL && state !=3D H= OLLOW) { + fail(ASSERTION_FAILED, + "Expected persistent-nontransactional or hollow; = got " +=20 + getStateOfInstance(obj)); + } + tx =3D null; + pm.close(); + pm =3D null; // make sure to get a different pm so obj is = not in cache + } + =20 + // pessimistic transactional access + if (debug) logger.debug("pessimistic"); + pm =3D getPM(); + tx =3D pm.currentTransaction(); + tx.setOptimistic(false); + tx.begin(); + obj =3D pm.getObjectById(oid, true); + state =3D currentState (obj); + tx.commit(); + tx =3D null; + if (state !=3D PERSISTENT_CLEAN) { + fail(ASSERTION_FAILED, + "Expected persistent-clean; got " + getStateOfInstanc= e(obj)); + } + pm.close(); + pm =3D null; // make sure to get a different pm so obj is not = in cache + =20 + // optimistic transactional access + if (isOptimisticSupported()) { + if (debug) logger.debug("optimistic"); + pm =3D getPM(); + tx =3D pm.currentTransaction(); + tx.setOptimistic(true); + tx.begin(); + obj =3D pm.getObjectById(oid, true); + state =3D currentState (obj); + tx.commit(); + if (state !=3D PERSISTENT_NONTRANSACTIONAL & state !=3D HO= LLOW) { + fail(ASSERTION_FAILED, + "Expected persistent-nontransactional; got " + ge= tStateOfInstance(obj)); + } + tx =3D null; + pm.close(); + pm =3D null; // make sure to get a different pm so obj is = not in cache + } + } + finally { + if (debug) logger.debug ("END GetObjectById"); + + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdNoValidationInstanceInCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdNoValidationInstanceInCa= che.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/GetObjectByIdNoValidationInstanceInCache.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdNoValidationInstanceInCache.java Fri Mar 18 17:07:39 20= 05 @@ -0,0 +1,84 @@ +/* + * 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: Get Object By Id No Validation, Instance In Cache + *
+ *Keywords: identity cache + *
+ *Assertion IDs: A12.5.6-2 + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false +for the second parameter named validate, and there is already an instance = in the cache with the +same JDO identity as the oid parameter, then this method returns it. + + */ + + +public class GetObjectByIdNoValidationInstanceInCache extends PersistenceM= anagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-2 (GetObjectByIdNoValidationInstanceInCache) fa= iled: "; + =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(GetObjectByIdNoValidationInstanceInCache.class= ); + } + + /** */ + public void testGetObjectByIdNoValidationInstanceInCache() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + int curr =3D currentState(p1); + + Object oid =3D pm.getObjectId(p1); + tx.commit(); + + tx.begin(); + Object obj =3D pm.getObjectById(oid, false); + + if (p1 !=3D obj) + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, false) should find existing in= stance in pm cache"); + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdNoValidationInstanceInCa= cheNoStateChange.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/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java Fri Mar 1= 8 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.persistencemanager; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Get Object By Id No Validation, Instance In Cache, No Stat= e Change + *
+ *Keywords: identity cache lifecycle + *
+ *Assertion IDs: A12.5.6-3 + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false for th= e second parameter named validate, and there is already an instance in the = cache with the same JDO identity as the oid parameter, there is no change m= ade to the state of the returned instance. + */ + +public class GetObjectByIdNoValidationInstanceInCacheNoStateChange extends= PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-3 (GetObjectByIdNoValidationInstanceInCacheNoSt= ateChange) 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(GetObjectByIdNoValidationInstanceInCacheNoStat= eChange.class); + } + + /** */ + public void testGetObjectByIdNoValidationInstanceInCacheNoStateChange(= ) { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + =20 + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + tx.commit(); + int curr =3D currentState(p1); + + tx.begin(); + Object obj =3D pm.getObjectById (oid, false); + + int actualState =3D currentState(obj); + + if (actualState !=3D curr) { + fail(ASSERTION_FAILED, + "State mismatched - Expected state: " + + curr + " Actual state: " + actualState); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdNoValidationInstanceNotInCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdNoValidationInstanceNotI= nCache.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/GetObjectByIdNoValidationInstanceNotInCache.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdNoValidationInstanceNotInCache.java Fri Mar 18 17:07:39= 2005 @@ -0,0 +1,87 @@ +/* + * 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: Get Object By Id No Validation Instance Not In Cache + *
+ *Keywords: identity cache + *
+ *Assertion IDs: A12.5.6-5 + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false for th= e second parameter named validate, and there is not an instance already in = the cache with the same JDO identity as the oid parameter, and there is a t= ransaction in progress, then this method creates an instance with the speci= fied JDO identity and returns it with a state of hollow, persistent-nontran= sactional, or persistent-clean, at the choice of the implementation. + */ + +public class GetObjectByIdNoValidationInstanceNotInCache extends Persisten= ceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-5 (GetObjectByIdNoValidationInstanceNotInCache)= 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(GetObjectByIdNoValidationInstanceNotInCache.cl= ass); + } + + /** */ + public void testGetObjectByIdNoValidationInstanceNotInCache() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + pm.evict(p1); + tx.commit(); + + tx.begin(); + Object obj =3D pm.getObjectById (oid, false); + + int curr =3D currentState(obj); + if ( curr =3D=3D HOLLOW || + curr =3D=3D PERSISTENT_NONTRANSACTIONAL || + curr =3D=3D PERSISTENT_CLEAN ) { + ; // expected result + }=20 + else { + fail(ASSERTION_FAILED, + "returned state mismatched - " + + " Actual state " + curr); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdNoValidationInstanceNotI= nCacheNoTx.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/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java Fri Mar 18 17:0= 7: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. + */ + +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: Get Object By Id No Validation Instance Not In Cache, No Tx + *
+ *Keywords: identity cache + *
+ *Assertion IDs: A12.5.6-4 + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of false for the +second parameter named validate, and there is not an instance already in t= he cache with the same JDO identity as the oid parameter, and there is no t= ransaction in progress, then this method creates an instance with the speci= fied JDO identity and returns it with a state of hollow or persistent-nontr= ansactional, at the choice of the implementation. + */ + +public class GetObjectByIdNoValidationInstanceNotInCacheNoTx extends Persi= stenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-4 (GetObjectByIdNoValidationInstanceNotInCacheN= oTx) 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(GetObjectByIdNoValidationInstanceNotInCacheNoT= x=2Eclass); + } + + /** */ + public void testGetObjectByIdNoValidationInstanceNotInCacheNoTx() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + pm.evict(p1); + tx.commit(); + + /* get oid for p1, no transaction in progress */ + Object obj =3D pm.getObjectById (oid, false); + + int curr =3D currentState(p1); + + if (curr =3D=3D HOLLOW || + curr =3D=3D PERSISTENT_NONTRANSACTIONAL || + curr =3D=3D PERSISTENT_CLEAN ) { + // expected result + }=20 + else { + fail(ASSERTION_FAILED, + "returned state mismatched - " + + " Actual state " + curr); + } + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdNoValidationInstanceNotInDatastore.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdNoValidationInstanceNotI= nDatastore.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/GetObjectByIdNoValidationInstanceNotInDatastore.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdNoValidationInstanceNotInDatastore.java Fri Mar 18 17:0= 7:39 2005 @@ -0,0 +1,81 @@ +/* + * 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.JDOObjectNotFoundException; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Get Object By Id No Validation Instance Not In Datastore + *
+ *Keywords: identity exception + *
+ *Assertion ID: A12.5.6-6. + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of +false for the second parameter named validate, +and the instance does not exist in the data store, a subsequent access +of the fields of the instance will throw a JDODatastoreException +if the instance does not exist at that time. + + */ + +public class GetObjectByIdNoValidationInstanceNotInDatastore extends Persi= stenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-6 (GetIgnoreCGetObjectByIdNoValidationInstanceN= otInDatastore) 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(GetObjectByIdNoValidationInstanceNotInDatastor= e=2Eclass); + } + + /** */ + public void testGetObjectByIdNoValidationInstanceNotInDatastore() { + if (debug) + logger.debug ("\nSTART GetObjectByIdNoValidationInstanceNotInD= atastore"); + Object oid =3D null; + pm =3D getPM(); + oid =3D createPCPointInstance(pm); + deletePCPointInstance(pm, oid); + =20 + try { + PCPoint p1 =3D (PCPoint)pm.getObjectById(oid, false); // might= throw exception here + if (debug) + logger.debug ("Got object in cache, even though not in dat= astore."); + p1.getX(); // if not thrown above, throws exception here + fail(ASSERTION_FAILED, + "accessing unknown instance should throw JDOObjectNotFoun= dException"); + }=20 + catch (JDOObjectNotFoundException ex) { + // expected exception + } + pm.close(); + pm =3D null; + if (debug) + logger.debug ("END GetObjectByIdNoValidationInstanceNotInDatas= tore"); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdNotResolved.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdNotResolved.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/GetObjectByIdNotResolved.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdNotResolved.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,85 @@ +/* + * 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.JDOObjectNotFoundException; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Get ObjectId For Null Or Not Persistent + *
+ *Keywords: identity + *
+ *Assertion IDs: A12.5.6-1 + *
+ *Assertion Description: +In a call to PersistenceManager.getObjectById, if the PersistenceManager is +unable to resolve the oid parameter to an ObjectId instance, then it throw= s a JDOUserException. + */ + +public class GetObjectByIdNotResolved extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-1 (GetObjectByIdNotResolved) 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(GetObjectByIdNotResolved.class); + } + + /* passing null paramameter to getObjectId */ + public void testGetObjectByIdNotResolved() { + pm =3D getPM(); + if (debug) logger.debug(" *** testObjectByIdNotResolved *** "); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + pm.deletePersistent(p1); + tx.commit(); + + tx.begin(); + try { + PCPoint p2 =3D (PCPoint) pm.getObjectById(oid, true); + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, true) should throw JDOObjectNo= tFoundException, if oid refers to an non existing object"); + }=20 + catch (JDOObjectNotFoundException e) { + // expected exception + } + tx.rollback(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} + Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdWithValidationInstanceInCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdWithValidationInstanceIn= Cache.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/GetObjectByIdWithValidationInstanceInCache.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdWithValidationInstanceInCache.java Fri Mar 18 17:07:39 = 2005 @@ -0,0 +1,87 @@ +/* + * 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: Get Object By Id With Validation Instance in Cache + *
+ *Keywords: identity cache + *
+ *Assertion IDs: A12.5.6-7 + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of true for the= second parameter named validate, and there is already a transactional inst= ance in the cache with the same JDO identity as the oid parameter, then thi= s method returns it. There is no change made to the state of the returned i= nstance. + */ + +public class GetObjectByIdWithValidationInstanceInCache extends Persistenc= eManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-7 (GetObjectByIdWithValidationInstanceInCache) = 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(GetObjectByIdWithValidationInstanceInCache.cla= ss); + } + + /** */ + public void testGetObjectByIdWithValidationInstanceInCache() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + tx.commit(); + int curr =3D currentState(p1); + + tx.begin(); + Object obj =3D pm.getObjectById(oid, false); + int curr2 =3D currentState(obj); + + if (obj !=3D p1) { + fail(ASSERTION_FAILED,=20 + "pm.getObjectById(oid, false) should find existing in= stance in pm cache"); + } + =20 + if (curr2 !=3D curr) { + fail(ASSERTION_FAILED, + "State changed in the returned instance, expected sta= te: " +=20 + curr + " Actual state: " + curr2); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdWithValidationInstanceIn= CacheNotInDatastore.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/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.java Fri Ma= r 18 17:07:39 2005 @@ -0,0 +1,87 @@ +/* + * 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.JDOObjectNotFoundException; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Get Object By Id With Validation, Instance in Cache, Not i= n Datastore + *
+ *Keywords: identity cache + *
+ *Assertion IDs: A12.5.6-8. + *
+ *Assertion Description: +If PersistenceManager.getObjectById is called with a value of true +for the second parameter named validate, and there is an instance already = in the cache with the +same JDO identity as the oid parameter, and the instance is not transactio= nal, and the instance +does not exist in the datastore, then a JDODatastoreException is thrown. + + */ + +public class GetObjectByIdWithValidationInstanceInCacheNotInDatastore exte= nds PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-8 (GetObjectByIdWithValidationInstanceInCacheNo= tInDatastore) 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(GetObjectByIdWithValidationInstanceInCacheNotI= nDatastore.class); + } + + /* passing null paramameter to getObjectId */ + public void testGetObjectByIdWithValidationInstanceInCacheNotInDatasto= re() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + pm.deletePersistent(p1); + tx.commit(); + =20 + tx.begin(); + try { + PCPoint p2 =3D (PCPoint) pm.getObjectById(oid, true); + fail(ASSERTION_FAILED, + "pm.getObjectById(oid, true) should throw JDOObjectNo= tFoundException, if oid refers to an non existing object"); + }=20 + catch (JDOObjectNotFoundException ex) { + // expected exception + } + tx.rollback(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectByIdWithValidationInstanceNo= tInCacheNotInDatastore.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/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.java (ad= ded) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore.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. + */ + +package org.apache.jdo.tck.api.persistencemanager; + +import javax.jdo.JDOObjectNotFoundException; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Get Object By Id With Validation, Instance Not in Cache, N= ot in Datastore + *
+ *Keywords: exception + *
+ *Assertion IDs: A12.6.5-2. + *
+ *Assertion Description: +Object getObjectById (Object oid, boolean validate) with validate=3D=3Dtru= e=2E If the instance does not exist in the datastore, then a JDOObjectNotFo= undException is thrown. + */ + +public class GetObjectByIdWithValidationInstanceNotInCacheNotInDatastore e= xtends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.6.5-2 (GetObjectByIdWithValidationInstanceNotInCach= eNotInDatastore) 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(GetObjectByIdWithValidationInstanceNotInCacheN= otInDatastore.class); + } + + /** */ + public void test() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + tx.setRestoreValues(false); //This should cause eviction of transa= ctional instances when transaction is later rolled back. + tx.begin(); =09 + PCPoint p1 =3D new PCPoint (1,3); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + tx.rollback(); + + tx.begin(); + try { + PCPoint p2 =3D (PCPoint) pm.getObjectById(oid, true); + fail(ASSERTION_FAILED, "pm.getObjectById(oid, true) should thr= ow JDOObjectNotFoundException, if oid refers to an non existing object"); + } + catch (JDOObjectNotFoundException ex) { + // expected exception + } + finally { + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persisten= cemanager/GetObjectId.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/api/persistencemanager/GetObjectId.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/persistencem= anager/GetObjectId.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/api/persistencem= anager/GetObjectId.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,80 @@ +/* + * 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: Get Objectid + *
+ *Keywords: identity + *
+ *Assertion ID: A12.5.6-10 + *
+ *Assertion Description: +The PersistenceManager.getObjectId method returns an ObjectId instance tha= t re presents the object identity of the specified JDO Instance. Test: The = method g etObjectById returns the exact same object, evaluating to true whe= n =3D=3D is used . + + */ + +public class GetObjectId extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.6-10 (GetObjectId) 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(GetObjectId.class); + } + =20 + /** */ + public void testGetObjectId() { + pm =3D getPM(); + Transaction tx =3D pm.currentTransaction(); + try { + PCPoint p1 =3D new PCPoint(8,8); + + tx =3D pm.currentTransaction(); + tx.begin(); + pm.makePersistent(p1); + Object oid =3D pm.getObjectId(p1); + tx.commit(); + + tx.begin(); + Object obj =3D pm.getObjectById(oid, false); + if (obj !=3D p1) { + fail(ASSERTION_FAILED, + "m.getObjectById(oid, false) should find existing ins= tance in pm cache."); + } + tx.rollback(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + pm.close(); + pm =3D null; + } +}