Hi,
attached you find a new patch with an updated version of the new
testclasses that run DataNucleus typesafe queries. This version adds
group by queries and runs the same tests for datastoreidentity.
A src/java/org/apache/jdo/tck/query/typesafe
A src/java/org/apache/jdo/tck/query/typesafe/TypesafeQueryTest.java
A src/java/org/apache/jdo/tck/query/typesafe/SimpleQueries.java
A src/java/org/apache/jdo/tck/query/typesafe/GroupingQueries.java
A src/java/org/apache/jdo/tck/query/typesafe/ProjectionQueries.java
A src/java/org/apache/jdo/tck/query/typesafe/ParameterQueries.java
A src/conf/typesafeQueries.conf
M pom.xml
The NPE in the APT when processing PersistenceCapable interfaces is
fixed in the latest DataNucleus version, so there is no need to remove
the directory companyAnnotatedPI anymore.
Regards Michael
Hi,
attached you find a patch adding new testclasses that run DataNucleus
typesafe queries.
Here is the list of changes:
! src/java/org/apache/jdo/tck/pc/companyAnnotatedPI
A src/java/org/apache/jdo/tck/query/typesafe
A src/java/org/apache/jdo/tck/query/typesafe/TypesafeQueryTest.java
A src/java/org/apache/jdo/tck/query/typesafe/SimpleQueries.java
A src/java/org/apache/jdo/tck/query/typesafe/ProjectionQueries.java
A src/java/org/apache/jdo/tck/query/typesafe/ParameterQueries.java
A src/conf/typesafeQueries.conf
A
src/testdata/org/apache/jdo/tck/pc/company/companyForTypesafeQueryTests.xml
M pom.xml
Please note, that I'm running Version 3.0.0-m1 of
datanucleus-jdo-query that runs into a NPE in the APT (see
NUCJDOQUERY-8). In order to avoid this I removed the company version
using PersistenceCapable interfaces
(src/java/org/apache/jdo/tck/pc/companyAnnotatedPI) from my local
workspace. The NPE is fixed in the DataNuclues trunk, so with the next
DN version we do not need this workaround anymore.
Regards Michael
--
*Michael Bouschen*
*Prokurist*
akquinet tech@spree GmbH
Bülowstr. 66, D-10783 Berlin
Fon: +49 30 235 520-33
Fax: +49 30 217 520-12
Email: [email protected]
Url: www.akquinet.de <http://www.akquinet.de>
akquinet tech@spree GmbH, Berlin
Geschäftsführung: Martin Weber, Prof. Dr. Christian Roth
Amtsgericht Berlin-Charlottenburg HRB 86780 B
USt.-Id. Nr.: DE 225 964 680
--
*Michael Bouschen*
*Prokurist*
akquinet tech@spree GmbH
Bülowstr. 66, D-10783 Berlin
Fon: +49 30 235 520-33
Fax: +49 30 217 520-12
Email: [email protected]
Url: www.akquinet.de <http://www.akquinet.de>
akquinet tech@spree GmbH, Berlin
Geschäftsführung: Martin Weber, Prof. Dr. Christian Roth
Amtsgericht Berlin-Charlottenburg HRB 86780 B
USt.-Id. Nr.: DE 225 964 680
Index: src/java/org/apache/jdo/tck/query/typesafe/TypesafeQueryTest.java
===================================================================
--- src/java/org/apache/jdo/tck/query/typesafe/TypesafeQueryTest.java
(revision 0)
+++ src/java/org/apache/jdo/tck/query/typesafe/TypesafeQueryTest.java
(revision 0)
@@ -0,0 +1,67 @@
+/*
+ * 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.typesafe;
+
+import javax.jdo.PersistenceManager;
+
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.pc.company.CompanyModelReader;
+import org.apache.jdo.tck.pc.company.CompanyFactoryRegistry;
+
+/**
+ * Superclass for all Testcases testing typesafe queries.
+ */
+public abstract class TypesafeQueryTest extends QueryTest {
+
+ public final String identitytype =
+ System.getProperty("jdo.tck.identitytype");
+ public boolean isAppIdentity = "applicationidentity".equals(identitytype);
+
+ /**
+ * Returns the name of the company test data resource.
+ * This implementation takes the testdata from a file specified as
+ * system property jdo.tck.testdata.
+ * @return name of the company test data resource.
+ */
+ protected String getCompanyTestDataResource() {
+ return inputFilename;
+ }
+
+ /**
+ * Reads a graph of company model objects from the internal reader. 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.
+ * This implementation uses a CompanyFactory whos name is taken
+ * from the system property jdo.tck.mapping.companyfactory.
+ */
+ public CompanyModelReader loadAndPersistCompanyModel(PersistenceManager
pm) {
+ getPM();
+ CompanyFactoryRegistry.registerFactory(pm);
+ return super.loadAndPersistCompanyModel(pm);
+ }
+
+ /**
+ * Return the array of teardown classes from the CompanyModelFactory.
+ * @return an array of teardown Class instances
+ */
+ protected Class[] getTearDownClasses() {
+ return CompanyFactoryRegistry.getInstance().getTearDownClasses();
+ }
+
+}
Index: src/java/org/apache/jdo/tck/query/typesafe/SimpleQueries.java
===================================================================
--- src/java/org/apache/jdo/tck/query/typesafe/SimpleQueries.java
(revision 0)
+++ src/java/org/apache/jdo/tck/query/typesafe/SimpleQueries.java
(revision 0)
@@ -0,0 +1,210 @@
+/*
+ * 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.typesafe;
+
+import java.util.List;
+
+import javax.jdo.Query;
+import javax.jdo.PersistenceManager;
+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.CompanyFactoryRegistry;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCDSEmployee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import org.datanucleus.query.typesafe.TypesafeQuery;
+import org.datanucleus.api.jdo.JDOPersistenceManager;
+
+/**
+ *<B>Title:</B> .
+ *<BR>
+ *<B>Keywords:</B> query, typesafe
+ *<BR>
+ *<B>Assertion ID:</B>
+ *<BR>
+ *<B>Assertion Description: </B>
+ */
+public class SimpleQueries extends TypesafeQueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion (SimpleQueries) failed: ";
+
+ /**
+ * 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(SimpleQueries.class);
+ }
+
+ /**
+ *
+ */
+ public void testBasicFilter() {
+ if (isAppIdentity)
+ runTestBasicFilterApp();
+ else
+ runTestBasicFilterDS();
+ }
+
+ /**
+ *
+ */
+ public void testOrdering() {
+ if (isAppIdentity)
+ runTestOrderingApp();
+ else
+ runTestOrderingDS();
+ }
+
+ /**
+ *
+ */
+ private void runTestBasicFilterApp() {
+ List<FCAppEmployee> expected =
+ getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCAppEmployee> tq =
jdopm.newTypesafeQuery(FCAppEmployee.class);
+ QFCAppEmployee cand = QFCAppEmployee.candidate();
+ List<FCAppEmployee> results =
+ tq.filter(cand.lastname.eq("emp1Last"))
+ .executeList();
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "lastname ==
emp1Last",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ *
+ */
+ private void runTestBasicFilterDS() {
+ List<FCDSEmployee> expected =
+ getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCDSEmployee> tq =
jdopm.newTypesafeQuery(FCDSEmployee.class);
+ QFCDSEmployee cand = QFCDSEmployee.candidate();
+ List<FCDSEmployee> results =
+ tq.filter(cand.lastname.eq("emp1Last"))
+ .executeList();
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "lastname ==
emp1Last",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+
+ /**
+ *
+ */
+ private void runTestOrderingApp() {
+ List<FCAppEmployee> expected =
+ getTransientCompanyModelInstancesAsList(new String[]{"emp5",
"emp1", "emp4", "emp3", "emp2"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCAppEmployee> tq =
jdopm.newTypesafeQuery(FCAppEmployee.class);
+ QFCAppEmployee cand = QFCAppEmployee.candidate();
+ List<FCAppEmployee> results =
+ tq.orderBy(cand.hiredate.asc())
+ .executeList();
+
+ // check query result
+ checkQueryResultWithOrder(ASSERTION_FAILED, "order by hiredate",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ *
+ */
+ private void runTestOrderingDS() {
+ List<FCDSEmployee> expected =
+ getTransientCompanyModelInstancesAsList(new String[]{"emp5",
"emp1", "emp4", "emp3", "emp2"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCDSEmployee> tq =
jdopm.newTypesafeQuery(FCDSEmployee.class);
+ QFCDSEmployee cand = QFCDSEmployee.candidate();
+ List<FCDSEmployee> results =
+ tq.orderBy(cand.hiredate.asc())
+ .executeList();
+
+ // check query result
+ checkQueryResultWithOrder(ASSERTION_FAILED, "order by hiredate",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadAndPersistCompanyModel(getPM());
+ addTearDownClass(getTearDownClasses());
+ }
+}
Index: src/java/org/apache/jdo/tck/query/typesafe/GroupingQueries.java
===================================================================
--- src/java/org/apache/jdo/tck/query/typesafe/GroupingQueries.java
(revision 0)
+++ src/java/org/apache/jdo/tck/query/typesafe/GroupingQueries.java
(revision 0)
@@ -0,0 +1,221 @@
+/*
+ * 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.typesafe;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jdo.Query;
+import javax.jdo.PersistenceManager;
+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.CompanyFactoryRegistry;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppFullTimeEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCAppFullTimeEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSFullTimeEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCDSEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCDSFullTimeEmployee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import org.datanucleus.query.typesafe.TypesafeQuery;
+import org.datanucleus.api.jdo.JDOPersistenceManager;
+
+/**
+ *<B>Title:</B> .
+ *<BR>
+ *<B>Keywords:</B> query, typesafe
+ *<BR>
+ *<B>Assertion ID:</B>
+ *<BR>
+ *<B>Assertion Description: </B>
+ */
+public class GroupingQueries extends TypesafeQueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion (SimpleQueries) failed: ";
+
+ /**
+ * 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(SimpleQueries.class);
+ }
+
+ /** */
+ public void testGrouping() {
+ if (isAppIdentity)
+ runTestGroupingApp();
+ else
+ runTestGroupingDS();
+ }
+
+ /** */
+ public void testHaving() {
+ if (isAppIdentity)
+ runTestHavingApp();
+ else
+ runTestHavingDS();
+ }
+
+ /**
+ *
+ */
+ private void runTestGroupingApp() {
+ List<Object[]> expected =
+ Arrays.asList(new Object[][] {
+ new Object[] {getTransientCompanyModelInstance("dept1"),
new Double(30000.0)},
+ new Object[] {getTransientCompanyModelInstance("dept2"),
new Double(45000.0)}});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCAppFullTimeEmployee> tq =
jdopm.newTypesafeQuery(FCAppFullTimeEmployee.class);
+ QFCAppFullTimeEmployee cand = QFCAppFullTimeEmployee.candidate();
+ List<Object[]> results =
+ tq.groupBy(cand.department)
+ .executeResultList(false, cand.department, cand.salary.sum());
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "group by
department",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ *
+ */
+ private void runTestGroupingDS() {
+ List<Object[]> expected =
+ Arrays.asList(new Object[][] {
+ new Object[] {getTransientCompanyModelInstance("dept1"),
new Double(30000.0)},
+ new Object[] {getTransientCompanyModelInstance("dept2"),
new Double(45000.0)}});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCDSFullTimeEmployee> tq =
jdopm.newTypesafeQuery(FCDSFullTimeEmployee.class);
+ QFCDSFullTimeEmployee cand = QFCDSFullTimeEmployee.candidate();
+ List<Object[]> results =
+ tq.groupBy(cand.department)
+ .executeResultList(false, cand.department, cand.salary.sum());
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "group by
department",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ *
+ */
+ private void runTestHavingApp() {
+ List<Object[]> expected =
+ Arrays.asList(new Object[][] {
+ new Object[] {getTransientCompanyModelInstance("dept1"),
new Double(33.0)},
+ new Object[] {getTransientCompanyModelInstance("dept2"),
new Double(0.0)}});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCAppEmployee> tq =
jdopm.newTypesafeQuery(FCAppEmployee.class);
+ QFCAppEmployee cand = QFCAppEmployee.candidate();
+ List<Object[]> results =
+
tq.groupBy(cand.department).having(cand.department.count().gt(0))
+ .executeResultList(false, cand.department,
cand.weeklyhours.avg());
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "group by
department",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ *
+ */
+ private void runTestHavingDS() {
+ List<Object[]> expected =
+ Arrays.asList(new Object[][] {
+ new Object[] {getTransientCompanyModelInstance("dept1"),
new Double(33.0)},
+ new Object[] {getTransientCompanyModelInstance("dept2"),
new Double(0.0)}});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCDSEmployee> tq =
jdopm.newTypesafeQuery(FCDSEmployee.class);
+ QFCDSEmployee cand = QFCDSEmployee.candidate();
+ List<Object[]> results =
+
tq.groupBy(cand.department).having(cand.department.count().gt(0))
+ .executeResultList(false, cand.department,
cand.weeklyhours.avg());
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "group by
department",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadAndPersistCompanyModel(getPM());
+ addTearDownClass(getTearDownClasses());
+ }
+
+}
Index: src/java/org/apache/jdo/tck/query/typesafe/ProjectionQueries.java
===================================================================
--- src/java/org/apache/jdo/tck/query/typesafe/ProjectionQueries.java
(revision 0)
+++ src/java/org/apache/jdo/tck/query/typesafe/ProjectionQueries.java
(revision 0)
@@ -0,0 +1,136 @@
+/*
+ * 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.typesafe;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.jdo.Query;
+import javax.jdo.PersistenceManager;
+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.CompanyFactoryRegistry;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCDSEmployee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import org.datanucleus.query.typesafe.TypesafeQuery;
+import org.datanucleus.api.jdo.JDOPersistenceManager;
+
+/**
+ *<B>Title:</B> .
+ *<BR>
+ *<B>Keywords:</B> query, typesafe
+ *<BR>
+ *<B>Assertion ID:</B>
+ *<BR>
+ *<B>Assertion Description: </B>
+ */
+public class ProjectionQueries extends TypesafeQueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion (ProjectionQueries) failed: ";
+
+ /**
+ * 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(ProjectionQueries.class);
+ }
+
+ /**
+ *
+ */
+ public void testProjection() {
+ if (isAppIdentity)
+ runTestProjectionApp();
+ else
+ runTestProjectionDS();
+ }
+
+ /**
+ *
+ */
+ public void runTestProjectionApp() {
+ List<String> expected = Arrays.asList(
+ new String[]{"emp1Last", "emp2Last", "emp3Last", "emp4Last",
"emp5Last"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCAppEmployee> tq =
jdopm.newTypesafeQuery(FCAppEmployee.class);
+ QFCAppEmployee cand = QFCAppEmployee.candidate();
+ List<String> results = tq.executeResultList(String.class, false,
cand.lastname);
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "SELECT lastname
FROM ...",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ *
+ */
+ public void runTestProjectionDS() {
+ List<String> expected = Arrays.asList(
+ new String[]{"emp1Last", "emp2Last", "emp3Last", "emp4Last",
"emp5Last"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCDSEmployee> tq =
jdopm.newTypesafeQuery(FCDSEmployee.class);
+ QFCDSEmployee cand = QFCDSEmployee.candidate();
+ List<String> results = tq.executeResultList(String.class, false,
cand.lastname);
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "SELECT lastname
FROM ...",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadAndPersistCompanyModel(getPM());
+ addTearDownClass(getTearDownClasses());
+ }
+}
Index: src/java/org/apache/jdo/tck/query/typesafe/ParameterQueries.java
===================================================================
--- src/java/org/apache/jdo/tck/query/typesafe/ParameterQueries.java
(revision 0)
+++ src/java/org/apache/jdo/tck/query/typesafe/ParameterQueries.java
(revision 0)
@@ -0,0 +1,141 @@
+/*
+ * 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.typesafe;
+
+import java.util.List;
+
+import javax.jdo.Query;
+import javax.jdo.PersistenceManager;
+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.CompanyFactoryRegistry;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCAppEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.FCDSEmployee;
+import org.apache.jdo.tck.pc.companyAnnotatedFC.QFCDSEmployee;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import org.datanucleus.query.typesafe.TypesafeQuery;
+import org.datanucleus.api.jdo.JDOPersistenceManager;
+
+/**
+ *<B>Title:</B> .
+ *<BR>
+ *<B>Keywords:</B> query, typesafe
+ *<BR>
+ *<B>Assertion ID:</B>
+ *<BR>
+ *<B>Assertion Description: </B>
+ */
+public class ParameterQueries extends TypesafeQueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion (ParameterQueries) failed: ";
+
+ /**
+ * 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(ParameterQueries.class);
+ }
+
+ /**
+ *
+ */
+ public void testParameter() {
+ if (isAppIdentity)
+ runTestParameterApp();
+ else
+ runTestParameterDS();
+ }
+
+ /**
+ *
+ */
+ public void runTestParameterApp() {
+ List<FCAppEmployee> expected =
+ getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCAppEmployee> tq =
jdopm.newTypesafeQuery(FCAppEmployee.class);
+ QFCAppEmployee cand = QFCAppEmployee.candidate();
+ List<FCAppEmployee> results =
+ tq.filter(cand.lastname.eq(tq.stringParameter("param")))
+ .setParameter("param", "emp1Last")
+ .executeList();
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "lastname == param",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ *
+ */
+ public void runTestParameterDS() {
+ List<FCDSEmployee> expected =
+ getTransientCompanyModelInstancesAsList(new String[]{"emp1"});
+
+ PersistenceManager pm = getPM();
+ JDOPersistenceManager jdopm = (JDOPersistenceManager)pm;
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ TypesafeQuery<FCDSEmployee> tq =
jdopm.newTypesafeQuery(FCDSEmployee.class);
+ QFCDSEmployee cand = QFCDSEmployee.candidate();
+ List<FCDSEmployee> results =
+ tq.filter(cand.lastname.eq(tq.stringParameter("param")))
+ .setParameter("param", "emp1Last")
+ .executeList();
+
+ // check query result
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, "lastname == param",
+ results, expected);
+ tx.commit();
+ tx = null;
+ } finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ loadAndPersistCompanyModel(getPM());
+ addTearDownClass(getTearDownClasses());
+ }
+}
Index: src/conf/typesafeQueries.conf
===================================================================
--- src/conf/typesafeQueries.conf (revision 0)
+++ src/conf/typesafeQueries.conf (revision 0)
@@ -0,0 +1,26 @@
+# 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.
+
+jdo.tck.description = A query test with standard mapping, testdata with all
relationships \
+and embedded objects, annotations
+jdo.tck.mapping.companyfactory =
org.apache.jdo.tck.pc.companyAnnotatedFC.CompanyFactoryAnnotatedFCConcreteDelegator
+jdo.tck.testdata = org/apache/jdo/tck/pc/company/companyForQueryTests.xml
+jdo.tck.mapping = 0
+jdo.tck.requiredOptions =
+jdo.tck.classes = \
+org.apache.jdo.tck.query.typesafe.SimpleQueries \
+org.apache.jdo.tck.query.typesafe.ProjectionQueries \
+org.apache.jdo.tck.query.typesafe.ParameterQueries \
+org.apache.jdo.tck.query.typesafe.GroupingQueries
Index: pom.xml
===================================================================
--- pom.xml (revision 1126206)
+++ pom.xml (working copy)
@@ -56,6 +56,8 @@
<dbproperties>-Dderby.system.home=${basedir}/target/database/derby</dbproperties>
<signaturefile>${basedir}/src/conf/jdo-3_1-signatures.txt</signaturefile>
<cfgs>
+ <cfg>typesafeQueries.conf</cfg>
+ <!--
<cfg>company1-1Relationships.conf</cfg>
<cfg>company1-MRelationships.conf</cfg>
<cfg>companyAllRelationships.conf</cfg>
@@ -113,6 +115,7 @@
<cfg>schemaAttributePackage.conf</cfg>
<cfg>security.conf</cfg>
<cfg>transactions.conf</cfg>
+ -->
</cfgs>
</configuration>
</plugin>
@@ -249,10 +252,12 @@
</resources>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <source>1.6</source>
+ <target>1.6</target>
</configuration>
</plugin>
<plugin>
@@ -266,8 +271,8 @@
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
- <doctitle>${pom.name} ${pom.currentVersion}</doctitle>
- <windowtitle>${pom.name}
${pom.currentVersion}</windowtitle>
+ <doctitle>${project.name} ${pom.currentVersion}</doctitle>
+ <windowtitle>${project.name}
${pom.currentVersion}</windowtitle>
</configuration>
</plugin>
</plugins>
@@ -277,7 +282,22 @@
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-core</artifactId>
+ <version>3.0.0-m3</version>
+ </dependency>
<dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-jdo-query</artifactId>
+ <version>3.0.0-m2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.datanucleus</groupId>
+ <artifactId>datanucleus-api-jdo</artifactId>
+ <version>3.0.0-m3</version>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
@@ -309,13 +329,17 @@
<reporting>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
+ <version>2.4</version>
<configuration>
<xmlPath>${basedir}/xdocs/changes.xml</xmlPath>
</configuration>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
+ <version>2.6</version>
<configuration>
<configLocation>${basedir}/../jdo_checks.xml</configLocation>
<headerLocation>${basedir}/../LICENSE.txt</headerLocation>