From: Kai Moritz Date: Tue, 10 Jan 2023 18:26:33 +0000 (+0100) Subject: WIP X-Git-Tag: TEST~6 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=d8dad0c2af815b587575257e414c4337e272e4b8;p=demos%2Fkafka%2Fchat WIP --- diff --git a/pom.xml b/pom.xml index f9c93a0c..7b32556f 100644 --- a/pom.xml +++ b/pom.xml @@ -75,18 +75,11 @@ testcontainers test - org.testcontainers junit-jupiter test - - - org.testcontainers - mongodb - test - 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 386c8202..06b6c2da 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 @@ -6,13 +6,16 @@ import de.juplo.kafka.chat.backend.persistence.InMemoryWithMongoDbStorageStrateg import de.juplo.kafka.chat.backend.persistence.storage.mongodb.ChatHomeRepository; import de.juplo.kafka.chat.backend.persistence.storage.mongodb.MongoDbStorageStrategy; import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataMongo; import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; 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.MongoDBContainer; +import org.testcontainers.containers.GenericContainer; import org.testcontainers.junit.jupiter.Container; import org.testcontainers.junit.jupiter.Testcontainers; @@ -21,7 +24,9 @@ import java.util.function.Supplier; @Testcontainers -@DataMongoTest +@ExtendWith({SpringExtension.class}) +@EnableAutoConfiguration +@AutoConfigureDataMongo @ContextConfiguration(initializers = DataSourceInitializer.class) @Slf4j public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrategyIT @@ -30,8 +35,6 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg MongoDbStorageStrategy storageStrategy; @Autowired Clock clock; - @Autowired - ChatHomeRepository repository; @Override @@ -47,10 +50,11 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg } @Container - private static final MongoDBContainer mongodb = - new MongoDBContainer("mongo:6") + private static final GenericContainer mongodb = + new GenericContainer("mongo:6") .withEnv("MONGO_INITDB_ROOT_USERNAME", "mongo") - .withEnv("MONGO_INITDB_ROOT_PASSWORD", "mongo"); + .withEnv("MONGO_INITDB_ROOT_PASSWORD", "mongo") + .withEnv("MONGO_INITDB_DATABASE", "test"); public static class DataSourceInitializer implements ApplicationContextInitializer @@ -62,9 +66,9 @@ public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrateg applicationContext, "spring.data.mongodb.host=localhost", "spring.data.mongodb.port=27017", - "spring.data.mongodb.database=test", "spring.data.mongodb.username=mongo", - "spring.data.mongodb.password=mongo"); + "spring.data.mongodb.password=mongo", + "spring.data.mongodb.database=test"); } } }