You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also noticed this issue which seems to mention the same problem: localstack/localstack#1067, but I'm not sure the PR mentioned in that issue was ever created and merged. I was able to fix this issue by creating a custom version of the LocalstackDockerExtension that implements TestInstancePostProcessor (which is loaded before the Spring application context under a PER_CLASS lifecycle) using the same code from the existing beforeAll method.
I can create a PR to add this fix, but I'm wondering if there's any better ways to get this working or if there's any issues with that approach?
The text was updated successfully, but these errors were encountered:
235daniel
changed the title
Localstack beans do not work with PER_CLASS JUnit Lifecycle
Localstack docker beans do not work with PER_CLASS JUnit Lifecycle
Jun 20, 2023
Under a
PER_CLASS
JUnit lifecycle, attempting to wire up Spring test beans (such as a DynamoDB client) returns this error:java.lang.RuntimeException: Container not started
. I believe this is because the Spring application context is loaded before the extension'sbeforeAll
method (https://github.com/localstack/localstack-java-utils/blob/master/src/main/java/cloud/localstack/docker/LocalstackDockerExtension.java#L33) initializes the Localstack containers within a PER_CLASS lifecycle.Also noticed this issue which seems to mention the same problem: localstack/localstack#1067, but I'm not sure the PR mentioned in that issue was ever created and merged. I was able to fix this issue by creating a custom version of the
LocalstackDockerExtension
that implementsTestInstancePostProcessor
(which is loaded before the Spring application context under a PER_CLASS lifecycle) using the same code from the existingbeforeAll
method.I can create a PR to add this fix, but I'm wondering if there's any better ways to get this working or if there's any issues with that approach?
The text was updated successfully, but these errors were encountered: