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 [2/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
Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultExpressions.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultExpressions.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultExpressions.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ResultExpressions.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.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.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> Result Expressions.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-5.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The result expressions include: ... 
+ * The result expression can be explicitly cast using the (cast) operator.
+ */
+public class ResultExpressions extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-5 (ResultExpressions) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        // this
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "this",
+        /*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),
+        
+        // field
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid",
+        /*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),
+        
+        // variable.field
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "project.projid",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projects.contains(project) && personid == 1",
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // variable
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "project",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projects.contains(project) && personid == 1",
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // COUNT(this)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(this)",
+        /*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),
+        
+        // COUNT(variable)
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "COUNT(project)",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projects.contains(project) && personid == 1",
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // SUM
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "SUM(personid)",
+        /*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),
+        
+        // MIN
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MIN(personid)",
+        /*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),
+        
+        // MAX
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "MAX(personid)",
+        /*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),
+        
+        // AVG
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "AVG(personid)",
+        /*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),
+        
+        // field expression
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "personid + 1",
+        /*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),
+        
+        // navigational expression this
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "this.personid",
+        /*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),
+
+        // navigational expression variable
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "project.projid",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projects.contains(project) && personid == 1",
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+
+        // navigational expression parameter
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "project.projid",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  "Project project",
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // navigational expression field
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "department.deptid",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // parameter
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "project",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  "Project project",
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // cast
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "(FullTimeEmployee)manager",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*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 = {
+        // this
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"}),
+        // field
+        Arrays.asList(new Object[]{new Long(1), new Long(2), 
+                new Long(3), new Long(4), new Long(5)}),
+        // variable.field
+        Arrays.asList(new Object[]{new Long(1)}),
+        // variable
+        getCompanyModelInstancesAsList(new String[]{"proj1"}),
+        // COUNT(this)
+        new Long(5),
+        // COUNT(variable)
+        new Long(1),
+        // SUM
+        new Long(1+2+3+4+5),
+        // MIN
+        new Long(1),
+        // MAX
+        new Long(5),
+        // AVG
+        new Long(3),
+        // field expression
+        Arrays.asList(new Object[]{new Long(2), new Long(3), 
+                new Long(4), new Long(5), new Long(6)}),
+        // navigational expression this
+        Arrays.asList(new Object[]{new Long(1), new Long(2), 
+                new Long(3), new Long(4), new Long(5)}),
+        // navigational expression variable
+        Arrays.asList(new Object[]{new Long(1)}),
+        // navigational expression parameter
+        Arrays.asList(new Object[]{new Long(1)}),
+        // navigational expression field
+        Arrays.asList(new Object[]{new Long(1)}),
+        // parameter
+        getCompanyModelInstancesAsList(new String[]{"proj1"}),
+        // cast
+        getCompanyModelInstancesAsList(new String[]{"emp2"})
+    };
+            
+    /**
+     * 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(ResultExpressions.class);
+    }
+    
+    /** */
+    public void testThis() {
+        int index = 0;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testField() {
+        int index = 1;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testVariableField() {
+        int index = 2;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testVariable() {
+        int index = 3;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testCountThis() {
+        int index = 4;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testCountVariable() {
+        int index = 5;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testSum() {
+        int index = 6;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testMin() {
+        int index = 7;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testMax() {
+        int index = 8;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testAvg() {
+        int index = 9;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testFieldExpression() {
+        int index = 10;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testNavigationalExpressionThis() {
+        int index = 11;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testNavigationalExpressionVariable() {
+        int index = 12;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testNavigationalExpressionParameter() {
+        int index = 13;
+        Object[] parameters = getCompanyModelInstances(new String[]{"proj1"});
+        executeQuery(index, parameters);
+    }
+
+    /** */
+    public void testNavigationalExpressionField() {
+        int index = 14;
+        executeQuery(index, null);
+    }
+
+    /** */
+    public void testParameter() {
+        int index = 15;
+        Object[] parameters = getCompanyModelInstances(new String[]{"proj1"});
+        executeQuery(index, parameters);
+    }
+
+    /** */
+    public void testCast() {
+        int index = 16;
+        executeQuery(index, null);
+    }
+
+    /** */
+    private void executeQuery(int index, Object[] parameters) {
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                parameters, expectedResult[index]);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                parameters, 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/ShapeOfResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ShapeOfResult.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ShapeOfResult.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/ShapeOfResult.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,334 @@
+/*
+ * 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.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.query.result.classes.FullName;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Shape of Result.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.12-2.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Table 6: Shape of Result (C is the candidate class)
+ */
+public class ShapeOfResult extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.12-2 (ShapeOfResult) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        // result: null
+        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),
+        
+        // result: this AS C
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "this AS Person",
+        /*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),
+        
+        // result: null, unique: true
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // result: this AS C, unique: true
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      "this AS Person",
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // result: expression of type T
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "firstname",
+        /*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),
+        
+        // result: expression of type T, unique: true
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      "firstname",
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // result: multiple expressions of type T
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "firstname, lastname",
+        /*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),
+        
+        // result: multiple expressions of type T, unique: true
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      "firstname, lastname",
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // result: multiple expressions of type T, result class
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "firstname, lastname",
+        /*INTO*/        FullName.class, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        
+        // result: multiple expressions of type T, result class, unique: true
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      "firstname, lastname",
+        /*INTO*/        FullName.class, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*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 = {
+        // result: null
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"}),
+        // result: this AS C
+        getCompanyModelInstancesAsList(new String[]{
+                "emp1", "emp2", "emp3", "emp4", "emp5"}),
+        // result: null, unique: true
+        getCompanyModelInstance("emp1"),
+        // result: this AS C, unique: true
+        getCompanyModelInstance("emp1"),
+        // result: expression of type T
+        Arrays.asList(new Object[]{"emp1First", "emp2First", 
+                "emp3First", "emp4First", "emp5First"}),
+        // result: expression of type T, unique: true
+        "emp1First",
+        // result: multiple expressions of type T
+        Arrays.asList(new Object[]{
+                new Object[]{"emp1First", "emp1Last"},
+                new Object[]{"emp2First", "emp2Last"},
+                new Object[]{"emp3First", "emp3Last"},
+                new Object[]{"emp4First", "emp4Last"},
+                new Object[]{"emp5First", "emp5Last"}}),
+        // result: multiple expressions of type T, unique: true
+        new Object[]{"emp1First", "emp1Last"},
+        // result: multiple expressions of type T, result class
+        Arrays.asList(new Object[]{
+                new FullName("emp1First", "emp1Last"),
+                new FullName("emp2First", "emp2Last"),
+                new FullName("emp3First", "emp3Last"),
+                new FullName("emp4First", "emp4Last"),
+                new FullName("emp5First", "emp5Last")}),
+        // result: multiple expressions of type T, result class, unique: true
+        new FullName("emp1First", "emp1Last")
+    };
+            
+    /**
+     * 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(ShapeOfResult.class);
+    }
+    
+    /** */
+    public void testNoResult() {
+        int index = 0;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testThisAsC() {
+        int index = 1;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testNoResultUnique() {
+        int index = 2;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testThisAsCUnique() {
+        int index = 3;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testSingleExpression() {
+        int index = 4;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testSingleExpressionUnique() {
+        int index = 5;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testMultipleExpressions() {
+        int index = 6;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testMultipleExpressionsUnique() {
+        int index = 7;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testMultipleExpressionsResultClass() {
+        int index = 8;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    public void testMultipleExpressionResultClassUnique() {
+        int index = 9;
+        execute(index, expectedResult[index]);
+    }
+
+    /** */
+    private void execute(int index, Object expected) {
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], expected);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expected);
+    }
+    
+    /**
+     * @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/Unique.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Unique.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Unique.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/Unique.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 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.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> Unique.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.11-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * When the value of the Unique flag is true, 
+ * then the result of a query is a single value, 
+ * with null used to indicate that none of the instances 
+ * in the candidates satisfied the filter. 
+ * If more than one instance satisfies the filter, 
+ * and the range is not limited to one result, 
+ * then execute throws a JDOUserException.
+ */
+public class Unique extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.11-1 (Unique) 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*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 1",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "personid == 0",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      Boolean.TRUE,
+        /*RESULT*/      null, 
+        /*INTO*/        null, 
+        /*FROM*/        Person.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "personid ASCENDING",
+        /*FROM*/        "0",
+        /*TO*/          "1"),
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        getCompanyModelInstance("emp1"),
+        null,
+        getCompanyModelInstance("emp1")
+    };
+            
+    /**
+     * 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(Unique.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() {
+        String singleString = "SELECT UNIQUE FROM " + Person.class.getName();
+        
+        Query query = getPM().newQuery(Person.class);
+        query.setUnique(true);
+        executeJDOQuery(ASSERTION_FAILED, query, singleString, 
+                false, null, null, false);
+        
+        query = getPM().newQuery(singleString);
+        executeJDOQuery(ASSERTION_FAILED, query, singleString, 
+                false, null, null, 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/VariableInResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/VariableInResult.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/VariableInResult.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/VariableInResult.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.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> Variable in Result.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.9-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If a variable or a field of a variable is included in the result, 
+ * either directly or via navigation through the variable, 
+ * then the semantics of the contains clause that include the variable change. 
+ * In this case, all values of the variable 
+ * that satisfy the filter are included in the result.
+ */
+public class VariableInResult extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.9-3 (VariableInResult) 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*/      "project",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projects.contains(project) & project.name == 'orange'",
+        /*VARIABLES*/   "Project project",
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "project.projid, project.name",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "projects.contains(project) & project.name == 'orange'",
+        /*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 = {
+        // this
+        getCompanyModelInstancesAsList(new String[]{"proj1"}),
+        // Note: "orange" is not a bean name!
+        Arrays.asList(new Object[]{new Object[]{new Long(1), "orange"}})
+    };
+
+    /**
+     * 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(VariableInResult.class);
+    }
+    
+    /** */
+    public void testNoNavigation() {
+        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]);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/FullName.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/FullName.java?rev=345921&r1=345920&r2=345921&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/FullName.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/FullName.java Mon Nov 21 08:05:04 2005
@@ -16,6 +16,8 @@
  
 package org.apache.jdo.tck.query.result.classes;
 
+import org.apache.jdo.tck.util.EqualityHelper;
+
 /**
  * JDOQL result class having bean properties <code>firstname</code>,
  * <code>firstName</code>, <code>lastname</code>, and <code>lastName</code>.
@@ -51,15 +53,11 @@
      * @see Object#equals(java.lang.Object)
      */
     public boolean equals(Object o) {
+        if (!(o instanceof FullName))
+            return false;
         FullName other = (FullName) o;
-        if (this.firstName == null) {
-            return other.firstName == null;
-        }
-        if (this.lastName == null) {
-            return other.lastName == null;
-        }
-        return this.firstName.equals(other.firstName) &&
-               this.lastName.equals(other.lastName);
+        return EqualityHelper.equals(this.firstName, other.firstName) &&
+               EqualityHelper.equals(this.lastName, other.lastName);
     }
     
     /**

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/LongString.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/LongString.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/LongString.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/LongString.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,94 @@
+/*
+ * 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.classes;
+
+import org.apache.jdo.tck.util.EqualityHelper;
+
+/**
+ * JDOQL result class having bean properties <code>s</code> and <code>l</code>.
+ * These properties are used by JDO query tests in result clauses.
+ */
+public class LongString {
+
+    private long l;
+    private String s;
+    
+    public LongString() {}
+    
+    public LongString(int l, String s) {
+        this.l = l;
+        this.s = s;
+    }
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        int result = 0;
+        result += this.s != null ? this.s.hashCode() : 0;
+        result += (int) (this.l % Integer.MAX_VALUE);
+        return result;
+    }
+    
+    /**
+     * @see Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o) {
+        if (!(o instanceof LongString))
+            return false;
+        LongString other = (LongString) o;
+        return this.l == other.l &&
+               EqualityHelper.equals(this.s, other.s);
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString() {
+        return getClass().getName() + '(' +
+        this.l + ", " + this.s + ')';
+    }
+
+    /**
+     * @return Returns the l.
+     */
+    public long getL() {
+        return l;
+    }
+
+    /**
+     * @param l The l to set.
+     */
+    public void setL(int l) {
+        this.l = l;
+    }
+
+    /**
+     * @return Returns the s.
+     */
+    public String getS() {
+        return s;
+    }
+
+    /**
+     * @param s The s to set.
+     */
+    public void setS(String s) {
+        this.s = s;
+    }
+    
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/MissingNoArgsConstructor.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,70 @@
+/*
+ * 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.classes;
+
+
+/**
+ * JDOQL result class not having a no-args constructor.
+ */
+public class MissingNoArgsConstructor {
+
+    private long l;
+    
+    public MissingNoArgsConstructor(int l) {
+        this.l = l;
+    }
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        int result = 0;
+        result += (int) (this.l % Integer.MAX_VALUE);
+        return result;
+    }
+    
+    /**
+     * @see Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o) {
+        if (!(o instanceof MissingNoArgsConstructor))
+            return false;
+        MissingNoArgsConstructor other = (MissingNoArgsConstructor) o;
+        return this.l == other.l;
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString() {
+        return getClass().getName() + '(' + l + ')';
+    }
+
+    /**
+     * @return Returns the l.
+     */
+    public long getL() {
+        return l;
+    }
+
+    /**
+     * @param l The l to set.
+     */
+    public void setL(int l) {
+        this.l = l;
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/NoFieldsNoMethods.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,24 @@
+/*
+ * 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.classes;
+
+
+/**
+ * JDOQL result class not having any fields and methods.
+ */
+public class NoFieldsNoMethods {
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicLongField.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,55 @@
+/*
+ * 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.classes;
+
+/**
+ * JDOQL result class having a public lonf field.
+ */
+public class PublicLongField {
+
+    public long l;
+
+    public PublicLongField() {}
+
+    public PublicLongField(long l) {
+        this.l = l;
+    }
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        return (int) (this.l % Integer.MAX_VALUE);
+    }
+    
+    /**
+     * @see Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o) {
+        if (!(o instanceof PublicLongField))
+            return false;
+        PublicLongField other = (PublicLongField) o;
+        return this.l == other.l;
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString() {
+        return getClass().getName() + '(' + this.l + ')';
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java?rev=345921&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/result/classes/PublicPutMethod.java Mon Nov 21 08:05:04 2005
@@ -0,0 +1,63 @@
+/*
+ * 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.classes;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * JDOQL result class having a public lonf field.
+ */
+public class PublicPutMethod {
+
+    private Map map = new HashMap();
+    
+    public PublicPutMethod() {}
+    
+    public PublicPutMethod(Map map) {
+        this.map = map;
+    }
+    
+    public void put(Object key, Object value) {
+        this.map.put(key, value);
+    }
+    
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode() {
+        return this.map.hashCode();
+    }
+    
+    /**
+     * @see Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o) {
+        if (!(o instanceof PublicPutMethod))
+            return false;
+        PublicPutMethod other = (PublicPutMethod) o;
+        return this.map.equals(other.map);
+    }
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString() {
+        return getClass().getName() + '(' + this.map + ')';
+    }
+
+}

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/EqualityHelper.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/EqualityHelper.java?rev=345921&r1=345920&r2=345921&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/EqualityHelper.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/util/EqualityHelper.java Mon Nov 21 08:05:04 2005
@@ -746,6 +746,23 @@
         return true;
     }
 
+    /** Returns <code>true</code> if the specified objects are equal. 
+     * This is a helper method checking for identical and <code>null</code>
+     * objects before delegating to the regular equals method.
+     * @param o1 one object to be tested for equality
+     * @param o2 the other object to be tested for equality
+     * @return <code>true</code> if the specified objects are equal.
+     */
+    public static boolean equals(Object o1, Object o2) {
+        if (o1 == o2) {
+            return true;
+        }
+        if (o1 == null || o2 == null) {
+            return false;
+        }
+        return o1.equals(o2);
+    }
+    
     // Methods to support "close enough" comparison
 
     /** Returns <code>true</code> if the specified objects are close



Mime
View raw message