Disable WebTestClientContextCustomizer after AOT processing
After AOT processing, a WebTestClient bean will be defined directly so the context customizer that initiates its registration is not needed. Closes gh-32859
This commit is contained in:
@@ -18,6 +18,7 @@ package org.springframework.boot.test.web.reactive.server;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.aot.AotDetector;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
@@ -58,6 +59,9 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
|
||||
@Override
|
||||
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
|
||||
if (AotDetector.useGeneratedArtifacts()) {
|
||||
return;
|
||||
}
|
||||
SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(mergedConfig.getTestClass(),
|
||||
SpringBootTest.class);
|
||||
if (springBootTest.webEnvironment().isEmbedded()) {
|
||||
@@ -109,6 +113,9 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
|
||||
|
||||
@Override
|
||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
|
||||
if (AotDetector.useGeneratedArtifacts()) {
|
||||
return;
|
||||
}
|
||||
if (BeanFactoryUtils.beanNamesForTypeIncludingAncestors((ListableBeanFactory) this.beanFactory,
|
||||
WebTestClient.class, false, false).length == 0) {
|
||||
registry.registerBeanDefinition(WebTestClient.class.getName(),
|
||||
|
||||
Reference in New Issue
Block a user