Index: test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java (Revision 0) @@ -0,0 +1,280 @@ +/* + * 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.methods; + +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: Supported Map methods. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-47. + *
+ *Assertion Description: + * New supported String methods: + * + */ +public class SupportedStringMethods extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-47 (SupportedStringMethods) 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*/ "firstname.toLowerCase() == '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.toUpperCase() == '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.indexOf('First') == 4", + /*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.indexOf('First', 2) == 4", + /*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.matches('*First')", + /*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.substring(4) == 'First'", + /*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.substring(4,9) == 'First'", + /*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.startsWith('emp')", + /*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.endsWith('First')", + /*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 = { + {"emp1"}, + {"emp1"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"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(SupportedStringMethods.class); + } + + /** */ + public void testToLowerCase() { + int index = 0; + executeQuery(index); + } + + /** */ + public void testToUpperCase() { + int index = 1; + executeQuery(index); + } + + /** */ + public void testIndexOfString() { + int index = 2; + executeQuery(index); + } + + /** */ + public void testIndexOfStringInt() { + int index = 3; + executeQuery(index); + } + + /** */ + public void testMatches() { + int index = 4; + executeQuery(index); + } + + /** */ + public void testSubstringInt() { + int index = 5; + executeQuery(index); + } + + /** */ + public void testSubstringIntInt() { + int index = 6; + executeQuery(index); + } + + /** */ + public void testStartsWith() { + int index = 7; + executeQuery(index); + } + + /** */ + public void testEndsWith() { + int index = 8; + executeQuery(index); + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } + + /** */ + private void executeQuery(int index) { + Object[] expectedResultValues = + getCompanyModelInstances(expectedResult[index]); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResultValues); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResultValues); + } + +} Index: test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java (Revision 0) @@ -0,0 +1,126 @@ +/* + * 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.methods; + +import org.apache.jdo.tck.JDO_Test; +import org.apache.jdo.tck.pc.company.CompanyModelReader; +import org.apache.jdo.tck.pc.company.FullTimeEmployee; +import org.apache.jdo.tck.query.QueryElementHolder; +import org.apache.jdo.tck.query.QueryTest; +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + *Title: Supported Math methods. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-48. + *
+ *Assertion Description: + * Supported Math methods: + * + */ +public class SupportedMathMethods extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-48 (SupportedMathMethods) 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*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.abs(salary) > 10000", + /*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*/ FullTimeEmployee.class, + /*EXCLUDE*/ null, + /*WHERE*/ "Math.sqrt(salary) > 100", + /*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 = { + {"emp1", "emp5"}, + {"emp1", "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(SupportedMathMethods.class); + } + + /** */ + public void testAbs() { + int index = 0; + executeQuery(index); + } + + /** */ + public void testSqrt() { + int index = 1; + executeQuery(index); + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } + + /** */ + private void executeQuery(int index) { + Object[] expectedResultValues = + getCompanyModelInstances(expectedResult[index]); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResultValues); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResultValues); + } + +} Index: test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java (Revision 0) @@ -0,0 +1,127 @@ +/* + * 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.methods; + +import java.util.Collection; +import java.util.Iterator; + +import javax.jdo.JDOHelper; +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.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: Supported JDOHelper methods. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-49. + *
+ *Assertion Description: + * Supported JDOHelper methods: + * + */ +public class SupportedJDOHelperMethods extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-49 (SupportedJDOHelperMethods) 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*/ "JDOHelper.getObjectId(this)", + /*INTO*/ null, + /*FROM*/ Person.class, + /*EXCLUDE*/ null, + /*WHERE*/ null, + /*VARIABLES*/ null, + /*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(SupportedJDOHelperMethods.class); + } + + /** */ + public void testGetObjectById() { + int index = 0; + Object[] expectedResult = getExpectedResult(); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResult); + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } + + /** */ + private Object[] getExpectedResult() { + Object[] expectedResult; + PersistenceManager pm = getPM(); + Transaction transaction = pm.currentTransaction(); + transaction.begin(); + try { + Query query = pm.newQuery(Person.class); + try { + Collection result = (Collection) query.execute(); + expectedResult = new Object[result.size()]; + int j = 0; + for (Iterator i = result.iterator(); i.hasNext(); ) { + expectedResult[j++] = JDOHelper.getObjectId(i.next()); + } + } finally { + query.closeAll(); + } + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + } + return expectedResult; + } + +} Index: test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java =================================================================== --- test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java (Revision 0) +++ test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java (Revision 0) @@ -0,0 +1,148 @@ +/* + * 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.methods; + +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: Supported Map methods. + *
+ *Keywords: query + *
+ *Assertion ID: A14.6.2-46. + *
+ *Assertion Description: + * Supported Map methods: + * + */ +public class SupportedMapMethods extends QueryTest { + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A14.6.2-46 (SupportedMapMethods) 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*/ "phoneNumbers.get('home') == '1111'", + /*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*/ "phoneNumbers.containsKey('home')", + /*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*/ "phoneNumbers.containsValue('1111')", + /*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 = { + {"emp1"}, + {"emp1", "emp2", "emp3", "emp4", "emp5"}, + {"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(SupportedMapMethods.class); + } + + /** */ + public void testGet() { + int index = 0; + executeQuery(index); + } + + /** */ + public void testContainsKey() { + int index = 1; + executeQuery(index); + } + + /** */ + public void testContainsValue() { + int index = 2; + executeQuery(index); + } + + /** + * @see JDO_Test#localSetUp() + */ + protected void localSetUp() { + loadCompanyModel(getPM(), COMPANY_TESTDATA); + addTearDownClass(CompanyModelReader.getTearDownClasses()); + } + + /** */ + private void executeQuery(int index) { + Object[] expectedResultValues = + getCompanyModelInstances(expectedResult[index]); + executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResultValues); + executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], + expectedResultValues); + } + +} Index: test/conf/alltests.conf =================================================================== --- test/conf/alltests.conf (Revision 306550) +++ test/conf/alltests.conf (Arbeitskopie) @@ -302,6 +302,10 @@ org.apache.jdo.tck.query.jdoql.methods.MethodsAndObjectConstructionNotSupported \ org.apache.jdo.tck.query.jdoql.methods.StartsWithAndEndsWith \ org.apache.jdo.tck.query.jdoql.methods.SupportedCollectionMethods \ +org.apache.jdo.tck.query.jdoql.methods.SupportedJDOHelperMethods \ +org.apache.jdo.tck.query.jdoql.methods.SupportedMapMethods \ +org.apache.jdo.tck.query.jdoql.methods.SupportedMathMethods \ +org.apache.jdo.tck.query.jdoql.methods.SupportedStringMethods \ org.apache.jdo.tck.query.jdoql.operators.BinaryAddition \ org.apache.jdo.tck.query.jdoql.operators.BinarySubtraction \ org.apache.jdo.tck.query.jdoql.operators.BitwiseComplement \