db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r158179 [39/61] - in incubator/jdo/trunk/tck11: ./ assertions/ iut_jars/ test/ test/conf/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/jdo/ test/java/org/apache/jdo/tck/ test/java/org/apache/jdo/tck/api/ test/java/org/apache/jdo/tck/api/instancecallbacks/ test/java/org/apache/jdo/tck/api/jdohelper/ test/java/org/apache/jdo/tck/api/persistencemanager/ test/java/org/apache/jdo/tck/api/persistencemanagerfactory/ test/java/org/apache/jdo/tck/enhancement/ test/java/org/apache/jdo/tck/extents/ test/java/org/apache/jdo/tck/lifecycle/ test/java/org/apache/jdo/tck/lifecycle/nontransactional/ test/java/org/apache/jdo/tck/models/ test/java/org/apache/jdo/tck/models/embedded/ test/java/org/apache/jdo/tck/models/fieldtypes/ test/java/org/apache/jdo/tck/models/inheritance/ test/java/org/apache/jdo/tck/pc/ test/java/org/apache/jdo/tck/pc/company/ test/java/org/apache/jdo/tck/pc/fieldtypes/ test/java/org/apache/jdo/tck/pc/inheritance/ test/java/org/apache/jdo/tck/pc/instancecallbacks/ test/java/org/apache/jdo/tck/pc/lifecycle/ test/java/org/apache/jdo/tck/pc/mylib/ test/java/org/apache/jdo/tck/query/ test/java/org/apache/jdo/tck/query/operators/ test/java/org/apache/jdo/tck/transactions/ test/java/org/apache/jdo/tck/util/ test/jdo/ test/jdo/applicationidentity/ test/jdo/applicationidentity/org/ test/jdo/applicationidentity/org/apache/ test/jdo/applicationidentity/org/apache/jdo/ test/jdo/applicationidentity/org/apache/jdo/tck/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/company/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/applicationidentity/org/apache/jdo/tck/pc/mylib/ test/jdo/datastoreidentity/ test/jdo/datastoreidentity/org/ test/jdo/datastoreidentity/org/apache/ test/jdo/datastoreidentity/org/apache/jdo/ test/jdo/datastoreidentity/org/apache/jdo/tck/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/company/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/fieldtypes/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/inheritance/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/instancecallbacks/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/lifecycle/ test/jdo/datastoreidentity/org/apache/jdo/tck/pc/mylib/
Date Sat, 19 Mar 2005 01:09:52 GMT
Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/QueryWithNoFilter.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/QueryWithNoFilter.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/QueryWithNoFilter.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/QueryWithNoFilter.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Query with no Filter
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-1.
+ *<BR>
+ *<B>Assertion Description: </B> If the <code>Query</code> filter is not
+ *specified, then it defaults to <code>true</code>, which has the effect of
+ *filtering the input <code>Collection</code> only for class type.
+ */
+
+public class QueryWithNoFilter extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-1 (QueryWithNoFilter) 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(QueryWithNoFilter.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        runTestQueryWithNoFilter(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestQueryWithNoFilter(PersistenceManager pm) {
+        if(debug) logger.debug("\nExecuting test QueryWithNoFilter() ...");
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            Object results = query.execute();
+
+            // check query result
+            List expected = new ArrayList();
+            Object p1 = new PCPoint(0, 0);
+            Object p2 = new PCPoint(1, 1);
+            Object p3 = new PCPoint(2, 2);
+            Object p4 = new PCPoint(3, 3);
+            Object p5 = new PCPoint(4, 4);
+            expected.add(p1);
+            expected.add(p2);
+            expected.add(p3);
+            expected.add(p4);
+            expected.add(p5);
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/RestoredSerializedQueryInstanceLosesAssociationWithPM.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/RestoredSerializedQueryInstanceLosesAssociationWithPM.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/RestoredSerializedQueryInstanceLosesAssociationWithPM.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/RestoredSerializedQueryInstanceLosesAssociationWithPM.java Fri Mar 18 17:07:39 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;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import javax.jdo.JDOException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Restored Serialized Query Instance Loses Association With PM
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.3-8.
+ *<BR>
+ *<B>Assertion Description: </B>
+If a serialized instance is restored, it loses its association with its former
+<code>PersistenceManager</code>.
+
+ */
+
+public class RestoredSerializedQueryInstanceLosesAssociationWithPM
+    extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.3-8 (RestoredSerializedQueryInstanceLosesAssociationWithPM) 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(RestoredSerializedQueryInstanceLosesAssociationWithPM.class);
+    }
+
+    /** */
+    public void test() throws Exception {
+        pm = getPM();
+
+        checkRestoredQueryInstance(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void checkRestoredQueryInstance(PersistenceManager pm) throws Exception {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Query query = pm.newQuery();
+            Class clazz = org.apache.jdo.tck.pc.company.Project.class;
+            query.setClass(clazz);
+            query.setCandidates(pm.getExtent(clazz, false));
+            query.declareVariables("org.apache.jdo.tck.pc.company.Person a; org.apache.jdo.tck.pc.company.Person b" );
+            query.setFilter("reviewers.contains(a) && a.firstname==\"brazil\" || reviewers.contains(b) && b.firstname==\"brazil\"" );
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(query);
+            ObjectInputStream ois = 
+                new ObjectInputStream(
+                    new ByteArrayInputStream(baos.toByteArray()));
+            query = (Query) ois.readObject();
+            
+            try {
+                Object results = query.execute();
+                fail(ASSERTION_FAILED,
+                     "A deserialized query instance should not execute successfully without associating that instance to a persistence manager");
+            } 
+            catch (JDOException e) {
+                if (debug) logger.debug("Caught expected " + e);
+            }
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SeparateNamespaceForTypeNames.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SeparateNamespaceForTypeNames.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SeparateNamespaceForTypeNames.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SeparateNamespaceForTypeNames.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Namespace of Type Names Separate From Fields, Variables, Parameters
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.4-1.
+ *<BR>
+ *<B>Assertion Description: </B>
+Type names have their own namespace that is separate 
+from the namespace for fields, variables and parameters.
+
+ */
+
+public class SeparateNamespaceForTypeNames extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.4-1 (SeparateNamespaceForTypeNames) 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(SeparateNamespaceForTypeNames.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        try {
+            // read test data
+            CompanyModelReader reader = 
+                loadCompanyModel(pm, "org/apache/jdo/tck/query/company.xml");
+            runTest(pm, reader);
+        }
+        finally {
+            cleanupCompanyModel(pm);
+            pm.close();
+            pm = null;
+        }
+    }
+
+    /** */
+    void runTest(PersistenceManager pm, CompanyModelReader reader) {
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        Department dept1 = reader.getDepartment("dept1");
+
+
+        // query having a parameter with the same name as a type
+        Query query = pm.newQuery(Employee.class);
+        query.declareImports("import org.apache.jdo.tck.pc.company.Department");
+        query.declareParameters("Department Department");
+        query.setFilter("department == Department");
+        Object results = query.execute(dept1);
+
+        Collection expected = new HashSet();
+        expected.add(reader.getFullTimeEmployee("emp1"));
+        expected.add(reader.getFullTimeEmployee("emp2"));
+        expected.add(reader.getPartTimeEmployee("emp3"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+
+        // query having a parameter with the same name as a type
+        query = pm.newQuery(Department.class);
+        query.declareImports("import org.apache.jdo.tck.pc.company.Employee");
+        query.declareVariables("Employee Employee");
+        query.setFilter("employees.contains(Employee) && Employee.firstname == \"emp1First\"");
+        results = query.execute();
+
+        expected = new ArrayList();
+        expected.add(dept1);
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+
+        tx.commit();
+        tx = null;
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateCollection.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateCollection.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateCollection.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,107 @@
+/*
+ * 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;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Candidate Collection
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-5.
+ *<BR>
+ *<B>Assertion Description: </B> <code>Query.setCandidates(Collection
+ *candidateCollection)</code> binds the candidate <code>Collection</code>
+ *to the query instance.
+ */
+
+public class SetCandidateCollection extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-5 (SetCandidateCollection) 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(SetCandidateCollection.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        runTestSetCandidateCollection(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestSetCandidateCollection(PersistenceManager pm) {
+        if (debug) logger.debug("\nExecuting test SetCandidateCollection()...");
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(inserted);
+            Object results = query.execute();
+        
+            // check query result
+            List expected = new ArrayList();
+            Object p1 = new PCPoint(0, 0);
+            Object p2 = new PCPoint(1, 1);
+            Object p3 = new PCPoint(2, 2);
+            Object p4 = new PCPoint(3, 3);
+            Object p5 = new PCPoint(4, 4);
+            expected.add(p1);
+            expected.add(p2);
+            expected.add(p3);
+            expected.add(p4);
+            expected.add(p5);
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+            if (debug) logger.debug("Test SetCandidateCollection: Passed");
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateExtent.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateExtent.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateExtent.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetCandidateExtent.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Candidate Extent
+ *<BR>
+ *<B>Keywords:</B> query extent
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-6.
+ *<BR>
+ *<B>Assertion Description: </B> <code>Query.setCandidates(Extent
+ *candidateExtent)</code> binds the candidate <code>Extent</code> to the query
+ *instance.
+ */
+
+public class SetCandidateExtent extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-6 (SetCandidateExtent) 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(SetCandidateExtent.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        runTestSetCandidateExtent(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestSetCandidateExtent(PersistenceManager pm) {
+        if (debug) logger.debug("\nExecuting test SetCandidateExtent()...");
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            Object results = query.execute();
+
+            // check query result
+            List expected = new ArrayList();
+            Object p1 = new PCPoint(0, 0);
+            Object p2 = new PCPoint(1, 1);
+            Object p3 = new PCPoint(2, 2);
+            Object p4 = new PCPoint(3, 3);
+            Object p5 = new PCPoint(4, 4);
+            expected.add(p1);
+            expected.add(p2);
+            expected.add(p3);
+            expected.add(p4);
+            expected.add(p5);
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+            if (debug) logger.debug("Test SetCandidateExtent: Passed");
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetFilter.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetFilter.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetFilter.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetFilter.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,98 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Filter
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-7.
+ *<BR>
+ *<B>Assertion Description: </B>
+<code>Query.setFilter(String filter)</code> binds the query filter
+to the query instance.
+
+ */
+
+public class SetFilter extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-7 (SetFilter) 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(SetFilter.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        runTestNewQuery(pm);
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestNewQuery(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        Class clazz = PCPoint.class;
+        try {
+            Extent extent = pm.getExtent(clazz, true);
+            tx.begin();
+            Query query = pm.newQuery();
+            query.setClass(clazz);
+            query.setCandidates(extent);
+            query.setFilter("x == 2");
+            Object results = query.execute();
+            
+            // check query result
+            List expected = new ArrayList();
+            expected.add(new PCPoint(2, 2));
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetIgnoreCache.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetIgnoreCache.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetIgnoreCache.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetIgnoreCache.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set IgnoreCache
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-12.
+ *<BR>
+ *<B>Assertion Description: </B> <code>Query.setIgnoreCache(boolean flag)</code> 
+ *sets the IgnoreCache option for queries.
+ */
+
+public class SetIgnoreCache extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-12 (SetIgnoreCache) 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(SetIgnoreCache.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        runTestSetIgnoreCache01(pm);
+        runTestSetIgnoreCache02(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestSetIgnoreCache01(PersistenceManager pm)  {
+        Transaction tx = pm.currentTransaction();
+        tx.setOptimistic(false);
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+
+            if (debug)
+                logger.debug("Pessimistic: IgnoreCache - Setting value = true");
+            query.setIgnoreCache(true);
+            if(query.getIgnoreCache()) {
+                if (debug)
+                    logger.debug("Pessimistic: IgnoreCache - value = " +
+                                 query.getIgnoreCache());
+            } 
+            else {
+                fail(ASSERTION_FAILED,
+                     "query.getIgnoreCache() returns false after setting the flag to true");
+            }
+
+            if (debug)
+                logger.debug("Pessimistic: IgnoreCache - Setting value = false");
+            query.setIgnoreCache(false);
+            if(!query.getIgnoreCache()) {
+                if (debug)
+                    logger.debug("Pessimistic: IgnoreCache - value = " + 
+                                 query.getIgnoreCache());
+            } 
+            else {
+                fail(ASSERTION_FAILED,
+                     "query.getIgnoreCache() returns true after setting the flag to false");
+            }
+            query.compile();
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    void runTestSetIgnoreCache02(PersistenceManager pm) {
+        if (!isOptimisticSupported()) {
+            if (debug) logger.debug("Optimistic tx not supported");
+            return;
+        }
+        
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.setOptimistic(true);
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+
+            if (debug)
+                logger.debug("Optimistic: IgnoreCache - Setting value = true");
+            query.setIgnoreCache(true);
+            if(query.getIgnoreCache()) {
+                if (debug) 
+                    logger.debug("Optimistic: IgnoreCache - value = " +
+                                 query.getIgnoreCache());
+            }
+            else {
+                fail(ASSERTION_FAILED,
+                     "query.getIgnoreCache() returns false after setting the flag to true");
+            }
+
+            if (debug)
+                logger.debug("Optimistic: IgnoreCache - Setting value = false");
+            query.setIgnoreCache(false);
+            if(!query.getIgnoreCache()) {
+                if (debug) 
+                    logger.debug("Optimistic: IgnoreCache - value = " +
+                                 query.getIgnoreCache());
+            } 
+            else {
+                fail(ASSERTION_FAILED,
+                     "query.getIgnoreCache() returns true after setting the flag to false");
+            }
+            
+            query.compile();
+        
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetOrdering.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetOrdering.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetOrdering.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetOrdering.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+
+package org.apache.jdo.tck.query;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ListIterator;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.pc.fieldtypes.AllTypes;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Set Ordering
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6-11.
+ *<BR>
+ *<B>Assertion Description: </B>
+<code>Query.setOrdering(String ordering)</code> binds the ordering statements
+to the query instance.
+
+ */
+
+public class SetOrdering extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6-11 (SetOrdering) 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(SetOrdering.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        runTestAscending(pm);
+        runTestDescending(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestAscending(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            //ascending
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            query.setOrdering("x ascending");
+            Object results = query.execute();
+
+            // check result
+            printOutput(results, inserted);
+            checkQueryResultWithOrder(ASSERTION_FAILED, results, inserted);
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+    
+
+    /** */
+    void runTestDescending(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        Class clazz = PCPoint.class;
+        try {
+            tx.begin();
+
+            //descending
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            query.setOrdering("x descending");
+            Object results = query.execute();
+            
+            // check result
+            List expected = new ArrayList();
+            ListIterator li = inserted.listIterator(inserted.size());
+            // construct expected results by iterating inserted objects backwards
+            while (li.hasPrevious()) {
+                Object obj = li.previous();
+                expected.add(obj);
+            }
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithOrder(ASSERTION_FAILED, results, expected);
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetterReplacePreviousValues.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetterReplacePreviousValues.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetterReplacePreviousValues.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SetterReplacePreviousValues.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,113 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Setter replace previous values.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.15.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * All of these methods replace the previously set query element, by the 
+ * parameter. [The methods are not additive].
+ */
+
+public class SetterReplacePreviousValues extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.15 (SetterReplacePreviousValues) 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(SetterReplacePreviousValues.class);
+    }
+    
+    /** */
+    public void test() {
+        pm = getPM();
+                
+        try {
+            // read test data
+            CompanyModelReader reader = 
+                loadCompanyModel(pm, "org/apache/jdo/tck/query/company.xml");
+            runTest(pm, reader);
+        }
+        finally {
+            cleanupCompanyModel(pm);
+            pm.close();
+            pm = null;
+        }
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm, CompanyModelReader reader) {
+        Query q;
+        Collection result;
+        Collection expected;
+        
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        
+        // replace parameter declaration
+        q = pm.newQuery(Department.class, "deptid == param");
+        q.declareParameters("String x");
+        q.declareParameters("long param");
+        result = (Collection)q.execute(new Long(1));
+        expected = new HashSet();
+        expected.add(reader.getDepartment("dept1"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+       
+        // replace filter setting
+        q = pm.newQuery(Employee.class, "personid == 1L");
+        q.setFilter("personid == 2L");
+        result = (Collection)q.execute();
+        expected = new HashSet();
+        expected.add(reader.getFullTimeEmployee("emp2"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+        
+        // repalce variable declaration
+        q = pm.newQuery(Department.class);
+        q.declareVariables("Employee e1; Employee e2");
+        q.declareVariables("Employee e");
+        q.setFilter("employees.contains(e) && e.personid == 1");
+        result = (Collection)q.execute();
+        expected = new HashSet();
+        expected.add(reader.getDepartment("dept1"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+        
+        tx.rollback();
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/StartsWithAndEndsWith.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/StartsWithAndEndsWith.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/StartsWithAndEndsWith.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/StartsWithAndEndsWith.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,102 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> StartsWith and EndsWith Query Operators
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-33.
+ *<BR>
+ *<B>Assertion Description: </B>
+<code>String</code> methods <code>startsWith</code> and <code>endsWith</code>
+support wild card queries. JDO does not define any special semantic to the
+argument passed to the method; in particular,
+it does not define any wild card characters.
+
+ */
+
+public class StartsWithAndEndsWith extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-33 (StartsWithAndEndsWith) 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(StartsWithAndEndsWith.class);
+    }
+    
+    /** */
+    public void test() {
+        pm = getPM();
+                
+        try {
+            // read test data
+            CompanyModelReader reader = 
+                loadCompanyModel(pm, "org/apache/jdo/tck/query/company.xml");
+            runTest(pm, reader);
+        }
+        finally {
+            cleanupCompanyModel(pm);
+            pm.close();
+            pm = null;
+        }
+    }
+    
+     /** */
+    void runTest(PersistenceManager pm, CompanyModelReader reader) {
+        Query q;
+        Object result;
+        Collection expected;
+        
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+
+        // startsWith
+        q = pm.newQuery(Employee.class, "firstname.startsWith(\"emp1\")");
+        result = q.execute();
+        expected = new HashSet();
+        expected.add(reader.getFullTimeEmployee("emp1"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+            
+        // endsWith
+        q = pm.newQuery(Employee.class, "firstname.endsWith(\"1First\")");
+        result = q.execute();
+        expected = new HashSet();
+        expected.add(reader.getFullTimeEmployee("emp1"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+            
+        tx.commit();
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SupportedCollectionMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SupportedCollectionMethods.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SupportedCollectionMethods.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/SupportedCollectionMethods.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,124 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Employee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B>Supported collection methods
+ *<BR>
+ *<B>Keywords:</B> query collection 
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-44.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Supported collection methods:
+ * <UL>
+ * <LI>isEmpty</LI>
+ * <LI>contains</LI>
+ * </UL>
+ */
+
+public class SupportedCollectionMethods extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-36 (SupportedCollectionMethods) 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(SupportedCollectionMethods.class);
+    }
+    
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        try {
+            // read test data
+            CompanyModelReader reader = 
+                loadCompanyModel(pm, "org/apache/jdo/tck/query/company.xml");
+            runTestIsEmpty(pm, reader);
+            runTestContains(pm, reader);
+        }
+        finally {
+            cleanupCompanyModel(pm);
+            pm.close();
+            pm = null;
+        }
+    }
+    
+    /** */
+    void runTestIsEmpty(PersistenceManager pm, CompanyModelReader reader) {
+        Query q;
+        Object result;
+        Collection expected;
+
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+
+        q = pm.newQuery(Department.class, "!employees.isEmpty()");
+        result = q.execute();
+        expected = new HashSet();
+        expected.add(reader.getDepartment("dept1"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+
+        q = pm.newQuery(Employee.class, "team.isEmpty()");
+        result = q.execute();
+        expected = new HashSet();
+        expected.add(reader.getFullTimeEmployee("emp1"));
+        expected.add(reader.getFullTimeEmployee("emp2"));
+        expected.add(reader.getPartTimeEmployee("emp3"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+        
+        tx.commit();
+    }
+
+    /** */
+    void runTestContains(PersistenceManager pm, CompanyModelReader reader) {
+        Query q;
+        Object result;
+        Collection expected;
+
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+
+        q = pm.newQuery(Department.class);
+        q.setFilter("employees.contains(e) && e.personid == 1");
+        q.declareVariables("Employee e");
+        result = q.execute();
+        expected = new HashSet();
+        expected.add(reader.getDepartment("dept1"));
+        checkQueryResultWithoutOrder(ASSERTION_FAILED, result, expected);
+        
+        tx.commit();
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/ThisIsReservedWordForElementOfCollection.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/ThisIsReservedWordForElementOfCollection.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/ThisIsReservedWordForElementOfCollection.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/ThisIsReservedWordForElementOfCollection.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,86 @@
+/*
+ * 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;
+
+import java.util.Collection;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> This is Reserved Word for Element of Collection
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-12.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * <code>this</code> is a reserved word which means the element of the
+ * candidate collection being evaluated.
+ */
+
+public class ThisIsReservedWordForElementOfCollection extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-12 (ThisIsReservedWordForElementOfCollection) 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(ThisIsReservedWordForElementOfCollection.class);
+    }
+    
+    /** */
+    public void test() {
+        pm = getPM();
+        
+        try {
+            loadPrimitiveTypes(pm);
+            runTest(pm);
+        }
+        finally {
+            cleanupDatabase(pm, PrimitiveTypes.class);
+            pm.close();
+            pm = null;
+        }
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+
+        Collection instance9 = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "id == 9").execute();
+                
+        // compare this with a parameter
+        runParameterPrimitiveTypesQuery(
+            "this == param", "PrimitiveTypes param", instance9.iterator().next(),
+            pm, instance9, ASSERTION_FAILED);
+
+        // use this to access a field 
+        runParameterPrimitiveTypesQuery(
+            "this.intNotNull == intNotNull", "int intNotNull", new Integer(9), 
+            pm, instance9, ASSERTION_FAILED);
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/UseOfThisToAcessHiddenField.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/UseOfThisToAcessHiddenField.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/UseOfThisToAcessHiddenField.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/UseOfThisToAcessHiddenField.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,137 @@
+/*
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Use of this to Access Hidden Field
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.4-4.
+ *<BR>
+ *<B>Assertion Description: </B> A hidden field may be accessed using the
+ *<code>'this'</code> qualifier: <code>this.fieldName</code>.
+ */
+
+public class UseOfThisToAcessHiddenField extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.4-4 (UseOfThisToAcessHiddenField) 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(UseOfThisToAcessHiddenField.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        runTestUseOfThisToAcessHiddenField01(pm);
+        runTestUseOfThisToAcessHiddenField02(pm);
+        
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void runTestUseOfThisToAcessHiddenField01(PersistenceManager pm) {
+        if (debug) 
+            logger.debug("\nExecuting test UseOfThisToAcessHiddenField01() ...");
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            query.declareParameters("Integer x");
+            query.setFilter("this.x == x");
+            Object results = query.execute(new java.lang.Integer(2));
+
+            // check query result
+            List expected = new ArrayList();
+            Object p3 = new PCPoint(2, 2);
+            expected.add(p3);
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+            if (debug)
+                logger.debug("Test UseOfThisToAcessHiddenField01(): Passed");
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+
+    /** */
+    void runTestUseOfThisToAcessHiddenField02(PersistenceManager pm) {
+        if (debug) 
+            logger.debug("\nExecuting test UseOfThisToAcessHiddenField02() ...");
+
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            query.declareParameters("Integer y");
+            query.setFilter("this.y == y");
+            Object results = query.execute(new java.lang.Integer(3));
+
+            // check query result
+            List expected = new ArrayList();
+            Object p4 = new PCPoint(3, 3);
+            expected.add(p4);
+            expected = getFromInserted(expected);
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+            if (debug)
+                logger.debug("Test UseOfThisToAcessHiddenField02(): Passed");
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/VariableDeclaredWithSameNameAsFieldOfCandidateClass.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,104 @@
+/*
+ * 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;
+
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Variable Declared with Same Name as Field of Candidate Class
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.4-3.
+ *<BR>
+ *<B>Assertion Description: </B>
+A field of the candidate class of a <code>Query</code> can be hidden if a
+variable is declared with the same name.
+
+ */
+
+public class VariableDeclaredWithSameNameAsFieldOfCandidateClass extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.4-3 (VariableDeclaredWithSameNameAsFieldOfCandidateClass) 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(VariableDeclaredWithSameNameAsFieldOfCandidateClass.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        checkQueryVariables(pm);
+
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void checkQueryVariables(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        Class clazz = org.apache.jdo.tck.pc.company.Project.class;
+        try {
+            tx.begin();
+            Query query = pm.newQuery();
+            query.setClass(clazz);
+            query.setCandidates(pm.getExtent(clazz, false));
+            try {
+                query.declareVariables( "org.apache.jdo.tck.pc.company.Person reviewers;" );
+                query.setFilter( "reviewers.contains(reviewers)" );
+                Object results = query.execute();
+                fail(ASSERTION_FAILED,
+                     "Variable declaration \"Person reviewers\" did not hide field Person.reviewers");
+            }
+            catch (JDOUserException e) {
+                // expected exception
+                if (debug) logger.debug( "Caught expected " + e);
+            }
+        } 
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+
+        try {
+            tx.begin();
+            Query query = pm.newQuery();
+            query.setClass(clazz);
+            query.setCandidates(pm.getExtent(clazz, false));
+            query.declareVariables( "org.apache.jdo.tck.pc.company.Person reviewers;" );
+            query.setFilter( "this.reviewers.contains(reviewers) && reviewers.firstname==\"brazil\"" );
+            Object results = query.execute();
+        } 
+        finally {
+            if (tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/WhiteSpaceIsACharacterAndIgnored.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/WhiteSpaceIsACharacterAndIgnored.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/WhiteSpaceIsACharacterAndIgnored.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/WhiteSpaceIsACharacterAndIgnored.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.query;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> White Space is a Character and is Ignored
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-6.
+ *<BR>
+ *<B>Assertion Description: </B> White space (non-printing characters space,
+ *tab, carriage return, and line feed) is a separator and is otherwise ignored
+ *in a <code>Query</code> filter.
+ */
+
+public class WhiteSpaceIsACharacterAndIgnored extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-6 (WhiteSpaceIsACharacterAndIgnored) 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(WhiteSpaceIsACharacterAndIgnored.class);
+    }
+
+    Collection expected = null; 
+    
+    /** */
+    public void test() {
+        pm = getPM();
+
+        initDatabase(pm, PCPoint.class);
+        initExpectedResult(pm, "x == 0");
+
+        // Escape Sequence
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\t == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\n == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\f == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\r == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\n == \t 0 \r");
+        // Unicode
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u0009 == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u000c == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\u0020 == 0");
+        // Octal Escape
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\11 == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\12 == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\14 == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\15 == 0");
+        runTestWhiteSpaceIsACharacterAndIgnored01(pm, "x\40 == 0");
+            
+        pm.close();
+        pm = null;
+    }
+
+    /** */
+    void initExpectedResult(PersistenceManager pm, String filter) {
+        Transaction tx = pm.currentTransaction();
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            query.setFilter(filter);
+            expected = (Collection) query.execute();
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+        
+    /** */
+    void runTestWhiteSpaceIsACharacterAndIgnored01(PersistenceManager pm,
+                                                   String filter) {
+        Transaction tx = pm.currentTransaction();
+        Collection results = null;
+        try {
+            tx.begin();
+
+            Query query = pm.newQuery();
+            query.setClass(PCPoint.class);
+            query.setCandidates(pm.getExtent(PCPoint.class, false));
+            query.setFilter(filter);
+            results = (Collection) query.execute();
+            printOutput(results, expected);
+            checkQueryResultWithoutOrder(ASSERTION_FAILED, results, expected);
+            if (debug)
+                logger.debug("Test WhiteSpaceIsACharacterAndIgnored01(\"" +
+                             filter + "\"): Passed");
+
+            tx.commit();
+            tx = null;
+        }
+        finally {
+            if ((tx != null) && tx.isActive())
+                tx.rollback();
+        }
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/company.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/company.xml?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/company.xml (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/company.xml Fri Mar 18 17:07:39 2005
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+    <description>Company instances for query testing</description>
+
+    <bean id="dept1" class="org.apache.jdo.tck.pc.company.Department">
+        <constructor-arg index="0" type="long"><value>1</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String" ><value>Development</value></constructor-arg>
+        <property name="employees">
+            <set>
+                <ref local="emp1"/>
+                <ref local="emp2"/>
+                <ref local="emp3"/>
+            </set>
+        </property>
+    </bean>
+
+    <bean id="emp1" class="org.apache.jdo.tck.pc.company.FullTimeEmployee">
+        <constructor-arg index="0" type="long"><value>1</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>emp1First</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>emp1Last</value></constructor-arg>
+        <constructor-arg index="3" type="java.lang.String"><value>emp1Middle</value></constructor-arg>
+        <constructor-arg index="4" type="java.util.Date"><value>10/Jun/1970</value></constructor-arg>
+        <constructor-arg index="5" type="org.apache.jdo.tck.pc.company.Address"><ref local="addr1"/></constructor-arg>
+        <constructor-arg index="6" type="java.util.Date"><value>1/Jan/1999</value></constructor-arg>
+        <constructor-arg index="7" type="double"><value>20000</value></constructor-arg>
+        <property name="department"><ref bean="dept1"/></property>
+        <property name="medicalInsurance"><ref bean="medicalIns1"/></property>
+        <property name="phoneNumbers">
+	    <map>
+                <entry key="home"><value>1111</value></entry>
+                <entry key="work"><value>123456-1</value></entry>
+            </map>
+	</property>
+    </bean>
+    <bean id="emp2" class="org.apache.jdo.tck.pc.company.FullTimeEmployee">
+        <constructor-arg index="0" type="long"><value>2</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>emp2First</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>emp2Last</value></constructor-arg>
+        <constructor-arg index="3" type="java.lang.String"><value>emp2Middle</value></constructor-arg>
+        <constructor-arg index="4" type="java.util.Date"><value>22/Dec/1975</value></constructor-arg>
+        <constructor-arg index="5" type="org.apache.jdo.tck.pc.company.Address"><ref local="addr2"/></constructor-arg>
+        <constructor-arg index="6" type="java.util.Date"><value>1/Jul/2003</value></constructor-arg>
+        <constructor-arg index="7" type="double"><value>10000</value></constructor-arg>
+        <property name="department"><ref bean="dept1"/></property>
+        <property name="phoneNumbers">
+	    <map>
+                <entry key="home"><value>2222</value></entry>
+                <entry key="work"><value>123456-2</value></entry>
+            </map>
+	</property>
+    </bean>
+    <bean id="emp3" class="org.apache.jdo.tck.pc.company.PartTimeEmployee">
+        <constructor-arg index="0" type="long"><value>3</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>emp3First</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>emp3Last</value></constructor-arg>
+        <constructor-arg index="3" type="java.lang.String"><value>emp3Middle</value></constructor-arg>
+        <constructor-arg index="4" type="java.util.Date"><value>5/Sep/1972</value></constructor-arg>
+        <constructor-arg index="5" type="org.apache.jdo.tck.pc.company.Address"><ref local="addr3"/></constructor-arg>
+        <constructor-arg index="6" type="java.util.Date"><value>15/Aug/2002</value></constructor-arg>
+        <constructor-arg index="7" type="double"><value>15000</value></constructor-arg>
+        <property name="department"><ref bean="dept1"/></property>
+        <property name="phoneNumbers">
+	    <map>
+                <entry key="home"><value>3333</value></entry>
+                <entry key="work"><value>123456-3</value></entry>
+            </map>
+	</property>
+    </bean>
+
+    <bean id="addr1" class="org.apache.jdo.tck.pc.company.Address">
+        <constructor-arg index="0" type="long"><value>1</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>Unter den Linden 1</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>Berlin</value></constructor-arg>
+        <constructor-arg index="3" type="java.lang.String"><value></value></constructor-arg>
+        <constructor-arg index="4" type="java.lang.String"><value>12345</value></constructor-arg>
+        <constructor-arg index="5" type="java.lang.String"><value>Germany</value></constructor-arg>
+    </bean>
+    <bean id="addr2" class="org.apache.jdo.tck.pc.company.Address">
+        <constructor-arg index="0" type="long"><value>2</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>Broadway 1</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>New York</value></constructor-arg>
+        <constructor-arg index="3" type="java.lang.String"><value></value></constructor-arg>
+        <constructor-arg index="4" type="java.lang.String"><value>10000</value></constructor-arg>
+        <constructor-arg index="5" type="java.lang.String"><value>USA</value></constructor-arg>
+    </bean>
+    <bean id="addr3" class="org.apache.jdo.tck.pc.company.Address">
+        <constructor-arg index="0" type="long"><value>3</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>Market St.</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>San Francisco</value></constructor-arg>
+        <constructor-arg index="3" type="java.lang.String"><value></value></constructor-arg>
+        <constructor-arg index="4" type="java.lang.String"><value>94102</value></constructor-arg>
+        <constructor-arg index="5" type="java.lang.String"><value>USA</value></constructor-arg>
+    </bean>
+
+    <bean id="medicalIns1" class="org.apache.jdo.tck.pc.company.MedicalInsurance">
+        <constructor-arg index="0" type="long"><value>1</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>Carrier1</value></constructor-arg>
+        <constructor-arg index="2" type="java.lang.String"><value>PPO</value></constructor-arg>
+        <property name="employee"><ref bean="emp1"/></property>
+    </bean>
+</beans>

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinaryAddition.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinaryAddition.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinaryAddition.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinaryAddition.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,125 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Binary Addition Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-26.
+ *<BR>
+ *<B>Assertion Description: </B> The binary addition operator (<code>+</code>) is supported for all types as they are defined in the Java language. This includes the following types:
+<UL>
+<LI><code>byte, short, int, long, char, Byte, Short Integer, Long, Character</code></LI>
+<LI><code>float, double, Float, Double</code></LI>
+<LI><code>BigDecimal, BigInteger</code></LI>
+</UL>
+The operation on object-valued fields of wrapper types (<code>Boolean, Byte, Short, Integer, Long, Float</code>, and <code>Double</code>), and numeric types (<code>BigDecimal</code> and <code>BigInteger</code>) use the wrapped values as operands.
+ */
+
+public class BinaryAddition extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-26 (BinaryAddition) 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(BinaryAddition.class);
+    }
+
+    /** */
+    public void test() {
+        pm = getPM();
+
+        try {
+            loadPrimitiveTypes(pm);
+            runTest(pm);
+        }
+        finally {
+            cleanupDatabase(pm, PrimitiveTypes.class);
+            pm.close();
+            pm = null;
+        }
+    }
+
+    /** */
+    void runTest(PersistenceManager pm) {
+        if (debug) logger.debug("\nExecuting test BinaryAddition() ...");
+
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        
+        Collection instance9 = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "id == 9").execute();
+        Collection allOddInstances = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "booleanNull").execute();
+        
+        runSimplePrimitiveTypesQuery("id + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("byteNotNull + 1 == 10",
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("shortNotNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);            
+        runSimplePrimitiveTypesQuery("intNotNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);            
+        runSimplePrimitiveTypesQuery("longNotNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("floatNotNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("doubleNotNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("byteNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("shortNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("intNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("longNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("floatNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("doubleNull + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("bigDecimal + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("bigInteger + 1 == 10", 
+                                     pm, instance9, ASSERTION_FAILED);
+
+        runSimplePrimitiveTypesQuery("charNull + 1 == 'P'", 
+                                     pm, allOddInstances, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("charNotNull + 1 == 'P'", 
+                                     pm, allOddInstances, ASSERTION_FAILED);
+
+        tx.commit();
+    }
+}
+

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinarySubtraction.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinarySubtraction.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinarySubtraction.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BinarySubtraction.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,130 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Binary Subtraction Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-28.
+ *<BR>
+ *<B>Assertion Description: </B>
+The binary subtraction operator (<code>-</code>) is supported for all types as
+they are defined in the Java language. This includes the following types:
+<UL>
+<LI><code>byte, short, int, long, char, Byte, Short Integer, Long, Character</code></LI>
+<LI><code>float, double, Float, Double</code></LI>
+<LI><code>BigDecimal, BigInteger</code></LI>
+</UL>
+The operation on object-valued fields of wrapper types (<code>Boolean, Byte,
+Short, Integer, Long, Float</code>, and <code>Double</code>), and numeric types
+(<code>BigDecimal</code> and <code>BigInteger</code>)
+use the wrapped values as operands.
+
+ */
+
+public class BinarySubtraction extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-28 (BinarySubtraction) 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(BinarySubtraction.class);
+    }
+    
+    /** */
+    public void test() {
+        pm = getPM();
+
+        try {
+            loadPrimitiveTypes(pm);
+            runTest(pm);
+        }
+        finally {
+            cleanupDatabase(pm, PrimitiveTypes.class);
+            pm.close();
+            pm = null;
+        }
+    }
+
+    /** */
+    void runTest(PersistenceManager pm) {
+        if (debug) logger.debug("\nExecuting test BinarySubtraction() ...");
+
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        
+        Collection instance9 = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "id == 9").execute();
+        Collection allOddInstances = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "booleanNull").execute();
+        
+        runSimplePrimitiveTypesQuery("id - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("byteNotNull - 1 == 8",
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("shortNotNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);            
+        runSimplePrimitiveTypesQuery("intNotNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);            
+        runSimplePrimitiveTypesQuery("longNotNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("floatNotNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("doubleNotNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("byteNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("shortNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("intNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("longNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("floatNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("doubleNull - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("bigDecimal - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("bigInteger - 1 == 8", 
+                                     pm, instance9, ASSERTION_FAILED);
+
+        runSimplePrimitiveTypesQuery("charNull - 1 == 'N'", 
+                                     pm, allOddInstances, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("charNotNull - 1 == 'N'", 
+                                     pm, allOddInstances, ASSERTION_FAILED);
+
+        tx.commit();
+    }
+}

Added: incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BitwiseComplement.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BitwiseComplement.java?view=auto&rev=158179
==============================================================================
--- incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BitwiseComplement.java (added)
+++ incubator/jdo/trunk/tck11/test/java/org/apache/jdo/tck/query/operators/BitwiseComplement.java Fri Mar 18 17:07:39 2005
@@ -0,0 +1,111 @@
+/*
+ * 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.operators;
+
+import java.util.Collection;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+/**
+ *<B>Title:</B> Bitwise Complement Query Operator
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-24.
+ *<BR>
+ *<B>Assertion Description: </B>
+The integral unary bitwise complement operator (<code>~</code>) is supported
+for all types as they are defined in the Java language.
+This includes the following types:
+<UL>
+<LI><code>byte, short, int, long, char, Byte, Short Integer, Long, Character</code></LI>
+</UL>
+
+ */
+
+public class BitwiseComplement extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-24 (BitwiseComplement) 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(BitwiseComplement.class);
+    }
+    
+    /** */
+    public void test() {
+        pm = getPM();
+
+        try {
+            loadPrimitiveTypes(pm);
+            runTest(pm);
+        }
+        finally {
+            cleanupDatabase(pm, PrimitiveTypes.class);
+            pm.close();
+            pm = null;
+        }
+    }
+    
+    /** */
+    void runTest(PersistenceManager pm) {
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        
+        Collection instance9 = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "id == 9").execute();
+        Collection allOddInstances = (Collection)pm.newQuery(
+            PrimitiveTypes.class, "booleanNull").execute();
+        
+        runSimplePrimitiveTypesQuery("~id == -10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~byteNotNull == -10",
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~shortNotNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);            
+        runSimplePrimitiveTypesQuery("~intNotNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);            
+        runSimplePrimitiveTypesQuery("~longNotNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~byteNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~shortNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~intNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~longNull == -10", 
+                                     pm, instance9, ASSERTION_FAILED);
+  
+
+        runSimplePrimitiveTypesQuery("~charNull == -80", 
+                                     pm, allOddInstances, ASSERTION_FAILED);
+        runSimplePrimitiveTypesQuery("~charNotNull == -80", 
+                                     pm, allOddInstances, ASSERTION_FAILED);
+        
+        tx.commit();
+    }
+}



Mime
View raw message