Index: test/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/CharacterAndStringLiterals.java (Revision 0) @@ -0,0 +1,133 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.query.jdoql; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.mylib.MylibReader; +import org.apache.jdo.tck.pc.mylib.PrimitiveTypes; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Character and String Literals. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-42. + *
+ *Assertion Description: + * There is no distinction made between character literals and + * String literals. Single character String literals can be used + * wherever character literals are permitted. + * String literals are allowed to be delimited by single quote marks + * or double quote marks. This allows String literal filters + * to use single quote marks instead of escaped double quote marks. + */ +public class CharacterAndStringLiterals extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-42 (CharacterAndStringLiterals) failed: "; + + /** + * The array of invalid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] INVALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "stringNull.startsWith('Even') OR charNotNull == 'O.'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ PrimitiveTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ "stringNull.startsWith('Even') OR charNotNull == 'O'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** The expected results of valid queries. */ + private static String[][] expectedResult = { + {"primitiveTypesCharacterStringLiterals"} + }; + + /** + * 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(CharacterAndStringLiterals.class); + } + + /** */ + public void testPositive() { + if (isUnconstrainedVariablesSupported()) { + for (int i = 0; i < VALID_QUERIES.length; i++) { + Object[] expectedResultValues = + getMylibInstances(expectedResult[i]); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResultValues); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResultValues); + } + } + } + + /** */ + public void testNegative() { + for (int i = 0; i < INVALID_QUERIES.length; i++) { + compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false); + compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], + false); + } + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadMylib(getPM(), MYLIB_TESTDATA); + addTearDownClass(MylibReader.getTearDownClasses()); + } +} Index: test/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/PositiveRange.java (Revision 0) @@ -0,0 +1,96 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.query.jdoql; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Positive Range. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.8-1. + *
+ *Assertion Description: + * setRange(long fromIncl, long toExcl) + */ +public class PositiveRange extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.8-1 (PositiveRange) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 0, + /*TO*/ 5) + }; + + /** The expected results of valid queries. */ + private static String[][] expectedResult = { + {"emp1", "emp2", "emp3", "emp4", "emp5"} + }; + + /** + * 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(PositiveRange.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + Object[] expectedResultValues = + getCompanyModelInstances(expectedResult[i]); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResultValues); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResultValues); + } + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } +} Index: test/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/RangeAsString.java (Revision 0) @@ -0,0 +1,96 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.query.jdoql; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Range as String. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.8-3. + *
+ *Assertion Description: + * setRange(String range); + */ +public class RangeAsString extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.8-3 (RangeAsString) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ "0", + /*TO*/ "5") + }; + + /** The expected results of valid queries. */ + private static String[][] expectedResult = { + {"emp1", "emp2", "emp3", "emp4", "emp5"} + }; + + /** + * 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(RangeAsString.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + Object[] expectedResultValues = + getCompanyModelInstances(expectedResult[i]); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResultValues); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResultValues); + } + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } +} Index: test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java (Revision 0) @@ -0,0 +1,143 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.query.jdoql; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Negative Range. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.8-2. + *
+ *Assertion Description: + * If ((toExcl - fromIncl) <= 0) evaluates to true, if the result of the query + * execution is a List, the returned List contains no instances, + * and an Iterator obtained from the List returns false to hasNext(). + * If the result of the query execution is a single instance (setUnique(true)), + * it will have a value of null. + */ +public class NegativeRange extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.8-2 (NegativeRange) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 4), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 3), + new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 4), + new QueryElementHolder( + /*UNIQUE*/ Boolean.TRUE, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ 4, + /*TO*/ 3) + }; + + /** The expected results of valid queries. */ + private static String[][] expectedResult = { + {}, + {}, + {null}, + {null} + }; + + /** + * 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(NegativeRange.class); + } + + /** */ + public void testPositive() { + for (int i = 0; i < VALID_QUERIES.length; i++) { + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResult[i]); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], + expectedResult[i]); + } + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } +} Index: test/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/IdentifiersEqualFieldNames.java (Revision 0) @@ -0,0 +1,100 @@ +/* + * Copyright 2005 The Apache Software Foundation. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.jdo.tck.query.jdoql; + +import org.apache.jdo.tck.pc.company.Person; +import org.apache.jdo.tck.pc.fieldtypes.AllTypes; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Identifiers Equal Field Names. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-43. + *
+ *Assertion Description: + * Identifiers that are persistent field names or + * public final static field names are required + * to be supported by JDO implementations. + */ +public class IdentifiersEqualFieldNames extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-43 (IdentifiersEqualFieldNames) failed: "; + + /** + * The array of valid queries which may be executed as + * single string queries and as API queries. + */ + private static final QueryElementHolder[] VALID_QUERIES = { + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ "String firstname", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ AllTypes.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ "int NUM_VALUES", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** + * 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(IdentifiersEqualFieldNames.class); + } + + /** */ + public void testFieldNames() { + int i = 0; + compileAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + compileSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + } + + /** */ + public void testStaticFieldNames() { + int i = 1; + compileAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + compileSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], true); + } +} Index: test/conf/alltests.conf =================================================================== --- test/conf/alltests.conf (Revision 321057) +++ test/conf/alltests.conf (Arbeitskopie) @@ -274,12 +274,14 @@ org.apache.jdo.tck.query.api.SetterReplacePreviousValues \ org.apache.jdo.tck.query.jdoql.AssignmentPrePostIncrementDecrementNotSupported \ org.apache.jdo.tck.query.jdoql.Cast \ +org.apache.jdo.tck.query.jdoql.CharacterAndStringLiterals \ org.apache.jdo.tck.query.jdoql.ComparingCollectionFieldToNull \ org.apache.jdo.tck.query.jdoql.ComparingPersistentAndNonPersistentInstance \ org.apache.jdo.tck.query.jdoql.DenoteUniquenessInFilter \ org.apache.jdo.tck.query.jdoql.ExecuteQueryWhenPersistenceManagerIsClosed \ org.apache.jdo.tck.query.jdoql.ExecutingMultipleQueriesSimultaneouslyIsThreadSafe \ org.apache.jdo.tck.query.jdoql.ExecutingQueryWhenNoTransactionNoNontransactionalRead \ +org.apache.jdo.tck.query.jdoql.IdentifiersEqualFieldNames \ org.apache.jdo.tck.query.jdoql.IgnoreCacheFalse \ org.apache.jdo.tck.query.jdoql.MultipleActiveQueryInstanceInSamePersistenceManager \ org.apache.jdo.tck.query.jdoql.MultipleIdenticalImports \ @@ -287,13 +289,16 @@ org.apache.jdo.tck.query.jdoql.NavigationThroughACollectionField \ org.apache.jdo.tck.query.jdoql.NavigationThroughANullValuedField \ org.apache.jdo.tck.query.jdoql.NavigationThroughReferencesUsesDotOperator \ +org.apache.jdo.tck.query.jdoql.NegativeRange \ org.apache.jdo.tck.query.jdoql.NullCollectionsAndContainsMethod \ org.apache.jdo.tck.query.jdoql.NullCollectionsAndIsEmpty \ org.apache.jdo.tck.query.jdoql.OrderingSpecification \ org.apache.jdo.tck.query.jdoql.ParenthesesMarkOperatorPrecedence \ +org.apache.jdo.tck.query.jdoql.PositiveRange \ org.apache.jdo.tck.query.jdoql.QueryIsSerializable \ org.apache.jdo.tck.query.jdoql.QueryResultPassedToAnotherQuery \ org.apache.jdo.tck.query.jdoql.QueryWithNoFilter \ +org.apache.jdo.tck.query.jdoql.RangeAsString \ org.apache.jdo.tck.query.jdoql.RestoredSerializedQueryInstanceLosesAssociationWithPM \ org.apache.jdo.tck.query.jdoql.SeparateNamespaceForTypeNames \ org.apache.jdo.tck.query.jdoql.WhiteSpaceIsACharacterAndIgnored \ Index: test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml =================================================================== --- test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml (Revision 0) +++ test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml (Revision 0) @@ -0,0 +1,52 @@ + + + + + Mylib instances for query testing + + + + + + + + + + + + + 1 + 4 + 4 + 4 + 4 + 4.0 + 4.0 + 4.0 + 4.0 + + + + 2 + -4 + -4 + -4 + -4 + -4.0 + -4.0 + -4.0 + -4.0 + + + + 3 + O + O + Even + + + +