Skip to content

Add AddAutoConfigureWebTestClient recipe and support old TestRestTemplate location#922

Merged
MBoegers merged 3 commits intomainfrom
MBoegers/support-old-testresttemplate-location
Jan 28, 2026
Merged

Add AddAutoConfigureWebTestClient recipe and support old TestRestTemplate location#922
MBoegers merged 3 commits intomainfrom
MBoegers/support-old-testresttemplate-location

Conversation

@MBoegers
Copy link
Contributor

@MBoegers MBoegers commented Jan 28, 2026

Summary

  • Adds new AddAutoConfigureWebTestClient recipe for Spring Boot 4 migration
  • Updates AddAutoConfigureTestRestTemplate to detect both old (org.springframework.boot.test.web.client.TestRestTemplate) and new (org.springframework.boot.resttestclient.TestRestTemplate) package locations

Spring Boot 4 no longer auto-configures WebTestClient and TestRestTemplate in @SpringBootTest classes, so users need to add the explicit autoconfigure annotations.

See migration guide: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide#using-webclient-or-testresttemplate-and-springboottest

Test plan

  • Unit tests for AddAutoConfigureWebTestClient recipe
  • Unit tests for old TestRestTemplate location in AddAutoConfigureTestRestTemplate
  • Recipe CSV validation passes

…late location

Spring Boot 4 no longer auto-configures WebTestClient and TestRestTemplate in
@SpringBootTest classes. This adds a new recipe for WebTestClient and updates
the existing TestRestTemplate recipe to detect both old and new package locations.

See: moderneinc/rewrite-spring#115
Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved other than the missing reference; realistically I want to prevent recipes ending up on this list: https://docs.openrewrite.org/reference/standalone-recipes#rewrite-spring

@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Jan 28, 2026
@MBoegers MBoegers merged commit 0c419ef into main Jan 28, 2026
2 checks passed
@MBoegers MBoegers deleted the MBoegers/support-old-testresttemplate-location branch January 28, 2026 15:26
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants