Skip to content

Enhanced Testcontainers Support #112

Open
@mbechto

Description

@mbechto

We were trying to use the mq-container with Spring Boot 3.x Testcontainers with @ServiceConnection similar to what you can do with a PostgreSQL container:

@TestConfiguration(proxyBeanMethods = false)
public class TestcontainersConfiguration {
  @Bean
  @ServiceConnection
  @RestartScope
  PostgreSQLContainer<?> postgresContainer() {
    return new PostgreSQLContainer<>(DockerImageName.parse("postgres:latest"));
  }
}

Our intention is to avoid unnecessary container restarts between @SpringBootTests as that slows down the testing process significantly therefore @RestartScope. Maybe more importantly @ServiceConnection configures the correct connection properties, since Testcontainers exposes services on a random port (by default) this is crucial. So similar to PostgreSQL, we tried something like this:

@TestConfiguration(proxyBeanMethods = false)
public class TestcontainersConfiguration {
  @Bean
  @ServiceConnection
  @RestartScope
  GenericContainer<?> ibmMqTestContainer() {
    return new GenericContainer<>(DockerImageName.parse("ibm-messaging/mq-container:latest"));
  }
}

Resulting in the following error on startup:

org.springframework.boot.autoconfigure.service.connection.ConnectionDetailsNotFoundException: No ConnectionDetails found for source '@ServiceConnection source for Bean 'ibmMqTestContainer' defined in class path resource [TestcontainersConfiguration.class]'. You may need to add a 'name' to your @ServiceConnection annotation

After some debugging through Spring code, I guess this would require some integration to make it work, e.g. implementing some classes similar to the ActiveMQ Testcontainers integration.

  • ibmmq-jms-spring version: 3.3.1
  • Java version (including vendor and platform): Temurin-21.0.3+9
  • A small code sample that demonstrates the issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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