diff --git a/multi-store/pom.xml b/multi-store/pom.xml index 5c53decb3..a91dd33b0 100644 --- a/multi-store/pom.xml +++ b/multi-store/pom.xml @@ -30,6 +30,20 @@ test + + + + org.springframework.boot + spring-boot-testcontainers + test + + + + org.testcontainers + mongodb + test + + \ No newline at end of file diff --git a/multi-store/src/test/java/example/springdata/multistore/ApplicationConfigurationTest.java b/multi-store/src/test/java/example/springdata/multistore/ApplicationConfigurationTest.java index 7eac97ffe..e05a1afd3 100644 --- a/multi-store/src/test/java/example/springdata/multistore/ApplicationConfigurationTest.java +++ b/multi-store/src/test/java/example/springdata/multistore/ApplicationConfigurationTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,34 +15,46 @@ */ package example.springdata.multistore; +import static org.assertj.core.api.Assertions.*; + import example.springdata.multistore.customer.Customer; import example.springdata.multistore.shop.Order; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; 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.ApplicationContext; +import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.mongodb.repository.query.MongoEntityInformation; import org.springframework.data.repository.support.Repositories; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; +import org.testcontainers.containers.MongoDBContainer; +import org.testcontainers.utility.DockerImageName; /** * Integration test to check repository interfaces are assigned to the correct store modules. * * @author Oliver Gierke */ -@RunWith(SpringRunner.class) @SpringBootTest -public class ApplicationConfigurationTest { +class ApplicationConfigurationTest { @Autowired ApplicationContext context; + @TestConfiguration + static class Infrastructure { + + @Bean + @ServiceConnection + MongoDBContainer mongoDBContainer() { + return new MongoDBContainer(DockerImageName.parse("mongodb/mongodb-community-server")); + } + } + @Test - public void repositoriesAreAssignedToAppropriateStores() { + void repositoriesAreAssignedToAppropriateStores() { var repositories = new Repositories(context); diff --git a/multi-store/src/test/resources/logback.xml b/multi-store/src/test/resources/logback.xml index 0478c08d7..5a76a8fe3 100644 --- a/multi-store/src/test/resources/logback.xml +++ b/multi-store/src/test/resources/logback.xml @@ -13,4 +13,4 @@ - \ No newline at end of file + diff --git a/rest/starbucks/pom.xml b/rest/starbucks/pom.xml index 7dce29b98..aa0793a15 100644 --- a/rest/starbucks/pom.xml +++ b/rest/starbucks/pom.xml @@ -93,8 +93,9 @@ webjars-locator-core runtime - + + org.springframework.boot spring-boot-testcontainers