db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject svn commit: r331850 [1/2] - in /incubator/jdo/trunk/tck20: ./ test/java/org/apache/jdo/tck/pc/mylib/ test/java/org/apache/jdo/tck/query/ test/java/org/apache/jdo/tck/query/api/ test/jdo/applicationidentity/ test/jdo/applicationidentity/org/apache/jdo/t...
Date Tue, 08 Nov 2005 17:18:34 GMT
Author: brazil
Date: Tue Nov  8 09:17:35 2005
New Revision: 331850

URL: http://svn.apache.org/viewcvs?rev=331850&view=rev
Log:
JDO-163: Implement new JDO 2 query tests cases concerning query API Extensions

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PCClass.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/GetFetchPlan.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/Person.jdoquery
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/package.jdo
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/Person.jdoquery
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/package.jdo
Modified:
    incubator/jdo/trunk/tck20/project.properties
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java
    incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo
    incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo
    incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/company/package-derby.orm
    incubator/jdo/trunk/tck20/test/orm/applicationidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
    incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/company/package-derby.orm
    incubator/jdo/trunk/tck20/test/orm/datastoreidentity/org/apache/jdo/tck/pc/mylib/package-derby.orm
    incubator/jdo/trunk/tck20/test/sql/derby/applicationidentity/schema.sql
    incubator/jdo/trunk/tck20/test/sql/derby/datastoreidentity/schema.sql
    incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml

Modified: incubator/jdo/trunk/tck20/project.properties
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/project.properties?rev=331850&r1=331849&r2=331850&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/project.properties (original)
+++ incubator/jdo/trunk/tck20/project.properties Tue Nov  8 09:17:35 2005
@@ -173,6 +173,7 @@
     org/apache/jdo/tck/pc/inheritance/TopPersistE.java \
     org/apache/jdo/tck/pc/inheritance/TopPersistF.java \
     org/apache/jdo/tck/pc/inheritance/TopPersistH.java \
+    org/apache/jdo/tck/pc/mylib/PCClass.java \
     org/apache/jdo/tck/pc/mylib/PCPoint.java \
     org/apache/jdo/tck/pc/mylib/PCPoint2.java \
     org/apache/jdo/tck/pc/mylib/PCRect.java \
@@ -272,6 +273,7 @@
     org/apache/jdo/tck/pc/inheritance/TopPersistE.class \
     org/apache/jdo/tck/pc/inheritance/TopPersistF.class \
     org/apache/jdo/tck/pc/inheritance/TopPersistH.class \
+    org/apache/jdo/tck/pc/mylib/PCClass.class \
     org/apache/jdo/tck/pc/mylib/PCPoint.class \
     org/apache/jdo/tck/pc/mylib/PCPoint2.class \
     org/apache/jdo/tck/pc/mylib/PCRect.class \
@@ -330,6 +332,7 @@
     org/apache/jdo/tck/api/instancecallbacks/TestParts.class
 
 jdo.tck.jdometadata.files = \
+    package.jdo \
     org/apache/jdo/tck/api/instancecallbacks/package.jdo \
     org/apache/jdo/tck/pc/company/package.jdo \
     org/apache/jdo/tck/pc/fieldtypes/AllTypes.jdo \
@@ -378,6 +381,7 @@
     org/apache/jdo/tck/pc/instancecallbacks/package.jdo \
     org/apache/jdo/tck/pc/lifecycle/StateTransitionObj.jdo \
     org/apache/jdo/tck/pc/mylib/package.jdo \
+    org/apache/jdo/tck/pc/mylib/PCClass.jdo \
     org/apache/jdo/tck/pc/query/package.jdo \
     org/apache/jdo/tck/pc/singlefieldidentity/package.jdo \
     org/apache/jdo/tck/package.jdo

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java?rev=331850&r1=331849&r2=331850&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java Tue Nov  8 09:17:35 2005
@@ -43,7 +43,7 @@
     /** Teardown classes 
      */
     private static final Class[] tearDownClasses = new Class[] {
-        PrimitiveTypes.class
+        PrimitiveTypes.class, PCClass.class
     };
     
     /** 

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PCClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PCClass.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PCClass.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PCClass.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,178 @@
+/*
+ * 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.pc.mylib;
+
+import java.io.Serializable;
+
+import javax.jdo.listener.LoadCallback;
+
+public class PCClass implements LoadCallback {
+
+    private long id;
+    private int number1;
+    private int number2;
+    
+    private int transientNumber1;
+    private int transientNumber2;
+
+    public PCClass() {
+    }
+
+    /**
+     * @see LoadCallback#jdoPostLoad()
+     */
+    public void jdoPostLoad() {
+        transientNumber1 = number1;
+        transientNumber2 = number2;
+    }
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString() { 
+        return "PCClass(" + id + ")";
+    }
+
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode() { return (int)id ; }
+
+    /**
+     * @see Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object other) {
+        if (other != null && (other instanceof PCClass)) {
+            PCClass k = (PCClass)other;
+            return k.id == this.id;
+        }
+        return false;
+    }
+    
+    /**
+     * @return Returns the id.
+     */
+    public long getId() {
+        return id;
+    }
+
+    /**
+     * @param id The id to set.
+     */
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    /**
+     * @return Returns the number.
+     */
+    public int getNumber1() {
+        return number1;
+    }
+
+    /**
+     * @param number The number to set.
+     */
+    public void setNumber1(int number) {
+        this.number1 = number;
+    }
+
+    /**
+     * @return Returns the number2.
+     */
+    public int getNumber2() {
+        return number2;
+    }
+
+    /**
+     * @param number2 The number2 to set.
+     */
+    public void setNumber2(int number2) {
+        this.number2 = number2;
+    }
+
+    /**
+     * @return Returns the transientNumber1.
+     */
+    public int getTransientNumber1() {
+        return transientNumber1;
+    }
+
+    /**
+     * @param transientNumber1 The transientNumber1 to set.
+     */
+    public void setTransientNumber1(int transientNumber1) {
+        this.transientNumber1 = transientNumber1;
+    }
+
+    /**
+     * @return Returns the transientNumber2.
+     */
+    public int getTransientNumber2() {
+        return transientNumber2;
+    }
+
+    /**
+     * @param transientNumber2 The transientNumber2 to set.
+     */
+    public void setTransientNumber2(int transientNumber2) {
+        this.transientNumber2 = transientNumber2;
+    }
+
+    /**
+     * The objectid class for this class in case of application identity. 
+     */
+    public static class Oid implements Serializable, Comparable {
+
+        public long id;
+
+        public Oid() {
+        }
+
+        public Oid(String s) { id = Long.parseLong(justTheId(s)); }
+
+        public String toString() { return this.getClass().getName() + ": "  + id;}
+
+        public int hashCode() { return (int)id ; }
+
+        public boolean equals(Object other) {
+            if (other != null && (other instanceof Oid)) {
+                Oid k = (Oid)other;
+                return k.id == this.id;
+            }
+            return false;
+        }
+        
+        protected static String justTheId(String str) {
+            return str.substring(str.indexOf(':') + 1);
+        }
+
+        public int compareTo(Object o) {
+            if (o == null)
+                throw new ClassCastException();
+            if (o == this)
+                return 0;
+            long otherId = ((Oid)o).id;
+            if (id == otherId)
+                return 0;
+            else if (id < otherId)
+                return -1;
+            return 1;
+        }
+    }
+}
+

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java?rev=331850&r1=331849&r2=331850&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java Tue Nov  8 09:17:35 2005
@@ -694,33 +694,93 @@
     private Object execute(String assertion, 
             QueryElementHolder queryElementHolder, boolean asSingleString,
             Object[] parameters, Object[] expectedResult) {
-        Object result;
+        Query query = asSingleString ?
+                queryElementHolder.getSingleStringQuery(pm) :
+                    queryElementHolder.getAPIQuery(pm);
+        Object result = execute(assertion, query, queryElementHolder.toString(),
+                queryElementHolder.isUnique(), queryElementHolder.hasOrdering(),
+                parameters, expectedResult);
+        return result;
+    }
+
+    /**
+     * Executes the given query instance.
+     * Argument <code>parameters</code> is passed as an argument
+     * to the method {@link Query#executeWithArray(java.lang.Object[])}.
+     * If <code>parameters</code> are <code>null</code>,
+     * then method {@link Query#execute()} is called 
+     * on the given query instance instead.<p>
+     * 
+     * The result of query execution is compared against the argument 
+     * <code>expectedResult</code>. The array elements of that argument
+     * must match the content of the query result collection,
+     * otherwise this method throws an {@link AssertionFailedError} and 
+     * the calling test case fails prompting argument 
+     * <code>assertion</code>.<p>
+     * 
+     * In case of a unique query, only the first element 
+     * of the result collection is compared against the first array element 
+     * of argument <code>expectedResult</code>. 
+     * A <code>null</code> as the first element indicates, that the given query 
+     * has no results, e.g. the filter does not match 
+     * any persistent instances.<p>
+     * 
+     * If argument <code>expectedResult</code> is <code>null</code>,
+     * then the test case invoking this method is considered to be
+     * a negative test case. 
+     * Then, query execution is expected to throw a {@link JDOUserException}.
+     * If query execution succeeds in this case, then this method throws
+     * an {@link AssertionFailedError} and the calling test case fails
+     * prompting argument <code>assertion</code>.<p>
+     * 
+     * @param assertion the assertion to prompt if the test case fails.
+     * @param query the query to execute.
+     * @param asSingleString the single string representation of the query.
+     * This parameter is only used as part of the falure message.
+     * @param isUnique indicates if the query has a unique result.
+     * @param hasOrdering indicates if the query has an ordering clause.
+     * @param parameters the parmaters of the query.
+     * @param expectedResult the expected query result.
+     * @return the result collection
+     */
+    protected Object execute(String assertion, Query query, 
+            String singleStringQuery,
+            boolean isUnique, boolean hasOrdering,
+            Object[] parameters, Object[] expectedResult) {
+        boolean positive = expectedResult != null;
+        Object result = null;
         PersistenceManager pm = getPM();
         Transaction tx = pm.currentTransaction();
         tx.begin();
         try {
-            Query query = asSingleString ?
-                    queryElementHolder.getSingleStringQuery(pm) :
-                        queryElementHolder.getAPIQuery(pm);
             try {
                 result = parameters != null ? 
                         query.executeWithArray(parameters) : query.execute();
     
-                if (queryElementHolder.isUnique()) {
-                    checkUniqueResult(assertion, result, expectedResult[0]);
-                } else if (queryElementHolder.hasOrdering()) {
-                    List expectedResultList = 
-                        Arrays.asList(expectedResult);
-                    checkQueryResultWithOrder(assertion, result, 
-                            expectedResultList);
+                if (positive) {
+                    if (isUnique) {
+                        checkUniqueResult(assertion, result, expectedResult[0]);
+                    } else if (hasOrdering) {
+                        List expectedResultList = 
+                            Arrays.asList(expectedResult);
+                        checkQueryResultWithOrder(assertion, result, 
+                                expectedResultList);
+                    } else {
+                        Collection expectedResultCollection = 
+                            Arrays.asList(expectedResult);
+                        checkQueryResultWithoutOrder(assertion, result, 
+                                expectedResultCollection);
+                    }
                 } else {
-                    Collection expectedResultCollection = 
-                        Arrays.asList(expectedResult);
-                    checkQueryResultWithoutOrder(assertion, result, 
-                            expectedResultCollection);
+                    fail(assertion + "Query must throw JDOUserException: " + 
+                            singleStringQuery);
                 }
             } finally {
-                query.closeAll();
+                query.close(result);
+            }
+        } catch (JDOUserException e) {
+            if (positive) {
+                throw e;
             }
         } finally {
             if (tx.isActive()) {

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/ChangeQuery.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,103 @@
+/*
+ * 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.api;
+
+import java.math.BigDecimal;
+
+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.FullTimeEmployee;
+import org.apache.jdo.tck.pc.company.Person;
+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> Change Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-15.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The Query instance returned from this method can be modified 
+ * by the application, just like any other Query instance.
+ */
+public class ChangeQuery extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.5-15 (ChangeQuery) failed: ";
+    
+    /**
+     * 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(ChangeQuery.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        Query query = getPM().newNamedQuery(Person.class, "changeQuery");
+        
+        // change query
+        query.setResult("firstname, lastname");
+        query.setResultClass(FullName.class);
+        query.setClass(FullTimeEmployee.class);
+        String filter = "salary > 1000 & projects.contains(project) & " +
+                        "project.budget > limit";
+        query.setFilter(filter);
+        String imports = "import org.apache.jdo.tck.pc.company.Project; " +
+                         "import java.math.BigDecimal;";
+        query.declareImports(imports);
+        query.declareVariables("Project project");
+        query.declareParameters("BigDecimal limit");
+        query.setOrdering("personid ASCENDING");
+        query.setRange(0, 5);
+        String singleStringQuery = 
+            "SELECT firstname, lastname INTO FullName FROM FullTimeEmployee " +
+            "WHERE salary > 1000 & projects.contains(project) & " +
+            "project.budget > limit " +
+            "VARIABLES Project project PARAMETERS BigDecimal limit " +
+            "ORDER BY personid ASCENDING RANGE 0, 5";
+
+        // query parameters
+        Object[] parameters = {new BigDecimal("2000")};        
+        // expected result
+        Object[] expectedResult = {
+            new FullName("emp1First", "emp1Last"), 
+            new FullName("emp2First", "emp2Last"),
+            new FullName("emp5First", "emp5Last")
+        };
+
+        // execute query
+        execute(ASSERTION_FAILED, query, singleStringQuery, false, true, 
+                parameters, expectedResult);
+    }
+
+    /**
+     * @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/api/GetFetchPlan.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/GetFetchPlan.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/GetFetchPlan.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/GetFetchPlan.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,164 @@
+/*
+ * 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.api;
+
+import java.util.Collection;
+
+import javax.jdo.FetchPlan;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.MylibReader;
+import org.apache.jdo.tck.pc.mylib.PCClass;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Get Fetch Plan.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-21.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * This method retrieves the fetch plan associated with the Query. 
+ * It always returns the identical instance for the same Query instance. 
+ * Any change made to the fetch plan affects subsequent query execution.
+ */
+public class GetFetchPlan extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-21 (FetchPan) failed: ";
+    
+    /**
+     * 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(GetFetchPlan.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        Query query = getPM().newQuery(PCClass.class, "number1 == param");
+        query.declareParameters("int param");
+        
+        checkSameFetchPlanInstances(query);
+        checkDefaultFetchGroup(query);
+        checkFetchGroup2(query);
+        checkDefaultFetchGroup(query);
+    }
+
+    private void checkSameFetchPlanInstances(Query query) {
+        FetchPlan fetchPlan1 = query.getFetchPlan();
+        FetchPlan fetchPlan2 = query.getFetchPlan();
+        if (fetchPlan1 != fetchPlan2) {
+            fail(ASSERTION_FAILED + "Calling getFetchPlan twice on the same " +
+            "query instance results in two different fetch plan instances.");
+        }
+    }
+    
+    /**
+     * Checks if the given query loads fields
+     * assigned to the default fetch group.
+     * @param query the query
+     */
+    private void checkDefaultFetchGroup(Query query) {
+        Transaction transaction = query.getPersistenceManager().
+            currentTransaction();
+        transaction.begin();
+        Collection result = (Collection) query.execute(new Integer(10));
+        if (result.size() != 1) {
+            fail(ASSERTION_FAILED + "Query returned " + result.size() + 
+                    " instances, expected size is " + 1);
+        }
+        PCClass pcClass = (PCClass) result.iterator().next();
+        if (pcClass.getTransientNumber1() != 10) {
+            fail(ASSERTION_FAILED + 
+                    "Field PCClass.number1 is in the " +
+                    "default fetch group and should have been loaded. " +
+                    "The jdoPostLoad() callback has copied the field value " +
+                    "to a transient field which has an unexpected value: " + 
+                    pcClass.getTransientNumber1());
+        }
+        if (pcClass.getTransientNumber2() != 0) {
+            fail(ASSERTION_FAILED + 
+                    "Field PCClass.number2 is not in the " +
+                    "default fetch group and should not have been loaded. " +  
+                    "The jdoPostLoad() callback has copied the field value " +
+                    "to a transient field which has an unexpected value: " + 
+                    pcClass.getTransientNumber2());
+        }
+        transaction.commit();
+    }
+    
+    /**
+     * Checks if the given query loads fields assigned 
+     * to the default fetch group plus fetch group "fetchGroup2".
+     * For this purpose, the method temporarily adds fetch group "fetchGroup2"
+     * to the fetch plan of the given query instance. 
+     * That fetch group is assigned a different field 
+     * than the default fetch group. 
+     * Finally, that fetch group is removed from the fetch plan again.
+     * @param query the query
+     */
+    private void checkFetchGroup2(Query query) {
+        String fetchGoupName = "fetchGroup2";
+        query.getFetchPlan().addGroup(fetchGoupName);
+        try {
+            Transaction transaction = query.getPersistenceManager().
+                currentTransaction();
+            transaction.begin();
+            Collection result = (Collection) query.execute(new Integer(20));
+            if (result.size() != 1) {
+                fail(ASSERTION_FAILED + "Query returned " + result.size() + 
+                        " instances, expected size is " + 1);
+            }
+            PCClass pcClass = (PCClass) result.iterator().next();
+            if (pcClass.getTransientNumber1() != 20) {
+                fail(ASSERTION_FAILED + 
+                        "Field PCClass.number1 is in the " +
+                        "default fetch group and should have been loaded. " +
+                        "The jdoPostLoad() callback has copied the field value " +
+                        "to a transient field which has an unexpected value: " + 
+                        pcClass.getTransientNumber1());
+            }
+            if (pcClass.getTransientNumber2() != 20) {
+                fail(ASSERTION_FAILED + 
+                        "Field PCClass.number1 is in " +
+                        "fetch group 2 and should have been loaded. " +
+                        "The jdoPostLoad() callback has copied the field value " +
+                        "to a transient field which has an unexpected value: " + 
+                        pcClass.getTransientNumber2());
+            }
+            transaction.commit();
+        } finally {
+            query.getFetchPlan().removeGroup(fetchGoupName);
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadMylib(getPM(), MYLIB_TESTDATA);
+        addTearDownClass(MylibReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/InvalidNamedQuery.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,60 @@
+/*
+ * 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.api;
+
+import javax.jdo.JDOUserException;
+
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Invalid Named Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-16.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Named queries must be compilable. Attempts to get a named query 
+ * that cannot be compiled result in JDOUserException.
+ */
+public class InvalidNamedQuery extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.5-16 (InvalidNamedQuery) failed: ";
+    
+    /**
+     * 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(InvalidNamedQuery.class);
+    }
+    
+    /** */
+    public void testNegative() {
+        try {
+            getPM().newNamedQuery(Person.class, "invalidQuery");
+            fail(ASSERTION_FAILED + "Lookup of named query 'invalidQuery' " +
+                    " succeeded, though the query is not compilable.");
+        } catch (JDOUserException e) {
+        }
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/MetadataSearchOrder.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,128 @@
+/*
+ * 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.api;
+
+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.pc.mylib.MylibReader;
+import org.apache.jdo.tck.pc.mylib.PCClass;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Metadata Search Order.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-13.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If the named query is not found in already-loaded metadata, 
+ * the query is searched for using an algorithm. 
+ * Files containing metadata are examined in turn until the query is found. 
+ * The order is based on the metadata search order for class metadata, 
+ * but includes files named based on the query name.
+ */
+public class MetadataSearchOrder extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.5-13 (MetadataSearchOrder) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp2", "emp3", "emp4", "emp5"},
+        {"pcClass1", "pcClass2"},
+        {"emp3", "emp4", "emp5"},
+        {"emp4", "emp5"}
+    };
+            
+    /**
+     * The <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(MetadataSearchOrder.class);
+    }
+    
+    /** */
+    public void testPackageJDOInDefaultPackage() {
+        int index = 0;
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        executeNamedQuery(null, "packageJDOInDefaultPackage", 
+                false, expectedResultValues);
+    }
+    
+    /** */
+    public void testPackageJDO() {
+        int index = 1;
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        executeNamedQuery(Person.class, "packageJDO", 
+                false, expectedResultValues);
+    }
+    
+    /** */
+    public void testClassJDO() {
+        int index = 2;
+        Object[] expectedResultValues = 
+            getMylibInstances(expectedResult[index]);
+        executeNamedQuery(PCClass.class, "classJDO", 
+                false, expectedResultValues);
+    }
+    
+    /** */
+    public void testPackageORM() {
+        int index = 3;
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        executeNamedQuery(Person.class, "packageORM", 
+                false, expectedResultValues);
+    }
+    
+    /** */
+    public void testPackageJDOQuery() {
+        int index = 4;
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        executeNamedQuery(Person.class, "packageJDOQuery", 
+                false, expectedResultValues);
+    }
+
+    private void executeNamedQuery(Class candidateClass, String namedQuery,
+            boolean isUnique, Object[] expectedResultValues) {
+        Query query = getPM().newNamedQuery(candidateClass, namedQuery); 
+        execute(ASSERTION_FAILED, query, "Named query " + namedQuery,
+                isUnique, false, null, expectedResultValues);
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+        loadMylib(getPM(), MYLIB_TESTDATA);
+        addTearDownClass(MylibReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NamedQueryNotFound.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,60 @@
+/*
+ * 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.api;
+
+import javax.jdo.JDOUserException;
+
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Named Query not Found.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-14.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If the metadata is not found in the above, a JDOUserException is thrown.
+ */
+public class NamedQueryNotFound extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.5-14 (NamedQueryNotFound) failed: ";
+    
+    /**
+     * 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(NamedQueryNotFound.class);
+    }
+    
+    /** */
+    public void testNegative() {
+        try {
+            getPM().newNamedQuery(Person.class, "nonExistingNamedQuery");
+            fail(ASSERTION_FAILED + 
+                    "The lookup of named query 'nonExistingNamedQuery' " +
+                    "is successful, though that named query is undefined.");
+        } catch (JDOUserException e) {
+        }
+    }
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewNamedQuery.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.api;
+
+import javax.jdo.JDOException;
+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.QueryTest;
+import org.apache.jdo.tck.query.result.classes.FullName;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> New Named Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-12.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Construct a new query instance 
+ * with the given candidate class from a named query.
+ */
+public class NewNamedQuery extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.5-12 (NewNamedQuery) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static Object[][] expectedResult = {
+        {new FullName("emp1First", "emp1Last"), 
+            new FullName("emp2First", "emp2Last"),
+            new FullName("emp3First", "emp3Last"), 
+            new FullName("emp4First", "emp4Last"),
+            new FullName("emp5First", "emp5Last")},
+        {new FullName("emp1First", "emp1Last")}
+    };
+            
+    /**
+     * The <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(NewNamedQuery.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        executeNamedQuery(Person.class, "validNotUnique", 
+                false, expectedResult[index]);
+
+        index = 1;
+        executeNamedQuery(Person.class, "validUnique", 
+                true, expectedResult[index]);
+    }
+
+    /** */
+    public void testNegative() {
+        executeNamedQuery(Person.class, "invalidUnique", true, null);
+    }
+
+    private void executeNamedQuery(Class candidateClass, String namedQuery,
+            boolean isUnique, Object[] expectedResultValues) {
+        Query query = getPM().newNamedQuery(candidateClass, namedQuery); 
+        execute(ASSERTION_FAILED, query, "Named query " + namedQuery,
+                isUnique, false, null, expectedResultValues);
+    }
+    
+    /**
+     * @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/api/NewQuerySingleString.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/NewQuerySingleString.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,95 @@
+/*
+ * 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.api;
+
+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> Single String Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.5-11.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Construct a new query instance using the specified String 
+ * as the single-string representation of the query.
+ */
+public class NewQuerySingleString extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.5-11 (NewQuerySingleString) 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 static String[][] expectedResult = {
+            {"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(NewQuerySingleString.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            Object[] expectedResultValues = 
+                getCompanyModelInstances(expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
+                    expectedResultValues);
+        }
+    }
+
+    /**
+     * @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/api/QueryExtentions.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/QueryExtentions.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,85 @@
+/*
+ * 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.api;
+
+import java.util.HashMap;
+import java.util.Map;
+
+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.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Query Extentions.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.9-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Some JDO vendors provide extensions to the query, 
+ * and these extensions must be set in the query instance prior to execution.
+ */
+public class QueryExtentions extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.9-1 (QueryExtentions) failed: ";
+    
+    private static String singleStringQuery = 
+        "SELECT FROM " + Person.class.getName();
+
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp1", "emp2", "emp3", "emp4", "emp5"}
+    };
+            
+    /**
+     * The <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(QueryExtentions.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(singleStringQuery);
+        Map extentions = new HashMap();
+        extentions.put("unknown key 1", "unknown value 1");
+        query.setExtensions(extentions);
+        query.addExtension("unknown key 2", "unknown value 2");
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, expectedResultValues);
+    }
+    
+    /**
+     * @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/api/SetGrouping.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetGrouping.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,76 @@
+/*
+ * 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.api;
+
+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.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Grouping.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-17.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * void setGrouping (String grouping); 
+ * Specify the grouping of results for aggregates.
+ */
+public class SetGrouping extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-17 (SetGrouping) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static Object[][] expectedResult = {
+        {"emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}
+    };
+            
+    /**
+     * The <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(SetGrouping.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(Person.class);
+        query.setResult("lastname");
+        query.setGrouping("lastname");
+        String singleStringQuery = "SELECT lastname FROM Person GROUP BY lastname";
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, expectedResult[index]);
+    }
+    
+    /**
+     * @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/api/SetRange.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetRange.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,79 @@
+/*
+ * 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.api;
+
+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.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Range.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-20.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * setRange(int fromIncl, int toExcl); 
+ * Specify the number of instances to skip over 
+ * and the maximum number of result instances to return.
+ */
+public class SetRange extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-20 (SetRange) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp1", "emp2", "emp3", "emp4", "emp5"}
+    };
+            
+    /**
+     * The <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(SetRange.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(Person.class);
+        query.setRange(0, 5);
+        String singleStringQuery = 
+            "SELECT FROM Person RANGE 0, 5";
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, expectedResultValues);
+    }
+    
+    /**
+     * @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/api/SetResult.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResult.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.query.api;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Result.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-16.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * void setResult (String result); Specify the results of the query 
+ * if not instances of the candidate class.
+ */
+public class SetResult extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-16 (SetResult) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static Object[][] expectedResult = {
+        {"emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last"}
+    };
+            
+    /**
+     * The <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(SetResult.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(Person.class);
+        query.setResult("lastname");
+        String singleStringQuery = "SELECT lastname FROM Person";
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, expectedResult[index]);
+    }
+    
+    /** */
+    public void testNegative() {
+        Query query = getPM().newQuery(Person.class);
+        try { 
+            query.setResult("noname");
+            query.compile();
+            fail(ASSERTION_FAILED + "Compilation for query " +
+                    "'SELECT noname FROM Person' " +
+                    "succeeded, though the result clause is invalid.");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    /**
+     * @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/api/SetResultClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetResultClass.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,82 @@
+/*
+ * 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.api;
+
+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.QueryTest;
+import org.apache.jdo.tck.query.result.classes.FullName;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Result Class.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-19.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * void setResultClass (Class resultClass); 
+ * Specify the class to be used to return result instances.
+ */
+public class SetResultClass extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-19 (SetResultClass) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static Object[][] expectedResult = {
+        {new FullName("emp1First", "emp1Last"), 
+            new FullName("emp2First", "emp2Last"),
+            new FullName("emp3First", "emp3Last"),
+            new FullName("emp4First", "emp4Last"),
+            new FullName("emp5First", "emp5Last")}
+    };
+            
+    /**
+     * The <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(SetResultClass.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(Person.class);
+        query.setResultClass(FullName.class);
+        query.setResult("firstname, lastname");
+        String singleStringQuery = 
+            "SELECT firstname, lastname INTO FullName FROM Person";
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, 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/api/SetUnique.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SetUnique.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,90 @@
+/*
+ * 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.api;
+
+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.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Unique.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-18.
+ *<BR>
+ *<B>Assertion Description: </B>
+ *  void setUnique (boolean unique); 
+ *  Specify that there is a single result of the query.
+ */
+public class SetUnique extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-18 (SetUnique) failed: ";
+    
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp1"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"}
+    };
+            
+    /**
+     * The <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(SetUnique.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        boolean unique = true;
+        Query query = getPM().newQuery(Person.class);
+        query.setUnique(unique);
+        query.setFilter("lastname == 'emp1Last'");
+        String singleStringQuery = 
+            "SELECT FROM Person WHERE lastname == 'emp1Last'";
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                unique, false, null, expectedResultValues);
+
+        index = 1;
+        unique = false;
+        query = getPM().newQuery(Person.class);
+        query.setUnique(unique);
+        singleStringQuery = "SELECT FROM Person";
+        expectedResultValues = getCompanyModelInstances(expectedResult[index]);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                unique, false, null, expectedResultValues);
+    }
+    
+    /**
+     * @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/api/SingleStringQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/SingleStringQuery.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,122 @@
+/*
+ * 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.api;
+
+import java.math.BigDecimal;
+
+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.FullTimeEmployee;
+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> Single String Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-23.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The single string query is first parsed to yield the result, 
+ * result class, filter, variable list, parameter list, import list, 
+ * grouping, ordering, and range. 
+ * Then, the values specified in APIs setResult, setResultClass, 
+ * setFilter, declareVariables, declareParamters, declareImports, 
+ * setGrouping, setOrdering, and setRange 
+ * override the corresponding settings from the single string query.
+ */
+public class SingleStringQuery extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-23 (SingleStringQuery) failed: ";
+    
+    private static String singleStringQuery = 
+        "SELECT UNIQUE firstname, lastname " +
+        "INTO FullName " +
+        "FROM Person " +
+        "WHERE salary > 1000 & " +
+        "      projects.contains(project) & project.budget > limit & " +
+        "      firstname == 'emp1First' " +
+        "VARIABLES Project project " +
+        "PARAMETERS BigDecimal limit " +
+        "IMPORTS IMPORT org.apache.jdo.tck.query.result.classes.FullName; " +
+        "        IMPORT org.apache.jdo.tck.pc.company.Person; " +
+        "        IMPORT org.apache.jdo.tck.pc.company.Project; " +
+        "        IMPORT java.math.BigDecimal; " +
+        "ORDER BY personid ASCENDING" +
+        "GROUP BY firstname, lastname " +
+        "RANGE 0 TO 5";
+
+    /** The expected results of valid queries. */
+    private static Object[][] expectedResult = {
+        {new FullName("emp1First", "emp1Last")},
+        //Note: These are no bean names!
+        {"emp1First", "emp2First", "emp5First"} 
+    };
+            
+    /** Parameters of valid queries. */
+    private static Object[][] parameters = {
+        {new BigDecimal("2000")}
+    };
+            
+    /**
+     * 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(SingleStringQuery.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(singleStringQuery);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                true, true, parameters[index], expectedResult[index]);
+        
+        index = 1;
+        String singleStringQuery = 
+            "SELECT firstName FROM org.apache.jdo.tck.pc.company.FullTimeEmployee";
+        query.setUnique(false);
+        query.setResult(null);
+        query.setResultClass(null);
+        query.setClass(FullTimeEmployee.class);
+        query.setFilter(null);
+        query.declareVariables(null);
+        query.declareParameters(null);
+        query.declareImports(null);
+        query.setGrouping(null);
+        query.setOrdering(null);
+        query.setRange(0, 0);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, parameters[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/api/UnmodifiableQuery.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/api/UnmodifiableQuery.java Tue Nov  8 09:17:35 2005
@@ -0,0 +1,187 @@
+/*
+ * 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.api;
+
+import javax.jdo.JDOException;
+import javax.jdo.JDOUserException;
+import javax.jdo.Query;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.Person;
+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> Unmodifiable Query.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-22.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * The Unmodifiable option, when set to true, 
+ * disallows further modification of the query, 
+ * except for specifying the range and result class and ignoreCache option.
+ */
+public class UnmodifiableQuery extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-22 (UnmodifiableQuery) failed: ";
+    
+    private static String singleStringQuery = 
+        "SELECT firstname, lastname FROM org.apache.jdo.tck.pc.company.Person";
+
+    /** The expected results of valid queries. */
+    private static Object[][] expectedResult = {
+        {new FullName("emp1First", "emp1Last"), 
+            new FullName("emp2First", "emp2Last"),
+            new FullName("emp3First", "emp3Last"),
+            new FullName("emp4First", "emp4Last"),
+            new FullName("emp5First", "emp5Last")}
+    };
+            
+    /**
+     * The <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(UnmodifiableQuery.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        int index = 0;
+        Query query = getPM().newQuery(singleStringQuery);
+        query.setUnmodifiable();
+        query.setResultClass(FullName.class);
+        query.setRange(0, 5);
+        query.setIgnoreCache(true);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, expectedResult[index]);
+
+        query = getPM().newNamedQuery(Person.class, "unmodifiable");
+        query.setResultClass(FullName.class);
+        query.setRange(0, 5);
+        query.setIgnoreCache(true);
+        execute(ASSERTION_FAILED, query, singleStringQuery, 
+                false, false, null, expectedResult[index]);
+    }
+    
+    /** */
+    public void testNegative() {
+        Query query = getPM().newQuery(singleStringQuery);
+        query.setUnmodifiable();
+        checkSetters(query);
+
+        query = getPM().newNamedQuery(Person.class, "unmodifiable");
+        checkSetters(query);
+    }
+    
+    private void checkSetters(Query query) {
+        checkSetResult(query);
+        checkSetClass(query);
+        checkSetFilter(query);
+        checkDeclareVariables(query);
+        checkDeclareParameters(query);
+        checkDeclareImports(query);
+        checkSetOrdering(query);
+        checkSetGrouping(query);
+        checkSetOrdering(query);
+    }
+        
+    private void checkSetResult(Query query) {
+        try {
+            query.setResult("firstname, lastname");
+            methodFailed("setResult()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkSetClass(Query query) {
+        try {
+            query.setClass(Employee.class);
+            methodFailed("setClass()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkSetFilter(Query query) {
+        try {
+            query.setFilter("firstname == 'emp1First'");
+            methodFailed("setFilter()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkDeclareVariables(Query query) {
+        try {
+            query.declareVariables("Employee emp");
+            methodFailed("declareVariables()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkDeclareParameters(Query query) {
+        try {
+            query.declareParameters("Employee emp");
+            methodFailed("declareParameters()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkDeclareImports(Query query) {
+        try {
+            query.declareImports("import org.apache.jdo.tck.pc.company.Employee");
+            methodFailed("declareImports()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkSetGrouping(Query query) {
+        try {
+            query.setGrouping("firstname");
+            methodFailed("setGrouping()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void checkSetOrdering(Query query) {
+        try {
+            query.setOrdering("firstname ASCENDING");
+            methodFailed("setOrdering()");
+        } catch (JDOUserException e) {
+        }
+    }
+    
+    private void methodFailed(String method) {
+        fail(ASSERTION_FAILED + method + 
+                " on an unmodifiable query must throw JDOUserException." );
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+}

Added: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/Person.jdoquery
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/Person.jdoquery?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/Person.jdoquery (added)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/Person.jdoquery Tue Nov  8 09:17:35 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<!--
+This file contains a named query for class Person.
+-->
+<jdo>
+    <package name="org.apache.jdo.tck.pc.company">
+
+        <class name="Person">
+            <query name="packageJDOQuery">
+                SELECT FROM org.apache.jdo.tck.pc.company.Person
+                WHERE personid > 3
+            </query>
+        </class>
+
+    </package>
+</jdo>

Modified: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo?rev=331850&r1=331849&r2=331850&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo (original)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/package.jdo Tue Nov  8 09:17:35 2005
@@ -79,9 +79,39 @@
             <field name="middlename" default-fetch-group="false"/>
             <field name="address"
                    persistence-modifier="persistent"/>
-	    <field name="phoneNumbers" persistence-modifier="persistent">
+            <field name="phoneNumbers" persistence-modifier="persistent">
                 <map key-type="String" value-type="String"/>
             </field>
+            <query name="validNotUnique">
+                SELECT firstname, lastname 
+                INTO org.apache.jdo.tck.query.result.classes.FullName 
+                FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="validUnique">
+                SELECT UNIQUE firstname, lastname 
+                INTO org.apache.jdo.tck.query.result.classes.FullName 
+                FROM org.apache.jdo.tck.pc.company.Person 
+                WHERE firstname == 'emp1First'
+            </query>
+            <query name="invalidUnique">
+                SELECT UNIQUE firstname, lastname 
+                INTO org.apache.jdo.tck.query.result.classes.FullName
+                FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="unmodifiable" unmodifiable="true">
+                SELECT firstname, lastname 
+                FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="packageJDO">
+                SELECT FROM org.apache.jdo.tck.pc.company.Person
+                WHERE personid > 1
+            </query>
+            <query name="changeQuery">
+                SELECT FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="invalidQuery">
+                SeLeCt FrOm org.apache.jdo.tck.pc.company.Person
+            </query>
         </class>
 
         <class name="Project"

Added: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo (added)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo Tue Nov  8 09:17:35 2005
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<jdo>
+  <package name="org.apache.jdo.tck.pc.mylib">
+
+    <!-- This will not be required once the JDOModel is fixed so that
+         the defaults defined in section 18.4 of the spec are working
+    -->
+    <class name="PCClass" 
+           identity-type="application" objectid-class="org.apache.jdo.tck.pc.mylib.PCClass$Oid">
+      <field name="id" primary-key="true"/>
+      <field name="transientNumber1" persistence-modifier="none"/>
+      <field name="transientNumber2" persistence-modifier="none"/>
+      <fetch-group name="default">
+        <field name="number1"/>
+      </fetch-group>        
+      <fetch-group name="fetchGoup2" post-load="true">
+        <field name="number2"/>
+      </fetch-group>        
+      <query name="classJDO">
+          SELECT FROM org.apache.jdo.tck.pc.mylib.PCClass
+      </query>
+    </class>
+
+  </package>
+</jdo>
+

Added: incubator/jdo/trunk/tck20/test/jdo/applicationidentity/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/applicationidentity/package.jdo?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/applicationidentity/package.jdo (added)
+++ incubator/jdo/trunk/tck20/test/jdo/applicationidentity/package.jdo Tue Nov  8 09:17:35 2005
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<!--
+This file contains a named query which may be found 
+calling pm.newNamedQuery(null, "packageJDOInDefaultPackage").
+-->
+<jdo>
+    <query name="packageJDOInDefaultPackage">
+        SELECT FROM org.apache.jdo.tck.pc.company.Person
+    </query>
+</jdo>

Added: incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/Person.jdoquery
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/Person.jdoquery?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/Person.jdoquery (added)
+++ incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/Person.jdoquery Tue Nov  8 09:17:35 2005
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<!--
+This file contains a named query for class Person.
+-->
+<jdo>
+    <package name="org.apache.jdo.tck.pc.company">
+
+        <class name="Person">
+            <query name="packageJDOQuery">
+                SELECT FROM org.apache.jdo.tck.pc.company.Person
+                WHERE personid > 3
+            </query>
+        </class>
+
+    </package>
+</jdo>

Modified: incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo?rev=331850&r1=331849&r2=331850&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo (original)
+++ incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/package.jdo Tue Nov  8 09:17:35 2005
@@ -56,9 +56,39 @@
             <field name="middlename" default-fetch-group="false"/>
             <field name="address"
                    persistence-modifier="persistent"/>
-	    <field name="phoneNumbers" persistence-modifier="persistent">
+            <field name="phoneNumbers" persistence-modifier="persistent">
                 <map key-type="String" value-type="String"/>
             </field>
+            <query name="validNotUnique">
+                SELECT firstname, lastname 
+                INTO org.apache.jdo.tck.query.result.classes.FullName 
+                FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="validUnique">
+                SELECT UNIQUE firstname, lastname 
+                INTO org.apache.jdo.tck.query.result.classes.FullName 
+                FROM org.apache.jdo.tck.pc.company.Person 
+                WHERE firstname == 'emp1First'
+            </query>
+            <query name="invalidUnique">
+                SELECT UNIQUE firstname, lastname 
+                INTO org.apache.jdo.tck.query.result.classes.FullName
+                FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="unmodifiable" unmodifiable="true">
+                SELECT firstname, lastname 
+                FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="packageJDO">
+                SELECT FROM org.apache.jdo.tck.pc.company.Person
+                WHERE personid > 1
+            </query>
+            <query name="changeQuery">
+                SELECT FROM org.apache.jdo.tck.pc.company.Person
+            </query>
+            <query name="invalidQuery">
+                SeLeCt FrOm org.apache.jdo.tck.pc.company.Person
+            </query>
         </class>
 
         <class name="Project" identity-type="datastore">

Added: incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo (added)
+++ incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/PCClass.jdo Tue Nov  8 09:17:35 2005
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<jdo>
+  <package name="org.apache.jdo.tck.pc.mylib">
+
+    <!-- This will not be required once the JDOModel is fixed so that
+         the defaults defined in section 18.4 of the spec are working
+    -->
+    <class name="PCClass" identity-type="datastore">
+      <field name="transientNumber1" persistence-modifier="none"/>
+      <field name="transientNumber2" persistence-modifier="none"/>
+      <fetch-group name="default">
+        <field name="number1"/>
+      </fetch-group>
+      <fetch-group name="fetchGoup2" post-load="true">
+        <field name="number2"/>
+      </fetch-group>        
+      <query name="classJDO">
+          SELECT FROM org.apache.jdo.tck.pc.mylib.PCClass
+      </query>
+    </class>
+
+  </package>
+</jdo>
+

Added: incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/package.jdo
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/package.jdo?rev=331850&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/package.jdo (added)
+++ incubator/jdo/trunk/tck20/test/jdo/datastoreidentity/package.jdo Tue Nov  8 09:17:35 2005
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE jdo PUBLIC "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN" "http://java.sun.com/dtd/jdo_2_0.dtd">
+<!--
+This file contains a named query which may be found 
+calling pm.newNamedQuery(null, "packageJDOInDefaultPackage").
+-->
+<jdo>
+    <query name="packageJDOInDefaultPackage">
+        SELECT FROM org.apache.jdo.tck.pc.company.Person
+    </query>
+</jdo>



Mime
View raw message