Index: test/sql/derby/datastoreidentity/schema.sql =================================================================== --- test/sql/derby/datastoreidentity/schema.sql (Revision 321057) +++ test/sql/derby/datastoreidentity/schema.sql (Arbeitskopie) @@ -70,11 +70,12 @@ ------------------------- DROP TABLE JDOQLKeywordsAsFieldNames; +DROP TABLE NoExtent; -CREATE TABLE JDOQLKeywordsAsFieldNames ( +CREATE TABLE NoExtent ( DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY, ID VARCHAR(64) NOT NULL, - CONSTRAINT KEYWORDS_PK PRIMARY KEY (DATASTORE_IDENTITY) + CONSTRAINT NOEXTENT_PK PRIMARY KEY (DATASTORE_IDENTITY) ); ------------------------- Index: test/sql/derby/applicationidentity/schema.sql =================================================================== --- test/sql/derby/applicationidentity/schema.sql (Revision 321057) +++ test/sql/derby/applicationidentity/schema.sql (Arbeitskopie) @@ -66,12 +66,18 @@ ------------------------- DROP TABLE JDOQLKeywordsAsFieldNames; +DROP TABLE NoExtent; CREATE TABLE JDOQLKeywordsAsFieldNames ( ID VARCHAR(64) NOT NULL, CONSTRAINT KEYWORDS_PK PRIMARY KEY (ID) ); +CREATE TABLE NoExtent ( + ID VARCHAR(64) NOT NULL, + CONSTRAINT NOEXTENT_PK PRIMARY KEY (ID) +); + ------------------------- -- singlefieldidentity ------------------------- Index: test/java/org/apache/jdo/tck/pc/query/NoExtent.java =================================================================== --- test/java/org/apache/jdo/tck/pc/query/NoExtent.java (Revision 0) +++ test/java/org/apache/jdo/tck/pc/query/NoExtent.java (Revision 0) @@ -0,0 +1,36 @@ +/* + * 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.pc.query; + +/** + * The PC class for testing JDOQL queries. + */ +public class NoExtent { + + /** + * The primary key field. + */ + private String id; + + public NoExtent(String id) { + this.id = id; + } + + public String getId() { + return this.id; + } +} Index: test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/variables/MixedVariables.java (Revision 0) @@ -0,0 +1,147 @@ +/* + * 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.variables; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Employee; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Mixed Variables. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.5-3. + *
+ *Assertion Description: + * All variables must be explicitly declared, + * or all variables must be implicitly declared. + */ +public class MixedVariables extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-3 (MixedVariables) 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*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(employee) & employee.firstname == " + + "'emp1First' & projects.contains(project) " + + "& project.name == 'orange'", + /*VARIABLES*/ "Employee employee", + /*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*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(employee) & employee.firstname == " + + "'emp1First' & projects.contains(project) " + + "& project.name == 'orange'", + /*VARIABLES*/ "Employee employee; Project project", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(employee) & employee.firstname == " + + "'emp1First' & projects.contains(project) " + + "& project.name == 'orange'", + /*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 = { + {"emp2"}, + {"emp2"} + }; + + /** + * 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(MixedVariables.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); + } + } + + 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() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } +} Index: test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/variables/UnconstrainedVariable.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.variables; + +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: Unconstrained Variables. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.5-1. + *
+ *Assertion Description: + * A variable that is not constrained with an explicit contains clause + * is constrained by the extent of the persistence capable class + * (including subclasses). + */ +public class UnconstrainedVariable extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-1 (UnconstrainedVariable) 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*/ "department", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == 'emp1First'", + /*VARIABLES*/ "Department department", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** The expected results of valid queries. */ + private static String[][] expectedResult = { + {"dept1", "dept2"} + }; + + /** + * 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(UnconstrainedVariable.class); + } + + /** */ + public void testPositive() { + if (isUnconstrainedVariablesSupported()) { + 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/variables/VariablesAndFields.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesAndFields.java (Revision 0) @@ -0,0 +1,132 @@ +/* + * 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.variables; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.Employee; +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: Variables and Fields. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.5-4. + *
+ *Assertion Description: + * Names are treated as variable names if they are explicitly declared + * via declareVariables. Otherwise, names are treated as field names + * if they are members of the candidate class. + * Finally, names are treated as implicitly defined variable names. + */ +public class VariablesAndFields extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-4 (VariablesAndFields) 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*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(employee) & employee.firstname == " + + "'emp1First'", + /*VARIABLES*/ "Employee employee", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Employee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "team.contains(employee) & employee.firstname == " + + "'emp1First'", + /*VARIABLES*/ null, + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null), + new QueryElementHolder( + /*UNIQUE*/ null, + /*RESULT*/ null, + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ "firstname == 'emp1First'", + /*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 = { + {"emp2"}, + {"emp2"}, + {"emp1"} + }; + + /** + * 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(VariablesAndFields.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/variables/VariablesWithoutExtent.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/variables/VariablesWithoutExtent.java (Revision 0) @@ -0,0 +1,123 @@ +/* + * 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.variables; + +import javax.jdo.PersistenceManager; +import javax.jdo.Transaction; + +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.pc.query.NoExtent; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Variables without Extent. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.5-2. + *
+ *Assertion Description: + * If the class does not manage an Extent, + * then no results will satisfy the query. + */ +public class VariablesWithoutExtent extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.5-2 (VariablesWithoutExtent) 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*/ "noExtent", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ "NoExtent noExtent", + /*PARAMETERS*/ null, + /*IMPORTS*/ null, + /*GROUP BY*/ null, + /*ORDER BY*/ null, + /*FROM*/ null, + /*TO*/ null) + }; + + /** The expected results of valid queries. */ + private static String[][] expectedResult = { + {} + }; + + /** + * 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(VariablesWithoutExtent.class); + } + + /** */ + public void testPositive() { + if (isUnconstrainedVariablesSupported()) { + 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()); + NoExtent noExtent = new NoExtent("no extent 1"); + makePersistent(noExtent); + addTearDownInstance(noExtent); + } + + /** + * Makes the given instance persistent. + * @param o the instance to be made persistent. + */ + private void makePersistent(Object o) { + PersistenceManager pm = getPM(); + Transaction transaction = pm.currentTransaction(); + transaction.begin(); + try { + pm.makePersistent(o); + transaction.commit(); + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + } + } + +} Index: test/conf/alltests.conf =================================================================== --- test/conf/alltests.conf (Revision 321057) +++ test/conf/alltests.conf (Arbeitskopie) @@ -335,6 +335,10 @@ org.apache.jdo.tck.query.jdoql.parameters.ParameterBoundToDifferentPM \ org.apache.jdo.tck.query.jdoql.parameters.ParameterDeclaredWithSameNameAsFieldOfCandidateClass \ org.apache.jdo.tck.query.jdoql.parameters.PrimitiveParameterPassedAsNull \ +org.apache.jdo.tck.query.jdoql.variables.MixedVariables \ +org.apache.jdo.tck.query.jdoql.variables.UnconstrainedVariable \ +org.apache.jdo.tck.query.jdoql.variables.VariablesAndFields \ +org.apache.jdo.tck.query.jdoql.variables.VariablesWithoutExtent org.apache.jdo.tck.query.jdoql.variables.VariableDeclaredWithSameNameAsFieldOfCandidateClass \ org.apache.jdo.tck.query.result.ImmutableQueryResult \ org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenCommitted \ Index: test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo =================================================================== --- test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo (Revision 321057) +++ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo (Arbeitskopie) @@ -4,6 +4,7 @@ + Index: test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo =================================================================== --- test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo (Revision 321057) +++ test/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo (Arbeitskopie) @@ -9,6 +9,11 @@ + + + + Index: test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm =================================================================== --- test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm (Revision 321057) +++ test/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-derby.orm (Arbeitskopie) @@ -12,5 +12,10 @@ + + + + + Index: test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm =================================================================== --- test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm (Revision 321057) +++ test/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-derby.orm (Arbeitskopie) @@ -7,6 +7,10 @@ + + + + Index: project.properties =================================================================== --- project.properties (Revision 321057) +++ project.properties (Arbeitskopie) @@ -174,6 +174,7 @@ org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.java \ org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.java \ org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.java \ + org/apache/jdo/tck/pc/query/NoExtent.java \ org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.java \ org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.java \ org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.java \ @@ -266,6 +267,7 @@ org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackClass.class \ org/apache/jdo/tck/pc/instancecallbacks/InstanceCallbackNonPersistFdsClass.class \ org/apache/jdo/tck/pc/query/JDOQLKeywordsAsFieldNames.class \ + org/apache/jdo/tck/pc/query/NoExtent.class \ org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivebyte.class \ org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldByte.class \ org/apache/jdo/tck/pc/singlefieldidentity/PCPointSingleFieldPrimitivechar.class \