db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1632986 - in /db/jdo/trunk/tck/src: java/org/apache/jdo/tck/query/delete/ java/org/apache/jdo/tck/query/jdoql/ java/org/apache/jdo/tck/query/result/ testdata/org/apache/jdo/tck/pc/company/
Date Sun, 19 Oct 2014 20:05:43 GMT
Author: mbo
Date: Sun Oct 19 20:05:43 2014
New Revision: 1632986

URL: http://svn.apache.org/r1632986
Log:
JDO-721: add two new query test cases to test null position specification in the ordering
specification

Modified:
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/AggregateResult.java
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/DefaultUnique.java
    db/jdo/trunk/tck/src/testdata/org/apache/jdo/tck/pc/company/companyForQueryTests.xml

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java?rev=1632986&r1=1632985&r2=1632986&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java (original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/delete/DeletePersistentAll.java Sun
Oct 19 20:05:43 2014
@@ -97,13 +97,13 @@ public class DeletePersistentAll extends
     /** */
     public void testNoParametersAPI() {
         deletePersistentAllByAPIQuery(ASSERTION_FAILED, 
-                VALID_QUERIES[0], null, 10);
+                VALID_QUERIES[0], null, 11);
     }
     
     /** */
     public void testNoParametersSingleString() {
         deletePersistentAllBySingleStringQuery(ASSERTION_FAILED, 
-                VALID_QUERIES[0], null, 10);
+                VALID_QUERIES[0], null, 11);
     }
     
     /** */

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java?rev=1632986&r1=1632985&r2=1632986&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java (original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/OrderingSpecification.java Sun
Oct 19 20:05:43 2014
@@ -27,8 +27,11 @@ 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.DentalInsurance;
 import org.apache.jdo.tck.pc.fieldtypes.AllTypes;
 import org.apache.jdo.tck.pc.mylib.PCPoint;
+import org.apache.jdo.tck.query.QueryElementHolder;
 import org.apache.jdo.tck.query.QueryTest;
 import org.apache.jdo.tck.util.BatchTestRunner;
 
@@ -58,6 +61,55 @@ public class OrderingSpecification exten
     private static final String ASSERTION_FAILED = 
         "Assertion A14.6.6-1 (OrderingSpecification) failed: ";
     
+    /** 
+     * The array of valid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] VALID_QUERIES = {
+        // nulls first
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        DentalInsurance.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.lifetimeOrthoBenefit ascending nulls first",
+        /*FROM*/        null,
+        /*TO*/          null),
+        // nulls last
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        DentalInsurance.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.lifetimeOrthoBenefit ascending nulls last",
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        // nulls first
+        getTransientCompanyModelInstancesAsList(new String[]{
+                "dentalIns99", "dentalIns1", "dentalIns2", "dentalIns3", "dentalIns4", "dentalIns5"}),
+        // nulls last
+        getTransientCompanyModelInstancesAsList(new String[]{
+                "dentalIns1", "dentalIns2", "dentalIns3", "dentalIns4", "dentalIns5", "dentalIns99"})
+    };
+
     /**
      * The <code>main</code> is called when the class
      * is directly executed from the command line.
@@ -68,6 +120,14 @@ public class OrderingSpecification exten
     }
 
     /** */
+    public void testPositiveCompanyQueries() {
+        for (int i = 0; i < VALID_QUERIES.length; i++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[i], expectedResult[i]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[i], expectedResult[i]);
+        }
+    }
+
+    /** */
     public void testPositive() {
         PersistenceManager pm = getPM();
 
@@ -194,5 +254,7 @@ public class OrderingSpecification exten
     protected void localSetUp() {
         addTearDownClass(PCPoint.class);
         loadAndPersistPCPoints(getPM());
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+        loadAndPersistCompanyModel(getPM());
     }
 }

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/AggregateResult.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/AggregateResult.java?rev=1632986&r1=1632985&r2=1632986&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/AggregateResult.java (original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/AggregateResult.java Sun Oct
19 20:05:43 2014
@@ -562,7 +562,7 @@ public class AggregateResult extends Que
         // AVG(double)
         new Double(25000.0),
         // AVG(BigDecimal)
-        new Double("99.999"),
+        new Double("99.997"),
         // AVG(lifetimeOrthoBenefit)
         null,
         // AVG(((FullTimeEmployee)manager).salary)

Modified: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/DefaultUnique.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/DefaultUnique.java?rev=1632986&r1=1632985&r2=1632986&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/DefaultUnique.java (original)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/DefaultUnique.java Sun Oct 19
20:05:43 2014
@@ -161,7 +161,7 @@ public class DefaultUnique extends Query
         /*INTO*/        null, 
         /*FROM*/        DentalInsurance.class,
         /*EXCLUDE*/     null,
-        /*WHERE*/       null,
+        /*WHERE*/       "employee != null",
         /*VARIABLES*/   null,
         /*PARAMETERS*/  null,
         /*IMPORTS*/     null,
@@ -175,7 +175,7 @@ public class DefaultUnique extends Query
         /*INTO*/        null, 
         /*FROM*/        DentalInsurance.class,
         /*EXCLUDE*/     null,
-        /*WHERE*/       null,
+        /*WHERE*/       "employee != null",
         /*VARIABLES*/   null,
         /*PARAMETERS*/  null,
         /*IMPORTS*/     null,
@@ -189,7 +189,7 @@ public class DefaultUnique extends Query
         /*INTO*/        null, 
         /*FROM*/        DentalInsurance.class,
         /*EXCLUDE*/     null,
-        /*WHERE*/       null,
+        /*WHERE*/       "employee != null",
         /*VARIABLES*/   null,
         /*PARAMETERS*/  null,
         /*IMPORTS*/     null,
@@ -203,7 +203,7 @@ public class DefaultUnique extends Query
         /*INTO*/        null, 
         /*FROM*/        DentalInsurance.class,
         /*EXCLUDE*/     null,
-        /*WHERE*/       null,
+        /*WHERE*/       "employee != null",
         /*VARIABLES*/   null,
         /*PARAMETERS*/  null,
         /*IMPORTS*/     null,
@@ -221,16 +221,16 @@ public class DefaultUnique extends Query
                 "emp1", "emp2", "emp3", "emp4", "emp5"}),
         // results for aggregate queries
         new Long(5),
-        new Double("99.999"),
+        new Double("99.997"),
         new BigDecimal("2000.99"),
         new BigDecimal("2500000.99"),
         new BigDecimal("2552001.98"),
         // results for aggregate queries with grouping
         Arrays.asList(new Object[]{new Long(3), new Long(2)}),
-        Arrays.asList(new Object[]{new Double("99.999"), new Double("99.999")}),
-        Arrays.asList(new Object[]{new BigDecimal("99.999"), new BigDecimal("99.999")}),
-        Arrays.asList(new Object[]{new BigDecimal("99.999"), new BigDecimal("99.999")}),
-        Arrays.asList(new Object[]{new BigDecimal("299.997"), new BigDecimal("199.998")})
+        Arrays.asList(new Object[]{new Double("99.996"), new Double("99.9985")}),
+        Arrays.asList(new Object[]{new BigDecimal("99.995"), new BigDecimal("99.998")}),
+        Arrays.asList(new Object[]{new BigDecimal("99.997"), new BigDecimal("99.999")}),
+        Arrays.asList(new Object[]{new BigDecimal("299.988"), new BigDecimal("199.997")})
     };
             
     /**

Modified: db/jdo/trunk/tck/src/testdata/org/apache/jdo/tck/pc/company/companyForQueryTests.xml
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/testdata/org/apache/jdo/tck/pc/company/companyForQueryTests.xml?rev=1632986&r1=1632985&r2=1632986&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/testdata/org/apache/jdo/tck/pc/company/companyForQueryTests.xml (original)
+++ db/jdo/trunk/tck/src/testdata/org/apache/jdo/tck/pc/company/companyForQueryTests.xml Sun
Oct 19 20:05:43 2014
@@ -24,6 +24,7 @@
         <constructor-arg index="0">
             <list>
                 <ref local="company1"/>
+                <ref local="dentalIns99"/>
             </list>
         </constructor-arg>
     </bean>
@@ -346,28 +347,28 @@
     <bean id="dentalIns1" factory-bean="companyFactory" factory-method="newDentalInsurance">
         <constructor-arg index="0" type="long"><value>11</value></constructor-arg>
         <constructor-arg index="1" type="java.lang.String"><value>Carrier1</value></constructor-arg>
-        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.999</value></constructor-arg>
+        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.995</value></constructor-arg>
         <property name="employee"><ref bean="emp1"/></property>
     </bean>
 
     <bean id="dentalIns2" factory-bean="companyFactory" factory-method="newDentalInsurance">
         <constructor-arg index="0" type="long"><value>12</value></constructor-arg>
         <constructor-arg index="1" type="java.lang.String"><value>Carrier2</value></constructor-arg>
-        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.999</value></constructor-arg>
+        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.996</value></constructor-arg>
         <property name="employee"><ref bean="emp2"/></property>
     </bean>
 
     <bean id="dentalIns3" factory-bean="companyFactory" factory-method="newDentalInsurance">
         <constructor-arg index="0" type="long"><value>13</value></constructor-arg>
         <constructor-arg index="1" type="java.lang.String"><value>Carrier3</value></constructor-arg>
-        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.999</value></constructor-arg>
+        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.997</value></constructor-arg>
         <property name="employee"><ref bean="emp3"/></property>
     </bean>
 
     <bean id="dentalIns4" factory-bean="companyFactory" factory-method="newDentalInsurance">
         <constructor-arg index="0" type="long"><value>14</value></constructor-arg>
         <constructor-arg index="1" type="java.lang.String"><value>Carrier4</value></constructor-arg>
-        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.999</value></constructor-arg>
+        <constructor-arg index="2" type="java.math.BigDecimal"><value>99.998</value></constructor-arg>
         <property name="employee"><ref bean="emp4"/></property>
     </bean>
 
@@ -378,6 +379,12 @@
         <property name="employee"><ref bean="emp5"/></property>
     </bean>
 
+    <bean id="dentalIns99" factory-bean="companyFactory" factory-method="newDentalInsurance">
+        <constructor-arg index="0" type="long"><value>99</value></constructor-arg>
+        <constructor-arg index="1" type="java.lang.String"><value>Carrier99</value></constructor-arg>
+        <constructor-arg index="2" type="java.math.BigDecimal"><null/></constructor-arg>
+    </bean>
+
     <bean id="proj1" factory-bean="companyFactory" factory-method="newProject">
         <constructor-arg index="0" type="long"><value>1</value></constructor-arg>
         <constructor-arg index="1" type="java.lang.String"><value>orange</value></constructor-arg>



Mime
View raw message