spring-projects / spring-projects/spring-modulith
Add support of @Sql in tests of @ApplicationModuleListener
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.2k
- Forks
- 222
- PR merge metrics
- No merged PRs in 30d
Description
Could you please add support of sql scripts in tests of module listeners (org.springframework.modulith.events.ApplicationModuleListener)?
I. e. this:
@Test
@Sql("classpath:sql/some-inserts.sql", "classpath:sql/file-abcd.sql")
do inserts rows in one transaction, but this:
@ApplicationModuleListener
fun on(event: SomeCoolStuffHappened) {
creates a new txn and does not see inserts from @Sql. W/o this support one need to mock a bunch of stuff.
Thanks in advance!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how @ApplicationModuleListener test execution manages transactions and how Spring's @Sql scripts are applied. Reproduce the example with inserts from both SQL files, then add a regression test showing that the listener's new transaction can see those rows. Done means @Sql-backed listener tests work without mocking the involved components.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring-boot, sql
- Domain
- backend, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100