GH-116 - PublishedEvents now sees events from asynchronous event listeners as well.

The ApplicationListener we deploy to capture events published  during a test method execution now uses an InheritableThreadLocal so that events published on threads spawned from the main test execution thread also end up in the PublishedEvents instance prepared for the test method.

Also, the registration of that particular event listener avoids duplicate registrations by inspecting the application context in use for the test method execution for an already registered listener, falling back to registering one.
This commit is contained in:
Oliver Drotbohm
2023-01-13 16:13:34 +01:00
parent c4321c5305
commit 6616aaaffa
5 changed files with 152 additions and 4 deletions

View File

@@ -55,6 +55,12 @@
<artifactId>spring-boot-starter-test</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>