Index: test/java/org/apache/jdo/tck/query/sql/NewQuery.java
===================================================================
--- test/java/org/apache/jdo/tck/query/sql/NewQuery.java (Revision 0)
+++ test/java/org/apache/jdo/tck/query/sql/NewQuery.java (Revision 0)
@@ -0,0 +1,89 @@
+/*
+ * 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.sql;
+
+import java.util.Arrays;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *Title: New SQL Query.
+ *
+ *Keywords: query
+ *
+ *Assertion ID: A14.7-1.
+ *
+ *Assertion Description:
+ * In this case, the factory method that takes the language string and
+ * Object is used: newQuery (String language, Object query).
+ * The language parameter is javax.jdo.query.SQL and
+ * the query parameter is the SQL query string.
+ */
+public class NewQuery extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.7-1 (NewQuery) failed: ";
+
+ /**
+ * 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(NewQuery.class);
+ }
+
+ /** The array of valid SQL queries. */
+ private static final String[] VALID_SQL_QUERIES = {
+ "SELECT firstname, lastname FROM {0}.persons WHERE personid = ?"
+ };
+
+ /**
+ * The expected results of valid SQL queries.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[]{
+ new Object[]{"emp1First", "emp1Last"}})
+ };
+
+ /** Parameters of valid SQL queries. */
+ private static Object[][] parameters = {
+ {new Integer(1)}
+ };
+
+ /** */
+ public void testPositive() {
+ if (isSQLSupported()) {
+ for (int i = 0; i < VALID_SQL_QUERIES.length; i++) {
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[i],
+ null, null, parameters[i], expectedResult[i], false);
+ }
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadCompanyModel(getPM(), COMPANY_TESTDATA);
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ }
+}
Index: test/java/org/apache/jdo/tck/query/sql/CandidateClass.java
===================================================================
--- test/java/org/apache/jdo/tck/query/sql/CandidateClass.java (Revision 0)
+++ test/java/org/apache/jdo/tck/query/sql/CandidateClass.java (Revision 0)
@@ -0,0 +1,99 @@
+/*
+ * 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.sql;
+
+import java.util.Arrays;
+
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *Title: Candidate Class.
+ *
+ *Keywords: query
+ *
+ *Assertion ID: A14.7-3.
+ *
+ *Assertion Description:
+ * SQL queries can be defined without a candidate class.
+ * These queries can be found by name using the factory method newNamedQuery,
+ * specifying the class as null,
+ * or can be constructed without a candidate class.
+ */
+public class CandidateClass extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.7-3 (CandidateClass) failed: ";
+
+ /**
+ * 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(CandidateClass.class);
+ }
+
+ /** The array of valid SQL queries. */
+ private static final String[] VALID_SQL_QUERIES = {
+ "SELECT firstname, lastname FROM {0}.persons"
+ };
+
+ /**
+ * The expected results of valid SQL queries.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[]{
+ new Object[]{"emp1First", "emp1Last"},
+ new Object[]{"emp2First", "emp2Last"},
+ new Object[]{"emp3First", "emp3Last"},
+ new Object[]{"emp4First", "emp4Last"},
+ new Object[]{"emp5First", "emp5Last"}})
+ };
+
+ /** */
+ public void testNamedQuery() {
+ if (isSQLSupported()) {
+ int index = 0;
+ Query query = getPM().newNamedQuery(null, "SQLQuery");
+ executeJDOQuery(ASSERTION_FAILED, query, "Named SQL query",
+ false, null, expectedResult[index], true);
+ }
+ }
+
+ /** */
+ public void testNoCandidateClass() {
+ if (isSQLSupported()) {
+ int index = 0;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ null, null, null, expectedResult[index], false);
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadCompanyModel(getPM(), COMPANY_TESTDATA);
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ }
+}
Index: test/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java
===================================================================
--- test/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java (Revision 0)
+++ test/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java (Revision 0)
@@ -0,0 +1,173 @@
+/*
+ * 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.sql;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.mylib.MylibReader;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.query.result.classes.FullName;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *Title: Shape of Result.
+ *
+ *Keywords: query
+ *
+ *Assertion ID: A14.7-4.
+ *
+ *Assertion Description:
+ * Table 7: Shape of Result of SQL Query
+ */
+public class ShapeOfResult extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.7-4 (ShapeOfResult) failed: ";
+
+ /**
+ * 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(ShapeOfResult.class);
+ }
+
+ /** The array of valid SQL queries. */
+ private static final String[] VALID_SQL_QUERIES = {
+ // C
+ "SELECT * FROM {0}.PrimitiveTypes",
+ // C, unique
+ "SELECT * FROM {0}.PrimitiveTypes where id = 1",
+ // single column
+ "SELECT firstname FROM {0}.persons",
+ // single column, unique
+ "SELECT firstname FROM {0}.persons WHERE personid = 1",
+ // mutiple columns
+ "SELECT firstname, lastname FROM {0}.persons",
+ // mutiple columns, unique
+ "SELECT firstname, lastname FROM {0}.persons WHERE personid = 1",
+ // result class
+ "SELECT firstname, lastname FROM {0}.persons",
+ // result class, unique
+ "SELECT firstname, lastname FROM {0}.persons WHERE personid = 1"
+ };
+
+ /**
+ * The expected results of valid SQL queries.
+ */
+ private Object[] expectedResult = {
+ getMylibInstancesAsList(new String[]{
+ "primitiveTypesPositive", "primitiveTypesNegative",
+ "primitiveTypesCharacterStringLiterals"}),
+ getMylibInstance("primitiveTypesPositive"),
+ Arrays.asList(new Object[]{"emp1First", "emp2First", "emp3First",
+ "emp4First", "emp5First"}),
+ "emp1First",
+ Arrays.asList(new Object[]{
+ new Object[]{"emp1First", "emp1Last"},
+ new Object[]{"emp2First", "emp2Last"},
+ new Object[]{"emp3First", "emp3Last"},
+ new Object[]{"emp4First", "emp4Last"},
+ new Object[]{"emp5First", "emp5Last"}}),
+ new Object[]{"emp1First", "emp1Last"},
+ Arrays.asList(new Object[]{
+ new FullName("emp1First", "emp1Last"),
+ new FullName("emp2First", "emp2Last"),
+ new FullName("emp3First", "emp3Last"),
+ new FullName("emp4First", "emp4Last"),
+ new FullName("emp5First", "emp5Last")}),
+ new FullName("emp1First", "emp1Last")
+ };
+
+ /** */
+ public void testCanidateClass() {
+ if (isSQLSupported()) {
+ int index = 0;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ PrimitiveTypes.class, null, null,
+ expectedResult[index], false);
+ index++;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ PrimitiveTypes.class, null, null,
+ expectedResult[index], true);
+ }
+ }
+
+ /** */
+ public void testSingleColumn() {
+ if (isSQLSupported()) {
+ executeSQLQueries(2);
+ }
+ }
+
+ /** */
+ public void testMultipleColumn() {
+ if (isSQLSupported()) {
+ executeSQLQueries(4);
+ }
+ }
+
+ /** */
+ public void testResultClass() {
+ if (isSQLSupported()) {
+ executeSQLQueries(6, FullName.class);
+ }
+ }
+
+ /** */
+ public void testNegative() {
+ if (isSQLSupported()) {
+ String schema = getPMFProperty("javax.jdo.mapping.Schema");
+ String sql = MessageFormat.format(
+ "SELECT stringNull FROM {0}.PrimitiveTypes",
+ new Object[]{schema});
+ Query query = getPM().newQuery("javax.jdo.query.SQL", sql);
+ query.setClass(PrimitiveTypes.class);
+ compile(ASSERTION_FAILED, query, sql, false);
+ }
+ }
+
+ private void executeSQLQueries(int index) {
+ executeSQLQueries(index, null);
+ }
+
+ private void executeSQLQueries(int index, Class resultClass) {
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ null, resultClass, null, expectedResult[index], false);
+ index++;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ null, resultClass, null, expectedResult[index], true);
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadCompanyModel(getPM(), COMPANY_TESTDATA);
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ loadMylib(getPM(), MYLIB_TESTDATA);
+ addTearDownClass(MylibReader.getTearDownClasses());
+ }
+}
Index: test/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java
===================================================================
--- test/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java (Revision 0)
+++ test/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java (Revision 0)
@@ -0,0 +1,221 @@
+/*
+ * 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.sql;
+
+import java.text.MessageFormat;
+import java.util.Arrays;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.pc.mylib.MylibReader;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.query.result.classes.FullName;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *Title: Allowed API Methods.
+ *
+ *Keywords: query
+ *
+ *Assertion ID: A14.7-2.
+ *
+ *Assertion Description:
+ * The only methods that can be used are setClass
+ * to establish the candidate class,
+ * setUnique to declare that there is only one result row,
+ * and setResultClass to establish the result class.
+ */
+public class AllowedAPIMethods extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.7-2 (AllowedAPIMethods) failed: ";
+
+ /**
+ * 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(AllowedAPIMethods.class);
+ }
+
+ /** The array of valid SQL queries. */
+ private static final String[] VALID_SQL_QUERIES = {
+ "SELECT * FROM {0}.PrimitiveTypes",
+ "SELECT * FROM {0}.departments",
+ "SELECT * FROM {0}.persons",
+ "SELECT FIRSTNAME, LASTNAME FROM {0}.persons WHERE PERSONID = 1",
+ "SELECT FIRSTNAME, LASTNAME FROM {0}.persons"
+ };
+
+ /**
+ * The expected results of valid SQL queries.
+ */
+ private Object[] expectedResult = {
+ getMylibInstancesAsList(new String[]{
+ "primitiveTypesPositive",
+ "primitiveTypesNegative",
+ "primitiveTypesCharacterStringLiterals"}),
+ getCompanyModelInstancesAsList(new String[]{"dept1", "dept2"}),
+ getCompanyModelInstancesAsList(new String[]{
+ "emp1", "emp2", "emp3", "emp4", "emp5"}),
+ new Object[]{"emp1First", "emp1Last"},
+ Arrays.asList(new Object[]{
+ new FullName("emp1First", "emp1Last"),
+ new FullName("emp2First", "emp2Last"),
+ new FullName("emp3First", "emp3Last"),
+ new FullName("emp4First", "emp4Last"),
+ new FullName("emp5First", "emp5Last")})
+ };
+
+ /** */
+ public void testSetClass() {
+ if (isSQLSupported()) {
+ int index = 0;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ PrimitiveTypes.class, null, null,
+ expectedResult[index], false);
+
+ index = 1;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ Department.class, null, null,
+ expectedResult[index], false);
+
+ index = 2;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ Person.class, null, null,
+ expectedResult[index], false);
+ }
+ }
+
+ /** */
+ public void testSetUnique() {
+ if (isSQLSupported()) {
+ int index = 3;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ null, null, null, expectedResult[index], true);
+ }
+ }
+
+ /** */
+ public void testSetResultClass() {
+ if (isSQLSupported()) {
+ int index = 4;
+ executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+ null, FullName.class, null, expectedResult[index], false);
+ }
+ }
+
+ /** */
+ public void testNegative() {
+ if (isSQLSupported()) {
+ String schema = getPMFProperty("javax.jdo.mapping.Schema");
+ String sql = "SELECT PERSONID FROM {0}.persons";
+ sql = MessageFormat.format(sql, new Object[]{schema});
+ Query query = getPM().newQuery("javax.jdo.query.SQL", sql);
+ checkSetters(query);
+ }
+ }
+
+ private void checkSetters(Query query) {
+ checkSetResult(query);
+ checkSetFilter(query);
+ checkDeclareVariables(query);
+ checkDeclareParameters(query);
+ checkDeclareImports(query);
+ checkSetGrouping(query);
+ checkSetOrdering(query);
+ }
+
+ private void checkSetResult(Query query) {
+ try {
+ query.setResult("firstname, lastname");
+ methodFailed("setResult()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void checkSetFilter(Query query) {
+ try {
+ query.setFilter("WHERE personid = 1");
+ methodFailed("setFilter()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void checkDeclareVariables(Query query) {
+ try {
+ query.declareVariables("Employee emp");
+ methodFailed("declareVariables()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void checkDeclareParameters(Query query) {
+ try {
+ query.declareParameters("Employee emp");
+ methodFailed("declareParameters()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void checkDeclareImports(Query query) {
+ try {
+ query.declareImports("import org.apache.jdo.tck.pc.company.Employee");
+ methodFailed("declareImports()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void checkSetGrouping(Query query) {
+ try {
+ query.setGrouping("firstname");
+ methodFailed("setGrouping()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void checkSetOrdering(Query query) {
+ try {
+ query.setOrdering("firstname ASCENDING");
+ methodFailed("setOrdering()");
+ } catch (JDOUserException e) {
+ }
+ }
+
+ private void methodFailed(String method) {
+ fail(ASSERTION_FAILED + method +
+ " on a SQL query must throw JDOUserException." );
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadCompanyModel(getPM(), COMPANY_TESTDATA);
+ addTearDownClass(CompanyModelReader.getTearDownClasses());
+ loadMylib(getPM(), MYLIB_TESTDATA);
+ addTearDownClass(MylibReader.getTearDownClasses());
+ }
+}
Index: test/java/org/apache/jdo/tck/query/QueryTest.java
===================================================================
--- test/java/org/apache/jdo/tck/query/QueryTest.java (Revision 345902)
+++ test/java/org/apache/jdo/tck/query/QueryTest.java (Arbeitskopie)
@@ -18,6 +18,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -764,7 +765,7 @@
* Compiles the given query element holder instance
* as a JDO API query or single string query,
* depending on argument asSingleString.
- * Argument singleStringQuery exists to support queries
+ * Argument singleStringQuery is used to support queries
* which cannot be expressed as query element holder instances.
* That argument is ignored if argument queryElementHolder
* is set.
@@ -788,33 +789,49 @@
QueryElementHolder queryElementHolder, boolean asSingleString,
String singleStringQuery, boolean positive) {
PersistenceManager pm = getPM();
+ Query query;
+ if (queryElementHolder != null) {
+ if (asSingleString) {
+ query = queryElementHolder.getSingleStringQuery(pm);
+ } else {
+ query = queryElementHolder.getAPIQuery(pm);
+ }
+ } else {
+ query = getPM().newQuery(singleStringQuery);
+ }
+ compile(assertion, query, singleStringQuery, positive);
+ }
+
+ /**
+ * Compiles the given query instance.
+ * Argument positive determines if the compilation is supposed
+ * to succeed or to fail.
+ * If true and the compilation fails,
+ * then the test case fails prompting arguments assertion
+ * and queryText.
+ * If false and the compilation succeeds,
+ * then the test case fails prompting argument assertion
+ * and queryText.
+ * Otherwise the test case succeeds.
+ * @param assertion
+ * @param query
+ * @param queryText
+ * @param positive
+ */
+ protected void compile(String assertion,
+ Query query, String queryText, boolean positive) {
+ PersistenceManager pm = getPM();
Transaction tx = pm.currentTransaction();
tx.begin();
try {
- Query query;
- if (queryElementHolder != null) {
- if (asSingleString) {
- query = queryElementHolder.getSingleStringQuery(pm);
- } else {
- query = queryElementHolder.getAPIQuery(pm);
- }
- } else {
- query = getPM().newQuery(singleStringQuery);
- }
query.compile();
if (!positive) {
- String queryText = queryElementHolder != null ?
- queryElementHolder.toString() :
- singleStringQuery;
fail(assertion +
"Query compilation must throw JDOUserException: " +
queryText);
}
} catch (JDOUserException e) {
if (positive) {
- String queryText = queryElementHolder != null ?
- queryElementHolder.toString() :
- singleStringQuery;
fail(assertion + "Query '" + queryText +
"' must be compilable. The exception message is: " +
e.getMessage());
@@ -975,7 +992,7 @@
execute(assertion, queryElementHolder, true,
parameters, expectedResult);
}
-
+
/**
* Converts the given query element holder instance
* to a JDO query instance,
@@ -1029,6 +1046,43 @@
}
/**
+ * Executes the given SQL string as a JDO SQL query.
+ * The result of that query is compared against the given argument
+ * expectedResult.
+ * If the expected result does not match the returned query result,
+ * then the test case fails prompting argument assertion.
+ * Argument unique indicates, if the query is supposed
+ * to return a single result.
+ * @param assertion
+ * @param sql
+ * @param candidateClass
+ * @param resultClass
+ * @param parameters
+ * @param expectedResult
+ * @param unique
+ */
+ protected void executeSQLQuery(String assertion, String sql,
+ Class candidateClass, Class resultClass,
+ Object[] parameters, Object expectedResult, boolean unique) {
+ String schema = getPMFProperty("javax.jdo.mapping.Schema");
+ sql = MessageFormat.format(sql, new Object[]{schema});
+ if (logger.isDebugEnabled())
+ logger.debug("Executing SQL query: " + sql);
+ Query query = getPM().newQuery("javax.jdo.query.SQL", sql);
+ if (unique) {
+ query.setUnique(unique);
+ }
+ if (candidateClass != null) {
+ query.setClass(candidateClass);
+ }
+ if (resultClass != null) {
+ query.setResultClass(resultClass);
+ }
+ execute(assertion, query, sql, false,
+ parameters, expectedResult, true);
+ }
+
+ /**
* Executes the given query instance.
* Argument parameters is passed as an argument
* to the method {@link Query#executeWithArray(java.lang.Object[])}.
Index: test/java/org/apache/jdo/tck/JDO_Test.java
===================================================================
--- test/java/org/apache/jdo/tck/JDO_Test.java (Revision 345902)
+++ test/java/org/apache/jdo/tck/JDO_Test.java (Arbeitskopie)
@@ -698,6 +698,13 @@
return getPMF().supportedOptions().contains(
"javax.jdo.option.UnconstrainedVariables");
}
+
+ /** Reports whether SQL queries are supported. */
+ public boolean isSQLSupported() {
+ return getPMF().supportedOptions().contains(
+ "javax.jdo.query.SQL");
+ }
+
/**
* This utility method returns a String that indicates the
@@ -860,4 +867,13 @@
}
}
+ /**
+ * Returns the value of the PMF property
+ * given by argument key.
+ * @param key the key
+ * @return the value
+ */
+ protected String getPMFProperty(String key) {
+ return PMFPropertiesObject.getProperty(key);
+ }
}
Index: test/conf/alltests.conf
===================================================================
--- test/conf/alltests.conf (Revision 345902)
+++ test/conf/alltests.conf (Arbeitskopie)
@@ -377,6 +377,10 @@
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.query.sql.ShapeOfResult \
+org.apache.jdo.tck.query.sql.CandidateClass \
+org.apache.jdo.tck.query.sql.AllowedAPIMethods \
+org.apache.jdo.tck.query.sql.NewQuery \
org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenCommitted \
org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenRolledback \
org.apache.jdo.tck.transactions.AfterSetRollbackOnlyCommitFails \
Index: test/jdo/datastoreidentity/package.jdo
===================================================================
--- test/jdo/datastoreidentity/package.jdo (Revision 345902)
+++ test/jdo/datastoreidentity/package.jdo (Arbeitskopie)
@@ -8,4 +8,7 @@
SELECT FROM org.apache.jdo.tck.pc.company.Person
+
+ SELECT FIRSTNAME, LASTNAME FROM datastoreidentity0.persons
+
Index: test/jdo/applicationidentity/package.jdo
===================================================================
--- test/jdo/applicationidentity/package.jdo (Revision 345902)
+++ test/jdo/applicationidentity/package.jdo (Arbeitskopie)
@@ -8,4 +8,7 @@
SELECT FROM org.apache.jdo.tck.pc.company.Person
+
+ SELECT FIRSTNAME, LASTNAME FROM applicationidentity0.persons
+
Index: maven.xml
===================================================================
--- maven.xml (Revision 345902)
+++ maven.xml (Arbeitskopie)
@@ -398,9 +398,7 @@
+ includes="**/*.jdo, **/*.jdoquery, **/*.jdoTest.properties"/>