Index: test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java
===================================================================
--- test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java (Arbeitskopie)
@@ -23,8 +23,9 @@
import java.util.Locale;
import java.util.TimeZone;
+import org.apache.jdo.tck.util.ConversionHelper;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.propertyeditors.CustomDateEditor;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.InputStreamResource;
@@ -258,5 +259,9 @@
public static Class[] getTearDownClasses() {
return tearDownClasses;
}
+
+ public static Date stringToUtilDate(String value) {
+ return ConversionHelper.toUtilDate(DATE_PATTERN, "America/New_York", Locale.US, value);
+ }
}
Index: test/java/org/apache/jdo/tck/query/QueryTest.java
===================================================================
--- test/java/org/apache/jdo/tck/query/QueryTest.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/QueryTest.java (Arbeitskopie)
@@ -66,7 +66,19 @@
* getFromInserted).
*/
protected List inserted = new ArrayList();
+
+ /**
+ * The company model reader is used
+ * to read company model instances from an XML file.
+ */
+ private CompanyModelReader companyModelReader =
+ new CompanyModelReader(COMPANY_TESTDATA);
+ /**
+ * The mylib reader is used to read mylib instances from an XML file.
+ */
+ private MylibReader mylibReader = new MylibReader(MYLIB_TESTDATA);
+
// Helper methods to create persistent PCPoint instances
/**
@@ -185,36 +197,76 @@
}
/**
- * Returns an array of company model instances for beans names
+ * Returns a company model instance for the given bean name.
+ * @param beanName the bean name.
+ * @return the company model instance.
+ */
+ protected Object getCompanyModelInstance(String beanName) {
+ return beanName == null ?
+ null : companyModelReader.getBean(beanName);
+ }
+
+ /**
+ * Returns an array of company model instances for bean names
* in the given argument.
* @param beanNames the bean names of company mode instances.
* @return the array of company model instances.
+ * @deprecated
*/
protected Object[] getCompanyModelInstances(String[] beanNames) {
- CompanyModelReader reader = new CompanyModelReader(COMPANY_TESTDATA);
Object[] result = new Object[beanNames.length];
for (int i = 0; i < beanNames.length; i++) {
- result[i] = beanNames[i] == null ?
- null : reader.getBean(beanNames[i]);
+ result[i] = getCompanyModelInstance(beanNames[i]);
}
return result;
}
/**
+ * Returns a list of company model instances instances for beans names
+ * in the given argument.
+ * @param beanNames the bean names of company model instances.
+ * @return the list of company model instances.
+ */
+ protected List getCompanyModelInstancesAsList(String[] beanNames) {
+ return new ArrayList(
+ Arrays.asList(getCompanyModelInstances(beanNames)));
+ }
+
+ /**
+ * Returns a mylib instance for the given bean name.
+ * @param beanName the bean name.
+ * @return the mylib instance.
+ */
+ protected Object getMylibInstance(String beanName) {
+ return beanName == null ?
+ null : mylibReader.getBean(beanName);
+ }
+
+ /**
* Returns an array of mylib instances for beans names
* in the given argument.
* @param beanNames the bean names of mylib instances.
* @return the array of mylib instances.
+ * @deprecated
*/
protected Object[] getMylibInstances(String[] beanNames) {
- MylibReader reader = new MylibReader(MYLIB_TESTDATA);
Object[] result = new Object[beanNames.length];
for (int i = 0; i < beanNames.length; i++) {
- result[i] = reader.getBean(beanNames[i]);
+ result[i] = getMylibInstance(beanNames[i]);
}
return result;
}
+ /**
+ * Returns a list of mylib instances for beans names
+ * in the given argument.
+ * @param beanNames the bean names of mylib instances.
+ * @return the list of mylib instances.
+ */
+ protected List getMylibInstancesAsList(String[] beanNames) {
+ return Arrays.asList(getMylibInstances(beanNames));
+ }
+
// PrimitiveTypes helper methods (creation and query)
/** */
@@ -335,104 +387,43 @@
}
}
- // Helper methods to checka query result
+ // Helper methods to check query result
/** */
protected void checkQueryResultWithOrder(String assertion,
Object result,
- Collection expected) {
- if (result == null) {
- fail(assertion, "Query returns null");
+ Object expected) {
+ if (!equals(result, expected)) {
+ queryFailed(assertion, result, expected);
}
- if (!(result instanceof Collection)) {
- fail(assertion,
- "Query result is not a collection: " +
- result.getClass().getName());
- }
- if (!compareOrderedResults((Collection)result, expected)) {
- String lf = System.getProperty("line.separator");
- result =
- ConversionHelper.convertObjectArrayElements(result);
- expected =
- ConversionHelper.convertsElementsOfTypeObjectArray(expected);
- fail(assertion,
- "Wrong query result: " + lf +
- "query returns: " + result + lf +
- "expected result: " + expected);
- }
}
- /** This method implements the semantics of AbstractList.equals but
- * does not require that the parameters actually be Lists.
- */
- protected boolean compareOrderedResults(Collection first, Collection second) {
- if (first == second) {
- return true;
- } else {
- Iterator firstIterator = first.iterator();
- Iterator secondIterator = second.iterator();
- while (firstIterator.hasNext()) {
- if (!secondIterator.hasNext()) {
- // semantics of first.size() != second.size() without using size()
- return false;
- }
- Object firstObject = firstIterator.next();
- Object secondObject = secondIterator.next();
- if (!equals(firstObject, secondObject)) {
- return false;
- }
- }
- if (secondIterator.hasNext()) {
- // semantics of first.size() != second.size() without using size()
- return false;
- } else {
- return true;
- }
- }
- }
-
/** */
protected void checkQueryResultWithoutOrder(String assertion,
Object result,
- Collection expected) {
- if (result == null) {
- fail(assertion, "Query returns null");
- }
- if (!(result instanceof Collection)) {
- fail(assertion, "Query result is not a collection: " +
- result.getClass().getName());
- }
-
- if (!equalsCollection((Collection)result, expected)) {
- result =
- ConversionHelper.convertObjectArrayElements(result);
- expected =
- ConversionHelper.convertsElementsOfTypeObjectArray(expected);
- fail(assertion, "Wrong query result" +
- "\nexpected: " + expected +
- "\ngot: " + result);
- }
- }
-
- /** */
- protected void checkUniqueResult(String assertion,
- Object result,
- Object expected) {
- if ((result != null && expected == null) ||
- (result == null && expected != null) ||
- (result != null && expected != null)) {
+ Object expected) {
+ if (result instanceof Collection && expected instanceof Collection) {
+ if (!equalsCollection((Collection)result, (Collection)expected)) {
+ queryFailed(assertion, result, expected);
+ }
+ } else {
if (!equals(result, expected)) {
- String lf = System.getProperty("line.separator");
- result = ConversionHelper.
- convertObjectArrayElements(result);
- expected = ConversionHelper.
- convertObjectArrayElements(expected);
- fail(assertion, "Wrong query result: " + lf +
- "query returns: " + result + lf +
- "expected result: " + expected);
+ queryFailed(assertion, result, expected);
}
}
}
+
+ private void queryFailed(String assertion, Object result, Object expected) {
+ String lf = System.getProperty("line.separator");
+ result =
+ ConversionHelper.convertObjectArrayElements(result);
+ expected =
+ ConversionHelper.convertObjectArrayElements(expected);
+ fail(assertion,
+ "Wrong query result: " + lf +
+ "expected: " + expected + lf +
+ "got: " + result);
+ }
/**
* Returns true
@@ -452,13 +443,15 @@
boolean result;
if (o1 == o2) {
result = true;
- } if ((o1 instanceof Object[]) && (o2 instanceof Object[])) {
+ } else if ((o1 instanceof Object[]) && (o2 instanceof Object[])) {
result = equalsObjectArray((Object[])o1, (Object[])o2);
+ } else if ((o1 instanceof List) && (o2 instanceof List)) {
+ result = equalsList((List)o1, (List)o2);
} else if ((o1 instanceof Collection) && (o2 instanceof Collection)) {
result = equalsCollection((Collection)o1, (Collection)o2);
} else if ((o1 instanceof Map) && (o2 instanceof Map)) {
result = equalsMap((Map)o1, (Map)o2);
- }else if ((o1 instanceof Float) && (o2 instanceof Float)) {
+ } else if ((o1 instanceof Float) && (o2 instanceof Float)) {
result = closeEnough(((Float)o1).floatValue(),
((Float)o2).floatValue());
} else if ((o1 instanceof Double) && (o2 instanceof Double)) {
@@ -469,7 +462,7 @@
} else if (o1 != null) {
result = o1.equals(o2);
} else {
- // Due to the first if and the last if we have:
+ // Due to the first if and due to the last if, we have:
// o1 == null && o2 != null
result = false;
}
@@ -490,22 +483,56 @@
*/
private boolean equalsObjectArray(Object[] o1, Object[] o2) {
boolean result = true;
- if (o1.length != o2.length) {
- result = false;
- } else {
- for (int i = 0; i < o1.length; i++ ) {
- if (!equals(o1[i], o2[i])) {
- result = false;
- break;
+ if (o1 != o2) {
+ if (o1.length != o2.length) {
+ result = false;
+ } else {
+ for (int i = 0; i < o1.length; i++ ) {
+ if (!equals(o1[i], o2[i])) {
+ result = false;
+ break;
+ }
}
- }
- }
+ }
+ }
return result;
}
/**
* Returns true
* if o1 and o2 equal.
+ * This method iterates both lists and
+ * calls {@link QueryTest#equals(Object, Object)} on corresponding element.
+ * This method does not allow o1 and o2
+ * to be null both.
+ * @param o1 the first list
+ * @param o2 the second list
+ * @return true if o1 and o2 equal.
+ */
+ private boolean equalsList(List o1, List o2) {
+ boolean result = true;
+ if (o1 != o2) {
+ if (o1.size() != o2.size()) {
+ result = false;
+ } else {
+ Iterator i = o1.iterator();
+ Iterator ii = o2.iterator();
+ while (i.hasNext()) {
+ Object firstObject = i.next();
+ Object secondObject = ii.next();
+ if (!equals(firstObject, secondObject)) {
+ result = false;
+ break;
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns true
+ * if o1 and o2 equal.
* This method iterates over the first collection and
* checks if each instance is contained in the second collection
* by calling {@link QueryTest#contains(Collection, Object)}.
@@ -517,17 +544,19 @@
*/
private boolean equalsCollection(Collection o1, Collection o2) {
boolean result = true;
- if (o1.size() != o2.size()) {
- result = false;
- } else {
- for (Iterator i = o1.iterator(); i.hasNext(); ) {
- Object oo1 = i.next();
- if (!contains(o2, oo1)) {
- result = false;
- break;
+ if (o1 != o2) {
+ if (o1.size() != o2.size()) {
+ result = false;
+ } else {
+ for (Iterator i = o1.iterator(); i.hasNext(); ) {
+ Object oo1 = i.next();
+ if (!contains(o2, oo1)) {
+ result = false;
+ break;
+ }
}
- }
- }
+ }
+ }
return result;
}
@@ -545,12 +574,14 @@
*/
private boolean equalsMap(Map o1, Map o2) {
boolean result = true;
- if (o1.size() != o2.size()) {
- result = false;
- } else if (!equalsCollection(o1.keySet(), o2.keySet()) ||
- !equalsCollection(o1.values(), o2.values())) {
- result = false;
- }
+ if (o1 != o2) {
+ if (o1.size() != o2.size()) {
+ result = false;
+ } else if (!equalsCollection(o1.keySet(), o2.keySet()) ||
+ !equalsCollection(o1.values(), o2.values())) {
+ result = false;
+ }
+ }
return result;
}
@@ -778,14 +809,13 @@
/**
* Executes the given query element holder instance as a JDO API query.
* The result of that query is compared against the given argument
- * expectedResult. The array elements of that argument
- * must match the content of the result collection
- * returned by {@link Query#execute()}.
+ * expectedResult.
* If the expected result does not match the returned query result,
* then the test case fails prompting argument assertion.
* @param assertion the assertion to prompt if the test case fails.
* @param queryElementHolder the query to execute.
* @param expectedResult the expected query result.
+ * @deprecated
*/
protected void executeAPIQuery(String assertion,
QueryElementHolder queryElementHolder, Object[] expectedResult) {
@@ -795,21 +825,51 @@
/**
* Executes the given query element holder instance as a JDO API query.
* The result of that query is compared against the given argument
- * expectedResult. The array elements of that argument
- * must match the content of the result collection
- * returned by {@link Query#executeWithArray(java.lang.Object[])}.
- * Argument parameters is passed as the parameter
- * to that method.
+ * expectedResult.
* If the expected result does not match the returned query result,
* then the test case fails prompting argument assertion.
* @param assertion the assertion to prompt if the test case fails.
* @param queryElementHolder the query to execute.
* @param parameters the parmaters of the query.
* @param expectedResult the expected query result.
+ * @deprecated
*/
protected void executeAPIQuery(String assertion,
QueryElementHolder queryElementHolder,
Object[] parameters, Object[] expectedResult) {
+ executeAPIQuery(assertion, queryElementHolder,
+ parameters, Arrays.asList(expectedResult));
+ }
+
+ /**
+ * Executes the given query element holder instance as a JDO API 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.
+ * @param assertion the assertion to prompt if the test case fails.
+ * @param queryElementHolder the query to execute.
+ * @param expectedResult the expected query result.
+ */
+ protected void executeAPIQuery(String assertion,
+ QueryElementHolder queryElementHolder, Object expectedResult) {
+ executeAPIQuery(assertion, queryElementHolder, null, expectedResult);
+ }
+
+ /**
+ * Executes the given query element holder instance as a JDO API 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.
+ * @param assertion the assertion to prompt if the test case fails.
+ * @param queryElementHolder the query to execute.
+ * @param parameters the parmaters of the query.
+ * @param expectedResult the expected query result.
+ */
+ protected void executeAPIQuery(String assertion,
+ QueryElementHolder queryElementHolder,
+ Object[] parameters, Object expectedResult) {
if (logger.isDebugEnabled()) {
logger.debug("Executing API query: " + queryElementHolder);
}
@@ -821,14 +881,13 @@
* Executes the given query element holder instance
* as a JDO single string query.
* The result of that query is compared against the given argument
- * expectedResult. The array elements of that argument
- * must match the content of the result collection
- * returned by {@link Query#execute()}.
+ * expectedResult.
* If the expected result does not match the returned query result,
* then the test case fails prompting argument assertion.
* @param assertion the assertion to prompt if the test case fails.
* @param queryElementHolder the query to execute.
* @param expectedResult the expected query result.
+ * @deprecated
*/
protected void executeSingleStringQuery(String assertion,
QueryElementHolder queryElementHolder, Object[] expectedResult) {
@@ -840,21 +899,54 @@
* Executes the given query element holder instance
* as a JDO single string query.
* The result of that query is compared against the given argument
- * expectedResult. The array elements of that argument
- * must match the content of the result collection
- * returned by {@link Query#executeWithArray(java.lang.Object[])}.
- * Argument parameters is passed as the parameter
- * to that method.
+ * expectedResult.
* If the expected result does not match the returned query result,
* then the test case fails prompting argument assertion.
* @param assertion the assertion to prompt if the test case fails.
* @param queryElementHolder the query to execute.
* @param parameters the parmaters of the query.
* @param expectedResult the expected query result.
+ * @deprecated
*/
protected void executeSingleStringQuery(String assertion,
QueryElementHolder queryElementHolder,
Object[] parameters, Object[] expectedResult) {
+ executeSingleStringQuery(assertion, queryElementHolder,
+ parameters, Arrays.asList(expectedResult));
+ }
+
+ /**
+ * Executes the given query element holder instance
+ * as a JDO single string 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.
+ * @param assertion the assertion to prompt if the test case fails.
+ * @param queryElementHolder the query to execute.
+ * @param expectedResult the expected query result.
+ */
+ protected void executeSingleStringQuery(String assertion,
+ QueryElementHolder queryElementHolder, Object expectedResult) {
+ executeSingleStringQuery(assertion, queryElementHolder,
+ null, expectedResult);
+ }
+
+ /**
+ * Executes the given query element holder instance
+ * as a JDO single string 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.
+ * @param assertion the assertion to prompt if the test case fails.
+ * @param queryElementHolder the query to execute.
+ * @param parameters the parmaters of the query.
+ * @param expectedResult the expected query result.
+ */
+ protected void executeSingleStringQuery(String assertion,
+ QueryElementHolder queryElementHolder,
+ Object[] parameters, Object expectedResult) {
if (logger.isDebugEnabled())
logger.debug("Executing single string query: " +
queryElementHolder);
@@ -863,38 +955,58 @@
}
/**
- * Executes the given query element holder instance
- * as a JDO API query of a single string query,
- * depending on argument asSingleString.
- * The result of that query is compared against the given argument
- * expectedResult. The array elements of that argument
- * must match the content of the result collection
- * returned by {@link Query#executeWithArray(java.lang.Object[])}.
- * Argument parameters is passed as the parameter
- * to that method.
- * If the expected result does not match the returned query result,
- * then the test case fails prompting argument assertion.
+ * Converts the given query element holder instance
+ * to a JDO query instance,
+ * based on argument asSingleString.
+ * Afterwards, delegates to method
+ * {@link QueryTest#execute(String, Query, String, boolean, Object[], Object, boolean)}.
* @param assertion the assertion to prompt if the test case fails.
* @param queryElementHolder the query to execute.
* @param asSingleString determines if the query is executed as
* single string query or as API query.
* @param parameters the parmaters of the query.
* @param expectedResult the expected query result.
- * @return
+ * @return the query result
*/
private Object execute(String assertion,
QueryElementHolder queryElementHolder, boolean asSingleString,
- Object[] parameters, Object[] expectedResult) {
+ Object[] parameters, Object expectedResult) {
Query query = asSingleString ?
queryElementHolder.getSingleStringQuery(pm) :
queryElementHolder.getAPIQuery(pm);
- Object result = execute(assertion, query, queryElementHolder.toString(),
- queryElementHolder.isUnique(), queryElementHolder.hasOrdering(),
- parameters, expectedResult);
+ Object result = execute(assertion, query,
+ queryElementHolder.toString(),
+ queryElementHolder.hasOrdering(), parameters,
+ expectedResult, true);
return result;
}
/**
+ * Executes the given query instance delegating to
+ * {@link QueryTest#execute(String, Query, String, boolean, Object[], Object, boolean).
+ * Logs argument singleStringQuery
+ * if debug logging is enabled.
+ * @param assertion the assertion to prompt if the test case fails.
+ * @param query the query to execute.
+ * @param singleStringQuery the single string representation of the query.
+ * This parameter is only used as part of the falure message.
+ * @param hasOrdering indicates if the query has an ordering clause.
+ * @param parameters the parmaters of the query.
+ * @param expectedResult the expected query result.
+ * @param positive indicates if query execution is supposed to fail
+ * @return the query result
+ */
+ protected Object executeJDOQuery(String assertion, Query query,
+ String singleStringQuery, boolean hasOrdering,
+ Object[] parameters, Object expectedResult, boolean positive) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Executing JDO query: " + singleStringQuery);
+ }
+ return execute(assertion, query, singleStringQuery, hasOrdering,
+ parameters, expectedResult, positive);
+ }
+
+ /**
* Executes the given query instance.
* Argument parameters is passed as an argument
* to the method {@link Query#executeWithArray(java.lang.Object[])}.
@@ -903,20 +1015,12 @@
* on the given query instance instead.
*
* The result of query execution is compared against the argument
- * expectedResult. The array elements of that argument
- * must match the content of the query result collection,
- * otherwise this method throws an {@link AssertionFailedError} and
+ * expectedResult. If the two values differ,
+ * then this method throws an {@link AssertionFailedError} and
* the calling test case fails prompting argument
* assertion.
*
- * In case of a unique query, only the first element
- * of the result collection is compared against the first array element
- * of argument expectedResult.
- * A null as the first element indicates, that the given query
- * has no results, e.g. the filter does not match
- * any persistent instances.
- *
- * If argument expectedResult is null,
+ * If argument positive is false,
* then the test case invoking this method is considered to be
* a negative test case.
* Then, query execution is expected to throw a {@link JDOUserException}.
@@ -926,19 +1030,17 @@
*
* @param assertion the assertion to prompt if the test case fails.
* @param query the query to execute.
- * @param asSingleString the single string representation of the query.
+ * @param singleStringQuery the single string representation of the query.
* This parameter is only used as part of the falure message.
- * @param isUnique indicates if the query has a unique result.
* @param hasOrdering indicates if the query has an ordering clause.
* @param parameters the parmaters of the query.
* @param expectedResult the expected query result.
- * @return the result collection
+ * @param positive indicates if query execution is supposed to fail
+ * @return the query result
*/
- protected Object execute(String assertion, Query query,
- String singleStringQuery,
- boolean isUnique, boolean hasOrdering,
- Object[] parameters, Object[] expectedResult) {
- boolean positive = expectedResult != null;
+ private Object execute(String assertion, Query query,
+ String singleStringQuery, boolean hasOrdering,
+ Object[] parameters, Object expectedResult, boolean positive) {
Object result = null;
PersistenceManager pm = getPM();
Transaction tx = pm.currentTransaction();
@@ -947,20 +1049,18 @@
try {
result = parameters != null ?
query.executeWithArray(parameters) : query.execute();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Query result: " + ConversionHelper.
+ convertObjectArrayElements(result));
+ }
if (positive) {
- if (isUnique) {
- checkUniqueResult(assertion, result, expectedResult[0]);
- } else if (hasOrdering) {
- List expectedResultList =
- Arrays.asList(expectedResult);
+ if (hasOrdering) {
checkQueryResultWithOrder(assertion, result,
- expectedResultList);
+ expectedResult);
} else {
- Collection expectedResultCollection =
- Arrays.asList(expectedResult);
checkQueryResultWithoutOrder(assertion, result,
- expectedResultCollection);
+ expectedResult);
}
} else {
fail(assertion + "Query must throw JDOUserException: " +
Index: test/java/org/apache/jdo/tck/query/api/SetGrouping.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/SetGrouping.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/SetGrouping.java (Arbeitskopie)
@@ -16,6 +16,8 @@
package org.apache.jdo.tck.query.api;
+import java.util.Arrays;
+
import javax.jdo.Query;
import org.apache.jdo.tck.JDO_Test;
@@ -41,9 +43,14 @@
private static final String ASSERTION_FAILED =
"Assertion A14.6-17 (SetGrouping) failed: ";
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {"emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[] {
+ "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"})
};
/**
@@ -62,8 +69,8 @@
query.setResult("lastname");
query.setGrouping("lastname");
String singleStringQuery = "SELECT lastname FROM Person GROUP BY lastname";
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResult[index]);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java (Arbeitskopie)
@@ -61,9 +61,14 @@
/*TO*/ null)
};
- /** The expected results of valid queries. */
- private static String[][] expectedResult = {
- {"emp1", "emp2", "emp3", "emp4", "emp5"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ getCompanyModelInstancesAsList(new String[]{
+ "emp1", "emp2", "emp3", "emp4", "emp5"})
};
/**
@@ -78,10 +83,8 @@
/** */
public void testPositive() {
for (int i = 0; i < VALID_QUERIES.length; i++) {
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[i]);
executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i],
- expectedResultValues);
+ expectedResult[i]);
}
}
Index: test/java/org/apache/jdo/tck/query/api/SetResultClass.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/SetResultClass.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/SetResultClass.java (Arbeitskopie)
@@ -16,6 +16,8 @@
package org.apache.jdo.tck.query.api;
+import java.util.Arrays;
+
import javax.jdo.Query;
import org.apache.jdo.tck.JDO_Test;
@@ -42,13 +44,18 @@
private static final String ASSERTION_FAILED =
"Assertion A14.6-19 (SetResultClass) failed: ";
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {new FullName("emp1First", "emp1Last"),
- new FullName("emp2First", "emp2Last"),
- new FullName("emp3First", "emp3Last"),
- new FullName("emp4First", "emp4Last"),
- new FullName("emp5First", "emp5Last")}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[] {
+ new FullName("emp1First", "emp1Last"),
+ new FullName("emp2First", "emp2Last"),
+ new FullName("emp3First", "emp3Last"),
+ new FullName("emp4First", "emp4Last"),
+ new FullName("emp5First", "emp5Last")})
};
/**
@@ -68,8 +75,8 @@
query.setResult("firstname, lastname");
String singleStringQuery =
"SELECT firstname, lastname INTO FullName FROM Person";
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResult[index]);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/SetUnique.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/SetUnique.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/SetUnique.java (Arbeitskopie)
@@ -41,10 +41,15 @@
private static final String ASSERTION_FAILED =
"Assertion A14.6-18 (SetUnique) failed: ";
- /** The expected results of valid queries. */
- private static String[][] expectedResult = {
- {"emp1"},
- {"emp1", "emp2", "emp3", "emp4", "emp5"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ getCompanyModelInstance("emp1"),
+ getCompanyModelInstancesAsList(
+ new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"})
};
/**
@@ -59,25 +64,20 @@
/** */
public void testPositive() {
int index = 0;
- boolean unique = true;
Query query = getPM().newQuery(Person.class);
- query.setUnique(unique);
+ query.setUnique(true);
query.setFilter("lastname == 'emp1Last'");
String singleStringQuery =
"SELECT FROM Person WHERE lastname == 'emp1Last'";
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- unique, false, null, expectedResultValues);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
index = 1;
- unique = false;
query = getPM().newQuery(Person.class);
- query.setUnique(unique);
+ query.setUnique(false);
singleStringQuery = "SELECT FROM Person";
- expectedResultValues = getCompanyModelInstances(expectedResult[index]);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- unique, false, null, expectedResultValues);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/QueryExtentions.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/QueryExtentions.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/QueryExtentions.java (Arbeitskopie)
@@ -47,9 +47,14 @@
private static String singleStringQuery =
"SELECT FROM " + Person.class.getName();
- /** The expected results of valid queries. */
- private static String[][] expectedResult = {
- {"emp1", "emp2", "emp3", "emp4", "emp5"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ getCompanyModelInstancesAsList(
+ new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"})
};
/**
@@ -69,10 +74,8 @@
extentions.put("unknown key 1", "unknown value 1");
query.setExtensions(extentions);
query.addExtension("unknown key 2", "unknown value 2");
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResultValues);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/SetResult.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/SetResult.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/SetResult.java (Arbeitskopie)
@@ -16,6 +16,8 @@
package org.apache.jdo.tck.query.api;
+import java.util.Arrays;
+
import javax.jdo.JDOUserException;
import javax.jdo.Query;
@@ -42,9 +44,14 @@
private static final String ASSERTION_FAILED =
"Assertion A14.6-16 (SetResult) failed: ";
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {"emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[] {
+ "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"})
};
/**
@@ -62,8 +69,8 @@
Query query = getPM().newQuery(Person.class);
query.setResult("lastname");
String singleStringQuery = "SELECT lastname FROM Person";
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResult[index]);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/** */
Index: test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java (Arbeitskopie)
@@ -17,6 +17,7 @@
package org.apache.jdo.tck.query.api;
import java.math.BigDecimal;
+import java.util.Arrays;
import javax.jdo.Query;
@@ -66,10 +67,14 @@
"ORDER BY personid ASCENDING " +
"RANGE 0,5";
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {new FullName("emp1First", "emp1Last")},
- new String[]{"emp1", "emp2", "emp5"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ new FullName("emp1First", "emp1Last"),
+ getCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp5"})
};
/** Parameters of valid queries. */
@@ -90,8 +95,8 @@
public void testPositive() {
int index = 0;
Query query = getPM().newQuery(singleStringQuery);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- true, true, parameters[index], expectedResult[index]);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ true, parameters[index], expectedResult[index], true);
index = 1;
String singleStringQuery = "SELECT FROM FullTimeEmployee";
@@ -106,8 +111,8 @@
query.setGrouping(null);
query.setOrdering(null);
query.setRange(null);
- execute(ASSERTION_FAILED, query, singleStringQuery, false, false, null,
- getCompanyModelInstances((String[])expectedResult[index]));
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, false, null,
+ expectedResult[index], true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java (Arbeitskopie)
@@ -46,13 +46,22 @@
private static final String ASSERTION_FAILED =
"Assertion A14.5-13 (MetadataSearchOrder) failed: ";
- /** The expected results of valid queries. */
- private static String[][] expectedResult = {
- {"emp1", "emp2", "emp3", "emp4", "emp5"},
- {"emp2", "emp3", "emp4", "emp5"},
- {"pcClass1", "pcClass2"},
- {"emp3", "emp4", "emp5"},
- {"emp4", "emp5"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ getCompanyModelInstancesAsList(new String[]{
+ "emp1", "emp2", "emp3", "emp4", "emp5"}),
+ getCompanyModelInstancesAsList(new String[]{
+ "emp2", "emp3", "emp4", "emp5"}),
+ getMylibInstancesAsList(new String[]{
+ "pcClass1", "pcClass2"}),
+ getCompanyModelInstancesAsList(new String[]{
+ "emp3", "emp4", "emp5"}),
+ getCompanyModelInstancesAsList(new String[]{
+ "emp4", "emp5"})
};
/**
@@ -67,53 +76,43 @@
/** */
public void testPackageJDOInDefaultPackage() {
int index = 0;
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
executeNamedQuery(null, "packageJDOInDefaultPackage",
- false, expectedResultValues);
+ expectedResult[index]);
}
/** */
public void testPackageJDO() {
int index = 1;
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
executeNamedQuery(Person.class, "packageJDO",
- false, expectedResultValues);
+ expectedResult[index]);
}
/** */
public void testClassJDO() {
int index = 2;
- Object[] expectedResultValues =
- getMylibInstances(expectedResult[index]);
executeNamedQuery(PCClass.class, "classJDO",
- false, expectedResultValues);
+ expectedResult[index]);
}
/** */
public void testPackageORM() {
int index = 3;
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
executeNamedQuery(Person.class, "packageORM",
- false, expectedResultValues);
+ expectedResult[index]);
}
/** */
public void testClassJDOQuery() {
int index = 4;
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
executeNamedQuery(Person.class, "classJDOQuery",
- false, expectedResultValues);
+ expectedResult[index]);
}
private void executeNamedQuery(Class candidateClass, String namedQuery,
- boolean isUnique, Object[] expectedResultValues) {
+ Object expectedResult) {
Query query = getPM().newNamedQuery(candidateClass, namedQuery);
- execute(ASSERTION_FAILED, query, "Named query " + namedQuery,
- isUnique, false, null, expectedResultValues);
+ executeJDOQuery(ASSERTION_FAILED, query, "Named query " + namedQuery,
+ false, null, expectedResult, true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/SetRange.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/SetRange.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/SetRange.java (Arbeitskopie)
@@ -42,9 +42,14 @@
private static final String ASSERTION_FAILED =
"Assertion A14.6-20 (SetRange) failed: ";
- /** The expected results of valid queries. */
- private static String[][] expectedResult = {
- {"emp1", "emp2", "emp3", "emp4", "emp5"}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ getCompanyModelInstancesAsList(
+ new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"})
};
/**
@@ -63,10 +68,8 @@
query.setRange(0, 5);
String singleStringQuery =
"SELECT FROM Person RANGE 0, 5";
- Object[] expectedResultValues =
- getCompanyModelInstances(expectedResult[index]);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResultValues);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/ChangeQuery.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/ChangeQuery.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/ChangeQuery.java (Arbeitskopie)
@@ -17,6 +17,8 @@
package org.apache.jdo.tck.query.api;
import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.List;
import javax.jdo.Query;
@@ -82,15 +84,14 @@
// query parameters
Object[] parameters = {new BigDecimal("2000")};
// expected result
- Object[] expectedResult = {
+ List expectedResult = Arrays.asList(new Object[] {
new FullName("emp1First", "emp1Last"),
new FullName("emp2First", "emp2Last"),
- new FullName("emp5First", "emp5Last")
- };
+ new FullName("emp5First", "emp5Last")});
// execute query
- execute(ASSERTION_FAILED, query, singleStringQuery, false, true,
- parameters, expectedResult);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, true,
+ parameters, expectedResult, true);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java (Arbeitskopie)
@@ -16,7 +16,8 @@
package org.apache.jdo.tck.query.api;
-import javax.jdo.JDOException;
+import java.util.Arrays;
+
import javax.jdo.Query;
import org.apache.jdo.tck.JDO_Test;
@@ -43,14 +44,19 @@
private static final String ASSERTION_FAILED =
"Assertion A14.5-12 (NewNamedQuery) failed: ";
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {new FullName("emp1First", "emp1Last"),
- new FullName("emp2First", "emp2Last"),
- new FullName("emp3First", "emp3Last"),
- new FullName("emp4First", "emp4Last"),
- new FullName("emp5First", "emp5Last")},
- {new FullName("emp1First", "emp1Last")}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ 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")
};
/**
@@ -66,23 +72,23 @@
public void testPositive() {
int index = 0;
executeNamedQuery(Person.class, "validNotUnique",
- false, expectedResult[index]);
+ expectedResult[index], true);
index = 1;
executeNamedQuery(Person.class, "validUnique",
- true, expectedResult[index]);
+ expectedResult[index], true);
}
/** */
public void testNegative() {
- executeNamedQuery(Person.class, "invalidUnique", true, null);
+ executeNamedQuery(Person.class, "invalidUnique", null, false);
}
private void executeNamedQuery(Class candidateClass, String namedQuery,
- boolean isUnique, Object[] expectedResultValues) {
+ Object expectedResult, boolean positive) {
Query query = getPM().newNamedQuery(candidateClass, namedQuery);
- execute(ASSERTION_FAILED, query, "Named query " + namedQuery,
- isUnique, false, null, expectedResultValues);
+ executeJDOQuery(ASSERTION_FAILED, query, "Named query " + namedQuery,
+ false, null, expectedResult, positive);
}
/**
Index: test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java
===================================================================
--- test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java (Arbeitskopie)
@@ -16,7 +16,8 @@
package org.apache.jdo.tck.query.api;
-import javax.jdo.JDOException;
+import java.util.Arrays;
+
import javax.jdo.JDOUserException;
import javax.jdo.Query;
@@ -49,13 +50,18 @@
private static String singleStringQuery =
"SELECT firstname, lastname FROM org.apache.jdo.tck.pc.company.Person";
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {new FullName("emp1First", "emp1Last"),
- new FullName("emp2First", "emp2Last"),
- new FullName("emp3First", "emp3Last"),
- new FullName("emp4First", "emp4Last"),
- new FullName("emp5First", "emp5Last")}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[] {
+ new FullName("emp1First", "emp1Last"),
+ new FullName("emp2First", "emp2Last"),
+ new FullName("emp3First", "emp3Last"),
+ new FullName("emp4First", "emp4Last"),
+ new FullName("emp5First", "emp5Last")})
};
/**
@@ -75,15 +81,15 @@
query.setResultClass(FullName.class);
query.setRange(0, 5);
query.setIgnoreCache(true);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResult[index]);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
query = getPM().newNamedQuery(Person.class, "unmodifiable");
query.setResultClass(FullName.class);
query.setRange(0, 5);
query.setIgnoreCache(true);
- execute(ASSERTION_FAILED, query, singleStringQuery,
- false, false, null, expectedResult[index]);
+ executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery,
+ false, null, expectedResult[index], true);
}
/** */
Index: test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java
===================================================================
--- test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java (Arbeitskopie)
@@ -16,6 +16,9 @@
package org.apache.jdo.tck.query.jdoql.parameters;
+import java.util.Arrays;
+import java.util.List;
+
import org.apache.jdo.tck.JDO_Test;
import org.apache.jdo.tck.pc.company.CompanyModelReader;
import org.apache.jdo.tck.pc.company.Employee;
@@ -106,12 +109,22 @@
/*TO*/ ":five")
};
- /** The expected results of valid queries. */
- private static Object[][] expectedResult = {
- {"emp1", "emp2", "emp3", "emp4", "emp5"},
- {"emp1"},
- {"Development"}, /* Note: this is not a bean name! */
- {"emp1", "emp2", "emp3", "emp4", "emp5"}
+ private static String parameter = "parameterInResult";
+
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ getExpectedResultOfFirstQuery(
+ getCompanyModelInstancesAsList(new String[] {
+ "emp1", "emp2", "emp3", "emp4", "emp5"})),
+ getCompanyModelInstancesAsList(new String[]{"emp1"}),
+ /* Note: "Development" is not a bean name! */
+ Arrays.asList(new Object[]{"Development"}),
+ getCompanyModelInstancesAsList(new String[] {
+ "emp1", "emp2", "emp3", "emp4", "emp5"})
};
/**
@@ -126,37 +139,26 @@
/** */
public void testResult() {
int index = 0;
- Object[] pcInstances =
- getCompanyModelInstances(toStringArray(expectedResult[index]));
- Object[] expectedResultValues = new Object[pcInstances.length];
- String parameter = "parameterInResult";
- for (int i = 0; i < expectedResultValues.length; i++) {
- expectedResultValues[i] = new Object[] {pcInstances[i], parameter};
- }
- executeQuery(index, new Object[] {parameter}, expectedResultValues);
+ executeQuery(index, new Object[] {parameter});
}
/** */
public void testFilter() {
int index = 1;
- Object[] expectedResultValues =
- getCompanyModelInstances(toStringArray(expectedResult[index]));
- executeQuery(index, new Object[] {"emp1First"}, expectedResultValues);
+ executeQuery(index, new Object[] {"emp1First"});
}
/** */
public void testGrouping() {
int index = 2;
- executeQuery(index, new Object[] {new Long(3)}, expectedResult[index]);
+ executeQuery(index, new Object[] {new Long(3)});
}
/** */
public void testRange() {
int index = 3;
- Object[] expectedResultValues =
- getCompanyModelInstances(toStringArray(expectedResult[index]));
executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- new Object[] {new Long(0), new Long(5)}, expectedResultValues);
+ new Object[] {new Long(0), new Long(5)}, expectedResult[index]);
}
/**
@@ -168,17 +170,18 @@
}
/** */
- private void executeQuery(int index, Object[] parameters, Object[] expectedResultValues) {
+ private void executeQuery(int index, Object[] parameters) {
executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- parameters, expectedResultValues);
+ parameters, expectedResult[index]);
executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index],
- parameters, expectedResultValues);
+ parameters, expectedResult[index]);
}
- /** */
- private String[] toStringArray(Object[] array) {
- String[] result = new String[array.length];
- System.arraycopy(array, 0, result, 0, result.length);
- return result;
+ private List getExpectedResultOfFirstQuery(List instances) {
+ Object[] expectedResult = new Object[instances.size()];
+ for (int i = 0; i < expectedResult.length; i++) {
+ expectedResult[i] = new Object[] {instances.get(i), parameter};
+ }
+ return Arrays.asList(expectedResult);
}
}
Index: test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java
===================================================================
--- test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java (Revision 345238)
+++ test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java (Arbeitskopie)
@@ -16,6 +16,8 @@
package org.apache.jdo.tck.query.jdoql;
+import java.util.Arrays;
+
import org.apache.jdo.tck.JDO_Test;
import org.apache.jdo.tck.pc.company.CompanyModelReader;
import org.apache.jdo.tck.pc.company.Person;
@@ -106,12 +108,16 @@
/*TO*/ 3)
};
- /** The expected results of valid queries. */
- private static String[][] expectedResult = {
- {},
- {},
- {null},
- {null}
+ /**
+ * The expected results of valid queries.
+ * This field is not declared static
+ * to avoid file IO at class loading time.
+ */
+ private Object[] expectedResult = {
+ Arrays.asList(new Object[]{}),
+ Arrays.asList(new Object[]{}),
+ null,
+ null
};
/**
@@ -124,8 +130,8 @@
}
/** */
- public void testPositive() {
- for (int i = 0; i < VALID_QUERIES.length; i++) {
+ public void testNonUnique() {
+ for (int i = 0; i < 2; i++) {
executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i],
expectedResult[i]);
executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i],
@@ -133,6 +139,16 @@
}
}
+ /** */
+ public void testUnique() {
+ for (int i = 2; i < 4; i++) {
+ executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i],
+ expectedResult[i]);
+ executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i],
+ expectedResult[i]);
+ }
+ }
+
/**
* @see JDO_Test#localSetUp()
*/