diff --git a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java index f188cd98b..cc46cbbfc 100644 --- a/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java +++ b/jpa/multitenancy/multidatasource-multitenancy/src/test/java/com/example/multitenancy/common/DBContainerInitializer.java @@ -3,25 +3,26 @@ import org.springframework.test.context.DynamicPropertyRegistry; import org.springframework.test.context.DynamicPropertySource; import org.testcontainers.containers.PostgreSQLContainer; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; +import org.testcontainers.lifecycle.Startables; import org.testcontainers.oracle.OracleContainer; import org.testcontainers.utility.DockerImageName; -@Testcontainers(disabledWithoutDocker = true, parallel = true) public class DBContainerInitializer { - @Container private static final PostgreSQLContainer POSTGRE_SQL_CONTAINER = - new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("16.1-alpine")); + new PostgreSQLContainer<>(DockerImageName.parse("postgres").withTag("16.1-alpine")) + .withReuse(true); - @Container private static final OracleContainer ORACLE_CONTAINER = new OracleContainer( DockerImageName.parse("gvenzl/oracle-free") .withTag("23-slim-faststart")) .withReuse(true); + static { + Startables.deepStart(POSTGRE_SQL_CONTAINER, ORACLE_CONTAINER).join(); + } + @DynamicPropertySource static void addsDynamicProperties(DynamicPropertyRegistry propertyRegistry) { propertyRegistry.add("datasource.primary.url", ORACLE_CONTAINER::getJdbcUrl);