Skip to content

No ConnectionDetails found for source '@ServiceConnection source for Bean 'localStackContainer' #1519

@gregmagdits

Description

@gregmagdits

Type: Bug

Component:
Testing

Describe the bug
The @Serviceconnection annotation only seems to work for the deprecated org.testcontainers.containers.localstack.LocalStackContainer class and not its replacement org.testcontainers.localstack.LocalStackContainer class in v2 of LocalStack

see #1500
Sample

package com.example.demo;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;

// works v.1.21.3 of localstatck
// import org.testcontainers.containers.localstack.LocalStackContainer;

// doesnt work, v. 2.0.2 of localstack
import org.testcontainers.localstack.LocalStackContainer;
import org.testcontainers.utility.DockerImageName;

@SpringBootTest
class DemoApplicationTests {
    @Test
    void contextLoads() {
    }

    @TestConfiguration
    static class TestConfig {

        @Bean
        @ServiceConnection
        public LocalStackContainer localStackContainer() {
            return new LocalStackContainer(DockerImageName.parse("localstack/localstack:4.10"));
        }
    }

}

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