GH-9492: Honor @Nested in @SpringIntegrationTest

Fixes: #9492
Issue link: https://github.com/spring-projects/spring-integration/issues/9492

Switches `MockIntegrationContextCustomizerFactory` & `SpringIntegrationTestExecutionListener`
to use `TestContextAnnotationUtils` in order to properly support
`@NestedTestConfiguration` semantics.

Adds an integration test with a base class and several
`@Nested` inner test classes to verify the various
permutations of `@SpringIntegrationTest` inherit/override
behavior when used w/ `@NestedTestConfiguration`.

(cherry picked from commit 3a8e3abc7d)
This commit is contained in:
Martin Tomik
2024-09-23 20:04:00 -04:00
committed by Spring Builds
parent a83b1002a4
commit fd80c55d77
6 changed files with 161 additions and 7 deletions

View File

@@ -206,6 +206,8 @@ The endpoints are matched to the provided patterns, which support the following
This is useful when we would like to not have real connections to the target systems from inbound channel adapters (for example an AMQP Inbound Gateway, JDBC Polling Channel Adapter, WebSocket Message Producer in client mode, and so on).
The `@SpringIntegrationTest` honors the `org.springframework.test.context.NestedTestConfiguration` semantics, hence it can be declared on the outer class (or even its super class) - and `@SpringIntegrationTest` environment will be available to inherited `@Nested` tests.
The `MockIntegrationContext` is meant to be used in the target test cases for modifications to beans in the real application context.
For example, endpoints that have `autoStartup` overridden to `false` can be replaced with mocks, as the following example shows: