Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.query.jdoql.parameters » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    * 
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    * Unless required by applicable law or agreed to in writing, software 
   12    * distributed under the License is distributed on an "AS IS" BASIS, 
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
   14    * See the License for the specific language governing permissions and 
   15    * limitations under the License.
   16    */
   17   
   18   package org.apache.jdo.tck.query.jdoql.parameters;
   19   
   20   import org.apache.jdo.tck.JDO_Test;
   21   import org.apache.jdo.tck.pc.company.CompanyModelReader;
   22   import org.apache.jdo.tck.pc.company.Person;
   23   import org.apache.jdo.tck.query.QueryElementHolder;
   24   import org.apache.jdo.tck.query.QueryTest;
   25   import org.apache.jdo.tck.util.BatchTestRunner;
   26   
   27   /**
   28    *<B>Title:</B> Order of Parameters.
   29    *<BR>
   30    *<B>Keywords:</B> query
   31    *<BR>
   32    *<B>Assertion ID:</B> A14.6.13-3.
   33    *<BR>
   34    *<B>Assertion Description: </B>
   35    * If implicit parameters are used, their order of appearance in the query 
   36    * determines their order for binding to positional parameters for execution.
   37    */
   38   public class OrderOfParameters extends QueryTest {
   39   
   40       /** */
   41       private static final String ASSERTION_FAILED = 
   42           "Assertion A14.6.13-3 (OrderOfParameters) failed: ";
   43       
   44       /** 
   45        * The array of valid queries which may be executed as 
   46        * single string queries and as API queries.
   47        */
   48       private static final QueryElementHolder[] VALID_QUERIES = {
   49           new QueryElementHolder(
   50           /*UNIQUE*/      null,
   51           /*RESULT*/      null, 
   52           /*INTO*/        null, 
   53           /*FROM*/        Person.class,
   54           /*EXCLUDE*/     null,
   55           /*WHERE*/       "firstname == :param1 & lastname == :param2",
   56           /*VARIABLES*/   null,
   57           /*PARAMETERS*/  null,
   58           /*IMPORTS*/     null,
   59           /*GROUP BY*/    null,
   60           /*ORDER BY*/    null,
   61           /*FROM*/        null,
   62           /*TO*/          null)
   63       };
   64       
   65       /** 
   66        * The expected results of valid queries.
   67        */
   68       private Object[] expectedResult = {
   69           getTransientCompanyModelInstancesAsList(new String[]{"emp1"})
   70       };
   71               
   72       /** Parameters of valid queries. */
   73       private Object[][] parameters = {
   74           {"emp1First", "emp1Last"}
   75       };
   76               
   77       /**
   78        * The <code>main</code> is called when the class
   79        * is directly executed from the command line.
   80        * @param args The arguments passed to the program.
   81        */
   82       public static void main(String[] args) {
   83           BatchTestRunner.run(OrderOfParameters.class);
   84       }
   85       
   86       /** */
   87       public void testPositive() {
   88           for (int i = 0; i < VALID_QUERIES.length; i++) {
   89               executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
   90                       parameters[i], expectedResult[i]);
   91               executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], 
   92                       parameters[i], expectedResult[i]);
   93           }
   94       }
   95       
   96       /**
   97        * @see JDO_Test#localSetUp()
   98        */
   99       protected void localSetUp() {
  100           addTearDownClass(CompanyModelReader.getTearDownClasses());
  101           loadAndPersistCompanyModel(getPM());
  102       }
  103   }

Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.query.jdoql.parameters » [javadoc | source]