Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-boot-test 2.4.0 WebTestClient creation exception #24305

Closed
lyoumi opened this issue Dec 1, 2020 · 1 comment
Closed

spring-boot-test 2.4.0 WebTestClient creation exception #24305

lyoumi opened this issue Dec 1, 2020 · 1 comment
Labels
status: duplicate A duplicate of another issue

Comments

@lyoumi
Copy link

lyoumi commented Dec 1, 2020

Since spring-boot-test 2.4.0 update I got org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.test.web.reactive.server.WebTestClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No suitable default ClientHttpConnector found but when I check maven dependencies no reactive dependencies was found. After investigation I found discrepancy between spring-boot-test:2.3.5.RELEASE and spring-boot-test:2.4.0 in WebTestClientContextCustomizerFactory:

2.3.5.RELEASE (and earlier):

    public ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes> configAttributes) {
        return this.isWebClientPresent() && AnnotatedElementUtils.findMergedAnnotation(testClass, SpringBootTest.class) != null ? new WebTestClientContextCustomizer() : null;
    }

    private boolean isWebClientPresent() {
        return ClassUtils.isPresent("org.springframework.web.reactive.function.client.WebClient", this.getClass().getClassLoader());
    }

2.4.0:

	public ContextCustomizer createContextCustomizer(Class<?> testClass, List<ContextConfigurationAttributes> configAttributes) {
		SpringBootTest springBootTest = TestContextAnnotationUtils.findMergedAnnotation(testClass, SpringBootTest.class);
		return (springBootTest != null) ? new WebTestClientContextCustomizer() : null;
	}

	private boolean isWebClientPresent() {
		return ClassUtils.isPresent("org.springframework.web.reactive.function.client.WebClient", getClass().getClassLoader());
	}

If I'm correct there is no notes about this update at 2.4.0 release notes page. Could you check it and reply how to resolve this case?
Expected behaviour: no exceptions during test run because no WebClient present in classpath.
Actual behaviour: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.test.web.reactive.server.WebTestClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: No suitable default ClientHttpConnector found

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2020
@philwebb
Copy link
Member

philwebb commented Dec 1, 2020

Thanks for the report. This is a duplicate of #24152 which has been fixed on master and will be in 2.4.1.

@philwebb philwebb closed this as completed Dec 1, 2020
@philwebb philwebb added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants