Chore: Migrate testing infrastructure and SpEL evaluation to Spring Boot 4.0 / Spring 7#4318
Chore: Migrate testing infrastructure and SpEL evaluation to Spring Boot 4.0 / Spring 7#4318prathmeshcc wants to merge 6 commits intoGoogleCloudPlatform:8.0-migrationfrom
Conversation
- Upgrade Spring Boot to 4.0.0 and Spring Cloud to 2025.1.0 - Update documentation and remove legacy .jdk8 markers
- Replace deprecated @MockBean/@SpyBean with @MockitoBean/@MockitoSpyBean. - Explicitly add @AutoConfigureMockMvc and @AutoConfigureTestRestTemplate to web tests. - Update SpEL evaluation to use ValueExpressionDelegate and ValueEvaluationContext. - Update Health Indicator tests to reflect Actuator package and API restructuring. - Handle MappingException wrapping for Spanner/Datastore metadata tests. - Update TestRestTemplate and Jakarta annotation imports to new baseline packages. - Add necessary test-scoped dependencies for modular Spring Boot 4 testing.
...le/cloud/spring/autoconfigure/pubsub/health/PubSubHealthIndicatorAutoConfigurationTests.java
Outdated
Show resolved
Hide resolved
| "The primary key columns were not given a consecutive order. There is no property annotated with order 2 in EntityWithWronglyOrderedKeys."); | ||
| } | ||
|
|
||
| private void assertThatMappingExceptionCause(Runnable runnable, String expectedMessage) { |
There was a problem hiding this comment.
In Spring Data 4.0 (part of the 2025.1 release train), the MappingContext has been updated to provide a more consistent error-handling contract across all modules. Metadata discovery and entity mapping failures are now uniformly wrapped in a top-level org.springframework.data.mapping.MappingException. This change ensures our tests accurately reflect this new exception hierarchy by asserting that our domain-specific SpannerDataException is preserved as the underlying cause of the framework's mapping failure.
Ref: Spring Data 4 Migration Guide
There was a problem hiding this comment.
for the release notes, we should just mention that all MappingContext functions will have any exceptions wrapped in MappingContextException. If you were relying on specific root cause messages, you should update your code to use t.getCause().getMessage() to retrieve the specific error mesage.
There was a problem hiding this comment.
Would it be possible to use NestedExceptionUtils.getMostSpecificCause() here?
ldetmer
left a comment
There was a problem hiding this comment.
Overall looks good, just had a few clarifications
...le/cloud/spring/autoconfigure/pubsub/health/PubSubHealthIndicatorAutoConfigurationTests.java
Outdated
Show resolved
Hide resolved
...le/cloud/spring/autoconfigure/pubsub/health/PubSubHealthIndicatorAutoConfigurationTests.java
Outdated
Show resolved
Hide resolved
...va/com/google/cloud/spring/data/spanner/core/mapping/SpannerPersistentPropertyImplTests.java
Show resolved
Hide resolved
652f80c to
67e04a9
Compare
There was a problem hiding this comment.
should this also be reverted since we reverted this change?
ldetmer
left a comment
There was a problem hiding this comment.
can you just check the one comment i made?
67e04a9 to
98c2b9c
Compare
This PR contains the unit test fixes required for the Spring Boot 4.0 and Spring Framework 7 migration. These changes ensure that the test suite is compatible with the new modular architecture of Spring Boot 4, the upgraded Jakarta EE 11 baseline, and the refactored SpEL evaluation engine in Spring Data 4 (2025.1).
Verification Results