You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2014/12/11 22:47:26 UTC

svn commit: r1644775 - in /db/jdo/trunk: copyjdorijars/pom.xml tck/src/conf/jdoql.conf tck/src/conf/query.conf tck/src/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java tck/src/java/org/apache/jdo/tck/query/result/IfElseResult.java

Author: mbo
Date: Thu Dec 11 21:47:26 2014
New Revision: 1644775

URL: http://svn.apache.org/r1644775
Log:
JDO-650: Upgrade DN version + first tck test cases tesing JDOQL IF/ELSE

Added:
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/IfElseResult.java
Modified:
    db/jdo/trunk/copyjdorijars/pom.xml
    db/jdo/trunk/tck/src/conf/jdoql.conf
    db/jdo/trunk/tck/src/conf/query.conf

Modified: db/jdo/trunk/copyjdorijars/pom.xml
URL: http://svn.apache.org/viewvc/db/jdo/trunk/copyjdorijars/pom.xml?rev=1644775&r1=1644774&r2=1644775&view=diff
==============================================================================
--- db/jdo/trunk/copyjdorijars/pom.xml (original)
+++ db/jdo/trunk/copyjdorijars/pom.xml Thu Dec 11 21:47:26 2014
@@ -93,22 +93,22 @@
     <dependency>
       <groupId>org.datanucleus</groupId>
       <artifactId>datanucleus-core</artifactId>
-      <version>3.2.12</version>
+      <version>4.0.4</version>
     </dependency>
     <dependency>
       <groupId>org.datanucleus</groupId>
       <artifactId>datanucleus-rdbms</artifactId>
-      <version>3.2.11</version>
+      <version>4.0.5</version>
     </dependency>
     <dependency>
       <groupId>org.datanucleus</groupId>
       <artifactId>datanucleus-api-jdo</artifactId>
-      <version>3.2.8</version>
+      <version>4.0.4</version>
     </dependency>
     <dependency>
       <groupId>org.datanucleus</groupId>
       <artifactId>datanucleus-api-jpa</artifactId>
-      <version>3.3.7</version>
+      <version>4.0.5</version>
     </dependency>
     <dependency>
       <groupId>c3p0</groupId>

Modified: db/jdo/trunk/tck/src/conf/jdoql.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/conf/jdoql.conf?rev=1644775&r1=1644774&r2=1644775&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/conf/jdoql.conf (original)
+++ db/jdo/trunk/tck/src/conf/jdoql.conf Thu Dec 11 21:47:26 2014
@@ -31,6 +31,7 @@ org.apache.jdo.tck.query.jdoql.Executing
 org.apache.jdo.tck.query.jdoql.ExecutingQueryWhenNoTransactionNoNontransactionalRead \
 org.apache.jdo.tck.query.jdoql.Having \
 org.apache.jdo.tck.query.jdoql.IdentifiersEqualFieldNames \
+org.apache.jdo.tck.query.jdoql.IfElseInFilter \
 org.apache.jdo.tck.query.jdoql.IgnoreCacheFalse \
 org.apache.jdo.tck.query.jdoql.MultipleActiveQueryInstanceInSamePersistenceManager \
 org.apache.jdo.tck.query.jdoql.MultipleIdenticalImports \

Modified: db/jdo/trunk/tck/src/conf/query.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/conf/query.conf?rev=1644775&r1=1644774&r2=1644775&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/conf/query.conf (original)
+++ db/jdo/trunk/tck/src/conf/query.conf Thu Dec 11 21:47:26 2014
@@ -72,6 +72,7 @@ org.apache.jdo.tck.query.result.DefaultU
 org.apache.jdo.tck.query.result.DistinctCandidateInstances \
 org.apache.jdo.tck.query.result.DistinctQuery \
 org.apache.jdo.tck.query.result.Grouping \
+org.apache.jdo.tck.query.result.IfElseResult \
 org.apache.jdo.tck.query.result.ImmutableQueryResult \
 org.apache.jdo.tck.query.result.MethodsInResult \
 org.apache.jdo.tck.query.result.NPEInResultExpr \

Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java?rev=1644775&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/IfElseInFilter.java Thu Dec 11 21:47:26 2014
@@ -0,0 +1,158 @@
+/*
+ * 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.jdoql;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.FullTimeEmployee;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> Use of If Else expression in filter
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.x
+ *<BR>
+ *<B>Assertion Description: </B>
+ */
+
+public class IfElseInFilter extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion A14.6.x (IfElseInFilter) 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*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "this.salary > (IF (this.department.name == 'Development') 15000 ELSE 25000)",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.empid",
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "IF (this.department.name == 'Development') this.salary > 15000 ELSE this.salary > 25000",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.empid",
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+
+   /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        // Invalid type of condition expression 
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      null,
+        /*INTO*/        null, 
+        /*FROM*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "IF (this.department) 0 ELSE 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*/        FullTimeEmployee.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       "IF (this.department.name == 'Development') this.salary > 15000",
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+        
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        getTransientCompanyModelInstancesAsList(new String[]{"emp1", "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(DenoteUniquenessInFilter.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        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 testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+    
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+        loadAndPersistCompanyModel(getPM());
+    }
+}

Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/IfElseResult.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/IfElseResult.java?rev=1644775&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/IfElseResult.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/result/IfElseResult.java Thu Dec 11 21:47:26 2014
@@ -0,0 +1,177 @@
+/*
+ * 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.result;
+
+import java.util.Arrays;
+import java.math.BigDecimal;
+
+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.company.Employee;
+import org.apache.jdo.tck.pc.company.Project;
+import org.apache.jdo.tck.query.QueryElementHolder;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> IfElseResult.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> .
+ *<BR>
+ *<B>Assertion Description: </B>
+ */
+public class IfElseResult extends QueryTest {
+
+    /** */
+    private static final String ASSERTION_FAILED = 
+        "Assertion (IfElseResult) 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*/      "IF (this.employee == null) 'No employee' ELSE this.employee.lastname",
+        /*INTO*/        null, 
+        /*FROM*/        DentalInsurance.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.insid ascending",
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "IF (this.members.size() > 2) this.budget * 1.2 ELSE this.budget * 1.1",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.projid ascending",
+        /*FROM*/        null,
+        /*TO*/          null),
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "IF (this.reviewers.isEmpty()) 'No reviewer' ELSE IF (this.reviewers.size() == 1) 'Single reviewer' ELSE 'Reviewer team'",
+        /*INTO*/        null, 
+        /*FROM*/        Project.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    "this.projid ascending",
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+
+    /** 
+     * The array of invalid queries which may be executed as 
+     * single string queries and as API queries.
+     */
+    private static final QueryElementHolder[] INVALID_QUERIES = {
+        // Invalid type of condition expression 
+        new QueryElementHolder(
+        /*UNIQUE*/      null,
+        /*RESULT*/      "IF (this.firstName) 0 ELSE 1",
+        /*INTO*/        null, 
+        /*FROM*/        Employee.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*/      "IF (this.employee == null) 0",
+        /*INTO*/        null, 
+        /*FROM*/        DentalInsurance.class,
+        /*EXCLUDE*/     null,
+        /*WHERE*/       null,
+        /*VARIABLES*/   null,
+        /*PARAMETERS*/  null,
+        /*IMPORTS*/     null,
+        /*GROUP BY*/    null,
+        /*ORDER BY*/    null,
+        /*FROM*/        null,
+        /*TO*/          null)
+    };
+    
+    /** 
+     * The expected results of valid queries.
+     */
+    private Object[] expectedResult = {
+        Arrays.asList(new Object[] { "emp1Last", "emp2Last", "emp3Last", "emp4Last", "emp5Last", "No employee" }),
+        Arrays.asList(new Object[] { new BigDecimal("3000001.188"), new BigDecimal("55000"), new BigDecimal("2201.089") }),
+        Arrays.asList(new Object[] { "No reviewer", "Reviewer team", "Single reviewer" })
+    };
+            
+    /**
+     * 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(NullResults.class);
+    }
+    
+    /** */
+    public void testPositive() {
+        for (int index = 0; index < VALID_QUERIES.length; index++) {
+            executeAPIQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                            expectedResult[index]);
+            executeSingleStringQuery(ASSERTION_FAILED, VALID_QUERIES[index], 
+                                     expectedResult[index]);
+        }
+    }
+
+    /** */
+    public void testNegative() {
+        for (int i = 0; i < INVALID_QUERIES.length; i++) {
+            compileAPIQuery(ASSERTION_FAILED, INVALID_QUERIES[i], false);
+            compileSingleStringQuery(ASSERTION_FAILED, INVALID_QUERIES[i], 
+                    false);
+        }
+    }
+
+    /**
+     * @see JDO_Test#localSetUp()
+     */
+    protected void localSetUp() {
+        addTearDownClass(CompanyModelReader.getTearDownClasses());
+        loadAndPersistCompanyModel(getPM());
+    }
+}