Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 70525 invoked from network); 4 Apr 2005 19:50:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 4 Apr 2005 19:50:41 -0000 Received: (qmail 93004 invoked by uid 500); 4 Apr 2005 19:50:35 -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 Received: (qmail 92922 invoked by uid 99); 4 Apr 2005 19:50:34 -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 Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 04 Apr 2005 12:50:28 -0700 Received: (qmail 67514 invoked by uid 65534); 4 Apr 2005 19:43:46 -0000 Message-ID: <20050404194346.67513.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: Mon, 04 Apr 2005 19:43:46 -0000 Subject: svn commit: r160090 [8/63] - in incubator/jdo/trunk: ./ tck20/ tck20/assertions/ tck20/iut_jars/ tck20/test/ tck20/test/conf/ tck20/test/java/ tck20/test/java/org/ tck20/test/java/org/apache/ tck20/test/java/org/apache/jdo/ tck20/test/java/org/apache/jdo/tck/ tck20/test/java/org/apache/jdo/tck/api/ tck20/test/java/org/apache/jdo/tck/api/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/api/jdohelper/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/cache/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/close/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/extent/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/flags/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/getobject/ tck20/test/java/org/apache/jdo/tck/api/persistencemanager/lifecycle/ tck20/test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ tck20/test/java/org/apache/jdo/tck/enhancement/ tck20/test/java/org/apache/jdo/tck/extents/ tck20/test/java/org/apache/jdo/tck/lifecycle/ tck20/test/java/org/apache/jdo/tck/lifecycle/nontransactional/ tck20/test/java/org/apache/jdo/tck/models/ tck20/test/java/org/apache/jdo/tck/models/embedded/ tck20/test/java/org/apache/jdo/tck/models/fieldtypes/ tck20/test/java/org/apache/jdo/tck/models/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/ tck20/test/java/org/apache/jdo/tck/pc/company/ tck20/test/java/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/java/org/apache/jdo/tck/pc/inheritance/ tck20/test/java/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/java/org/apache/jdo/tck/pc/lifecycle/ tck20/test/java/org/apache/jdo/tck/pc/mylib/ tck20/test/java/org/apache/jdo/tck/query/ tck20/test/java/org/apache/jdo/tck/query/operators/ tck20/test/java/org/apache/jdo/tck/transactions/ tck20/test/java/org/apache/jdo/tck/util/ tck20/test/jdo/ tck20/test/jdo/applicationidentity/ tck20/test/jdo/applicationidentity/org/ tck20/test/jdo/applicationidentity/org/apache/ tck20/test/jdo/applicationidentity/org/apache/jdo/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/jdo/datastoreidentity/ tck20/test/jdo/datastoreidentity/org/ tck20/test/jdo/datastoreidentity/org/apache/ tck20/test/jdo/datastoreidentity/org/apache/jdo/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/ tck20/test/orm/applicationidentity/ tck20/test/orm/applicationidentity/org/ tck20/test/orm/applicationidentity/org/apache/ tck20/test/orm/applicationidentity/org/apache/jdo/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/orm/datastoreidentity/ tck20/test/orm/datastoreidentity/org/ tck20/test/orm/datastoreidentity/org/apache/ tck20/test/orm/datastoreidentity/org/apache/jdo/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/company/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/ tck20/test/sql/ tck20/test/sql/derby/ To: jdo-commits@db.apache.org From: mcaisse@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/close/AfterCloseAllMethodsThrowException.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/close/CloseThrowsExceptionWhenActiveTx.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/close/CloseThrowsExceptionWhenActiveT= x=2Ejava?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/CloseThrowsExceptionWhenActiveTx.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/CloseThrowsExceptionWhenActiveTx.java Mon Apr 4 12:41:23 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.close; + +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(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/close/CloseThrowsExceptionWhenActiveTx.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/close/IsClosedIsFalseUponConstruction.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponConstruction= .java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/IsClosedIsFalseUponConstruction.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/IsClosedIsFalseUponConstruction.java Mon Apr 4 12:41:23 2005 @@ -0,0 +1,59 @@ +/* + * 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.close; + +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Is Closed returns false Upon Construction + *
+ *Keywords: + *
+ *Assertion IDs: A12.5-3 + *
+ *Assertion Description: +The PersistenceManager.isClosed method returns false upon construction of +the PersistenceManager instance. +*/ + +public class IsClosedIsFalseUponConstruction extends PersistenceManagerTes= t { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5-3 (IsClosedIsFalseUponConstruction) 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(IsClosedIsFalseUponConstruction.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + if (pm.isClosed()) { + fail(ASSERTION_FAILED, + "pm is closed after creation"); + } + } +} + Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/close/IsClosedIsFalseUponConstruction.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/close/IsClosedIsFalseUponRetrievalFromPool.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/close/IsClosedIsFalseUponRetrievalFro= mPool.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/IsClosedIsFalseUponRetrievalFromPool.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/IsClosedIsFalseUponRetrievalFromPool.java Mon Apr 4 12:41:23 = 2005 @@ -0,0 +1,62 @@ +/* + * 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.close; + +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Is Closed Is False Upon Retrieval From a Pool + *
+ *Keywords: + *
+ *Assertion IDs: A12.5-4 + *
+ *Assertion Description: +The PersistenceManager.isClosed method returns false upon retrieval +of a PersistenceManager from a pool. +*/ + +public class IsClosedIsFalseUponRetrievalFromPool extends PersistenceManag= erTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5-4 (IsClosedIsFalseUponRetrievalFromPool) 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(IsClosedIsFalseUponRetrievalFromPool.class); + } + + /** */ + public void testIsClosed() { + String sname=3D"Jojo"; + String spswd=3D"mypswd"; + + pmf =3D getPMF(); + pm =3D pmf.getPersistenceManager(sname,spswd); + + if (pm.isClosed()) { + fail(ASSERTION_FAILED, + "pm is closed after creation"); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/close/IsClosedIsFalseUponRetrievalFromPool.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/close/IsClosedIsTrueAfterClose.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/close/IsClosedIsTrueAfterClose.java?v= iew=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/IsClosedIsTrueAfterClose.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/close/IsClosedIsTrueAfterClose.java Mon Apr 4 12:41:23 2005 @@ -0,0 +1,62 @@ +/* + * 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.close; + +import javax.jdo.PersistenceManagerFactory; + +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Is Closed Is True After Close + *
+ *Keywords: + *
+ *Assertion IDs: A12.5-5 + *
+ *Assertion Description: +The PersistenceManager.isClosed method returns true only after the +closemethod completes successfully, meaning the PersistenceManager has bee= n closed. (same as A35-01). +*/ + +public class IsClosedIsTrueAfterClose extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5-5 (IsClosedIsTrueAfterClose) 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(IsClosedIsTrueAfterClose.class); + } + + /** */ + public void test() { + PersistenceManagerFactory pmf =3D getPMF(); + pm =3D pmf.getPersistenceManager(); + pm.close(); + =20 + if (!pm.isClosed()) { + fail(ASSERTION_FAILED, + "pm.isClosed returns false after pm.close"); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/close/IsClosedIsTrueAfterClose.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/extent/GetExtentWithInstancesMadePersistentViaReachability.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/extent/GetExtentWithInstancesMadePers= istentViaReachability.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/extent/GetExtentWithInstancesMadePersistentViaReachability.java (add= ed) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/extent/GetExtentWithInstancesMadePersistentViaReachability.java Mon = Apr 4 12:41:23 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.extent; + +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(); + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/extent/GetExtentWithInstancesMadePersistentViaReachability.j= ava ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/extent/GetExtentWithNoSubclasses.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/extent/GetExtentWithNoSubclasses.java= ?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/extent/GetExtentWithNoSubclasses.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/extent/GetExtentWithNoSubclasses.java Mon Apr 4 12:41:23 2005 @@ -0,0 +1,112 @@ +/* + * 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.extent; + +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; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/extent/GetExtentWithNoSubclasses.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/extent/GetExtentWithSubclasses.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/extent/GetExtentWithSubclasses.java?v= iew=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/extent/GetExtentWithSubclasses.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/extent/GetExtentWithSubclasses.java Mon Apr 4 12:41:23 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.extent; + +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(); + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/extent/GetExtentWithSubclasses.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/flags/GetIgnoreCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/flags/GetIgnoreCache.java?view=3Dauto= &rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/GetIgnoreCache.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/GetIgnoreCache.java Mon Apr 4 12:41:23 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. + */ + +package org.apache.jdo.tck.api.persistencemanager.flags; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/flags/GetIgnoreCache.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/flags/SetIgnoreCacheToFalse.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToFalse.java?view= =3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetIgnoreCacheToFalse.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetIgnoreCacheToFalse.java Mon Apr 4 12:41:23 2005 @@ -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.flags; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Set IgnoreCache To False + *
+ *Keywords:cache + *
+ *Assertion ID: A12.5.3-3. + *
+ *Assertion Description: +The PersistenceManager.setIgnoreCache method called with a value of false = instructs the +query engine that the user expects queries to return results that reflect = changed values in the cache. + + + */ + +public class SetIgnoreCacheToFalse extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.3-3 (SetIgnoreCacheToFalse) 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(SetIgnoreCacheToFalse.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetIgnoreCacheToFalse(pm); + =20 + pm.close(); + pm =3D null; + } + + /** */ + private void runTestSetIgnoreCacheToFalse(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + PCPoint p1 =3D new PCPoint(); + tx.begin(); + pm.setIgnoreCache(false); + if (pm.getIgnoreCache()) { + fail(ASSERTION_FAILED, + "pm.getIgnoreCache() should return false after settin= g the flag to false."); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/flags/SetIgnoreCacheToFalse.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/flags/SetIgnoreCacheToTrue.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/flags/SetIgnoreCacheToTrue.java?view= =3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetIgnoreCacheToTrue.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetIgnoreCacheToTrue.java Mon Apr 4 12:41:23 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.flags; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Set IgnoreCache To True + *
+ *Keywords:cache + *
+ *Assertion ID: A12.5.3-2. + *
+ *Assertion Description: +The PersistenceManager.setIgnoreCache method called with a value of true i= s a hint to the +query engine that the user expects queries to be optimized to return appro= ximate results by ignoring changed values in the +cache. This is not testable, except to see whether the get/set works. + + + */ + +public class SetIgnoreCacheToTrue extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.3-2 (SetIgnoreCacheToTrue) 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(SetIgnoreCacheToTrue.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetIgnoreCacheToTrue(pm); + =20 + pm.close(); + pm =3D null; + } + + /** */ + public void runTestSetIgnoreCacheToTrue(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + PCPoint p1 =3D new PCPoint(); + tx.begin(); + pm.setIgnoreCache(true); + if (!pm.getIgnoreCache()) { + fail(ASSERTION_FAILED, + "pm.getIgnoreCache() should return true after setting= the flag to true."); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/flags/SetIgnoreCacheToTrue.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/flags/SetMultithreadedFalse.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedFalse.java?view= =3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetMultithreadedFalse.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetMultithreadedFalse.java Mon Apr 4 12:41:23 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.flags; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Set Multithreaded False + *
+ *Keywords: multithreaded + *
+ *Assertion ID: A12.7-2. + *
+ *Assertion Description: +If PersistenceManager.setMultithreaded is called with a value of false, a = value of false +will be returned when getMultithreaded is called. + + */ + +public class SetMultithreadedFalse extends PersistenceManagerTest{ + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.7-2 (SetMultithreadedFalse) 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(SetMultithreadedFalse.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetMultithreadedFalse(pm); + =20 + pm.close(); + pm =3D null; + } + =20 + /** */ + private void runTestSetMultithreadedFalse(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + PCPoint p1 =3D new PCPoint(); + tx.begin(); + pm.setMultithreaded(false); + if (pm.getMultithreaded()) { + fail(ASSERTION_FAILED, + "pm.getMultithreaded() should false true after settin= g the flag to false."); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/flags/SetMultithreadedFalse.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/flags/SetMultithreadedTrue.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/flags/SetMultithreadedTrue.java?view= =3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetMultithreadedTrue.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SetMultithreadedTrue.java Mon Apr 4 12:41:23 2005 @@ -0,0 +1,82 @@ +/* + * 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.flags; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Set Multithreaded True + *
+ *Keywords: multithreaded + *
+ *Assertion ID: A12.7-1. + *
+ *Assertion Description: +If PersistenceManager.setMultithreaded is called with a value of true, the= n the JDO +implementation must perform synchronizations to support multiple applicati= on threads. A value of true will be returned +when getMultithreaded is called. In testing, multi-threading should be tur= ned on and then multi-threading tests should +be run. + */ + +public class SetMultithreadedTrue extends PersistenceManagerTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.7-1 (SetMultithreadedTrue) 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(SetMultithreadedTrue.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetMultithreadedTrue(pm); + =20 + pm.close(); + pm =3D null; + } + =20 + /** */ + public void runTestSetMultithreadedTrue(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + pm.setMultithreaded(true); + if (!pm.getMultithreaded()) { + fail(ASSERTION_FAILED, + "pm.getMultithreaded() should true true after setting= the flag to true."); + } + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/flags/SetMultithreadedTrue.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/flags/SettingFlagsWithTransactionInstance.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/flags/SettingFlagsWithTransactionInst= ance.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SettingFlagsWithTransactionInstance.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/flags/SettingFlagsWithTransactionInstance.java Mon Apr 4 12:41:23 2= 005 @@ -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. + */ + +package org.apache.jdo.tck.api.persistencemanager.flags; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *Title: Setting Flags With Transaction instance + *
+ *Keywords: + *
+ *Assertion ID: A12.5.2-3. + *
+ *Assertion Description: +Even if the Transaction instance returned by PersistenceManager.currentTra= nsaction +cannot be used for transaction completion (due to external transaction man= agement), it still can be used to set flags. + + */ + +public class SettingFlagsWithTransactionInstance extends PersistenceManage= rTest { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A12.5.2-3 (SettingFlagsWithTransactionInstance) 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(SettingFlagsWithTransactionInstance.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSettingFlagsWithTransactionInstance(pm); + =20 + pm.close(); + pm =3D null; + } + + + /** */ + private void runTestSettingFlagsWithTransactionInstance(PersistenceMan= ager pm) { + Transaction tx =3D pm.currentTransaction(); + tx.setNontransactionalRead(false); + tx.setNontransactionalWrite(false); + tx.setRetainValues(false); + tx.setOptimistic(false); + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/flags/SettingFlagsWithTransactionInstance.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectById.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectById.java?view=3Da= uto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectById.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectById.java Mon Apr 4 12:41:23 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.getobject; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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(); + } + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectById.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdNoValidationInstanceInCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationIn= stanceInCache.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceInCache.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceInCache.java Mon Apr 4 1= 2:41:23 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.getobject; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdNoValidationInstanceInCache.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.j= ava URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationIn= stanceInCacheNoStateChange.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java= (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateChange.java= Mon Apr 4 12:41:23 2005 @@ -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.getobject; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdNoValidationInstanceInCacheNoStateCha= nge.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationIn= stanceNotInCache.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java Mon Apr = 4 12:41:23 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.getobject; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCache.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationIn= stanceNotInCacheNoTx.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java (adde= d) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.java Mon A= pr 4 12:41:23 2005 @@ -0,0 +1,89 @@ +/* + * 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.getobject; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdNoValidationInstanceNotInCacheNoTx.ja= va ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNoValidationIn= stanceNotInDatastore.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java (adde= d) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.java Mon A= pr 4 12:41:23 2005 @@ -0,0 +1,82 @@ +/* + * 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.getobject; + +import javax.jdo.JDOObjectNotFoundException; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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"); + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdNoValidationInstanceNotInDatastore.ja= va ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdNotResolved.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdNotResolved.ja= va?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNotResolved.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdNotResolved.java Mon Apr 4 12:41:23 2005 @@ -0,0 +1,86 @@ +/* + * 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.getobject; + +import javax.jdo.JDOObjectNotFoundException; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} + Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdNotResolved.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdWithValidationInstanceInCache.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidation= InstanceInCache.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdWithValidationInstanceInCache.java (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdWithValidationInstanceInCache.java Mon Apr 4= 12:41:23 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.getobject; + +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdWithValidationInstanceInCache.java ---------------------------------------------------------------------------= --- svn:executable =3D * Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persisten= cemanager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastor= e=2Ejava URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/= apache/jdo/tck/api/persistencemanager/getobject/GetObjectByIdWithValidation= InstanceInCacheNotInDatastore.java?view=3Dauto&rev=3D160090 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.j= ava (added) +++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/persistencem= anager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDatastore.j= ava Mon Apr 4 12:41:23 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.getobject; + +import javax.jdo.JDOObjectNotFoundException; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; +import org.apache.jdo.tck.api.persistencemanager.PersistenceManagerTest; + +/** + *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; + } +} Propchange: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/api/pers= istencemanager/getobject/GetObjectByIdWithValidationInstanceInCacheNotInDat= astore.java ---------------------------------------------------------------------------= --- svn:executable =3D *