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;
@Testcontainers
-@DataMongoTest
+@ExtendWith({SpringExtension.class})
+@EnableAutoConfiguration
+@AutoConfigureDataMongo
@ContextConfiguration(initializers = DataSourceInitializer.class)
@Slf4j
public class InMemoryWithMongoDbStorageStrategyIT extends AbstractStorageStrategyIT
MongoDbStorageStrategy storageStrategy;
@Autowired
Clock clock;
- @Autowired
- ChatHomeRepository repository;
@Override
}
@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<ConfigurableApplicationContext>
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");
}
}
}