Author: mbo
Date: Tue Sep 19 21:02:49 2017
New Revision: 1808943
URL: http://svn.apache.org/viewvc?rev=1808943&view=rev
Log:
JDO-749: TCK tests for support of java.time types in queries
Added:
db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateSample.java
db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java
db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java
db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java
db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java
db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java
Modified:
db/jdo/trunk/tck/src/conf/jdoql.conf
db/jdo/trunk/tck/src/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo
db/jdo/trunk/tck/src/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo
db/jdo/trunk/tck/src/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-standard.orm
db/jdo/trunk/tck/src/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-standard.orm
db/jdo/trunk/tck/src/sql/derby/applicationidentity/schema.sql
db/jdo/trunk/tck/src/sql/derby/datastoreidentity/schema.sql
Modified: db/jdo/trunk/tck/src/conf/jdoql.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/conf/jdoql.conf?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/conf/jdoql.conf (original)
+++ db/jdo/trunk/tck/src/conf/jdoql.conf Tue Sep 19 21:02:49 2017
@@ -64,6 +64,9 @@ org.apache.jdo.tck.query.jdoql.methods.M
org.apache.jdo.tck.query.jdoql.methods.StartsWithAndEndsWith \
org.apache.jdo.tck.query.jdoql.methods.SupportedCollectionMethods \
org.apache.jdo.tck.query.jdoql.methods.SupportedDateMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedLocalDateMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedLocalDateTimeMethods \
+org.apache.jdo.tck.query.jdoql.methods.SupportedLocalTimeMethods \
org.apache.jdo.tck.query.jdoql.methods.SupportedTimeMethods \
org.apache.jdo.tck.query.jdoql.methods.SupportedJDOHelperMethods \
org.apache.jdo.tck.query.jdoql.methods.SupportedListMethods \
Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateSample.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateSample.java?rev=1808943&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateSample.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateSample.java Tue Sep 19
21:02:49 2017
@@ -0,0 +1,70 @@
+/*
+ * 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.pc.query;
+
+import java.io.Serializable;
+import java.time.LocalDate;
+
+public class LocalDateSample implements Serializable {
+
+ private long id;
+ private LocalDate localDate;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public LocalDate getLocalDate() {
+ return localDate;
+ }
+
+ public void setLocalDate(LocalDate localDate) {
+ this.localDate = localDate;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (id ^ (id >>> 32));
+ result = prime * result + ((localDate == null) ? 0 : localDate.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LocalDateSample other = (LocalDateSample) obj;
+ if (id != other.id)
+ return false;
+ if (localDate == null) {
+ if (other.localDate != null)
+ return false;
+ } else if (!localDate.equals(other.localDate))
+ return false;
+ return true;
+ }
+}
Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java?rev=1808943&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalDateTimeSample.java Tue Sep
19 21:02:49 2017
@@ -0,0 +1,70 @@
+/*
+ * 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.pc.query;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+public class LocalDateTimeSample implements Serializable {
+
+ private long id;
+ private LocalDateTime localDateTime;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public LocalDateTime getLocalDateTime() {
+ return localDateTime;
+ }
+
+ public void setLocalDateTime(LocalDateTime localDateTime) {
+ this.localDateTime = localDateTime;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (id ^ (id >>> 32));
+ result = prime * result + ((localDateTime == null) ? 0 : localDateTime.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LocalDateTimeSample other = (LocalDateTimeSample) obj;
+ if (id != other.id)
+ return false;
+ if (localDateTime == null) {
+ if (other.localDateTime != null)
+ return false;
+ } else if (!localDateTime.equals(other.localDateTime))
+ return false;
+ return true;
+ }
+}
Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java?rev=1808943&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/LocalTimeSample.java Tue Sep 19
21:02:49 2017
@@ -0,0 +1,70 @@
+/*
+ * 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.pc.query;
+
+import java.io.Serializable;
+import java.time.LocalTime;
+
+public class LocalTimeSample implements Serializable {
+
+ private long id;
+ private LocalTime localTime;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public LocalTime getLocalTime() {
+ return localTime;
+ }
+
+ public void setLocalTime(LocalTime localTime) {
+ this.localTime = localTime;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (id ^ (id >>> 32));
+ result = prime * result + ((localTime == null) ? 0 : localTime.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ LocalTimeSample other = (LocalTimeSample) obj;
+ if (id != other.id)
+ return false;
+ if (localTime == null) {
+ if (other.localTime != null)
+ return false;
+ } else if (!localTime.equals(other.localTime))
+ return false;
+ return true;
+ }
+}
Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java?rev=1808943&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java
(added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateMethods.java
Tue Sep 19 21:02:49 2017
@@ -0,0 +1,168 @@
+/*
+ * 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.methods;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.query.LocalDateSample;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.time.LocalDate;
+import java.time.Month;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *<B>Title:</B> Supported LocalDate methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-60.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * New supported LocalDate methods:
+ * <ul>
+ * <li>getDayOfMonth()</li>
+ * <li>getMonthValue()</li>
+ * <li>getYear()</li>
+ * </ul>
+ */
+public class SupportedLocalDateMethods extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-60 (SupportedLocalDateMethods) failed: ";
+
+ /** */
+ private Object oidOfLocalDate1;
+
+ /** */
+ private Object oidOfLocalDate2;
+
+ /**
+ * 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(SupportedLocalDateMethods.class);
+ }
+
+ /** */
+ public void testDayOfMonth() {
+ final String filter = "localDate.getDayOfMonth() == 12";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate1));
+
+ Query q = pm.newQuery(LocalDateSample.class, filter);
+ List<LocalDateSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testMonthValue() {
+ final String filter = "localDate.getMonthValue() == 8";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate2));
+
+ Query q = pm.newQuery(LocalDateSample.class, filter);
+ List<LocalDateSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testYear() {
+ final String filter = "localDate.getYear() == 2017";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate1));
+ expectedResult.add((LocalDateSample)pm.getObjectById(oidOfLocalDate2));
+
+ Query q = pm.newQuery(LocalDateSample.class, filter);
+ List<LocalDateSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(LocalDateSample.class);
+ insertLocalDateSampleData(getPM());
+ }
+
+ /** */
+ private void insertLocalDateSampleData(PersistenceManager pm) {
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ LocalDateSample lds1 = new LocalDateSample();
+ lds1.setId(1);
+ LocalDate localDate1 = LocalDate.of(2017, Month.SEPTEMBER, 12);
+ lds1.setLocalDate(localDate1);
+ pm.makePersistent(lds1);
+
+ LocalDateSample lds2 = new LocalDateSample();
+ lds2.setId(2);
+ LocalDate localDate2 = LocalDate.of(2017, Month.AUGUST, 20);
+ lds2.setLocalDate(localDate2);
+ pm.makePersistent(lds2);
+
+ tx.commit();
+ oidOfLocalDate1 = pm.getObjectId(lds1);
+ oidOfLocalDate2 = pm.getObjectId(lds2);
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+}
Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java?rev=1808943&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java
(added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalDateTimeMethods.java
Tue Sep 19 21:02:49 2017
@@ -0,0 +1,235 @@
+/*
+ * 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.methods;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.query.LocalDateTimeSample;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.time.LocalDateTime;
+import java.time.Month;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *<B>Title:</B> Supported LocalDateTime methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-60.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * New supported LocalDateTime methods:
+ * <ul>
+ * <li>getDayOfMonth()</li>
+ * <li>getMonthValue()</li>
+ * <li>getYear()</li>
+ * <li>getHour()</li>
+ * <li>getMinute()</li>
+ * <li>getSecond()</li>
+ * </ul>
+ */
+public class SupportedLocalDateTimeMethods extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-60 (SupportedLocalDateTimeMethods) failed: ";
+
+ /** */
+ private Object oidOfLocalDateTime1;
+
+ /** */
+ private Object oidOfLocalDateTime2;
+
+ /**
+ * 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(SupportedLocalDateTimeMethods.class);
+ }
+
+ /** */
+ public void testDayOfMonth() {
+ final String filter = "localDateTime.getDayOfMonth() == 12";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateTimeSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1));
+
+ Query q = pm.newQuery(LocalDateTimeSample.class, filter);
+ List<LocalDateTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testMonthValue() {
+ final String filter = "localDateTime.getMonthValue() == 8";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateTimeSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime2));
+
+ Query q = pm.newQuery(LocalDateTimeSample.class, filter);
+ List<LocalDateTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testYear() {
+ final String filter = "localDateTime.getYear() == 2017";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateTimeSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1));
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime2));
+
+ Query q = pm.newQuery(LocalDateTimeSample.class, filter);
+ List<LocalDateTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testHour() {
+ final String filter = "localDateTime.getHour() == 14";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateTimeSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1));
+
+ Query q = pm.newQuery(LocalDateTimeSample.class, filter);
+ List<LocalDateTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testMinute() {
+ final String filter = "localDateTime.getMinute() == 22";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateTimeSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime2));
+
+ Query q = pm.newQuery(LocalDateTimeSample.class, filter);
+ List<LocalDateTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testSecond() {
+ final String filter = "localDateTime.getSecond() == 25";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalDateTimeSample> expectedResult = new ArrayList<>();
+ expectedResult.add((LocalDateTimeSample)pm.getObjectById(oidOfLocalDateTime1));
+
+ Query q = pm.newQuery(LocalDateTimeSample.class, filter);
+ List<LocalDateTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(LocalDateTimeSample.class);
+ insertLocalDateTimeSampleData(getPM());
+ }
+
+ /** */
+ private void insertLocalDateTimeSampleData(PersistenceManager pm) {
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ LocalDateTimeSample lds1 = new LocalDateTimeSample();
+ lds1.setId(1);
+ LocalDateTime localDateTime1 = LocalDateTime.of(2017, Month.SEPTEMBER, 12, 14,
10, 25);
+ lds1.setLocalDateTime(localDateTime1);
+ pm.makePersistent(lds1);
+
+ LocalDateTimeSample lds2 = new LocalDateTimeSample();
+ lds2.setId(2);
+ LocalDateTime localDateTime2 = LocalDateTime.of(2017, Month.AUGUST, 20, 9, 22,
12);
+ lds2.setLocalDateTime(localDateTime2);
+ pm.makePersistent(lds2);
+
+ tx.commit();
+ oidOfLocalDateTime1 = pm.getObjectId(lds1);
+ oidOfLocalDateTime2 = pm.getObjectId(lds2);
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+}
Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java?rev=1808943&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java
(added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/jdoql/methods/SupportedLocalTimeMethods.java
Tue Sep 19 21:02:49 2017
@@ -0,0 +1,169 @@
+/*
+ * 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.methods;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.query.LocalTimeSample;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+import java.time.LocalTime;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *<B>Title:</B> Supported LocalTime methods.
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> A14.6.2-60.
+ *<BR>
+ *<B>Assertion Description: </B>
+ * New supported LocalTime methods:
+ * <ul>
+ * <li>getHour()</li>
+ * <li>getMinute()</li>
+ * <li>getSecond()</li>
+ * </ul>
+ */
+public class SupportedLocalTimeMethods extends QueryTest {
+
+ /** */
+ private static final String ASSERTION_FAILED =
+ "Assertion A14.6.2-60 (SupportedLocalTimeMethods) failed: ";
+
+ /** */
+ private Object oidOfLocalTime1;
+
+ /** */
+ private Object oidOfLocalTime2;
+
+ /**
+ * 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(SupportedLocalTimeMethods.class);
+ }
+
+ /** */
+ public void testHour() {
+ final String filter = "localTime.getHour() == 14";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalTimeSample> expectedResult = new ArrayList();
+ expectedResult.add((LocalTimeSample)pm.getObjectById(oidOfLocalTime1));
+
+ Query q = pm.newQuery(LocalTimeSample.class, filter);
+ List<LocalTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testMinute() {
+ final String filter = "localTime.getMinute() == 22";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalTimeSample> expectedResult = new ArrayList();
+ expectedResult.add((LocalTimeSample)pm.getObjectById(oidOfLocalTime2));
+
+ Query q = pm.newQuery(LocalTimeSample.class, filter);
+ List<LocalTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /** */
+ public void testSecond() {
+ final String filter = "localTime.getSecond() == 25";
+ PersistenceManager pm = getPM();
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+ List<LocalTimeSample> expectedResult = new ArrayList();
+ expectedResult.add((LocalTimeSample)pm.getObjectById(oidOfLocalTime1));
+
+ Query q = pm.newQuery(LocalTimeSample.class, filter);
+ List<LocalTimeSample> results = q.executeList();
+ checkQueryResultWithoutOrder(ASSERTION_FAILED, filter, results, expectedResult);
+ tx.commit();
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+
+ /**
+ * @see JDO_Test#localSetUp()
+ */
+ protected void localSetUp() {
+ addTearDownClass(LocalTimeSample.class);
+ insertLocalTimeSampleData(getPM());
+ }
+
+ /** */
+ private void insertLocalTimeSampleData(PersistenceManager pm) {
+ Transaction tx = pm.currentTransaction();
+ try {
+ tx.begin();
+
+ LocalTimeSample lds1 = new LocalTimeSample();
+ lds1.setId(1);
+ LocalTime localTime1 = LocalTime.of(14, 10, 25);
+ lds1.setLocalTime(localTime1);
+ pm.makePersistent(lds1);
+
+ LocalTimeSample lds2 = new LocalTimeSample();
+ lds2.setId(2);
+ LocalTime localTime2 = LocalTime.of(9, 22, 12);
+ lds2.setLocalTime(localTime2);
+ pm.makePersistent(lds2);
+
+ tx.commit();
+ oidOfLocalTime1 = pm.getObjectId(lds1);
+ oidOfLocalTime2 = pm.getObjectId(lds2);
+ tx = null;
+ }
+ finally {
+ if ((tx != null) && tx.isActive())
+ tx.rollback();
+ }
+ }
+}
Modified: db/jdo/trunk/tck/src/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo (original)
+++ db/jdo/trunk/tck/src/jdo/applicationidentity/org/apache/jdo/tck/pc/query/package.jdo Tue
Sep 19 21:02:49 2017
@@ -37,7 +37,22 @@
<field name="time" persistence-modifier="persistent"/>
</class>
- <class name="OptionalSample" identity-type="application">
+ <class name="LocalDateSample" identity-type="application">
+ <field name="id" primary-key="true"/>
+ <field name="localDate" persistence-modifier="persistent"/>
+ </class>
+
+ <class name="LocalDateTimeSample" identity-type="application">
+ <field name="id" primary-key="true"/>
+ <field name="localDateTime" persistence-modifier="persistent"/>
+ </class>
+
+ <class name="LocalTimeSample" identity-type="application">
+ <field name="id" primary-key="true"/>
+ <field name="localTime" persistence-modifier="persistent"/>
+ </class>
+
+ <class name="OptionalSample" identity-type="application">
<field name="id" primary-key="true"/>
<field name="optionalPC"
field-type="org.apache.jdo.tck.pc.query.OptionalSample"
Modified: db/jdo/trunk/tck/src/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo (original)
+++ db/jdo/trunk/tck/src/jdo/datastoreidentity/org/apache/jdo/tck/pc/query/package.jdo Tue
Sep 19 21:02:49 2017
@@ -28,6 +28,18 @@
<field name="time" persistence-modifier="persistent"/>
</class>
+ <class name="LocalDateSample">
+ <field name="localDate" persistence-modifier="persistent"/>
+ </class>
+
+ <class name="LocalDateTimeSample">
+ <field name="localDateTime" persistence-modifier="persistent"/>
+ </class>
+
+ <class name="LocalTimeSample">
+ <field name="localTime" persistence-modifier="persistent"/>
+ </class>
+
<class name="OptionalSample">
<field name="optionalPC"
field-type="org.apache.jdo.tck.pc.query.OptionalSample"
Modified: db/jdo/trunk/tck/src/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-standard.orm
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-standard.orm?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-standard.orm
(original)
+++ db/jdo/trunk/tck/src/orm/applicationidentity/org/apache/jdo/tck/pc/query/package-standard.orm
Tue Sep 19 21:02:49 2017
@@ -34,6 +34,21 @@
<field name="time" column="TIME"/>
</class>
+ <class name="LocalDateSample" table="LocalDateSample">
+ <field name="id" column="ID"/>
+ <field name="localDate" column="LOCAL_DATE"/>
+ </class>
+
+ <class name="LocalDateTimeSample" table="LocalDateTimeSample">
+ <field name="id" column="ID"/>
+ <field name="localDateTime" column="LOCAL_DATE_TIME"/>
+ </class>
+
+ <class name="LocalTimeSample" table="LocalTimeSample">
+ <field name="id" column="ID"/>
+ <field name="localTime" column="LOCAL_TIME"/>
+ </class>
+
<class name="OptionalSample" table="OptionalSample">
<field name="id" column="ID"/>
<field name="optionalPC">
Modified: db/jdo/trunk/tck/src/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-standard.orm
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-standard.orm?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-standard.orm
(original)
+++ db/jdo/trunk/tck/src/orm/datastoreidentity/org/apache/jdo/tck/pc/query/package-standard.orm
Tue Sep 19 21:02:49 2017
@@ -40,7 +40,25 @@ This file contains the schema informatio
<field name="time" column="TIME"/>
</class>
- <class name="OptionalSample" table="OptionalSample">
+ <class name="LocalDateSample" table="LocalDateSample">
+ <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+ <field name="id" column="ID"/>
+ <field name="localDate" column="LOCAL_DATE"/>
+ </class>
+
+ <class name="LocalDateTimeSample" table="LocalDateTimeSample">
+ <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+ <field name="id" column="ID"/>
+ <field name="localDateTime" column="LOCAL_DATE_TIME"/>
+ </class>
+
+ <class name="LocalTimeSample" table="LocalTimeSample">
+ <datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
+ <field name="id" column="ID"/>
+ <field name="localTime" column="LOCAL_TIME"/>
+ </class>
+
+ <class name="OptionalSample" table="OptionalSample">
<datastore-identity strategy="identity" column="DATASTORE_IDENTITY"/>
<field name="id" column="ID"/>
<field name="optionalPC">
Modified: db/jdo/trunk/tck/src/sql/derby/applicationidentity/schema.sql
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/sql/derby/applicationidentity/schema.sql?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/sql/derby/applicationidentity/schema.sql (original)
+++ db/jdo/trunk/tck/src/sql/derby/applicationidentity/schema.sql Tue Sep 19 21:02:49 2017
@@ -155,6 +155,24 @@ CREATE TABLE TimeSample (
CONSTRAINT TIMESAMPLE_PK PRIMARY KEY (ID)
);
+CREATE TABLE LocalDateSample (
+ ID INTEGER NOT NULL,
+ LOCAL_DATE DATE,
+ CONSTRAINT LOCALDATESAMPLE_PK PRIMARY KEY (ID)
+);
+
+CREATE TABLE LocalDateTimeSample (
+ ID INTEGER NOT NULL,
+ LOCAL_DATE_TIME TIMESTAMP,
+ CONSTRAINT LOCALDATETIMESAMPLE_PK PRIMARY KEY (ID)
+);
+
+CREATE TABLE LocalTimeSample (
+ ID INTEGER NOT NULL,
+ LOCAL_TIME TIME,
+ CONSTRAINT LOCALTIMESAMPLE_PK PRIMARY KEY (ID)
+);
+
CREATE TABLE OptionalSample (
ID INTEGER NOT NULL,
OPTIONAL_PC INTEGER REFERENCES OptionalSample ON DELETE NO ACTION,
Modified: db/jdo/trunk/tck/src/sql/derby/datastoreidentity/schema.sql
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/sql/derby/datastoreidentity/schema.sql?rev=1808943&r1=1808942&r2=1808943&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/sql/derby/datastoreidentity/schema.sql (original)
+++ db/jdo/trunk/tck/src/sql/derby/datastoreidentity/schema.sql Tue Sep 19 21:02:49 2017
@@ -144,6 +144,27 @@ CREATE TABLE TimeSample (
CONSTRAINT TIMESAMPLE_PK PRIMARY KEY (DATASTORE_IDENTITY)
);
+CREATE TABLE LocalDateSample (
+ DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+ ID INTEGER NOT NULL,
+ LOCAL_DATE DATE,
+ CONSTRAINT LOCALDATESAMPLE_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+CREATE TABLE LocalDateTimeSample (
+ DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+ ID INTEGER NOT NULL,
+ LOCAL_DATE_TIME TIMESTAMP,
+ CONSTRAINT LOCALDATETIMESAMPLE_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
+CREATE TABLE LocalTimeSample (
+ DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
+ ID INTEGER NOT NULL,
+ LOCAL_TIME TIME,
+ CONSTRAINT LOCALTIMESAMPLE_PK PRIMARY KEY (DATASTORE_IDENTITY)
+);
+
CREATE TABLE OptionalSample (
DATASTORE_IDENTITY INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY,
ID INTEGER NOT NULL,
|