From baadf28fc30713e1fd6d80cbced26e4e17bdb727 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 5 Jun 2025 12:24:28 +0100 Subject: [PATCH] Move MultipartAutoConfigurationTests to main code's module --- .../spring-boot-autoconfigure-all/build.gradle | 4 ---- .../spring-boot-servlet/build.gradle | 9 +++++++++ .../MultipartAutoConfigurationTests.java | 13 +++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) rename spring-boot-project/{spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet => spring-boot-servlet/src/test/java/org/springframework/boot/servlet/autoconfigure}/MultipartAutoConfigurationTests.java (96%) diff --git a/spring-boot-project/spring-boot-autoconfigure-all/build.gradle b/spring-boot-project/spring-boot-autoconfigure-all/build.gradle index 5e4f53c90d..c9e7037f59 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure-all/build.gradle @@ -29,7 +29,3 @@ dependencies { testRuntimeOnly("org.apache.httpcomponents.client5:httpclient5") } - -test { - jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED" -} diff --git a/spring-boot-project/spring-boot-servlet/build.gradle b/spring-boot-project/spring-boot-servlet/build.gradle index 69aabf7a7d..5b00c281f5 100644 --- a/spring-boot-project/spring-boot-servlet/build.gradle +++ b/spring-boot-project/spring-boot-servlet/build.gradle @@ -18,8 +18,17 @@ dependencies { optional("jakarta.servlet:jakarta.servlet-api") optional("org.springframework.security:spring-security-config") + testImplementation(project(":spring-boot-project:spring-boot-jetty")) testImplementation(project(":spring-boot-project:spring-boot-test")) + testImplementation(project(":spring-boot-project:spring-boot-tomcat")) testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) + testImplementation(project(":spring-boot-project:spring-boot-undertow")) + testImplementation("org.springframework:spring-webmvc") testRuntimeOnly("ch.qos.logback:logback-classic") + testRuntimeOnly("org.apache.httpcomponents.client5:httpclient5") +} + +tasks.named("test") { + jvmArgs += "--add-opens=java.base/java.net=ALL-UNNAMED" } diff --git a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java b/spring-boot-project/spring-boot-servlet/src/test/java/org/springframework/boot/servlet/autoconfigure/MultipartAutoConfigurationTests.java similarity index 96% rename from spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java rename to spring-boot-project/spring-boot-servlet/src/test/java/org/springframework/boot/servlet/autoconfigure/MultipartAutoConfigurationTests.java index 92e38ef943..e847ac885a 100644 --- a/spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-servlet/src/test/java/org/springframework/boot/servlet/autoconfigure/MultipartAutoConfigurationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.autoconfigure.web.servlet; +package org.springframework.boot.servlet.autoconfigure; import java.net.URI; import java.util.stream.Stream; @@ -28,8 +28,6 @@ import org.junit.jupiter.params.provider.MethodSource; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.jetty.servlet.JettyServletWebServerFactory; -import org.springframework.boot.servlet.autoconfigure.MultipartAutoConfiguration; -import org.springframework.boot.servlet.autoconfigure.MultipartProperties; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.testsupport.classpath.ForkedClassPath; import org.springframework.boot.testsupport.web.servlet.DirtiesUrlFactories; @@ -38,7 +36,6 @@ import org.springframework.boot.tomcat.servlet.TomcatServletWebServerFactory; import org.springframework.boot.undertow.servlet.UndertowServletWebServerFactory; import org.springframework.boot.web.server.autoconfigure.ServerProperties; import org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext; -import org.springframework.boot.webmvc.autoconfigure.DispatcherServletAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -267,8 +264,7 @@ class MultipartAutoConfigurationTests { } @Configuration(proxyBeanMethods = false) - @Import({ TomcatServletWebServerAutoConfiguration.class, DispatcherServletAutoConfiguration.class, - MultipartAutoConfiguration.class }) + @Import({ TomcatServletWebServerAutoConfiguration.class, MultipartAutoConfiguration.class }) @EnableConfigurationProperties(MultipartProperties.class) static class BaseConfiguration { @@ -279,6 +275,11 @@ class MultipartAutoConfigurationTests { return properties; } + @Bean + DispatcherServlet dispatcherServlet() { + return new DispatcherServlet(); + } + } @Configuration(proxyBeanMethods = false)