From 7227c30917378b168d04f724930a5b53f132b3ef Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 8 Jul 2024 19:42:28 +0200 Subject: [PATCH 1/2] Allow tests to pass on Windows JVM (non-UTF-8 default encoding) See gh-33071 --- ...WebFluxViewResolutionIntegrationTests.java | 4 +-- .../ViewResolutionIntegrationTests.java | 28 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxViewResolutionIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxViewResolutionIntegrationTests.java index df1ccbd312..0f25c773e0 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxViewResolutionIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/config/WebFluxViewResolutionIntegrationTests.java @@ -70,8 +70,8 @@ class WebFluxViewResolutionIntegrationTests { @Test void freemarkerWithInvalidConfig() { assertThatRuntimeException() - .isThrownBy(() -> runTest(InvalidFreeMarkerWebFluxConfig.class)) - .withMessageContaining("In addition to a FreeMarker view resolver "); + .isThrownBy(() -> runTest(InvalidFreeMarkerWebFluxConfig.class)) + .withMessageContaining("In addition to a FreeMarker view resolver "); } @Test diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java index 573a7cd5a2..1d1a64e8d1 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/config/annotation/ViewResolutionIntegrationTests.java @@ -18,7 +18,6 @@ package org.springframework.web.servlet.config.annotation; import java.nio.charset.StandardCharsets; -import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -51,11 +50,7 @@ class ViewResolutionIntegrationTests { private static final String EXPECTED_BODY = "Hello, Java Café"; - - @BeforeAll - static void verifyDefaultFileEncoding() { - assertThat(System.getProperty("file.encoding")).as("JVM default file encoding").isEqualTo("UTF-8"); - } + private static final boolean utf8Default = StandardCharsets.UTF_8.name().equals(System.getProperty("file.encoding")); @Nested @@ -64,15 +59,17 @@ class ViewResolutionIntegrationTests { @Test void freemarkerWithInvalidConfig() { assertThatRuntimeException() - .isThrownBy(() -> runTest(InvalidFreeMarkerWebConfig.class)) - .withMessageContaining("In addition to a FreeMarker view resolver "); + .isThrownBy(() -> runTest(InvalidFreeMarkerWebConfig.class)) + .withMessageContaining("In addition to a FreeMarker view resolver "); } @Test void freemarkerWithDefaults() throws Exception { MockHttpServletResponse response = runTest(FreeMarkerWebConfig.class); assertThat(response.isCharset()).as("character encoding set in response").isTrue(); - assertThat(response.getContentAsString()).isEqualTo(EXPECTED_BODY); + if (utf8Default) { + assertThat(response.getContentAsString()).isEqualTo(EXPECTED_BODY); + } // Prior to Spring Framework 6.2, the charset is not updated in the Content-Type. // Thus, we expect ISO-8859-1 instead of UTF-8. assertThat(response.getCharacterEncoding()).isEqualTo("ISO-8859-1"); @@ -83,7 +80,9 @@ class ViewResolutionIntegrationTests { void freemarkerWithExistingViewResolver() throws Exception { MockHttpServletResponse response = runTest(ExistingViewResolverConfig.class); assertThat(response.isCharset()).as("character encoding set in response").isTrue(); - assertThat(response.getContentAsString()).isEqualTo(EXPECTED_BODY); + if (utf8Default) { + assertThat(response.getContentAsString()).isEqualTo(EXPECTED_BODY); + } // Prior to Spring Framework 6.2, the charset is not updated in the Content-Type. // Thus, we expect ISO-8859-1 instead of UTF-8. assertThat(response.getCharacterEncoding()).isEqualTo("ISO-8859-1"); @@ -190,20 +189,23 @@ class ViewResolutionIntegrationTests { } } + @Nested class GroovyMarkupTests { @Test void groovyMarkupInvalidConfig() { assertThatRuntimeException() - .isThrownBy(() -> runTest(InvalidGroovyMarkupWebConfig.class)) - .withMessageContaining("In addition to a Groovy markup view resolver "); + .isThrownBy(() -> runTest(InvalidGroovyMarkupWebConfig.class)) + .withMessageContaining("In addition to a Groovy markup view resolver "); } @Test void groovyMarkup() throws Exception { MockHttpServletResponse response = runTest(GroovyMarkupWebConfig.class); - assertThat(response.getContentAsString()).isEqualTo(EXPECTED_BODY); + if (utf8Default) { + assertThat(response.getContentAsString()).isEqualTo(EXPECTED_BODY); + } } From 7322a0d3c5dbd5b7b4a14cbd6a1d6609c2ae58f6 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 8 Jul 2024 19:43:19 +0200 Subject: [PATCH 2/2] Upgrade to Groovy 4.0.22, Tomcat 10.1.25, Jetty 12.0.11, Undertow 2.3.14 --- framework-platform/framework-platform.gradle | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/framework-platform/framework-platform.gradle b/framework-platform/framework-platform.gradle index 6d3c3bbc12..57476241f9 100644 --- a/framework-platform/framework-platform.gradle +++ b/framework-platform/framework-platform.gradle @@ -13,11 +13,11 @@ dependencies { api(platform("io.netty:netty5-bom:5.0.0.Alpha5")) api(platform("io.projectreactor:reactor-bom:2023.0.7")) api(platform("io.rsocket:rsocket-bom:1.1.3")) - api(platform("org.apache.groovy:groovy-bom:4.0.21")) + api(platform("org.apache.groovy:groovy-bom:4.0.22")) api(platform("org.apache.logging.log4j:log4j-bom:2.21.1")) api(platform("org.assertj:assertj-bom:3.26.0")) - api(platform("org.eclipse.jetty:jetty-bom:12.0.10")) - api(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.10")) + api(platform("org.eclipse.jetty:jetty-bom:12.0.11")) + api(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.11")) api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.7.3")) api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.0")) api(platform("org.junit:junit-bom:5.10.3")) @@ -55,9 +55,9 @@ dependencies { api("io.r2dbc:r2dbc-spi:1.0.0.RELEASE") api("io.reactivex.rxjava3:rxjava:3.1.8") api("io.smallrye.reactive:mutiny:1.10.0") - api("io.undertow:undertow-core:2.3.13.Final") - api("io.undertow:undertow-servlet:2.3.13.Final") - api("io.undertow:undertow-websockets-jsr:2.3.13.Final") + api("io.undertow:undertow-core:2.3.14.Final") + api("io.undertow:undertow-servlet:2.3.14.Final") + api("io.undertow:undertow-websockets-jsr:2.3.14.Final") api("io.vavr:vavr:0.10.4") api("jakarta.activation:jakarta.activation-api:2.0.1") api("jakarta.annotation:jakarta.annotation-api:2.0.0") @@ -101,12 +101,12 @@ dependencies { api("org.apache.derby:derbyclient:10.16.1.1") api("org.apache.derby:derbytools:10.16.1.1") api("org.apache.httpcomponents.client5:httpclient5:5.3.1") - api("org.apache.httpcomponents.core5:httpcore5-reactive:5.2.4") + api("org.apache.httpcomponents.core5:httpcore5-reactive:5.2.5") api("org.apache.poi:poi-ooxml:5.2.5") - api("org.apache.tomcat.embed:tomcat-embed-core:10.1.24") - api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.24") - api("org.apache.tomcat:tomcat-util:10.1.24") - api("org.apache.tomcat:tomcat-websocket:10.1.24") + api("org.apache.tomcat.embed:tomcat-embed-core:10.1.25") + api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.25") + api("org.apache.tomcat:tomcat-util:10.1.25") + api("org.apache.tomcat:tomcat-websocket:10.1.25") api("org.aspectj:aspectjrt:1.9.22.1") api("org.aspectj:aspectjtools:1.9.22.1") api("org.aspectj:aspectjweaver:1.9.22.1") @@ -115,7 +115,7 @@ dependencies { api("org.codehaus.jettison:jettison:1.5.4") api("org.crac:crac:1.4.0") api("org.dom4j:dom4j:2.1.4") - api("org.eclipse.jetty:jetty-reactive-httpclient:4.0.4") + api("org.eclipse.jetty:jetty-reactive-httpclient:4.0.5") api("org.eclipse.persistence:org.eclipse.persistence.jpa:3.0.4") api("org.eclipse:yasson:2.0.4") api("org.ehcache:ehcache:3.10.8")