db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcai...@apache.org
Subject svn commit: r502822 - in /db/jdo/trunk/tck20/src: conf/ java/org/apache/jdo/tck/query/ java/org/apache/jdo/tck/query/sql/
Date Sat, 03 Feb 2007 01:14:14 GMT
Author: mcaisse
Date: Fri Feb  2 17:14:13 2007
New Revision: 502822

URL: http://svn.apache.org/viewvc?view=rev&rev=502822
Log:
JDO-378

Added:
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java
Modified:
    db/jdo/trunk/tck20/src/conf/query.conf
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/QueryTest.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NewQuery.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java
    db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java

Modified: db/jdo/trunk/tck20/src/conf/query.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/conf/query.conf?view=diff&rev=502822&r1=502821&r2=502822
==============================================================================
--- db/jdo/trunk/tck20/src/conf/query.conf (original)
+++ db/jdo/trunk/tck20/src/conf/query.conf Fri Feb  2 17:14:13 2007
@@ -84,4 +84,5 @@
 org.apache.jdo.tck.query.sql.ShapeOfResult \
 org.apache.jdo.tck.query.sql.NoCandidateClass \
 org.apache.jdo.tck.query.sql.AllowedAPIMethods \
-org.apache.jdo.tck.query.sql.NewQuery
+org.apache.jdo.tck.query.sql.NewQuery \
+org.apache.jdo.tck.query.sql.ExecuteWithMap

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/QueryTest.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/QueryTest.java?view=diff&rev=502822&r1=502821&r2=502822
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/QueryTest.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/QueryTest.java Fri Feb  2 17:14:13
2007
@@ -1173,8 +1173,8 @@
      * to return a single result.
      */
     protected void executeSQLQuery(String assertion, String sql, 
-            Class candidateClass, Class resultClass, 
-            Object[] parameters, Object expectedResult, boolean unique) {
+            Class candidateClass, Class resultClass, boolean positive,
+            Object parameters, Object expectedResult, boolean unique) {
         String schema = getPMFProperty("javax.jdo.mapping.Schema");
         sql = MessageFormat.format(sql, new Object[]{schema});
         if (logger.isDebugEnabled())
@@ -1190,7 +1190,7 @@
             query.setResultClass(resultClass);
         }
         execute(assertion, query, sql, false, 
-                parameters, expectedResult, true);
+                parameters, expectedResult, positive);
     }
 
     /**

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java?view=diff&rev=502822&r1=502821&r2=502822
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/AllowedAPIMethods.java Fri Feb
 2 17:14:13 2007
@@ -95,17 +95,17 @@
         if (isSQLSupported()) {
             int index = 0;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    PrimitiveTypes.class, null, null, 
+                    PrimitiveTypes.class, null, true, null, 
                     expectedResult[index], false);
 
             index = 1;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    Department.class, null, null, 
+                    Department.class, null, true, null, 
                     expectedResult[index], false);
 
             index = 2;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    Person.class, null, null, 
+                    Person.class, null, true, null, 
                     expectedResult[index], false);
         }
     }
@@ -115,7 +115,7 @@
         if (isSQLSupported()) {
             int index = 3;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, null, null, expectedResult[index], true);
+                    null, null, true, null, expectedResult[index], true);
         }
     }
 
@@ -124,7 +124,8 @@
         if (isSQLSupported()) {
             int index = 4;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, FullName.class, null, expectedResult[index], false);
+                    null, FullName.class, true, null, expectedResult[index],
+                    false);
         }
     }
 

Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java?view=auto&rev=502822
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java (added)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ExecuteWithMap.java Fri Feb 
2 17:14:13 2007
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sql;
+
+import java.util.HashMap;
+
+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.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> ExecuteWithMap
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.7-5.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * If the parameter list is a Map, then the keys of the Map
+ * must be instances of Integer whose intValue is 1..n. 
+ * The value in the Map corresponding to the key whose intValue is 1
+ * is bound to the first ? in the SQL statement, and so forth. 
+ */
+public class ExecuteWithMap extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.7-5 (ExecuteWithMap)";
+    
+    /**
+     * 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(ExecuteWithMap.class);
+    }
+    
+    /** The array of valid SQL queries. */
+    private static final String[] VALID_SQL_QUERIES = {
+        "SELECT * FROM {0}.PrimitiveTypes WHERE intNotNull = ? "
+            + "OR stringNull = ?",
+        "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?"
+            + " AND MIDDLENAME = ? AND CITY = ?",
+        "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? AND LASTNAME = ?"
+            + " AND MIDDLENAME = ? AND CITY = ?"
+    };
+    
+    /** 
+     * The expected results of valid SQL queries.
+     */
+    private Object[] expectedResult = {
+        getTransientMylibInstancesAsList(new String[]{
+                "primitiveTypesPositive", 
+                "primitiveTypesCharacterStringLiterals"}),
+        getTransientCompanyModelInstancesAsList(new String[]{"emp2"}),
+        getTransientCompanyModelInstancesAsList(new String[]{"emp2"})
+    };
+
+    /** 
+     * Maps of parameter values
+     */
+    private static HashMap hm1 = new HashMap();
+    private static HashMap hm2 = new HashMap();
+    private static HashMap hm3 = new HashMap();
+    private static HashMap hm4 = new HashMap();
+    private static HashMap illegalMapMissingKeyTwo = new HashMap();
+    private static HashMap illegalMapStartsWithZero = new HashMap();
+    private static HashMap illegalMapStringKeys = new HashMap();
+    static {
+        // valid parameter values
+        hm1.put(new Integer(1), new Integer(4));
+        hm1.put(new Integer(2), "Even");
+
+        hm2.put(new Integer(1), "emp2First");
+        hm2.put(new Integer(2), "emp2Last");
+        hm2.put(new Integer(3), "emp2Middle");
+        hm2.put(new Integer(4), "New York");
+
+        hm3 = (HashMap) hm2.clone();
+        // extra entry okay, should be ignored by impl
+        hm3.put(new Integer(0), "emp2First");
+
+        hm4 = (HashMap) hm2.clone();
+        // extra entry okay, should be ignored by impl
+        hm4.put(new Integer(5), "New York");
+
+        // invalid parameter values
+        illegalMapMissingKeyTwo.put(new Integer(1), "emp2First");
+        illegalMapMissingKeyTwo.put(new Integer(3), "emp2Last");
+        illegalMapMissingKeyTwo.put(new Integer(4), "emp2Middle");
+        illegalMapMissingKeyTwo.put(new Integer(5), "New York");
+
+        illegalMapStartsWithZero.put(new Integer(0), "emp2First");
+        illegalMapStartsWithZero.put(new Integer(1), "emp2Last");
+        illegalMapStartsWithZero.put(new Integer(2), "emp2Middle");
+        illegalMapStartsWithZero.put(new Integer(3), "New York");
+
+        illegalMapStringKeys.put(new String("1dog"), "emp2First");
+        illegalMapStringKeys.put(new String("2dog"), "emp2Last");
+        illegalMapStringKeys.put(new String("3dog"), "emp2Middle");
+        illegalMapStringKeys.put(new String("4dog"), "New York");
+    };
+    private static HashMap[] parameterMap = new HashMap[]{hm1, hm2, hm3};
+            
+    /** */
+    public void testSetClass() {
+        if (isSQLSupported()) {
+            int index = 0;
+            executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+                    PrimitiveTypes.class, null, true,
+                    parameterMap[index], expectedResult[index], false);
+
+            index = 1;
+            executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+                    Person.class, null, true,
+                    parameterMap[index], expectedResult[index], false);
+
+            index = 2;
+            executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+                    Person.class, null, true,
+                    parameterMap[index], expectedResult[index], false);
+
+            index = 3;
+            executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
+                    Person.class, null, true,
+                    parameterMap[index], expectedResult[index], false);
+        }
+    }
+
+    /** */
+    public void testNegative() {
+        if (isSQLSupported()) {
+            String query = "SELECT * FROM {0}.persons WHERE FIRSTNAME = ? "
+                + "AND LASTNAME = ? AND MIDDLENAME = ? AND CITY = ? "
+                + "AND FUNDINGDEPT = ?";
+            String singleStringQuery = query;
+            executeSQLQuery(ASSERTION_FAILED, query, Person.class, null,
+                    false, illegalMapMissingKeyTwo, null, false); 
+            executeSQLQuery(ASSERTION_FAILED, query, Person.class, null,
+                    false, illegalMapStartsWithZero, null, false); 
+            executeSQLQuery(ASSERTION_FAILED, query, Person.class, null,
+                    false, illegalMapStringKeys, null, false); 
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+        addTearDownClass(MylibReader.getTearDownClasses());
+        loadAndPersistCompanyModel(getPM());
+        loadAndPersistMylib(getPM());
+    }
+}

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NewQuery.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NewQuery.java?view=diff&rev=502822&r1=502821&r2=502822
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NewQuery.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NewQuery.java Fri Feb  2 17:14:13
2007
@@ -75,7 +75,8 @@
         if (isSQLSupported()) {
             for (int i = 0; i < VALID_SQL_QUERIES.length; i++) {
                 executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[i],
-                        null, null, parameters[i], expectedResult[i], false);
+                        null, null, true, parameters[i], expectedResult[i],
+                        false);
             }
         }
     }

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java?view=diff&rev=502822&r1=502821&r2=502822
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/NoCandidateClass.java Fri Feb
 2 17:14:13 2007
@@ -86,7 +86,7 @@
         if (isSQLSupported()) {
             int index = 0;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, null, null, expectedResult[index], false);
+                    null, null, true, null, expectedResult[index], false);
         }
     }
 

Modified: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java?view=diff&rev=502822&r1=502821&r2=502822
==============================================================================
--- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java (original)
+++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/query/sql/ShapeOfResult.java Fri Feb  2
17:14:13 2007
@@ -115,11 +115,11 @@
         if (isSQLSupported()) {
             int index = 0;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    PrimitiveTypes.class, null, null, 
+                    PrimitiveTypes.class, null, true, null,
                     expectedResult[index], false);
             index++;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    PrimitiveTypes.class, null, null, 
+                    PrimitiveTypes.class, null, true, null,
                     expectedResult[index], true);
         }
     }
@@ -129,10 +129,10 @@
         if (isSQLSupported()) {
             int index = 2;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, null, null, expectedResult[index], false);
+                    null, null, true, null, expectedResult[index], false);
             index++;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, null, null, expectedResult[index], true);
+                    null, null, true, null, expectedResult[index], true);
         }
     }
     
@@ -141,10 +141,10 @@
         if (isSQLSupported()) {
             int index = 4;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, null, null, expectedResult[index], false);
+                    null, null, true, null, expectedResult[index], false);
             index++;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, null, null, expectedResult[index], true);
+                    null, null, true, null, expectedResult[index], true);
         }
     }
     
@@ -153,10 +153,10 @@
         if (isSQLSupported()) {
             int index = 6;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, FullName.class, null, expectedResult[index], false);
+                    null, FullName.class, true, null, expectedResult[index], false);
             index++;
             executeSQLQuery(ASSERTION_FAILED, VALID_SQL_QUERIES[index],
-                    null, FullName.class, null, expectedResult[index], true);
+                    null, FullName.class, true, null, expectedResult[index], true);
         }
     }
     



Mime
View raw message