feat: Add support for Spring 7 and Spring Boot 4 #1884
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Spring Framework 7.0 and Spring Boot 4.0 Support
Overview
This PR adds comprehensive support for Spring Framework 7.0 and Spring Boot 4.0 to pact-jvm, enabling developers to use the latest Spring ecosystem while maintaining full contract testing capabilities.
Therefore the changes are inspired by the latest provider module for Spring Framework 6.0.
Note
This PR builds on top of branch
4.7.xas there is already Kotlin 2.2.0 supported which is a minimum requirement for Spring 7 (see: https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-7.0-Release-Notes)Key Features
New Spring 7 Module (
provider:spring7)HttpHeaders.containsHeader())DeferredResultand async request processingSpring Boot 4.0 Integration
org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest)Technical Implementation
Core Components
Spring7MockMvcTestTarget: Main test target implementation for Spring 7Test Coverage
MockMvcTestTargetWebMvcTestJavawith proper security configurationMockMvcTestTargetWebMvcTestwith Kotlin DSL supportMockMvcTestWithCookieSpecwith cookie handlingWebFluxTargetSpecfor reactive applicationsDeferredResultandCompletableFuturesupportSpring Boot 4.0 Migration Considerations
@Import(SecurityTestConfiguration.class)for proper Spring Boot 4.0 test context loadingRequirements
Testing
All existing tests pass, plus new Spring 7-specific test coverage:
🔄 Migration Path
For New Projects
For Existing Spring 6 Projects
The API is fully compatible - simply change your dependency from
spring6tospring7: