Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 87171 invoked from network); 19 Mar 2005 05:12:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Mar 2005 05:12:24 -0000 Received: (qmail 90839 invoked by uid 500); 19 Mar 2005 05:12:24 -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 93022 invoked by uid 99); 19 Mar 2005 01:16:39 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Message-ID: <20050319010955.29725.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:55 -0000 Subject: svn commit: r158179 [49/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/query/operato= rs/SignInversion.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/SignInversion.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/query/operators/= SignInversion.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= SignInversion.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,127 @@ +/* + * 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.query.operators; + +import java.util.Collection; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Sign Inversion Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-29. + *
+ *Assertion Description: +The numeric sign inversion operator (-) is supported for all = types +as they are defined in the Java language. This includes the following type= s: +
    +
  • byte, short, int, long, char, Byte, Short Integer, Long, Charact= er
  • +
  • float, double, Float, Double
  • +
  • BigDecimal, BigInteger
+The operation on object-valued fields of wrapper types (Boolean, Byt= e, +Short, Integer, Long, Float, and Double), and numeric = types +(BigDecimal and BigInteger) +use the wrapped values as operands. + + */ + +public class SignInversion extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-29 (SignInversion) 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(SignInversion.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + + try { + loadPrimitiveTypes(pm); + runTest(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + =20 + /** */ + void runTest(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + =20 + Collection instance9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 9").execute(); + Collection allOddInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + =20 + runSimplePrimitiveTypesQuery("-id =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-byteNotNull =3D=3D -9", + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-shortNotNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); = =20 + runSimplePrimitiveTypesQuery("-intNotNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); = =20 + runSimplePrimitiveTypesQuery("-longNotNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-floatNotNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-doubleNotNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-byteNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-shortNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-intNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-longNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-floatNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-doubleNull =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-bigDecimal =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("-bigInteger =3D=3D -9",=20 + pm, instance9, ASSERTION_FAILED); + + runSimplePrimitiveTypesQuery("-charNull =3D=3D -79",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + runSimplePrimitiveTypesQuery("-charNotNull =3D=3D -79",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/StringConcatenation.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/StringConcatenation.java?view=3Dauto&rev=3D1= 58179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= StringConcatenation.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= StringConcatenation.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,104 @@ +/* + * 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.query.operators; + +import java.util.Collection; +import java.util.HashSet; + +import javax.jdo.PersistenceManager; +import javax.jdo.Query; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: String Concatenation Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-27. + *
+ *Assertion Description: +The String concatenation operator (+) is support= ed +for the String type only. + + */ + +public class StringConcatenation extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-27 (StringConcatenation) 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(StringConcatenation.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + try { + // read test data + CompanyModelReader reader =3D=20 + loadCompanyModel(pm, "org/apache/jdo/tck/query/company.xml= "); + runTest(pm, reader); + } + finally { + cleanupCompanyModel(pm); + pm.close(); + pm =3D null; + } + } + =20 + /** */ + void runTest(PersistenceManager pm, CompanyModelReader reader) { + Query q; + Object result; + Collection expected; + =20 + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + + // string literal + string literal=20 + q =3D pm.newQuery(Employee.class); + q.setFilter("firstname =3D=3D \"emp1\" + \"First\""); + result =3D q.execute(); + expected =3D new HashSet(); + expected.add(reader.getFullTimeEmployee("emp1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected); + =20 + // string field + string literal=20 + q =3D pm.newQuery(Employee.class); + q.declareParameters("String param"); + q.setFilter("firstname + \"Ext\" =3D=3D param"); + result =3D q.execute("emp1FirstExt"); + expected =3D new HashSet(); + expected.add(reader.getFullTimeEmployee("emp1")); + checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected); + =20 + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/UnaryPlus.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/UnaryPlus.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/query/operators/= UnaryPlus.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= UnaryPlus.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,93 @@ +/* + * 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.query.operators; + +import java.util.Collection; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Unary Addition Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-25. + *
+ *Assertion Description: +The unary addition operator (+) is supported for all types as= they +are defined in the Java language. This includes the following types: +
    +
  • byte, short, int, long, char, Byte, Short Integer, Long, Charact= er
  • +
  • float, double, Float, Double
  • +
  • BigDecimal, BigInteger
  • +
+The operation on object-valued fields of wrapper types (Boolean, Byt= e, +Short, Integer, Long, Float, and Double), and numeric = types +(BigDecimal and BigInteger) use the wrapped values as operand= s=2E + + */ + +public class UnaryPlus extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-25 (UnaryPlus) 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(UnaryPlus.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + + try { + loadPrimitiveTypes(pm); + runTestBinaryAddition(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + + /** */ + void runTestBinaryAddition(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting test BinaryAddition() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + =20 + Collection instance9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 9").execute(); + =20 + runSimplePrimitiveTypesQuery("+id =3D=3D 9",=20 + pm, instance9, ASSERTION_FAILED); + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= AfterCompletionMethodCalledWhenCommitted.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenCommitted.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/transactions/Aft= erCompletionMethodCalledWhenCommitted.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Aft= erCompletionMethodCalledWhenCommitted.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. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import javax.transaction.Status; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: After Completion Method Called When Committed + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.3-6. + *
+ *Assertion Description: +The afterCompletionmethod of the Synchronization instance registered with = a Transaction +will be called during the behavior specified for the transaction completio= n method commit with a value of +Status.STATUS_COMMITTE + */ + + + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/11/01 1.0 + */ +public class AfterCompletionMethodCalledWhenCommitted=20 + extends JDO_Test=20 + implements Synchronization { + =20 + private boolean afterCompletionCalled; + private Transaction tx; + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.3-6 (AfterCompletionMethodCalledWhenCommitted) 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(AfterCompletionMethodCalledWhenCommitted.class= ); + } =20 + =20 + /** */ + public void test() { + pm =3D getPM(); + + runTestAfterCompletionMethodCalledWhenCommitted(pm);=20 + + pm.close();=20 + pm =3D null; + } + + /** */ + public void beforeCompletion() { + try { + if (debug)=20 + logger.debug("before Complition isActive returns" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected= exception: " + ex); + } =20 + } + + /** */ + public void afterCompletion(int status) { + if (status =3D=3D javax.transaction.Status.STATUS_COMMITTED) { + afterCompletionCalled =3D true; + } + else {=20 + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " +=20 + Status.STATUS_COMMITTED + ", got " + status); + } + } +=20 + /** test transactions.setSynchronization() */ + void runTestAfterCompletionMethodCalledWhenCommitted(PersistenceManage= r pm) { + tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + =20 + tx.setSynchronization(this); + afterCompletionCalled =3D false ;=20 + tx.commit(); + tx =3D null; + + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke afterCompletion method"); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= AfterCompletionMethodCalledWhenRolledback.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/AfterCompletionMethodCalledWhenRolledback.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/transactions/Aft= erCompletionMethodCalledWhenRolledback.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Aft= erCompletionMethodCalledWhenRolledback.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. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import javax.transaction.Status; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: After Completion Method Called When Rolledback + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.3-7. + *
+ *Assertion Description: + * The afterCompletion method of the Synchronization instance registered w= ith a=20 + * Transaction will be called after the behavior specified for the method + * rollback with a value of Status.STATUS_ROLLEDBACK.=20 + */ + + + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/11/01 1.0 + */ +public class AfterCompletionMethodCalledWhenRolledback=20 + extends JDO_Test=20 + implements Synchronization { + =20 + private boolean afterCompletionCalled; + private Transaction tx; + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.3-7 (AfterCompletionMethodCalledWhenRolledback) f= ailed: "; + =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(AfterCompletionMethodCalledWhenRolledback.clas= s); + } =20 + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestAfterCompletionMethodCalledWhenRolledback(pm);=20 + + pm.close();=20 + pm =3D null; + } + + /** */ + public void beforeCompletion() { + try { + if (debug)=20 + logger.debug("before Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected= exception: " + ex); + } =20 + } + + /** */ + public void afterCompletion(int status) { + if (status =3D=3D javax.transaction.Status.STATUS_ROLLEDBACK) { + afterCompletionCalled =3D true; + } + else {=20 + fail(ASSERTION_FAILED,=20 + "afterCompletion: incorrect status, expected " +=20 + Status.STATUS_ROLLEDBACK + ", got " + status); + } + } + + /** test transactions.setSynchronization() */ + void runTestAfterCompletionMethodCalledWhenRolledback(PersistenceManag= er pm) { + tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + =20 + tx.setSynchronization(this); + afterCompletionCalled =3D false ;=20 + tx.rollback(); + tx =3D null; + + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "rollback didn't invoke afterCompletion method"); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= BeforeCompletionMethodCalled.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/BeforeCompletionMethodCalled.java?view=3Dauto&r= ev=3D158179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Bef= oreCompletionMethodCalled.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Bef= oreCompletionMethodCalled.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,119 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import javax.transaction.Status; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Before Completion Method Called=20 + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.3-4. + *
+ *Assertion Description: +The beforeCompletion method of the +Synchronization instance registered with a Transaction will be +called during the behavior specified for the transaction completion +method commit.=20 + + */ + + + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/15/01 1.0 + */ +public class BeforeCompletionMethodCalled=20 + extends JDO_Test=20 + implements Synchronization { + + private boolean beforeCompletionCalled; + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.3-4 (BeforeCompletionMethodCalled) 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(BeforeCompletionMethodCalled.class); + } =20 + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestBeforeCompletionMethodCalled(pm);=20 + + pm.close(); + pm =3D null; + } + + /** */ + public void beforeCompletion(){ + beforeCompletionCalled =3D true; + if (debug) logger.debug ("beforeCompletion called "); + } + =20 + /** */ + public void afterCompletion(int status) { + if (status !=3D javax.transaction.Status.STATUS_COMMITTED) { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " +=20 + Status.STATUS_COMMITTED + ", got " + status); + } + } + =20 + /** test transactions.setSynchronization() */ + void runTestBeforeCompletionMethodCalled(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + =20 + tx.setSynchronization(this); + beforeCompletionCalled =3D false ;=20 + tx.commit(); + tx =3D null; + + if (!beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke beforeCompletion method"); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= BeforeCompletionMethodNotCalledBeforeRollback.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/BeforeCompletionMethodNotCalledBeforeRollback.j= ava?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/transactions/Bef= oreCompletionMethodNotCalledBeforeRollback.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Bef= oreCompletionMethodNotCalledBeforeRollback.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,114 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import javax.transaction.Status; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Before Completion Method Not Called Before Rolledback + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.3-5. + *
+ *Assertion Description: + The beforeCompletion method of the Synchronization instance registered wi= th a Transaction will not be +called before rollback.=20 + + */ + + + /* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/15/01 1.0 + */ +public class BeforeCompletionMethodNotCalledBeforeRollback=20 + extends JDO_Test=20 + implements Synchronization { + =20 + private boolean beforeCompletionCalled; + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.3-5 (BeforeCompletionMethodNotCalledBeforeRollbac= k) 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(BeforeCompletionMethodNotCalledBeforeRollback.= class); + } =20 + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestBeforeCompletionMethodNotCalledBeforeRollback(pm);=20 + + pm.close();=20 + pm =3D null; + } + + /** */ + public void beforeCompletion() { + beforeCompletionCalled =3D true ; + } + + /** */ + public void afterCompletion(int status) { + if (status !=3D javax.transaction.Status.STATUS_ROLLEDBACK) { + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " +=20 + Status.STATUS_ROLLEDBACK + ", got " + status); + } + } + + /** test transactions.rollback() */ + void runTestBeforeCompletionMethodNotCalledBeforeRollback(PersistenceM= anager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + =20 + tx.setSynchronization(this); + beforeCompletionCalled =3D false ;=20 + tx.rollback(); + tx =3D null; + =20 + if (beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "rollback invoked beforeCompletion, but it should not= ."); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= Commit.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/Commit.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/transactions/Com= mit.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Com= mit.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,143 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import javax.transaction.Status; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Commit + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.4-1. + *
+ *Assertion Description: + The commit method performs the following operations: +
    +
  • calls the beforeCompletion method of the + Synchronization instance registered with the + Transaction;
  • +
  • flushes dirty persistent instances;
  • +
  • notifies the underlying data store to commit the transaction + (this cannot be tested)
  • +
  • transitions persistent instances according to the life cycle specific= ation;
  • +
  • calls the afterCompletion method of the Synchroniz= ation + instance registered with the Transaction with the results of= the + data store commit operation.
  • +
+ */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/15/01 1.0 + */ +public class Commit extends JDO_Test implements Synchronization { + =20 + private boolean beforeCompletionCalled; + private boolean afterCompletionCalled; + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.4-1 (Commit) 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(Commit.class); + } =20 + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestCommit(pm);=20 + + pm.close(); + pm =3D null; + } + + /** */ + public void beforeCompletion(){ + beforeCompletionCalled =3D true; + if (debug) logger.debug("beforeCompletion called "); + } + =20 + /** */ + public void afterCompletion(int status) { + if (status =3D=3D Status.STATUS_COMMITTED) { + afterCompletionCalled =3D true; + if (debug) logger.debug("afterCompletion called\n "); + } + else {=20 + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " +=20 + Status.STATUS_COMMITTED + ", got " + status); + } + } + + /** test transactions.setSynchronization() */ + void runTestCommit(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + if (!JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "P-NEW instance expected to be dirty, JDOHelper.isDir= ty returns false."); + } + =20 + tx.setSynchronization(this); + beforeCompletionCalled =3D false;=20 + afterCompletionCalled =3D false;=20 + tx.commit(); + tx =3D null; + =20 + if (JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "P-NEW instance should transition to HOLLOW or P-NONT= X and then it should not be dirty, JDOHelper.isDirty returns true."); + } + if (!beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke beforeCompletion method"); + } + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke afterCompletion method"); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= GetOptimistic.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/GetOptimistic.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/transactions/Get= Optimistic.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Get= Optimistic.java Fri Mar 18 17:07:39 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. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.PersistenceManagerFactory; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.query.BoundParameterCheck; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Get Optimistic + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.1-2. + *
+ *Assertion Description: + The transactions.getOptimistic method=20 + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/09/01 1.0 + */ +public class GetOptimistic extends JDO_Test { + private PersistenceManagerFactory pmf; + private PersistenceManager pm; + private PersistenceManager pm1; + private Transaction transaction; + private boolean flag; + private boolean flag2; + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.1-2 (BoundParameterCheck) 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(BoundParameterCheck.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestGetOptimistic(pm); + + pm.close();=20 + pm =3D null; + } + + /** test transactions.getOptimistic() */ + public void runTestGetOptimistic(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + if (isOptimisticSupported()) { + tx.setOptimistic(true); + tx.begin(); + if (!tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns false after setting t= he flag to true."); + } + tx.commit(); + if (!tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns false after setting t= he flag to true."); + } + } + =20 + tx.setOptimistic(false); + tx.begin(); + if (tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns true after setting the fl= ag to false."); + } + tx.commit(); + if (tx.getOptimistic()) { + fail(ASSERTION_FAILED, + "tx.getOptimistic() returns true after setting the fl= ag to false."); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= GetPersistenceManager.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/GetPersistenceManager.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/transactions/Get= PersistenceManager.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Get= PersistenceManager.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,92 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +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 Persistence Manager + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.1-1. + *
+ *Assertion Description: + The transactions.getPersistenceManager method returns associated persiste= nce manager=20 + if the object parameter ia not null and implements persistenceCapable. + evaluating to true when =3D=3D is used.=20 + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 9/26/01 1.0 + */ +public class GetPersistenceManager extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.1-1 (GetPersistenceManager) 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(GetPersistenceManager.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestGetPersistenceManager(pm); + + pm.close();=20 + pm =3D null; + } + =20 + /** test transactions.getPersistenceManager() */ + void runTestGetPersistenceManager(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + PersistenceManager pm1 =3D tx.getPersistenceManager(); + tx.commit(); + tx =3D null; + + if (pm1 !=3D pm) + fail(ASSERTION_FAILED, + "tx.getPersistenceManager() returned unexpected pm, e= xpected " + pm + ", got " + pm1); + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= GetRetainValues.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/GetRetainValues.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/transactions/Get= RetainValues.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Get= RetainValues.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,103 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Get Retain Values + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.2-17. + *
+ *Assertion Description: + Transaction.getRetainValues returns the currently active setting for the=20 + RetainValues flag. + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/09/01 1.0 + */ +public class GetRetainValues extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.2-17 (GetRetainValues) 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(GetRetainValues.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestGetRetainValues(pm); =20 + + pm.close();=20 + pm =3D null; + } + + /** test transaction.getRetainValues()*/ + public void runTestGetRetainValues(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.setRetainValues(true); + tx.begin(); + if (!tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns false after setting the f= lag to true."); + } + tx.commit(); + if (!tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns false after setting the f= lag to true."); + } + =20 + tx.setRetainValues(false); + tx.begin(); + if (tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns true after setting the fl= ag to false."); + } + tx.commit(); + if (tx.getRetainValues()) { + fail(ASSERTION_FAILED, + "tx.getRetainValues returns true after setting the fl= ag to false."); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= GetSynchronization.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/GetSynchronization.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/transactions/Get= Synchronization.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Get= Synchronization.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,126 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Get Synchronization + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.3-8. + *
+ *Assertion Description: + A call to Transaction.getSynchronization + retrieves the Synchronization instance that has been registered via + setSynchronization.=20 + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/11/01 1.0 + */ +public class GetSynchronization=20 + extends JDO_Test=20 + implements Synchronization { + =20 + private Transaction tx; + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.3-8 (GetSynchronization) 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(GetSynchronization.class); + } + + /** */ + public void beforeCompletion(){ + try { + if (debug)=20 + logger.debug("before Complition isActive returns :" + + tx.isActive()); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected= exception: " + ex); + } + } + + /** */ + public void afterCompletion(int status) { + try { + if (debug)=20 + logger.debug("after Complition isActive returns :" + + tx.isActive());=20 + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in afterCompletion throws unexpected = exception: " + ex); + } + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestGetSynchronization(pm);=20 + + pm.close();=20 + pm =3D null; + } + + /** test transactions.getSynchronization() */ + void runTestGetSynchronization(PersistenceManager pm) { + tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + =20 + tx.setSynchronization(this); + Synchronization s =3D tx.getSynchronization(); + if (s !=3D this) { + fail(ASSERTION_FAILED, + "wrong synchronization instance, expected " + this + = ", got " + s); + } + =20 + tx.commit(); + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= IsActive.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/IsActive.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/transactions/IsA= ctive.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/IsA= ctive.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,101 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Is Active + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.1-2. + *
+ *Assertion Description: + The transactions.isActive method tells whether there is an active=20 + transaction. There will be an active transaction if the begin method + has been executed but neither commit nor rollback has been executed. + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/09/01 1.0 + */ +public class IsActive extends JDO_Test { + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.1-2 (IsActive) 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(IsActive.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestIsActive(pm); + + pm.close();=20 + pm =3D null; + } + + /** test transactions.isActive() */ + void runTestIsActive(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + if (!tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns false after tx.begin"); + } + tx.commit(); + =20 + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true after tx.commit"); + } + + tx.begin(); + tx.rollback(); + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true after tx.rollback"); + } + =20 + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= IsActiveUntilAfterCompletionMethodCalled.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/IsActiveUntilAfterCompletionMethodCalled.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/transactions/IsA= ctiveUntilAfterCompletionMethodCalled.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/IsA= ctiveUntilAfterCompletionMethodCalled.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. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Is Active Until After Completion Method Called + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.1-3. + *
+ *Assertion Description: + Transaction.isActive returns true after the transaction has been started,= until the afterCompletion + synchronization method is called + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/09/01 1.0 + */ +public class IsActiveUntilAfterCompletionMethodCalled=20 + extends JDO_Test=20 + implements Synchronization { + =20 + private Transaction tx; + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.1-3 (IsActiveUntilAfterCompletionMethodCalled) 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(IsActiveUntilAfterCompletionMethodCalled.class= ); + } + + /** */ + public void beforeCompletion() { + try { + if (!tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns false in beforeCompletion."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in beforeCompletion throws unexpected= exception: " + ex); + } + } + + /** */ + public void afterCompletion(int status) { + try { + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true in afterCompletion."); + } + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.isActive called in afterCompletion throws unexpected = exception: " + ex); + } + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestIsActiveUntilAfterCompletionMethodCalled(pm); +=20 + pm.close();=20 + pm =3D null; + } + =20 + /** test transactions.isActive() */ + void runTestIsActiveUntilAfterCompletionMethodCalled(PersistenceManage= r pm) { + tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + tx.setSynchronization(this); + if (!tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns false after tx.begin before tx.c= ommit is completed."); + } + =20 + tx.commit(); + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "tx.isActive returns true after tx.commit."); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= Rollback.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/Rollback.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/transactions/Rol= lback.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Rol= lback.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,154 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.JDOHelper; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import javax.transaction.Status; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.PCPoint; +import org.apache.jdo.tck.query.BoundParameterCheck; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Rollback + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.4-2. + *
+ *Assertion Description: + The commit method performs the following operations: +
    +
  • transitions persistent instances + according to the life cycle specification;
  • +
  • rolls back changes made in this transaction from the data store;
  • +
  • calls the afterCompletion method of the + Synchronization instance registered with the + Transaction.
  • +
+ + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/17/01 1.0 + */ +public class Rollback=20 + extends JDO_Test=20 + implements Synchronization { + =20 + private boolean beforeCompletionCalled; + private boolean afterCompletionCalled; + =20 + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.4-2 (BoundParameterCheck) 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(BoundParameterCheck.class); + } + =20 + /** */ + public void beforeCompletion(){ + beforeCompletionCalled =3D true; + if (debug) logger.debug ("beforeCompletion called "); + } + =20 + /** */ + public void afterCompletion(int status) { + if (status =3D=3D javax.transaction.Status.STATUS_ROLLEDBACK) { + afterCompletionCalled =3D true; + if (debug) logger.debug("afterCompletion called\n "); + } + else {=20 + fail(ASSERTION_FAILED, + "afterCompletion: incorrect status, expected " +=20 + Status.STATUS_ROLLEDBACK + ", got " + status); + } + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestRollback(pm); + + pm.close();=20 + pm =3D null; + } + =20 + /** test transactions.setSynchronization() */ + void runTestRollback(PersistenceManager pm) { + Transaction tx =3D pm.currentTransaction(); + try { + tx.begin(); + PCPoint p1 =3D new PCPoint(1,3); + pm.makePersistent(p1); + tx.commit(); + =20 + tx.begin(); + p1.setX(55); + =20 + if (!JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "JDOHelper.isDirty returns false when called for dirt= y instance."); + } + =20 + tx.setSynchronization(this); + beforeCompletionCalled =3D false;=20 + afterCompletionCalled =3D false ;=20 + tx.rollback();=20 + =20 + if (JDOHelper.isDirty(p1)) { + fail(ASSERTION_FAILED, + "P-NEW instance should transition to HOLLOW or P-NONT= X and then it should not be dirty, JDOHelper.isDirty returns true."); + } + int x =3D p1.getX(); + if (x !=3D 1) { + fail(ASSERTION_FAILED, + "tx.rollback should rollback change of ip1.x, expecte= d 1, got " + x); + } + =20 + if (beforeCompletionCalled) { + fail(ASSERTION_FAILED, + "rollback did invoke beforeCompletion method."); + } + if (!afterCompletionCalled) { + fail(ASSERTION_FAILED, + "commit didn't invoke afterCompletion method."); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= SetNontransactionalRead.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/SetNontransactionalRead.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/transactions/Set= NontransactionalRead.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Set= NontransactionalRead.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,155 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import java.util.Collection; +import java.util.Date; +import java.util.Iterator; + +import javax.jdo.PersistenceManager; +import javax.jdo.Query; +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.util.BatchTestRunner; + + +/** + *Title: Set Nontransactional Read + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.2-9. + *
+ *Assertion Description: + If an implementation supports nontransactional read, then a call to + Transaction.setNontransactionalRead with a parameter value of + true will set the flag to true and allows persi= stent + instances to be read outside of a transaction. + Queries and navigation will be allowed without an active transaction. + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/18/01 1.0 + */ +public class SetNontransactionalRead extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.2-9 (SetNontransactionalRead) 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(SetNontransactionalRead.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetNontransactionalRead(pm); + + pm.close();=20 + pm =3D null; + } + + /** test transactions.setNonteansactionalRead() */ + public void runTestSetNontransactionalRead(PersistenceManager pm) { + if (!isNontransactionalReadSupported()) { + if (debug) + logger.debug("Implementation does not support non transact= ional read"); + return; + } + =20 + Transaction tx =3D pm.currentTransaction(); + try { + tx.setNontransactionalRead(true); + tx.begin(); + Company c =3D new Company(1L, "MyCompany", new Date(), null); + Department d =3D new Department(999, "MyDepartment", c); + pm.makePersistent(c); + pm.makePersistent(d); + Object oid =3D pm.getObjectId(d); + if (!tx.getNontransactionalRead()) { + fail(ASSERTION_FAILED, + "tx.getNontransactionalRead returns false after setti= ng the flag to true."); + } + tx.commit(); + if (!tx.getNontransactionalRead()) { + fail(ASSERTION_FAILED, + "tx.getNontransactionalRead returns false after setti= ng the flag to true."); + } + + // make sure transaction is not active + if (tx.isActive()) { + fail(ASSERTION_FAILED, + "transaction still active after tx.commit."); + } + tx =3D null; + + // read department + d =3D (Department)pm.getObjectById(oid, true); + long deptid =3D d.getDeptid(); + if (deptid !=3D 999) { + fail("Reading department outside of a transaction returns = unexpected value of d.deptid, expected 999, got " + deptid); + } + + // navigate from department to company + c =3D d.getCompany(); + if (c =3D=3D null) { + fail("Navigating from department to company outside of a = transaction returns null."); + } + String companyName =3D c.getName(); + if (!"MyCompany".equals(companyName)) { + fail("Navigated company returns unexpected value of c.name= , expected MyCompany, got " + companyName); + } + + // run query + Query q =3D pm.newQuery(Department.class); + q.setFilter("name =3D=3D \"MyDepartment\""); + Collection result =3D (Collection)q.execute(); + Iterator i =3D result.iterator(); + if (!i.hasNext()) { + fail(ASSERTION_FAILED, + "Query outside of a transaction returned empty collec= tion."); + } + d =3D (Department)i.next(); + String deptName =3D d.getName(); + if (!"MyDepartment".equals(deptName)) { + fail("Department in query result returns unexpected value = of d.name, expected MyDepartment, got " + deptName); + } + if (i.hasNext()) { + fail(ASSERTION_FAILED, + "Query outside of a transaction returns more than one= instance."); + } + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= SetNontransactionalReadCalledDuringTxCompletion.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/SetNontransactionalReadCalledDuringTxCompletion= .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/transactions/Set= NontransactionalReadCalledDuringTxCompletion.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Set= NontransactionalReadCalledDuringTxCompletion.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,144 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.JDOUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Set Nontransactional Read Called During TX Completion + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.2-1. + *
+ *Assertion Description: + If the setNontransactionalRead method of the Transaction interface is + called during commit or rollback processing (within the beforeCompletion = and afterCompletion + synchronization methods), a JDOUserException is thrown.=20 + + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/18/01 1.0 + */ +public class SetNontransactionalReadCalledDuringTxCompletion=20 + extends JDO_Test=20 + implements Synchronization { + + private Transaction tx; + =20 + private boolean nonTransactionalReadFlag; + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.2-1 (SetNontransactionalReadCalledDuringTxComplet= ion) 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(SetNontransactionalReadCalledDuringTxCompletio= n=2Eclass); + } + =20 + /** */ + public void beforeCompletion() { + if (debug) logger.debug("beforeCompletion."); + try { + tx.setNontransactionalRead(nonTransactionalReadFlag); + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead called in beforeCompletion sh= ould throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("caught expected exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead called in beforeCompletion th= rows unexpected exception: " + ex); + } + } + =20 + /** */ + public void afterCompletion(int status) { + if (debug) logger.debug("afterCompletion."); + try { + tx.setNontransactionalRead(nonTransactionalReadFlag); + } + catch (JDOUserException ex) { + // TBD: need to remove this catch block as soon as the JDORI is + // fixed see 'Issue 61: Transaction.isActive issues' + if (debug) logger.debug("caught exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead called in afterCompletion thr= ows unexpected exception: " + ex); + } + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetNontransactionalReadCalledDuringTxCompletion(pm); + =20 + pm.close();=20 + pm =3D null; + } + =20 + /** test transactions.setNonteansactionalRead() */ + public void runTestSetNontransactionalReadCalledDuringTxCompletion(Per= sistenceManager pm) { + /** + if (!isNontransactionalReadSupported()) { + if (verbose) println("Implementation does not support non tran= sactional read"); + return; + } + */ + tx =3D pm.currentTransaction(); + try { + tx.setSynchronization(this); =20 + =20 + nonTransactionalReadFlag =3D false; + tx.begin(); + tx.commit(); + + if (isNontransactionalReadSupported()) { + nonTransactionalReadFlag =3D true; + tx.begin(); + tx.commit(); + } + =20 + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= SetNontransactionalReadTrueWhenNotSupported.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/SetNontransactionalReadTrueWhenNotSupported.jav= a?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/transactions/Set= NontransactionalReadTrueWhenNotSupported.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Set= NontransactionalReadTrueWhenNotSupported.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,94 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.JDOUnsupportedOptionException; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Set Nontransactional Read True When Not Supported + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.2-5. + *
+ *Assertion Description: + If an implementation does not support nontransactional read, then a + call to Transaction.setNontransactionalRead with a parameter value of tru= e will + * cause a JDOUnsupportedOptionException to be thrown. + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/18/01 1.0 + */ +public class SetNontransactionalReadTrueWhenNotSupported extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.2-5 (SetNontransactionalReadTrueWhenNotSupported)= 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(SetNontransactionalReadTrueWhenNotSupported.cl= ass); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetNontransactionalReadTrueWhenNotSupported(pm); =20 + + pm.close();=20 + pm =3D null; + } + =20 + /* test transactions.setNonteansactionalRead() + * =20 + */ + public void runTestSetNontransactionalReadTrueWhenNotSupported( + PersistenceManager pm) { + if (isNontransactionalReadSupported()) { + if (debug) + logger.debug("Implementation does support non transactiona= l read."); + return; + } + + Transaction tx =3D pm.currentTransaction(); + try { + tx.setNontransactionalRead(true); + fail(ASSERTION_FAILED, + "tx.setNontransactionalRead(true) should throw JDOUnsuppo= rtedOptionException, if the implementation does not support non transaction= al read."); + } + catch (JDOUnsupportedOptionException ex) { + // expected excepted + if (debug) logger.debug("caught expected exception " + ex); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= SetNontransactionalWriteCalledDuringTxCompletion.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/SetNontransactionalWriteCalledDuringTxCompletio= n=2Ejava?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/transactions/Set= NontransactionalWriteCalledDuringTxCompletion.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Set= NontransactionalWriteCalledDuringTxCompletion.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. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.JDOUserException; +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; +import javax.transaction.Synchronization; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Set Nontransactional Write Called During TX Completion + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.2-1. + *
+ *Assertion Description: + If the setNontransactionalWrite method of the Transaction interface is + called during commit or rollback processing (within the beforeCompletion + and afterCompletion synchronization methods), a JDOUserException is throw= n=2E=20 + + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/18/01 1.0 + */ +public class SetNontransactionalWriteCalledDuringTxCompletion=20 + extends JDO_Test=20 + implements Synchronization { + + private Transaction tx; + =20 + private boolean nonTransactionalWriteFlag; + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.2-2 (SetNontransactionalWriteCalledDuringTxComple= tion) 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(SetNontransactionalWriteCalledDuringTxCompleti= on.class); + } + =20 + /** */ + public void beforeCompletion() { + if (debug) logger.debug("beforeCompletion."); + try { + tx.setNontransactionalWrite(nonTransactionalWriteFlag); + fail(ASSERTION_FAILED, + "tx.setNontransactionalWrite called in beforeCompletion s= hould throw JDOUserException."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) logger.debug("Caught expected exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalWrite called in beforeCompletion t= hrows unexpected exception: " + ex); + } + } + =20 + /** */ + public void afterCompletion(int status) { + if (debug) logger.debug("afterCompletion."); + try { + tx.setNontransactionalWrite(nonTransactionalWriteFlag); + } + catch (JDOUserException ex) { + // TBD: need to remove this catch block as soon as the JDORI is + // fixed see 'Issue 61: Transaction.isActive issues' + if (debug) logger.debug("caught exception " + ex); + } + catch (Exception ex) { + fail(ASSERTION_FAILED, + "tx.setNontransactionalWrite called in afterCompletion th= rows unexpected exception: " + ex); + } + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetNontransactionalWriteCalledDuringTxCompletion(pm); + =20 + pm.close();=20 + pm =3D null; + } + =20 + /** test transactions.setNonteansactionalWrite() */ + public void runTestSetNontransactionalWriteCalledDuringTxCompletion(Pe= rsistenceManager pm) { + tx =3D pm.currentTransaction(); + try { + tx.setSynchronization(this); =20 + =20 + nonTransactionalWriteFlag =3D false; + tx.begin(); + tx.commit(); + + if (isNontransactionalWriteSupported()) { + nonTransactionalWriteFlag =3D true; + tx.begin(); + tx.commit(); + } + else if (debug) + logger.debug("Implementation does not support nontransaction= al write"); + =20 + tx =3D null; + } + finally { + if ((tx !=3D null) && tx.isActive()) + tx.rollback(); + } + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/= SetOptimistic.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/transactions/SetOptimistic.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/transactions/Set= Optimistic.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/transactions/Set= Optimistic.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,90 @@ +/* + * Copyright 2005 The Apache Software Foundation. + *=20 + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at=20 + *=20 + * http://www.apache.org/licenses/LICENSE-2.0 + *=20 + * Unless required by applicable law or agreed to in writing, software=20 + * distributed under the License is distributed on an "AS IS" BASIS,=20 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied= .=20 + * See the License for the specific language governing permissions and=20 + * limitations under the License. + */ +=20 +package org.apache.jdo.tck.transactions; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.util.BatchTestRunner; + + +/** + *Title: Set Optimistic + *
+ *Keywords: transactions + *
+ *Assertion ID: A13.4.2-14. + *
+ *Assertion Description: + A call to Transaction.setOptimistic causes the optimistic setting passed = to replace the optimistic setting + currently active, if the Optimistic optional feature is supported.=20 + + */ + + +/* + * Revision History + * =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + * Author : Date : Version =20 + * Azita Kamangar 10/09/01 1.0 + */ +public class SetOptimistic extends JDO_Test { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A13.4.2-14 (SetOptimistic) 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(SetOptimistic.class); + } + + /** */ + public void test() { + pm =3D getPM(); + =20 + runTestSetOptimistic(pm); =20 + + pm.close();=20 + pm =3D null; + } + + /** */ + void runTestSetOptimistic(PersistenceManager pm) { + if (!isOptimisticSupported()) { + if (debug) logger.debug("Optimistic not supported."); + return; + } + =20 + Transaction tx =3D pm.currentTransaction(); + boolean orig =3D tx.getOptimistic(); + tx.setOptimistic(!orig); + if (tx.getOptimistic() =3D=3D orig) { + fail(ASSERTION_FAILED, + "changing the optimistic flag by calling tx.setOptimistic= does not have a effect."); + } + if ((tx !=3D null) && tx.isActive()) { + tx.rollback(); + } + } +} +