You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ja...@apache.org on 2025/05/20 21:23:07 UTC
(grails-core) 01/02: Update tests for Java 20+
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch java-20-date-time-formatting
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit c46d303812a2e9d4a26ead28699494ff148ac741
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Tue May 20 17:22:07 2025 -0400
Update tests for Java 20+
---
.../plugins/web/DefaultDateHelperSpec.groovy | 50 +++++++++++++++++++---
1 file changed, 45 insertions(+), 5 deletions(-)
diff --git a/grails-gsp/plugin/src/test/groovy/org/grails/plugins/web/DefaultDateHelperSpec.groovy b/grails-gsp/plugin/src/test/groovy/org/grails/plugins/web/DefaultDateHelperSpec.groovy
index 804f57f234..3cc1bc344f 100644
--- a/grails-gsp/plugin/src/test/groovy/org/grails/plugins/web/DefaultDateHelperSpec.groovy
+++ b/grails-gsp/plugin/src/test/groovy/org/grails/plugins/web/DefaultDateHelperSpec.groovy
@@ -96,10 +96,9 @@ class DefaultDateHelperSpec extends Specification {
null | '8:00 AM'
}
- @PendingFeature
- @Requires({ !Jvm.current.isJava17() })
+ @Requires({ Jvm.current.isJava20Compatible() })
@Unroll
- void "Java 21+ - Full getTimeFormat for style #style returns #expected"(String style, String expected) {
+ void "Java 20+ - getTimeFormat for style #style returns #expected"(String style, String expected) {
given:
DateTimeFormatter format
@@ -111,8 +110,10 @@ class DefaultDateHelperSpec extends Specification {
format.format(localTime) == expected
where:
- style | expected
- 'FULL' | '8:00:00 AM UTC'
+ style | expected
+ 'LONG' | '8:00:00 AM UTC'
+ 'MEDIUM' | '8:00:00 AM'
+ null | '8:00 AM'
}
@Requires({ Jvm.current.isJava17() })
@@ -133,6 +134,24 @@ class DefaultDateHelperSpec extends Specification {
'FULL' | '8:00:00 AM Coordinated Universal Time'
}
+ @Requires({ Jvm.current.isJava20Compatible() })
+ @Unroll
+ void "Java 20+ - Full getTimeFormat for style #style returns #expected"(String style, String expected) {
+ given:
+ DateTimeFormatter format
+
+ when:
+ format = helper.getTimeFormat(style, ZoneId.of('UTC'), Locale.ENGLISH)
+
+ then:
+ format.zone == ZoneId.of('UTC')
+ format.format(localTime) == expected
+
+ where:
+ style | expected
+ 'FULL' | '8:00:00 AM Coordinated Universal Time'
+ }
+
@Requires({ jvm.isJava8() })
@Unroll("for getDateTimeFormat(#dateStyle, #timeStyle) => #expected")
void "Java 8 - test getDateTimeFormat"(String dateStyle, String timeStyle, String expected) {
@@ -175,6 +194,27 @@ class DefaultDateHelperSpec extends Specification {
null | null | '1/5/41, 8:00 AM'
}
+ @Requires({ Jvm.current.isJava20Compatible() })
+ @Unroll("for getDateTimeFormat(#dateStyle, #timeStyle) => #expected")
+ void "Java 20+ - test getDateTimeFormat"(String dateStyle, String timeStyle, String expected) {
+ given:
+ DateTimeFormatter format
+
+ when:
+ format = helper.getDateTimeFormat(dateStyle, timeStyle, ZoneId.of('UTC'), Locale.ENGLISH)
+
+ then:
+ format.zone == ZoneId.of('UTC')
+ format.format(LocalDateTime.of(localDate, localTime)) == expected
+
+ where:
+ dateStyle | timeStyle | expected
+ 'FULL' | 'FULL' | 'Sunday, January 5, 1941, 8:00:00 AM Coordinated Universal Time'
+ 'LONG' | 'LONG' | 'January 5, 1941, 8:00:00 AM UTC'
+ 'MEDIUM' | 'MEDIUM' | 'Jan 5, 1941, 8:00:00 AM'
+ null | null | '1/5/41, 8:00 AM'
+ }
+
void "test supportsDatePickers"() {
expect:
helper.supportsDatePicker(Date)