Move `DisableReactorResourceFactory...` to spring-boot-test

Move `DisableReactorResourceFactoryGlobalResources...` support from
`spring-boot-web-server-test` back to `spring-boot-test` since it's
useful if Reactor Netty is being used directly and removes the need
for the `spring-boot-web-server-test` dependency.

See gh-46356
See gh-47322
This commit is contained in:
Phillip Webb 2025-09-30 11:36:52 -07:00
parent 7c8a15629b
commit 82795f9966
7 changed files with 13 additions and 11 deletions

View File

@ -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")

View File

@ -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;

View File

@ -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<ContextConfigurationAttributes> 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;

View File

@ -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;

View File

@ -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

View File

@ -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