Browse Source

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
pull/47381/head
Phillip Webb 3 months ago
parent
commit
82795f9966
  1. 1
      core/spring-boot-test/build.gradle
  2. 2
      core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java
  3. 10
      core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java
  4. 4
      core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/package-info.java
  5. 1
      core/spring-boot-test/src/main/resources/META-INF/spring.factories
  6. 2
      core/spring-boot-test/src/test/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java
  7. 4
      module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories

1
core/spring-boot-test/build.gradle

@ -33,6 +33,7 @@ dependencies { @@ -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")

2
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java → core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesBeanPostProcessor.java

@ -14,7 +14,7 @@ @@ -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;

10
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java → core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactory.java

@ -14,7 +14,7 @@ @@ -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; @@ -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;

4
module/spring-boot-web-server-test/src/main/java/org/springframework/boot/web/server/test/reactor/netty/package-info.java → core/spring-boot-test/src/main/java/org/springframework/boot/test/http/client/package-info.java

@ -15,9 +15,9 @@ @@ -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;

1
core/spring-boot-test/src/main/resources/META-INF/spring.factories

@ -4,6 +4,7 @@ org.springframework.boot.test.context.ImportsContextCustomizerFactory,\ @@ -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

2
module/spring-boot-web-server-test/src/test/java/org/springframework/boot/web/server/test/reactor/netty/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java → core/spring-boot-test/src/test/java/org/springframework/boot/test/http/client/DisableReactorResourceFactoryGlobalResourcesContextCustomizerFactoryTests.java

@ -14,7 +14,7 @@ @@ -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;

4
module/spring-boot-web-server-test/src/main/resources/META-INF/spring.factories

@ -1,7 +1,3 @@ @@ -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

Loading…
Cancel
Save