db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject svn commit: r345514 - in /incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck: pc/company/ query/ query/api/ query/jdoql/ query/jdoql/parameters/
Date Fri, 18 Nov 2005 16:20:28 GMT
Author: brazil
Date: Fri Nov 18 08:20:10 2005
New Revision: 345514

URL: http://svn.apache.org/viewcvs?rev=345514&view=rev
Log:
JDO-216: Result handling in class QueryTest must be capable to consider return types of java.lang.Object.

Modified:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/CompanyModelReader.java Fri Nov 18 08:20:10 2005
@@ -23,8 +23,9 @@
 import java.util.Locale;
 import java.util.TimeZone;
 
-import org.springframework.beans.propertyeditors.CustomDateEditor;
+import org.apache.jdo.tck.util.ConversionHelper;
 import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.beans.propertyeditors.CustomDateEditor;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.core.io.InputStreamResource;
 
@@ -257,6 +258,10 @@
      */
     public static Class[] getTearDownClasses() {
         return tearDownClasses;
+    }
+    
+    public static Date stringToUtilDate(String value) {
+        return ConversionHelper.toUtilDate(DATE_PATTERN, "America/New_York", Locale.US, value);
     }
 }
 

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java Fri Nov 18 08:20:10 2005
@@ -66,6 +66,18 @@
      * 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,74 @@
     }
     
     /**
-     * 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. 
      */
     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. 
      */
     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 +385,47 @@
         }
     }
     
-    // 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");
-        }
-        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);
+                                             Object expected) {
+        if (!equals(result, expected)) {
+            queryFailed(assertion, 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) {
+        // We need to explicitly check on collections passed as parameters
+        // because equals(Object, Object) checks on lists and afterwards 
+        // on collections. This ensures, lists are compared without order
+        // for queries without an ordering specification.
+        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 <code>true</code> 
@@ -452,13 +445,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 +464,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;
         }
@@ -482,6 +477,10 @@
      * This method iterates over both object arrays and calls
      * {@link QueryTest#equals(Object, Object)} passing
      * corresponding instances.
+     * {@link QueryTest#equals(Object, Object)} is called rather than
+     * {@link Object#equals(java.lang.Object)} because object arrays
+     * having equal elements cannot be compared calling  
+     * {@link Object#equals(java.lang.Object)}.
      * This method does not allow <code>o1</code> and <code>o2</code>
      * to be <code>null</code> both. 
      * @param o1 the first object array
@@ -490,22 +489,60 @@
      */
     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 <code>true</code> 
      * if <code>o1</code> and <code>o2</code> equal.
+     * This method iterates both lists and 
+     * calls {@link QueryTest#equals(Object, Object)} on corresponding elements.
+     * {@link QueryTest#equals(Object, Object)} is called rather than
+     * {@link Object#equals(java.lang.Object)} because object arrays
+     * having equal elements cannot be compared calling  
+     * {@link Object#equals(java.lang.Object)}.
+     * This method does not allow <code>o1</code> and <code>o2</code>
+     * to be <code>null</code> both. 
+     * @param o1 the first list
+     * @param o2 the second list
+     * @return <code>true</code> if <code>o1</code> and <code>o2</code> 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 <code>true</code> 
+     * if <code>o1</code> and <code>o2</code> 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 +554,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 +584,22 @@
      */
     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 {
+                for (Iterator i = o1.entrySet().iterator(); i.hasNext(); ) {
+                    Map.Entry entry = (Map.Entry) i.next();
+                    Object key = entry.getKey();
+                    Object value = entry.getValue();
+                    Object value2 = o2.get(key);
+                    if (!equals(value, value2)) {
+                        result = false;
+                        break;
+                    }
+                }
+            } 
+        }
         return result;
     }
     
@@ -559,6 +608,10 @@
      * in the given collection.
      * This method iterates the given collection and calls
      * {@link QueryTest#equals(Object, Object)} for each instance.
+     * {@link QueryTest#equals(Object, Object)} is called rather than
+     * {@link Object#equals(java.lang.Object)} because object arrays
+     * having equal elements cannot be compared calling  
+     * {@link Object#equals(java.lang.Object)}.
      * @param col the collection
      * @param o the object
      * @return <code>true</code> if <code>o</code> is contained
@@ -778,14 +831,13 @@
     /**
      * Executes the given query element holder instance as a JDO API query.
      * The result of that query is compared against the given argument 
-     * <code>expectedResult</code>. The array elements of that argument
-     * must match the content of the result collection 
-     * returned by {@link Query#execute()}.
+     * <code>expectedResult</code>. 
      * If the expected result does not match the returned query result,
      * then the test case fails prompting argument <code>assertion</code>.
      * @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 +847,51 @@
     /**
      * Executes the given query element holder instance as a JDO API query.
      * The result of that query is compared against the given argument 
-     * <code>expectedResult</code>. The array elements of that argument
-     * must match the content of the result collection 
-     * returned by {@link Query#executeWithArray(java.lang.Object[])}.
-     * Argument <code>parameters</code> is passed as the parameter 
-     * to that method.
+     * <code>expectedResult</code>. 
      * If the expected result does not match the returned query result,
      * then the test case fails prompting argument <code>assertion</code>.
      * @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 
+     * <code>expectedResult</code>. 
+     * If the expected result does not match the returned query result,
+     * then the test case fails prompting argument <code>assertion</code>.
+     * @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 
+     * <code>expectedResult</code>. 
+     * If the expected result does not match the returned query result,
+     * then the test case fails prompting argument <code>assertion</code>.
+     * @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 +903,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 
-     * <code>expectedResult</code>. The array elements of that argument
-     * must match the content of the result collection 
-     * returned by {@link Query#execute()}.
+     * <code>expectedResult</code>. 
      * If the expected result does not match the returned query result,
      * then the test case fails prompting argument <code>assertion</code>.
      * @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 +921,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 
-     * <code>expectedResult</code>. The array elements of that argument
-     * must match the content of the result collection 
-     * returned by {@link Query#executeWithArray(java.lang.Object[])}.
-     * Argument <code>parameters</code> is passed as the parameter 
-     * to that method.
+     * <code>expectedResult</code>. 
      * If the expected result does not match the returned query result,
      * then the test case fails prompting argument <code>assertion</code>.
      * @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 
+     * <code>expectedResult</code>. 
+     * If the expected result does not match the returned query result,
+     * then the test case fails prompting argument <code>assertion</code>.
+     * @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 
+     * <code>expectedResult</code>. 
+     * If the expected result does not match the returned query result,
+     * then the test case fails prompting argument <code>assertion</code>.
+     * @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 +977,58 @@
     }
     
     /**
-     * Executes the given query element holder instance 
-     * as a JDO API query of a single string query,
-     * depending on argument <code>asSingleString</code>.
-     * The result of that query is compared against the given argument 
-     * <code>expectedResult</code>. The array elements of that argument
-     * must match the content of the result collection 
-     * returned by {@link Query#executeWithArray(java.lang.Object[])}.
-     * Argument <code>parameters</code> 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 <code>assertion</code>.
+     * Converts the given query element holder instance 
+     * to a JDO query instance,
+     * based on argument <code>asSingleString</code>.
+     * 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 <code>singleStringQuery</code> 
+     * 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 <code>parameters</code> is passed as an argument
      * to the method {@link Query#executeWithArray(java.lang.Object[])}.
@@ -903,20 +1037,12 @@
      * on the given query instance instead.<p>
      * 
      * The result of query execution is compared against the argument 
-     * <code>expectedResult</code>. The array elements of that argument
-     * must match the content of the query result collection,
-     * otherwise this method throws an {@link AssertionFailedError} and 
+     * <code>expectedResult</code>. If the two values differ, 
+     * then this method throws an {@link AssertionFailedError} and 
      * the calling test case fails prompting argument 
      * <code>assertion</code>.<p>
      * 
-     * In case of a unique query, only the first element 
-     * of the result collection is compared against the first array element 
-     * of argument <code>expectedResult</code>. 
-     * A <code>null</code> as the first element indicates, that the given query 
-     * has no results, e.g. the filter does not match 
-     * any persistent instances.<p>
-     * 
-     * If argument <code>expectedResult</code> is <code>null</code>,
+     * If argument <code>positive</code> is <code>false</code>,
      * 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 +1052,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 +1071,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: " + 

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java Fri Nov 18 08:20:10 2005
@@ -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);
     }
 
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java Fri Nov 18 08:20:10 2005
@@ -46,13 +46,20 @@
     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.
+     */
+    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 +74,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java Fri Nov 18 08:20:10 2005
@@ -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,17 @@
     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.
+     */
+    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 +70,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java Fri Nov 18 08:20:10 2005
@@ -61,9 +61,12 @@
         /*TO*/          null)
     };
 
-    /** The expected results of valid queries. */
-    private static String[][] expectedResult = {
-            {"emp1", "emp2", "emp3", "emp4", "emp5"}
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"})
     };
             
     /**
@@ -78,10 +81,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]);
         }
     }
 

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java Fri Nov 18 08:20:10 2005
@@ -47,9 +47,12 @@
     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.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstancesAsList(
+                new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"})
     };
             
     /**
@@ -69,10 +72,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java Fri Nov 18 08:20:10 2005
@@ -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,12 @@
     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.
+     */
+    private Object[] expectedResult = {
+        Arrays.asList(new Object[] {
+                "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"})
     };
             
     /**
@@ -62,8 +67,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java Fri Nov 18 08:20:10 2005
@@ -42,9 +42,12 @@
     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.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstancesAsList(
+                new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"})
     };
             
     /**
@@ -63,10 +66,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java Fri Nov 18 08:20:10 2005
@@ -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,12 @@
     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.
+     */
+    private Object[] expectedResult = {
+        Arrays.asList(new Object[] {
+                "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"})
     };
             
     /**
@@ -62,8 +67,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);
     }
     
     /** */

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java Fri Nov 18 08:20:10 2005
@@ -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,16 @@
     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.
+     */
+    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 +73,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java Fri Nov 18 08:20:10 2005
@@ -41,10 +41,13 @@
     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.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstance("emp1"),
+        getCompanyModelInstancesAsList(
+                new String[]{"emp1", "emp2", "emp3", "emp4", "emp5"})
     };
             
     /**
@@ -59,25 +62,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java Fri Nov 18 08:20:10 2005
@@ -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,12 @@
         "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.
+     */
+    private Object[] expectedResult = {
+        new FullName("emp1First", "emp1Last"),
+        getCompanyModelInstancesAsList(new String[]{"emp1", "emp2", "emp5"}) 
     };
             
     /** Parameters of valid queries. */
@@ -90,8 +93,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 +109,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);
     }
     
     /**

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java Fri Nov 18 08:20:10 2005
@@ -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,16 @@
     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.
+     */
+    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 +79,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);
     }
     
     /** */

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/NegativeRange.java Fri Nov 18 08:20:10 2005
@@ -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,14 @@
         /*TO*/          3)
     };
 
-    /** The expected results of valid queries. */
-    private static String[][] expectedResult = {
-        {},
-        {},
-        {null},
-        {null}
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        Arrays.asList(new Object[]{}),
+        Arrays.asList(new Object[]{}),
+        null,
+        null
     };
             
     /**
@@ -124,8 +128,18 @@
     }
     
     /** */
-    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], 
+                    expectedResult[i]);
+        }
+    }
+
+    /** */
+    public void testUnique() {
+        for (int i = 2; i < 4; i++) {
             executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
                     expectedResult[i]);
             executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java?rev=345514&r1=345513&r2=345514&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/parameters/ImplicitParameters.java Fri Nov 18 08:20:10 2005
@@ -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,20 @@
         /*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.
+     */
+    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 +137,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 +168,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);
     }
 }



Mime
View raw message