Skip to content
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

Localstack docker beans do not work with PER_CLASS JUnit Lifecycle #104

Open
235daniel opened this issue Jun 20, 2023 · 0 comments
Open

Comments

@235daniel
Copy link

235daniel commented 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's beforeAll 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 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?

@235daniel 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
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

No branches or pull requests

1 participant