db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject svn commit: r345921 [1/2] - in /incubator/jdo/trunk/tck20/test: conf/ java/org/apache/jdo/tck/query/result/ java/org/apache/jdo/tck/query/result/classes/ java/org/apache/jdo/tck/util/
Date Mon, 21 Nov 2005 16:05:25 GMT
Author: brazil
Date: Mon Nov 21 08:05:04 2005
New Revision: 345921

URL: http://svn.apache.org/viewcvs?rev=345921&view=rev
Log:
JDO-164: Implement new JDO 2 query tests cases concerning result handling.

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/AggregateResult.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultResult.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultUnique.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistinctQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistintCandidateInstances.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Grouping.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Having.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NullResults.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultExpressions.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ShapeOfResult.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Unique.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/VariableInResult.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/LongString.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java
Modified:
    incubator/jdo/trunk/tck20/test/conf/alltests.conf
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/FullName.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/EqualityHelper.java

Modified: incubator/jdo/trunk/tck20/test/conf/alltests.conf
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/alltests.conf?rev=345921&r1=345920&r2=345921&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/alltests.conf (original)
+++ incubator/jdo/trunk/tck20/test/conf/alltests.conf Mon Nov 21 08:05:04 2005
@@ -376,7 +376,21 @@
 org.apache.jdo.tck.query.jdoql.variables.VariablesAndFields \
 org.apache.jdo.tck.query.jdoql.variables.VariablesWithoutExtent \
 org.apache.jdo.tck.query.jdoql.variables.VariableDeclaredWithSameNameAsFieldOfCandidateClass \
+org.apache.jdo.tck.query.result.AggregateResult \
+org.apache.jdo.tck.query.result.DefaultResult \
+org.apache.jdo.tck.query.result.DefaultUnique \
+org.apache.jdo.tck.query.result.DistintCandidateInstances \
+org.apache.jdo.tck.query.result.DistinctQuery \
+org.apache.jdo.tck.query.result.Grouping \
+org.apache.jdo.tck.query.result.Having \
 org.apache.jdo.tck.query.result.ImmutableQueryResult \
+org.apache.jdo.tck.query.result.NPEInResultExpr \
+org.apache.jdo.tck.query.result.NullResults \
+org.apache.jdo.tck.query.result.ResultClassRequirements \
+org.apache.jdo.tck.query.result.ResultExpressions \
+org.apache.jdo.tck.query.result.ShapeOfResult \
+org.apache.jdo.tck.query.result.Unique \
+org.apache.jdo.tck.query.result.VariableInResult \
 org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenCommitted \
 org.apache.jdo.tck.transactions.AfterCompletionMethodCalledWhenRolledback \
 org.apache.jdo.tck.transactions.AfterSetRollbackOnlyCommitFails \
@@ -404,4 +418,3 @@
 org.apache.jdo.tck.transactions.SetRetainValuesTrueWhenNotSupported \
 org.apache.jdo.tck.transactions.SetSynchronization \
 org.apache.jdo.tck.transactions.SetSynchronizationToNull
-

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/AggregateResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/AggregateResult.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/AggregateResult.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/AggregateResult.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,496 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+import java.math.BigDecimal;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.DentalInsurance;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Aggregate Result.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-6.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Count returns Long. Sum returns Long for integral types and 
+ * the field's type for other Number types 
+ * (BigDecimal, BigInteger, Float, and Double). 
+ * Sum is invalid if applied to non-Number types. 
+ * Avg, min, and max return the type of the expression.
+ */
+public class AggregateResult extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-6 (AggregateResult) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        // COUNT
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(this)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // COUNT
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(this)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 0",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // COUNT
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(manager)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // SUM(long)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "SUM(personid)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // SUM(double)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "SUM(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // SUM(BigDecimal)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "SUM(budget)",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // SUM
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "SUM(budget)",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projid == 0",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MIN(long)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MIN(personid)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MIN(double)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MIN(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MIN(BigDecimal)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MIN(budget)",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MIN
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MIN(budget)",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projid == 0",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MAX(long)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MAX(personid)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MAX(double)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MAX(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MAX(BigDecimal)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MAX(budget)",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // MAX
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MAX(budget)",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projid == 0",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // AVG(long)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "AVG(personid)",
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // AVG(double)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "AVG(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // AVG(BigDecimal)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "AVG(lifetimeOrthoBenefit)",
+        /*INTO*/        null, 
+        /*FROM*/        DentalInsurance.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+
+        // AVG
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "AVG(lifetimeOrthoBenefit)",
+        /*INTO*/        null, 
+        /*FROM*/        DentalInsurance.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "insid == 0",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+        
+    };
+    
+    /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        // SUM
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "SUM(firstname)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+        
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        // COUNT
+        new Long(3),
+        // COUNT
+        new Long(0),
+        // COUNT
+        new Long(2),
+        // SUM(long)
+        new Long(1+2+5),
+        // SUM(double)
+        new Double(20000.0+10000.0+45000.0),
+        // SUM(BigDecimal)
+        new BigDecimal("2500000.99").add
+            (new BigDecimal("50000.00")).add(new BigDecimal("2000.99")),
+        // SUM
+        null,
+        // MIN(long)
+        new Long(1),
+        // MIN(double)
+        new Double(10000.0),
+        // MIN(BigDecimal)
+        new BigDecimal("2000.99"),
+        // MIN
+        null,
+        // MAX(long)
+        new Long(5),
+        // MAX(double)
+        new Double(45000.0),
+        // MAX(BigDecimal)
+        new BigDecimal("2500000.99"),
+        // MAX
+        null,
+        // AVG(long)
+        new Long(3),
+        // AVG(double)
+        new Double(25000.0),
+        // AVG(BigDecimal)
+        new BigDecimal("99.999"),
+        // AVG
+        null
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(AggregateResult.class);
+    }
+    
+    /** */
+    public void testCount() {
+        for(int i = 0; i < 3; i++) {
+            executeQuery(i);
+        }
+    }
+
+    /** */
+    public void testSUM() {
+        for(int i = 3; i < 7; i++) {
+            executeQuery(i);
+        }
+    }
+
+    /** */
+    public void testMIN() {
+        for(int i = 7; i < 11; i++) {
+            executeQuery(i);
+        }
+    }
+
+    /** */
+    public void testMAX() {
+        for(int i = 11; i < 15; i++) {
+            executeQuery(i);
+        }
+    }
+
+    /** */
+    public void testAVG() {
+        for(int i = 15; i < 19; i++) {
+            executeQuery(i);
+        }
+    }
+
+    public void testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+
+    /** */
+    private void executeQuery(int index) {
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultResult.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultResult.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultResult.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Default Result.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-8.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If not specified, the result defaults to distinct this as C.
+ */
+public class DefaultResult extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-8 (DefaultResult) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"}) 
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(DefaultResult.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultUnique.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultUnique.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultUnique.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DefaultUnique.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+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.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Default Unique.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.11-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The default Unique setting is true for aggregate results 
+ * without a grouping expression, and false otherwise.
+ */
+public class DefaultUnique extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.11-2 (DefaultUnique) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(department)", 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(department)", 
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    "department",
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"}),
+        new Long(5),
+        Arrays.asList(new Object[]{new Long(3), new Long(2)})
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(DefaultUnique.class);
+    }
+    
+    /** */
+    public void testThis() {
+        int index = 0;
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /** */
+    public void testAggregateNoGrouping() {
+        int index = 1;
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /** */
+    public void testAggregateGrouping() {
+        int index = 2;
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistinctQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistinctQuery.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistinctQuery.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistinctQuery.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+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.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Disctinct Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If distinct is specified, the query result does not include any duplicates. 
+ * If the result parameter specifies more than one result expression, 
+ * duplicates are those with matching values for each result expression.
+ */
+public class DistinctQuery extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-1 (DistinctQuery) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "DISTINCT department",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department.deptid, department.name",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "DISTINCT department.deptid, department.name",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstancesAsList(new String[]{
+                "dept1", "dept1", "dept1", "dept2", "dept2"}),
+        getCompanyModelInstancesAsList(new String[]{
+                "dept1", "dept2"}),
+        Arrays.asList(new Object[] {
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(2),"Human Resources"},
+                new Object[]{new Long(2),"Human Resources"}}),
+        Arrays.asList(new Object[] {
+                new Object[]{new Long(1),"Development"},
+                new Object[]{new Long(2),"Human Resources"}}) 
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(DistinctQuery.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistintCandidateInstances.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistintCandidateInstances.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistintCandidateInstances.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/DistintCandidateInstances.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Disctinct Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Queries against an extent always consider only distinct candidate instances,
+ * regardless of whether distinct is specified. 
+ * Queries against a collection might contain duplicate candidate instances; 
+ * the distinct keyword removes duplicates from the candidate collection 
+ * in this case.
+ */
+public class DistintCandidateInstances extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-2 (DistintCandidateInstances) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "DISTINCT",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        addAll(getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"}),
+               getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"})),
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"})
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(DistintCandidateInstances.class);
+    }
+    
+    /** */
+    public void testExtentQueries() {
+        if (isUnconstrainedVariablesSupported()) {
+            for (int i = 0; i < VALID_QUERIES.length; i++) {
+                executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                        expectedResult[i]);
+                executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                        expectedResult[i]);
+            }
+        }
+    }
+     
+    /** */
+    public void testCollectionQueries() {
+        String singleStringQuery = "SELECT FROM " + Person.class.getName();
+        String singleStringDistinctQuery = 
+            "SELECT DISTNICT FROM " + Person.class.getName();
+        
+        Query query = getPM().newQuery();
+        query.setClass(Person.class);
+        query.setCandidates((Collection)expectedResult[0]);
+        executeJDOQuery(ASSERTION_FAILED, query, singleStringQuery, 
+                false, null, expectedResult[0], true);
+        
+        query.setResult("DISTINCT");
+        executeJDOQuery(ASSERTION_FAILED, query, singleStringDistinctQuery, 
+                false, null, expectedResult[1], true);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+    
+    private List addAll(List list1, List list2) {
+        list1.addAll(list2);
+        return list1;
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Grouping.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Grouping.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Grouping.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Grouping.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+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.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Grouping.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.10-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * When grouping is specified, each result expression must be one of: 
+ * an expression contained in the grouping expression; 
+ * or, an aggregate expression evaluated once per group. 
+ * The query groups all elements where all expressions 
+ * specified in setGrouping have the same values. 
+ * The query result consists of one element per group.
+ */
+public class Grouping extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.10-1 (Grouping) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department, SUM(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    "department",
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department, salary",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    "department",
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        Arrays.asList(new Object[] {
+            new Object[] {getCompanyModelInstance("dept1"), new Double(45000.0)},
+            new Object[] {getCompanyModelInstance("dept2"), new Double(58000.0)}})
+    };
+        
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(Grouping.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+        }
+    }
+
+    /** */
+    public void testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Having.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Having.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Having.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Having.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+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.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Having.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.10-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * When having is specified, the having expression consists of 
+ * arithmetic and boolean expressions containing aggregate expressions.
+ */
+public class Having extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.10-2 (Having) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department, SUM(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    "department HAVING COUNT(department.employees) > 0",
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department, SUM(salary)",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    "department HAVING firstname == 'emp1First'",
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+            Arrays.asList(new Object[] {
+                    getCompanyModelInstance("dept1"),
+                    new Double(45000.0),
+                    getCompanyModelInstance("dept2"),
+                    new Double(58000.0)})
+    };
+        
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(Having.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+        }
+    }
+
+    /** */
+    public void testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NPEInResultExpr.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+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.Department;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> NullPointerException in Result Expression.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-4.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If any result is a navigational expression, 
+ * and a non-terminal field or variable has a null value for a particular set 
+ * of conditions (the result calculation would throw NullPointerException), 
+ * then the result is null for that result expression.
+ */
+public class NPEInResultExpr extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-4 (NPEInResultExpr) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "manager.lastname",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "employee.manager.lastname",
+        /*INTO*/        null, 
+        /*FROM*/        Department.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "employees.contains(employee)",
+        /*VARIABLES*/   "Employee employee",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        //Note: None of the entries below are bean names!
+        Arrays.asList(new Object[]{
+                "emp2Last", null, "emp2Last", "emp2Last", "emp2Last"}),
+        Arrays.asList(new Object[]{
+                "emp2Last", null, "emp2Last", "emp2Last", "emp2Last"})
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(NPEInResultExpr.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResult[i]);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NullResults.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NullResults.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NullResults.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/NullResults.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+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.Employee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Null Results.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-7.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If the returned value from a query specifying a result is null, 
+ * this indicates that the expression specified as the result was null.
+ */
+public class NullResults extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-7 (NullResults) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      "manager",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "lastname == 'emp2Last'",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "manager",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "lastname == 'emp2Last'",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "DISTINCT manager",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        null,
+        Arrays.asList(new Object[]{null}),
+        getCompanyModelInstancesAsList(new String[]{"emp2", null}) 
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(NullResults.class);
+    }
+    
+    /** */
+    public void testUnique() {
+        int index = 0;
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /** */
+    public void testNavigation() {
+        int index = 1;
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /** */
+    public void testDistinctNavigation() {
+        int index = 2;
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultClassRequirements.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,470 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.result;
+
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.query.result.classes.LongString;
+import org.apache.jdo.tck.query.result.classes.MissingNoArgsConstructor;
+import org.apache.jdo.tck.query.result.classes.NoFieldsNoMethods;
+import org.apache.jdo.tck.query.result.classes.PublicLongField;
+import org.apache.jdo.tck.query.result.classes.PublicPutMethod;
+import org.apache.jdo.tck.util.BatchTestRunner;
+import org.apache.jdo.tck.util.ConversionHelper;
+
+/**
+ *<B>Title:</B> Result Class Requirements.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.12-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The result class may be one of the java.lang classes ...
+ */
+public class ResultClassRequirements extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.12-1 (ResultClassRequirements) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        // Long
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid",
+        /*INTO*/        Long.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // Double
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "salary",
+        /*INTO*/        Double.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // BigDecimal
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "budget",
+        /*INTO*/        BigDecimal.class, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // java.util.Date
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "hiredate",
+        /*INTO*/        java.util.Date.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // Map
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "phoneNumbers",
+        /*INTO*/        Map.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // user defined result class
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid AS l, lastname AS s",
+        /*INTO*/        LongString.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // constructor
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "new LongString(personid, lastname)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // public fields
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid AS l",
+        /*INTO*/        PublicLongField.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // public put method
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid, lastname",
+        /*INTO*/        PublicPutMethod.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        // TCK class, invalid property
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid, lastname",
+        /*INTO*/        LongString.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // JDK class
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid, lastname",
+        /*INTO*/        Long.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // JDK class, non assignment compatible
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "lastname",
+        /*INTO*/        Long.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // TCK class, salary field is not assignment compatible
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid AS l, salary AS s",
+        /*INTO*/        LongString.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // TCK class, non existing constructor
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "new LongString(personid)",
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // TCK class, no no-args constructor
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid",
+        /*INTO*/        MissingNoArgsConstructor.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // TCK class, no no-args constructor
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid",
+        /*INTO*/        NoFieldsNoMethods.class, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+    };
+        
+    // Two dimensional arrays to be converted to maps 
+    // in the expected result.
+    private static Object[][] phoneNumbers1 = 
+        {{"home", "1111"}, 
+         {"work", "123456-1"}};
+    private static Object[][] phoneNumbers2 = 
+        {{"home", "2222"}, 
+         {"work", "123456-2"}};
+    private static Object[][] phoneNumbers5 = 
+        {{"home", "3363"}, 
+         {"work", "126456-3"}};
+    private static Object[][] publicPutMethod1 =
+        {{"personid", new Long(1)}, {"lastname", "emp1Last"}};
+    private static Object[][] publicPutMethod2 =
+        {{"personid", new Long(2)}, {"lastname", "emp2Last"}};
+    private static Object[][] publicPutMethod5 =
+        {{"personid", new Long(5)}, {"lastname", "emp5Last"}};
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        // Long
+        Arrays.asList(new Object[]{new Long(1), new Long(2), new Long(5)}),
+        // Double
+        Arrays.asList(new Object[]{
+                new Double(20000.0), new Double(10000.0), new Double(45000.0)}),
+        // BigDecimal
+        Arrays.asList(new Object[]{new BigDecimal("2500000.99"), 
+                new BigDecimal("50000.00"), new BigDecimal("2000.99")}),
+        // java.util.Date
+        Arrays.asList(new Object[]{
+                CompanyModelReader.stringToUtilDate("1/Jan/1999"), 
+                CompanyModelReader.stringToUtilDate("1/Jul/2003"), 
+                CompanyModelReader.stringToUtilDate("15/Aug/1998")}),
+        // Map
+        Arrays.asList(new Object[]{
+                ConversionHelper.arrayToMap(phoneNumbers1),
+                ConversionHelper.arrayToMap(phoneNumbers2),
+                ConversionHelper.arrayToMap(phoneNumbers5)}),
+        // user defined result class
+        Arrays.asList(new Object[]{
+                new LongString(1, "emp1Last"), 
+                new LongString(2, "emp2Last"), 
+                new LongString(5, "emp5Last")}),
+        // constructor
+        Arrays.asList(new Object[]{
+                new LongString(1, "emp1Last"), 
+                new LongString(2, "emp2Last"), 
+                new LongString(5, "emp5Last")}),
+        // public fields
+        Arrays.asList(new Object[]{
+                new PublicLongField(1), 
+                new PublicLongField(2), 
+                new PublicLongField(5)}),
+        // public put method
+        Arrays.asList(new Object[]{
+                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod1)),
+                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod2)),
+                new PublicPutMethod(ConversionHelper.arrayToMap(publicPutMethod5))})
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(ResultClassRequirements.class);
+    }
+    
+    /** */
+    public void testLong() {
+        int index = 0;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testDouble() {
+        int index = 1;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testBigDecimal() {
+        int index = 2;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testDate() {
+        int index = 3;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testMap() {
+        int index = 4;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testUserDefinedResultClass() {
+        int index = 5;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testConstructor() {
+        int index = 6;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testFields() {
+        int index = 7;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testPut() {
+        int index = 8;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+
+    /** */
+    private void executeQuery(int index) {
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult[index]);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}



Mime
View raw message