Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 92482 invoked from network); 19 Mar 2005 05:35:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 19 Mar 2005 05:35:34 -0000 Received: (qmail 8336 invoked by uid 500); 19 Mar 2005 05:35:34 -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 88161 invoked by uid 99); 19 Mar 2005 01:09:56 -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: <20050319010952.29631.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:52 -0000 Subject: svn commit: r158179 [40/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/BooleanLogicalAND.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/BooleanLogicalAND.java?view=3Dauto&rev=3D158= 179 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/= BooleanLogicalAND.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= BooleanLogicalAND.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,174 @@ +/* + * 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.JDOUserException; +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.mylib.PrimitiveTypes; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Boolean Logical AND Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-20. + *
+ *Assertion Description: +The Boolean logical AND (not bitwise) operator (&) is sup= ported +for all types as they are defined in the Java language. +This includes the following types: +
    +
  • Boolean, boolean
  • +
+ */ + +public class BooleanLogicalAND extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-20 (BooleanLogicalAND) 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(BooleanLogicalAND.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + try { + loadPrimitiveTypes(pm); + runPositiveTest(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + + /** */ + public void testBitwiseAND() { + pm =3D getPM(); + =20 + runNegativeTest(pm); + =20 + pm.close(); + pm =3D null; + } + =20 + /** */ + void runPositiveTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting positive test BooleanLogicalA= ND() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + + Collection instance9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 9").execute(); + Collection allOddInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty =3D new HashSet(); + =20 + // case true & true + runSimplePrimitiveTypesQuery("true & true",=20 + pm, allInstances, ASSERTION_FAILED); + + // case true & false + runSimplePrimitiveTypesQuery("true & false",=20 + pm, empty, ASSERTION_FAILED); + + // case false & true + runSimplePrimitiveTypesQuery("false & true",=20 + pm, empty, ASSERTION_FAILED); + + // case false & false + runSimplePrimitiveTypesQuery("false & false",=20 + pm, empty, ASSERTION_FAILED); + + // case boolean & boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 & booleanNotNull= ",=20 + pm, instance9, ASSERTION_FAILED); + + // case boolean & Boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 & booleanNull",=20 + pm, instance9, ASSERTION_FAILED); + // case Boolean & boolean + runSimplePrimitiveTypesQuery("booleanNull & intNotNull =3D=3D 9",=20 + pm, instance9, ASSERTION_FAILED); + // case Boolean & Boolean + runSimplePrimitiveTypesQuery("booleanNull & booleanNull",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param & id =3D=3D 9",=20 + "Boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param & id =3D=3D 9",=20 + "Boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param & id =3D=3D 9",=20 + "boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param & id =3D=3D 9",=20 + "boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + tx.commit(); + } + + /** */ + void runNegativeTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting positive test BooleanLogicalA= ND() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + =20 + try { + Query q =3D pm.newQuery(PrimitiveTypes.class,=20 + "intNotNull & intNotNull"); + Object result =3D q.execute(); + fail(ASSERTION_FAILED, + "Query uisng bitwise & operator should throw JDOUserExcep= tion."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } + tx.commit(); + } + =20 +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/BooleanLogicalOR.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/BooleanLogicalOR.java?view=3Dauto&rev=3D1581= 79 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=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/= BooleanLogicalOR.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= BooleanLogicalOR.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,178 @@ +/* + * 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.JDOUserException; +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.mylib.PrimitiveTypes; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Boolean Logical OR Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-22. + *
+ *Assertion Description: +The Boolean logical OR (not bitwise) operator (|) is supporte= d for +all types as they are defined in the Java language. +This includes the following types: +
    +
  • Boolean, boolean
  • +
+ */ + +public class BooleanLogicalOR extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-22 (BooleanLogicalOR) 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(BooleanLogicalOR.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + try { + loadPrimitiveTypes(pm); + runPositiveTest(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + =20 + /** */ + public void testBitwiseAND() { + pm =3D getPM(); + =20 + runNegativeTest(pm); + =20 + pm.close(); + pm =3D null; + } + =20 + /** */ + void runPositiveTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting positive test BooleanLogicalO= R() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + + Collection instance9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 9").execute(); + Collection instancesLess3 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id < 3").execute(); + Collection allOddInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty =3D new HashSet(); + =20 + // case true | true + runSimplePrimitiveTypesQuery("true | true",=20 + pm, allInstances, ASSERTION_FAILED); + + // case true | false + runSimplePrimitiveTypesQuery("true | false",=20 + pm, allInstances, ASSERTION_FAILED); + + // case false | true + runSimplePrimitiveTypesQuery("false | true",=20 + pm, allInstances, ASSERTION_FAILED); + + // case false | false + runSimplePrimitiveTypesQuery("false | false",=20 + pm, empty, ASSERTION_FAILED); + + // case boolean | boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 | booleanNotNull= ",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + runSimplePrimitiveTypesQuery("id =3D=3D 1 | id =3D=3D 2",=20 + pm, instancesLess3, ASSERTION_FAILED); + + // case boolean | Boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 | booleanNull",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + // case Boolean | boolean + runSimplePrimitiveTypesQuery("booleanNull | intNotNull =3D=3D 9",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + // case Boolean | Boolean + runSimplePrimitiveTypesQuery("booleanNull | booleanNull",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param | id =3D=3D 9",=20 + "Boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED= ); + runParameterPrimitiveTypesQuery("param | id =3D=3D 9",=20 + "Boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param | id =3D=3D 9",=20 + "boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED= ); + runParameterPrimitiveTypesQuery("param | id =3D=3D 9",=20 + "boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + tx.commit(); + } + + /** */ + void runNegativeTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting positive test BooleanLogicalA= ND() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + =20 + try { + Query q =3D pm.newQuery(PrimitiveTypes.class,=20 + "intNotNull | intNotNull"); + Object result =3D q.execute(); + fail(ASSERTION_FAILED, + "Query uisng bitwise | operator should throw JDOUserExcep= tion."); + } + catch (JDOUserException ex) { + // expected exception + if (debug) { + logger.debug("expected exception: " + ex); + } + } + tx.commit(); + } + =20 +} + Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/ComparisonTests.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/ComparisonTests.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/= ComparisonTests.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= ComparisonTests.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.query.operators; + +import java.util.Collection; +import java.util.Iterator; + +import javax.jdo.Extent; +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.fieldtypes.AllTypes; + +public abstract class ComparisonTests extends JDO_Test { =20 + protected PersistenceManager pm; + protected Query query; + protected Transaction tx; + protected Collection query_result; + =20 + protected static String BooleanParameter =3D "Boolean value"; + protected static String booleanParameter =3D "boolean value"; + protected static String ByteParameter =3D "Byte value"; + protected static String byteParameter =3D "byte value"; + protected static String CharacterParameter =3D "Character valu= e"; + protected static String charParameter =3D "char value"; + protected static String DoubleParameter =3D "Double value"; + protected static String doubleParameter =3D "double value"; + protected static String FloatParameter =3D "Float value"; + protected static String floatParameter =3D "float value"; + protected static String IntegerParameter =3D "Integer value"; + protected static String intParameter =3D "int value"; + protected static String LongParameter =3D "Long value"; + protected static String longParameter =3D "long value"; + protected static String ShortParameter =3D "Short value"; + protected static String shortParameter =3D "short value"; + protected static String StringParameter =3D "String value"; + protected static String LocaleParameter =3D "java.util.Locale = value"; + protected static String BigDecimalParameter =3D "java.math.Big= Decimal value"; + protected static String BigIntegerParameter =3D "java.math.Big= Integer value"; + protected static String DateParameter =3D "java.util.Date valu= e"; + protected static String AllTypesParameter =3D "org.apache.jdo.= tck.pc.fieldtypes.AllTypes value"; + =20 + /** */ + protected void verifyDataLoaded(PersistenceManager pm) + { + Transaction tx =3D pm.currentTransaction(); + int cnt =3D 0; + try { + tx.begin(); + Extent e =3D pm.getExtent(AllTypes.class, false); + Iterator i =3D e.iterator(); + while(i.hasNext()){ + Object o =3D i.next(); + cnt++; + } + e.close(i); + tx.rollback(); + =20 + if (cnt =3D=3D AllTypes.NUM_VALUES) + return; + =20 + tx.begin(); + i =3D e.iterator(); + while (i.hasNext()) { + Object o =3D i.next(); + pm.deletePersistent(o); + } + e.close(i); + tx.commit(); + } + finally { + if ((tx !=3Dnull) && tx.isActive()) + tx.rollback(); + } + AllTypes.load(pm); + } + + + /** */ + protected void fail(String assertion, String message, String filter, S= tring parameter) + { + StringBuffer buf =3D new StringBuffer(); + buf.append(message); + buf.append("("); + buf.append(" filter \"").append(filter).append("\""); + if (parameter !=3D null) { + buf.append(" , parameter \"").append(parameter).append("\""); + } + buf.append(")"); + =20 + fail(assertion, buf.toString()); + } + =20 + /** */ + protected void runQuery(PersistenceManager pm,=20 + String filter, String parameter, Object parame= terValue,=20 + String assertion) + { + Extent e =3D pm.getExtent(AllTypes.class, false); + query =3D pm.newQuery(e, filter); + query_result =3D null; + try { + if (parameter !=3D null) { + query.declareParameters(parameter); + query_result =3D (Collection) query.execute(parameterValue= ); + }=20 + else { + query_result =3D (Collection) query.execute(); + } + }=20 + catch (Throwable throwable) { + if (debug) + throwable.printStackTrace(); + fail(assertion, "Exception on Query.execute " + throwable, fil= ter, parameter); + query_result =3D null; + if (tx.isActive())=20 + tx.rollback(); + return; + } + if (query_result =3D=3D null) { + fail(assertion, "Query.execute returned a null", filter, param= eter); + if (tx.isActive())=20 + tx.rollback(); + } + } =20 +} + Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/ConditionalAND.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/ConditionalAND.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/= ConditionalAND.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= ConditionalAND.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,139 @@ +/* + * 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.Transaction; + +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Conditional AND Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-21. + *
+ *Assertion Description: +The conditional AND operator (&&) is supported for all +types as they are defined in the Java language. +This includes the following types: +
    +
  • Boolean, boolean
  • +
+*/ + +public class ConditionalAND extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-21 (ConditionalAND) 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(ConditionalAND.class); + } + =20 + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + try { + loadPrimitiveTypes(pm); + runTest(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + =20 + /** */ + void runTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting test ConditionalAND() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + + Collection instance9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 9").execute(); + Collection allOddInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty =3D new HashSet(); + =20 + // case true && true + runSimplePrimitiveTypesQuery("true && true",=20 + pm, allInstances, ASSERTION_FAILED); + + // case true && false + runSimplePrimitiveTypesQuery("true && false",=20 + pm, empty, ASSERTION_FAILED); + + // case false && true + runSimplePrimitiveTypesQuery("false && true",=20 + pm, empty, ASSERTION_FAILED); + + // case false && false + runSimplePrimitiveTypesQuery("false && false",=20 + pm, empty, ASSERTION_FAILED); + + // case boolean && boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 && booleanNotNul= l",=20 + pm, instance9, ASSERTION_FAILED); + + // case boolean && Boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 && booleanNull",=20 + pm, instance9, ASSERTION_FAILED); + // case Boolean && boolean + runSimplePrimitiveTypesQuery("booleanNull && intNotNull =3D=3D 9",=20 + pm, instance9, ASSERTION_FAILED); + // case Boolean && Boolean + runSimplePrimitiveTypesQuery("booleanNull && booleanNull",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param && id =3D=3D 9",=20 + "Boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param && id =3D=3D 9",=20 + "Boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param && id =3D=3D 9",=20 + "boolean param", Boolean.TRUE, + pm, instance9, ASSERTION_FAILED); + runParameterPrimitiveTypesQuery("param && id =3D=3D 9",=20 + "boolean param", Boolean.FALSE, + pm, empty, ASSERTION_FAILED); + + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/ConditionalOR.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/ConditionalOR.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/= ConditionalOR.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= ConditionalOR.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,139 @@ +/* + * 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.Transaction; + +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Conditional OR Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-23. + *
+ *Assertion Description: +The conditional OR operator (||) is supported for all types +as they are defined in the Java language. This includes the following type= s: +
    +
  • Boolean, boolean
  • +
+ */ + +public class ConditionalOR extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-23 (ConditionalOR) 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(ConditionalOR.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + =20 + try { + loadPrimitiveTypes(pm); + runTest(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + =20 + /** */ + void runTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting test ConditionalOR() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + + Collection instance9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 9").execute(); + Collection instancesLess3 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id < 3").execute(); + Collection allOddInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "booleanNull").execute(); + Collection allInstances =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "true").execute(); + Collection empty =3D new HashSet(); + =20 + // case true || true + runSimplePrimitiveTypesQuery("true || true",=20 + pm, allInstances, ASSERTION_FAILED); + + // case true || false + runSimplePrimitiveTypesQuery("true || false",=20 + pm, allInstances, ASSERTION_FAILED); + + // case false || true + runSimplePrimitiveTypesQuery("false || true",=20 + pm, allInstances, ASSERTION_FAILED); + + // case false || false + runSimplePrimitiveTypesQuery("false || false",=20 + pm, empty, ASSERTION_FAILED); + + // case boolean || boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 || booleanNotNul= l",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + runSimplePrimitiveTypesQuery("id =3D=3D 1 || id =3D=3D 2",=20 + pm, instancesLess3, ASSERTION_FAILED); + + // case boolean || Boolean + runSimplePrimitiveTypesQuery("intNotNull =3D=3D 9 || booleanNull",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + // case Boolean || boolean + runSimplePrimitiveTypesQuery("booleanNull || intNotNull =3D=3D 9",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + // case Boolean || Boolean + runSimplePrimitiveTypesQuery("booleanNull || booleanNull",=20 + pm, allOddInstances, ASSERTION_FAILED= ); + + // case Boolean parameter + runParameterPrimitiveTypesQuery("param || id =3D=3D 9",=20 + "Boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED= ); + runParameterPrimitiveTypesQuery("param || id =3D=3D 9",=20 + "Boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + + // case boolean parameter + runParameterPrimitiveTypesQuery("param || id =3D=3D 9",=20 + "boolean param", Boolean.TRUE, + pm, allInstances, ASSERTION_FAILED= ); + runParameterPrimitiveTypesQuery("param || id =3D=3D 9",=20 + "boolean param", Boolean.FALSE, + pm, instance9, ASSERTION_FAILED); + tx.commit(); + } +} Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operato= rs/Division.java URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/= apache/jdo/tck/query/operators/Division.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/= Division.java (added) +++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/= Division.java Fri Mar 18 17:07:39 2005 @@ -0,0 +1,131 @@ +/* + * 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: Division Query Operator + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-31. + *
+ *Assertion Description: +The division 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 operands. + */ + +public class Division extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED =3D=20 + "Assertion A14.6.2-31 (Division) 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(Division.class); + } + =20 + /** */ + public void test() { + pm =3D getPM(); + + try { + loadPrimitiveTypes(pm); + runTest(pm); + } + finally { + cleanupDatabase(pm, PrimitiveTypes.class); + pm.close(); + pm =3D null; + } + } + + /** */ + void runTest(PersistenceManager pm) { + if (debug) logger.debug("\nExecuting test Division() ..."); + + Transaction tx =3D pm.currentTransaction(); + tx.begin(); + =20 + Collection instance8 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 8").execute(); + =20 + Collection instances8And9 =3D (Collection)pm.newQuery( + PrimitiveTypes.class, "id =3D=3D 8 || id =3D=3D 9").execute(); + =20 + runSimplePrimitiveTypesQuery("id / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("byteNotNull / 2 =3D=3D 4", + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNotNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED)= ; =20 + runSimplePrimitiveTypesQuery("intNotNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED)= ; =20 + runSimplePrimitiveTypesQuery("longNotNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + /* testing float division? + runSimplePrimitiveTypesQuery("floatNotNull / 2 =3D=3D 4",=20 + pm, instance8, ASSERTION_FAILED);*/ + /* testing double division? + runSimplePrimitiveTypesQuery("doubleNotNull / 2 =3D=3D 4",=20 + pm, instance8, ASSERTION_FAILED);*/ + runSimplePrimitiveTypesQuery("byteNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("shortNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("intNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + runSimplePrimitiveTypesQuery("longNull / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + /* testing float division? + runSimplePrimitiveTypesQuery("floatNull / 2 =3D=3D 4",=20 + pm, instance8, ASSERTION_FAILED);*/ + /* testing double division? + runSimplePrimitiveTypesQuery("doubleNull / 2 =3D=3D 4",=20 + pm, instance8, ASSERTION_FAILED);*/ + /* testing BigDecimal division? Scaling issue! + runSimplePrimitiveTypesQuery("bigDecimal / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED)= ;*/ + runSimplePrimitiveTypesQuery("bigInteger / 2 =3D=3D 4",=20 + pm, instances8And9, ASSERTION_FAILED); + + tx.commit(); + } +}