8000 Localstack docker beans do not work with PER_CLASS JUnit Lifecycle · Issue #104 · localstack/localstack-java-utils · GitHub
[go: up one dir, main page]

Skip to content
Localstack docker beans do not work with PER_CLASS JUnit Lifecycle #104
Open
@235daniel

Description

@235daniel

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0