From: Kai Moritz Date: Tue, 10 Jan 2023 18:57:59 +0000 (+0100) Subject: WIP X-Git-Tag: TEST~3 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=d307c316c6ae3ac989736ba875e31bdb3a5c51a7;p=demos%2Fkafka%2Fchat WIP --- diff --git a/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java b/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java index 6992d86c..66f06d42 100644 --- a/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java +++ b/src/test/java/de/juplo/kafka/chat/backend/persistence/InMemoryWithMongoDbStorageStrategyIT.java @@ -19,6 +19,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.support.TestPropertySourceUtils; import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -75,13 +76,15 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg } } + private static final int MONGODB_PORT = 27017; @Container - private static final GenericContainer mongodb = + private static final GenericContainer CONTAINER = new GenericContainer("mongo:6") .withEnv("MONGO_INITDB_ROOT_USERNAME", "mongo") .withEnv("MONGO_INITDB_ROOT_PASSWORD", "mongo") - .withEnv("MONGO_INITDB_DATABASE", "test"); + .withEnv("MONGO_INITDB_DATABASE", "test") + .withExposedPorts(MONGODB_PORT); public static class DataSourceInitializer implements ApplicationContextInitializer @@ -92,10 +95,12 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg TestPropertySourceUtils.addInlinedPropertiesToEnvironment( applicationContext, "spring.data.mongodb.host=localhost", - "spring.data.mongodb.port=27017", + "spring.data.mongodb.port=" + CONTAINER.getMappedPort(MONGODB_PORT), "spring.data.mongodb.username=mongo", "spring.data.mongodb.password=mongo", "spring.data.mongodb.database=test"); - } + + Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(log); + CONTAINER.followOutput(logConsumer); } } }