db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject svn commit: r326519 - in /incubator/jdo/trunk/tck20/test: conf/ java/org/apache/jdo/tck/pc/mylib/ java/org/apache/jdo/tck/query/ java/org/apache/jdo/tck/query/jdoql/methods/ testdata/org/apache/jdo/tck/pc/mylib/
Date Wed, 19 Oct 2005 10:27:48 GMT
Author: brazil
Date: Wed Oct 19 03:27:35 2005
New Revision: 326519

URL: http://svn.apache.org/viewcvs?rev=326519&view=rev
Log:
JDO-159: Implement new JDO 2 query tests cases concerning new supported methods.

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java
    incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/
    incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml
Modified:
    incubator/jdo/trunk/tck20/test/conf/alltests.conf
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java

Modified: incubator/jdo/trunk/tck20/test/conf/alltests.conf
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/conf/alltests.conf?rev=326519&r1=326518&r2=326519&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/conf/alltests.conf (original)
+++ incubator/jdo/trunk/tck20/test/conf/alltests.conf Wed Oct 19 03:27:35 2005
@@ -314,6 +314,10 @@
 org.apache.jdo.tck.query.jdoql.methods.MethodsAndObjectConstructionNotSupported \
 org.apache.jdo.tck.query.jdoql.methods.StartsWithAndEndsWith \
 org.apache.jdo.tck.query.jdoql.methods.SupportedCollectionMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedJDOHelperMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedMapMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedMathMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedStringMethods \
 org.apache.jdo.tck.query.jdoql.operators.BinaryAddition \
 org.apache.jdo.tck.query.jdoql.operators.BinarySubtraction \
 org.apache.jdo.tck.query.jdoql.operators.BitwiseComplement \

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java?rev=326519&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/MylibReader.java Wed Oct 19 03:27:35 2005
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+ 
+package org.apache.jdo.tck.pc.mylib;
+
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import org.springframework.beans.propertyeditors.CustomDateEditor;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.InputStreamResource;
+
+/**
+ * Utility class to create a mylib instances from an xml
+ * representation. 
+ */
+public class MylibReader extends XmlBeanFactory {
+
+    /** The format of date values in the xml representation */
+    public static final String DATE_PATTERN = "d/MMM/yyyy";
+
+    /** The name of the root list bean. */
+    public static final String ROOT_LIST_NAME = "root";
+
+    /** Teardown classes 
+     */
+    private static final Class[] tearDownClasses = new Class[] {
+        PrimitiveTypes.class
+    };
+    
+    /** 
+     * Create a MylibReader for the specified resourceName. 
+     * @param resourceName the name of the resource
+     */
+    public MylibReader(String resourceName) {
+        // Use the class loader of the PrimitiveTypes class to find the resource
+        this(resourceName, PrimitiveTypes.class.getClassLoader());
+    }
+
+    /** 
+     * Create a MylibReader for the specified resourceName. 
+     * @param resourceName the name of the resource
+     */
+    public MylibReader(String resourceName, ClassLoader classLoader) {
+        super(new ClassPathResource(resourceName, classLoader));
+        configureFactory();
+    }
+
+    /**
+     * Create a MylibReader for the specified InputStream.
+     * @param stream the input stream
+     */
+    public MylibReader(InputStream stream) {
+        super(new InputStreamResource(stream));
+        configureFactory();
+    }
+
+    /** 
+     * Returns a list of root objects. The method expects to find a bean
+     * called "root" of type list in the xml and returns it.
+     * @return a list of root instances
+     */
+    public List getRootList() {
+        return (List)getBean(ROOT_LIST_NAME);
+    }
+    
+    /** 
+     * Configure the MylibReader, e.g. register CustomEditor classes
+     * to convert the string representation of a property into an instance
+     * of the right type.
+     */
+    private void configureFactory() {
+        SimpleDateFormat formatter = new SimpleDateFormat(DATE_PATTERN, Locale.US);
+        formatter.setTimeZone(TimeZone.getTimeZone("America/New_York"));
+        CustomDateEditor dateEditor = 
+            new CustomDateEditor(formatter, true);
+        registerCustomEditor(Date.class, dateEditor);
+    }
+    
+    // Convenience methods
+
+    /** 
+     * Convenience method returning an Address instance for the specified
+     * name. The method returns <code>null</code> if there is no Address
+     * bean with the specified name. 
+     * @param name the name of the bean to return.
+     * @return the instance of the bean or <code>null</code> if there no
+     * Address bean.
+     */
+    public PrimitiveTypes getPrimitiveTypes(String name) {
+        return (PrimitiveTypes)getBean(name, PrimitiveTypes.class);
+    }
+
+    /**
+     * @return Returns the tearDownClasses.
+     */
+    public static Class[] getTearDownClasses() {
+        return tearDownClasses;
+    }
+}
+

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java?rev=326519&r1=326518&r2=326519&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/mylib/PrimitiveTypes.java Wed Oct 19 03:27:35 2005
@@ -61,6 +61,74 @@
     public String toString() { 
         return "PrimitiveTypes(" + id + ")";
     }
+    
+    public int hashCode() {
+        int hashCode = 0;
+        hashCode += id;
+        hashCode += booleanNotNull ? 
+                Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode();
+        hashCode += booleanNull != null ? booleanNull.hashCode() : 0;
+        hashCode += byteNotNull;
+        hashCode += byteNull != null ? byteNull.hashCode() : 0;
+        hashCode += shortNotNull;
+        hashCode += shortNull != null ? shortNull.hashCode() : 0;
+        hashCode += intNotNull;
+        hashCode += intNull != null ? intNull.hashCode() : 0;
+        hashCode += longNotNull;
+        hashCode += longNull != null ? longNull.hashCode() : 0;
+        hashCode += floatNotNull;
+        hashCode += floatNull != null ? floatNull.hashCode() : 0;
+        hashCode += doubleNotNull;
+        hashCode += doubleNull != null ? doubleNull.hashCode() : 0;
+        hashCode += charNotNull;
+        hashCode += charNull != null ? charNull.hashCode() : 0;
+        hashCode += dateNull != null ? dateNull.hashCode() : 0;
+        hashCode += stringNull != null ? stringNull.hashCode() : 0;
+        hashCode += bigDecimal != null ? bigDecimal.hashCode() : 0;
+        hashCode += bigInteger != null ? bigDecimal.hashCode() : 0;
+        hashCode += PrimitiveTypes != null ? PrimitiveTypes.hashCode() : 0;
+        return hashCode;
+    }
+
+    public boolean equals(Object o) {
+        PrimitiveTypes p = (PrimitiveTypes) o;
+        if (id != p.id) return false;
+        if (booleanNotNull != p.booleanNotNull) return false;
+        if (booleanNull != null) return booleanNull.equals(p.booleanNull);
+        else if (p.booleanNull != null) return false;
+        if (byteNotNull != p.byteNotNull) return false;
+        if (byteNull != null) return byteNull.equals(p.byteNull);
+        else if (p.byteNull != null) return false;
+        if (shortNotNull != p.shortNotNull) return false;
+        if (shortNull != null) return shortNull.equals(p.shortNull);
+        else if (p.shortNull != null) return false;
+        if (intNotNull != p.intNotNull) return false;
+        if (intNull != null) return intNull.equals(p.intNull);
+        else if (p.intNull != null) return false;
+        if (longNotNull != p.longNotNull) return false;
+        if (longNull != null) return longNull.equals(p.longNull);
+        else if (p.longNull != null) return false;
+        if (floatNotNull != p.floatNotNull) return false;
+        if (floatNull != null) return floatNull.equals(p.floatNull);
+        else if (p.floatNull != null) return false;
+        if (doubleNotNull != p.doubleNotNull) return false;
+        if (doubleNull != null) return doubleNull.equals(p.doubleNull);
+        else if (p.doubleNull != null) return false;
+        if (charNotNull != p.charNotNull) return false;
+        if (charNull != null) return charNull.equals(p.charNull);
+        else if (p.charNull != null) return false;
+        if (dateNull != null) return dateNull.equals(p.dateNull);
+        else if (p.dateNull != null) return false;
+        if (stringNull != null) return stringNull.equals(p.stringNull);
+        else if (p.stringNull != null) return false;
+        if (bigDecimal != null) return bigDecimal.equals(p.bigDecimal);
+        else if (p.bigDecimal != null) return false;
+        if (bigInteger != null) return bigInteger.equals(p.bigInteger);
+        else if (p.bigInteger != null) return false;
+        if (PrimitiveTypes != null) return PrimitiveTypes.equals(p.PrimitiveTypes);
+        else if (p.PrimitiveTypes != null) return false;
+        return true;
+    }
 
     public PrimitiveTypes() {
     }

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java?rev=326519&r1=326518&r2=326519&view=diff
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/QueryTest.java Wed Oct 19 03:27:35 2005
@@ -39,6 +39,7 @@
 import org.apache.jdo.tck.pc.company.Insurance;
 import org.apache.jdo.tck.pc.company.Person;
 import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.pc.mylib.MylibReader;
 import org.apache.jdo.tck.pc.mylib.PCPoint;
 import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
 
@@ -51,6 +52,10 @@
     public static final String COMPANY_TESTDATA = 
         "org/apache/jdo/tck/pc/company/companyForQueryTests.xml";
 
+    /** */
+    public static final String MYLIB_TESTDATA = 
+        "org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml";
+
     /** 
      * List of inserted instances (see methods insertPCPoints and
      * getFromInserted). 
@@ -136,6 +141,24 @@
         return reader;
     }
     
+    /** 
+     * Reads a graph of company model objects from the specified xml file. This 
+     * methods explictly calls makePersistent for all named instances using the
+     * specified PersistenceManager. The method returns the CompanyModelReader 
+     * instance allowing to access a compay model instance by name.
+     */
+    public MylibReader loadMylib(PersistenceManager pm, String filename) {
+        MylibReader reader = new MylibReader(filename);
+        Transaction tx = pm.currentTransaction();
+        tx.begin();
+        List rootList = (List)reader.getRootList();
+        pm.makePersistentAll(rootList);
+        if (debug) logger.debug("inserted " + rootList);
+        tx.commit();
+        tx = null;
+        return reader;
+    }
+    
     /** */
     public void cleanupCompanyModel(PersistenceManager pm) {
         Transaction tx = pm.currentTransaction();
@@ -157,7 +180,7 @@
     }
     
     /**
-     * Returns an array of company mode instances for beans names 
+     * Returns an array of company model instances for beans names 
      * in the given argument.
      * @param beanNames the bean names of company mode instances.
      * @return the array of company model instances. 
@@ -171,6 +194,21 @@
         return result;
     }
     
+    /**
+     * Returns an array of mylib instances for beans names 
+     * in the given argument.
+     * @param beanNames the bean names of mylib instances.
+     * @return the array of mylib instances. 
+     */
+    protected Object[] getMylibInstances(String[] beanNames) {
+        MylibReader reader = new MylibReader(MYLIB_TESTDATA);
+        Object[] result = new Object[beanNames.length];
+        for (int i = 0; i < beanNames.length; i++) {
+            result[i] = reader.getBean(beanNames[i]);
+        }
+        return result;
+    }
+    
     // PrimitiveTypes helper methods (creation and query)
 
     /** */
@@ -664,21 +702,25 @@
             Query query = asSingleString ?
                     queryElementHolder.getSingleStringQuery(pm) :
                         queryElementHolder.getAPIQuery(pm);
-            result = parameters != null ? 
-                    query.executeWithArray(parameters) : query.execute();
-
-            if (queryElementHolder.isUnique()) {
-                checkUniqueResult(assertion, result, expectedResult[0]);
-            } else if (queryElementHolder.hasOrdering()) {
-                List expectedResultList = 
-                    Arrays.asList(expectedResult);
-                checkQueryResultWithOrder(assertion, result, 
-                        expectedResultList);
-            } else {
-                Collection expectedResultCollection = 
-                    Arrays.asList(expectedResult);
-                checkQueryResultWithoutOrder(assertion, result, 
-                        expectedResultCollection);
+            try {
+                result = parameters != null ? 
+                        query.executeWithArray(parameters) : query.execute();
+    
+                if (queryElementHolder.isUnique()) {
+                    checkUniqueResult(assertion, result, expectedResult[0]);
+                } else if (queryElementHolder.hasOrdering()) {
+                    List expectedResultList = 
+                        Arrays.asList(expectedResult);
+                    checkQueryResultWithOrder(assertion, result, 
+                            expectedResultList);
+                } else {
+                    Collection expectedResultCollection = 
+                        Arrays.asList(expectedResult);
+                    checkQueryResultWithoutOrder(assertion, result, 
+                            expectedResultCollection);
+                }
+            } finally {
+                query.closeAll();
             }
         } finally {
             if (tx.isActive()) {

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java?rev=326519&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedJDOHelperMethods.java Wed Oct 19 03:27:35 2005
@@ -0,0 +1,166 @@
+/*
+ * 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.jdoql.methods;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Supported JDOHelper methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-49.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Supported JDOHelper methods:
+ * <ul>
+ * <li> JDOHelper.getObjectId(Object)
+ * </ul>
+ */
+public class SupportedJDOHelperMethods extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-49 (SupportedJDOHelperMethods) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      "JDOHelper.getObjectId(this)", 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       null,
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "JDOHelper.getObjectId(this) == oid",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  "Object oid",
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null)
+    };
+
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(SupportedJDOHelperMethods.class);
+    }
+    
+    /** */
+    public void testGetObjectById() {
+        // query 1
+        int index = 0;
+        Object[] expectedResult = getExpectedResult(true, Person.class);
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResult);
+
+        // query 2
+        index = 1;
+        expectedResult = getExpectedResult(false, Person.class, "personid = 1");
+        Object[] parameters = new Object[expectedResult.length];
+        for (int i = 0; i < parameters.length; i++) {
+            parameters[i] = JDOHelper.getObjectId(expectedResult);
+        }
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                parameters, expectedResult);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                parameters, expectedResult);
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+
+    /** */
+    private Object[] getExpectedResult(boolean oidsWanted, Class candidateClass) {
+        return getExpectedResult(oidsWanted, candidateClass, null);
+    }
+    
+    /** */
+    private Object[] getExpectedResult(boolean oidsWanted, 
+            Class candidateClass, String filter) {
+        Object[] expectedResult;
+        PersistenceManager pm = getPM();
+        Transaction transaction = pm.currentTransaction();
+        transaction.begin();
+        try {
+            Query query = filter == null ? pm.newQuery(candidateClass) :
+                pm.newQuery(candidateClass, filter);
+            try {
+                Collection result = (Collection) query.execute();
+                expectedResult = new Object[result.size()];
+                int j = 0;
+                for (Iterator i = result.iterator(); i.hasNext(); ) {
+                    Object o = i.next();
+                    if (oidsWanted) {
+                        expectedResult[j++] = JDOHelper.getObjectId(o);
+                    } else {
+                        expectedResult[j++] = o;
+                    }
+                }
+            } finally {
+                query.closeAll();
+            }
+        } finally {
+            if (transaction.isActive()) {
+                transaction.rollback();
+            }
+        }
+        return expectedResult;
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java?rev=326519&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMapMethods.java Wed Oct 19 03:27:35 2005
@@ -0,0 +1,148 @@
+/*
+ * 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.jdoql.methods;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Supported Map methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-46.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Supported Map methods:
+ * <ul>
+ * <li> get(Object)
+ * <li> containsKey(Object)
+ * <li> containsValue(Object)
+ * </ul>
+ */
+public class SupportedMapMethods extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-46 (SupportedMapMethods) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "phoneNumbers.get('home') == '1111'",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "phoneNumbers.containsKey('home')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "phoneNumbers.containsValue('1111')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null)
+    };
+
+    /** The expected results of valid queries. */
+    private static String[][] expectedResult = {
+        {"emp1"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp1"}
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(SupportedMapMethods.class);
+    }
+    
+    /** */
+    public void testGet() {
+        int index = 0;
+        executeQuery(index);
+    }
+    
+    /** */
+    public void testContainsKey() {
+        int index = 1;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testContainsValue() {
+        int index = 2;
+        executeQuery(index);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+
+    /** */
+    private void executeQuery(int index) {
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResultValues);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResultValues);
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java?rev=326519&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedMathMethods.java Wed Oct 19 03:27:35 2005
@@ -0,0 +1,307 @@
+/*
+ * 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.jdoql.methods;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.mylib.MylibReader;
+import org.apache.jdo.tck.pc.mylib.PrimitiveTypes;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Supported Math methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-48.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * Supported Math methods:
+ * <ul>
+ * <li> Math.abs(numeric)
+ * <li> Math.sqrt(numeric)
+ * </ul>
+ */
+public class SupportedMathMethods extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-48 (SupportedMathMethods) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     * These queries are used to test Math.abs.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES_ABS = {
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(intNotNull) == 4",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(intNull) == 4",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(longNotNull) == 4",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(longNull) == 4",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(floatNotNull) < 4.1 &&" +
+                                "Math.abs(floatNotNull) > 3.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(floatNull) < 4.1 &&" +
+                                "Math.abs(floatNull) > 3.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(doubleNotNull) < 4.1 &&" +
+                                "Math.abs(doubleNotNull) > 3.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "Math.abs(doubleNull) < 4.1 &&" +
+                                "Math.abs(doubleNull) > 3.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null)
+    };
+
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     * These queries are used to test Math.sqrt.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES_SQRT = {
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "doubleNotNull > 0 && " +
+                                "Math.sqrt(doubleNotNull) < 2.1 && " +
+                                "Math.sqrt(doubleNotNull) > 1.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "doubleNull > 0 && " +
+                                "Math.sqrt(doubleNull) < 2.1 && " +
+                                "Math.sqrt(doubleNull) > 1.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "intNotNull > 0 && " +
+                                "Math.sqrt(intNotNull) < 2.1 && " +
+                                "Math.sqrt(intNotNull) > 1.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        PrimitiveTypes.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "intNull > 0 && " +
+                                "Math.sqrt(intNull) < 2.1 && " +
+                                "Math.sqrt(intNull) > 1.9",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+    };
+
+    /** The expected results of valid queries testing Math.abs. */
+    private static String[][] expectedResultABS = {
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"},
+        {"primitiveTypesPositive", "primitiveTypesNegative"}
+    };
+        
+    /** The expected results of valid queries testing Math.sqrt. */
+    private static String[][] expectedResultSQRT = {
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"},
+        {"primitiveTypesPositive"}
+    };
+            
+    /**
+     * 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(SupportedMathMethods.class);
+    }
+    
+    /** */
+    public void testAbs() {
+        for (int i = 0; i < VALID_QUERIES_ABS.length; i++) {
+            Object[] expectedResultValues = 
+                getMylibInstances(expectedResultABS[i]);
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES_ABS[i], 
+                    expectedResultValues);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES_ABS[i], 
+                    expectedResultValues);
+        }
+    }
+    
+    /** */
+    public void testSqrt() {
+        for (int i = 0; i < VALID_QUERIES_SQRT.length; i++) {
+            Object[] expectedResultValues = 
+                getMylibInstances(expectedResultSQRT[i]);
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES_SQRT[i], 
+                    expectedResultValues);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES_SQRT[i], 
+                    expectedResultValues);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadMylib(getPM(), MYLIB_TESTDATA);
+        addTearDownClass(MylibReader.getTearDownClasses());
+    }
+
+}

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java?rev=326519&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/query/jdoql/methods/SupportedStringMethods.java Wed Oct 19 03:27:35 2005
@@ -0,0 +1,315 @@
+/*
+ * 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.jdoql.methods;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.Department;
+import org.apache.jdo.tck.pc.company.Person;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Supported String methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-47.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * New supported String methods:
+ * <ul>
+ * <li> toLowerCase()
+ * <li> toUpperCase()
+ * <li> indexOf(String)
+ * <li> indexOf(String, int)
+ * <li> matches(String)
+ * <li> substring(int)
+ * <li> substring(int, int)
+ * <li> startsWith()
+ * <li> endsWith()
+ * </ul>
+ */
+public class SupportedStringMethods extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.2-47 (SupportedStringMethods) failed: ";
+    
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.toLowerCase() == 'emp1first'",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.toUpperCase() == 'EMP1FIRST'",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "name.indexOf('e') == 1",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Department.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "name.indexOf('e', 2) == 3",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.matches('.*First')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.matches('emp.First')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.matches('(?i)EMP1FIRST')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.substring(4) == 'First'",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.substring(4,9) == 'First'",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.startsWith('emp')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null),
+        new QueryElementHolder(
+                /*UNIQUE*/      null,
+                /*RESULT*/      null, 
+                /*INTO*/        null, 
+                /*FROM*/        Person.class,
+                /*EXCLUDE*/     null,
+                /*WHERE*/       "firstname.endsWith('First')",
+                /*VARIABLES*/   null,
+                /*PARAMETERS*/  null,
+                /*IMPORTS*/     null,
+                /*GROUP BY*/    null,
+                /*ORDER BY*/    null,
+                /*FROM*/        null,
+                /*TO*/          null)
+    };
+
+    /** 
+     * The expected results of valid queries.
+     * The strings are names of bean instances loaded by spring.  
+     */
+    private static String[][] expectedResult = {
+        {"emp1"},
+        {"emp1"},
+        {"dept1"},
+        {"dept1"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp1"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"},
+        {"emp1", "emp2", "emp3", "emp4", "emp5"}
+    };
+            
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(SupportedStringMethods.class);
+    }
+    
+    /** */
+    public void testToLowerCase() {
+        int index = 0;
+        executeQuery(index);
+    }
+    
+    /** */
+    public void testToUpperCase() {
+        int index = 1;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testIndexOfString() {
+        int index = 2;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testIndexOfStringInt() {
+        int index = 3;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testMatches() {
+        int index = 4;
+        executeQuery(index);
+        executeQuery(++index);
+        executeQuery(++index);
+    }
+
+    /** */
+    public void testSubstringInt() {
+        int index = 7;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testSubstringIntInt() {
+        int index = 8;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testStartsWith() {
+        int index = 9;
+        executeQuery(index);
+    }
+
+    /** */
+    public void testEndsWith() {
+        int index = 10;
+        executeQuery(index);
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        loadCompanyModel(getPM(), COMPANY_TESTDATA);
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+    }
+
+    /** */
+    private void executeQuery(int index) {
+        Object[] expectedResultValues = 
+            getCompanyModelInstances(expectedResult[index]);
+        executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResultValues);
+        executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                expectedResultValues);
+    }
+}

Added: incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml?rev=326519&view=auto
==============================================================================
--- incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml (added)
+++ incubator/jdo/trunk/tck20/test/testdata/org/apache/jdo/tck/pc/mylib/mylibForQueryTests.xml Wed Oct 19 03:27:35 2005
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
+
+<beans>
+    <description>Mylib instances for query testing</description>
+
+    <bean id="root" class="java.util.ArrayList">
+        <constructor-arg index="0">
+            <list>
+                <ref local="primitiveTypesPositive"/>
+                <ref local="primitiveTypesNegative"/>
+            </list>
+        </constructor-arg>
+    </bean>
+
+    <bean id="primitiveTypesPositive" class="org.apache.jdo.tck.pc.mylib.PrimitiveTypes">
+        <property name="id"><value>1</value></property>
+        <property name="intNotNull"><value>4</value></property>
+        <property name="intNull"><value>4</value></property>
+        <property name="longNotNull"><value>4</value></property>
+        <property name="longNull"><value>4</value></property>
+        <property name="floatNotNull"><value>4.0</value></property>
+        <property name="floatNull"><value>4.0</value></property>
+        <property name="doubleNotNull"><value>4.0</value></property>
+        <property name="doubleNull"><value>4.0</value></property>
+    </bean>
+
+    <bean id="primitiveTypesNegative" class="org.apache.jdo.tck.pc.mylib.PrimitiveTypes">
+        <property name="id"><value>2</value></property>
+        <property name="intNotNull"><value>-4</value></property>
+        <property name="intNull"><value>-4</value></property>
+        <property name="longNotNull"><value>-4</value></property>
+        <property name="longNull"><value>-4</value></property>
+        <property name="floatNotNull"><value>-4.0</value></property>
+        <property name="floatNull"><value>-4.0</value></property>
+        <property name="doubleNotNull"><value>-4.0</value></property>
+        <property name="doubleNull"><value>-4.0</value></property>
+    </bean>
+
+</beans>
+



Mime
View raw message