diff --git a/core/spring-boot-test/build.gradle b/core/spring-boot-test/build.gradle index 3ef5e388292..64269caf640 100644 --- a/core/spring-boot-test/build.gradle +++ b/core/spring-boot-test/build.gradle @@ -33,6 +33,7 @@ dependencies { optional("jakarta.json.bind:jakarta.json.bind-api") optional("jakarta.servlet:jakarta.servlet-api") optional("junit:junit") + optional("io.projectreactor.netty:reactor-netty-http") optional("org.assertj:assertj-core") optional("org.hamcrest:hamcrest-core") optional("org.hamcrest:hamcrest-library") diff --git a/module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java similarity index 95% rename from module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java index f015fcbad61..dd018a3361a 100644 --- a/module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.web.server.test.reactor.netty; +package org.springframework.boot.test.http.client; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; diff --git a/module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java similarity index 84% rename from module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java index 33470900473..9c4dbb0d6d0 100644 --- a/module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.web.server.test.reactor.netty; +package org.springframework.boot.test.http.client; import java.util.List; @@ -36,12 +36,16 @@ import org.springframework.util.ClassUtils; */ class DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory implements ContextCustomizerFactory { - String REACTOR_RESOURCE_FACTORY_CLASS = "org.springframework.http.client.ReactorResourceFactory"; + private static final String REACTOR_RESOURCE_FACTORY_CLASS = "org.springframework.http.client.ReactorResourceFactory"; + + private static final String REACTOR_NETTY_CLASS = "reactor.netty.ReactorNetty"; @Override public @Nullable ContextCustomizer createContextCustomizer(Class testClass, List configAttributes) { - if (ClassUtils.isPresent(this.REACTOR_RESOURCE_FACTORY_CLASS, testClass.getClassLoader())) { + ClassLoader classLoader = testClass.getClassLoader(); + if (ClassUtils.isPresent(REACTOR_RESOURCE_FACTORY_CLASS, classLoader) + && ClassUtils.isPresent(REACTOR_NETTY_CLASS, classLoader)) { return new DisableReactorResourceFactoryGlobalResourcesContextCustomizerCustomizer(); } return null; diff --git a/module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/package-info.java b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/package-info.java similarity index 85% rename from module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/package-info.java rename to core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/package-info.java index 3a652551542..ee2f8adb887 100644 --- a/module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/package-info.java +++ b/core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/package-info.java @@ -15,9 +15,9 @@ */ /** - * Spring Boot support for testing Reactor Netty. + * Spring Boot support for HTTP client testing. */ @NullMarked -package org.springframework.boot.web.server.test.reactor.netty; +package org.springframework.boot.test.http.client; import org.jspecify.annotations.NullMarked; diff --git a/core/spring-boot-test/src/main/resources/META-INF/spring.factories b/core/spring-boot-test/src/main/resources/META-INF/spring.factories index 6ab6fb5634f..74b012ead52 100644 --- a/core/spring-boot-test/src/main/resources/META-INF/spring.factories +++ b/core/spring-boot-test/src/main/resources/META-INF/spring.factories @@ -4,6 +4,7 @@ org.springframework.boot.test.context.ImportsContextCustomizerFactory,\ org.springframework.boot.test.context.PropertyMappingContextCustomizerFactory,\ org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizerFactory,\ org.springframework.boot.test.context.filter.annotation.TypeExcludeFiltersContextCustomizerFactory,\ +org.springframework.boot.test.http.client.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory,\ org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory,\ org.springframework.boot.test.web.reactive.client.WebTestClientContextCustomizerFactory,\ org.springframework.boot.test.web.servlet.client.RestTestClientContextCustomizerFactory diff --git a/module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java b/core/spring-boot-test/src/test/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java similarity index 96% rename from module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java rename to core/spring-boot-test/src/test/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java index 4dc118dd265..04baaa02a42 100644 --- a/module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java +++ b/core/spring-boot-test/src/test/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.web.server.test.reactor.netty; +package org.springframework.boot.test.http.client; import org.junit.jupiter.api.Test; diff --git a/module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories b/module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories index e19a044d420..b0f03622985 100644 --- a/module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories +++ b/module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories @@ -1,7 +1,3 @@ # Environment Post Processors org.springframework.boot.EnvironmentPostProcessor=\ org.springframework.boot.web.server.test.SpringBootTestRandomPortEnvironmentPostProcessor - -# Spring Test Context Customizer Factories -org.springframework.test.context.ContextCustomizerFactory=\ -org.springframework.boot.web.server.test.reactor.netty.DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory