GH-3679: Better caching for SpringIntegrationTest (#3792)

* GH-3679: Better caching for SpringIntegrationTest

Fixes https://github.com/spring-projects/spring-integration/issues/3679

The `@SpringIntegrationTest` makes a test cache key based on its attributes values
when the same application context can be used in different test classes
with different endpoints to have stopped originally.

* Rework an `IntegrationEndpointsInitializer` to the `SpringIntegrationTestExecutionListener`
which consult a `MockIntegrationContext` for endpoints to be started or not before
the test execution and definitely stopped after the test execution to have a flexibility
with the cached context
* Improve a `MockIntegrationContext` to gather `AbstractEndpoint` beans and have them
marked for stopping in the beginning of the application context.
The `SpringIntegrationTestExecutionListener` takes care about startup in its `beforeTestClass()`
* Verify different state for the `SpringIntegrationTest` with the `CachedSpringIntegrationTestAnnotationTests`

* * Improve `SpringIntegrationTestExecutionListener` performance
when no `@SpringIntegrationTest.noAutoStartup()` is configured
* Fix `CachedSpringIntegrationTestAnnotationTests` check `isRunning()`
for the endpoint under the testing instead of `isAutoStartup()`
which is changed in one test class, but not other, and the order
of their execution would matter
* Migrate `MockMessageSourceTests` to JUnit 5 as a roadmap of the whole project

* Fixes https://github.com/spring-projects/spring-integration/issues/3787
This commit is contained in:
Artem Bilan
2022-05-09 13:38:10 -04:00
committed by GitHub
parent 0ad89147b2
commit 18e410afbe
9 changed files with 155 additions and 141 deletions

View File

@@ -196,7 +196,7 @@ First we configure our test class with a `@SpringIntegrationTest` annotation to
====
[source,java]
----
@RunWith(SpringRunner.class)
@SpringJUnitConfig
@SpringIntegrationTest(noAutoStartup = {"inboundChannelAdapter", "*Source*"})
public class MyIntegrationTests {