Skip to content

GH-3679: Better caching for SpringIntegrationTest #3792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2022

Conversation

artembilan
Copy link
Member

Fixes #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

Fixes spring-projects#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`
artembilan added 2 commits May 6, 2022 12:14
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
@artembilan
Copy link
Member Author

BTW, with the TestExecutionListener approach the fix works even with JUnit 4. No reason to be hard-dependent on JUnit 5 yet 😄 !

@garyrussell garyrussell merged commit 18e410a into spring-projects:main May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reconsider @SpringIntegrationTest
2 participants