|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2021 the original author or authors. |
| 2 | + * Copyright 2014-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
15 | 15 | */
|
16 | 16 | package example.springdata.multistore;
|
17 | 17 |
|
| 18 | +import static org.assertj.core.api.Assertions.*; |
| 19 | + |
18 | 20 | import example.springdata.multistore.customer.Customer;
|
19 | 21 | import example.springdata.multistore.shop.Order;
|
20 | 22 |
|
21 |
| -import org.junit.Test; |
22 |
| -import org.junit.runner.RunWith; |
| 23 | +import org.junit.jupiter.api.Test; |
23 | 24 | import org.springframework.beans.factory.annotation.Autowired;
|
24 | 25 | import org.springframework.boot.test.context.SpringBootTest;
|
| 26 | +import org.springframework.boot.test.context.TestConfiguration; |
| 27 | +import org.springframework.boot.testcontainers.service.connection.ServiceConnection; |
25 | 28 | import org.springframework.context.ApplicationContext;
|
| 29 | +import org.springframework.context.annotation.Bean; |
26 | 30 | import org.springframework.data.jpa.repository.support.JpaEntityInformation;
|
27 | 31 | import org.springframework.data.mongodb.repository.query.MongoEntityInformation;
|
28 | 32 | import org.springframework.data.repository.support.Repositories;
|
29 |
| -import org.springframework.test.context.junit4.SpringRunner; |
30 |
| - |
31 |
| -import static org.assertj.core.api.Assertions.assertThat; |
| 33 | +import org.testcontainers.containers.MongoDBContainer; |
| 34 | +import org.testcontainers.utility.DockerImageName; |
32 | 35 |
|
33 | 36 | /**
|
34 | 37 | * Integration test to check repository interfaces are assigned to the correct store modules.
|
35 | 38 | *
|
36 | 39 | * @author Oliver Gierke
|
37 | 40 | */
|
38 |
| -@RunWith(SpringRunner.class) |
39 | 41 | @SpringBootTest
|
40 |
| -public class ApplicationConfigurationTest { |
| 42 | +class ApplicationConfigurationTest { |
41 | 43 |
|
42 | 44 | @Autowired ApplicationContext context;
|
43 | 45 |
|
| 46 | + @TestConfiguration |
| 47 | + static class Infrastructure { |
| 48 | + |
| 49 | + @Bean |
| 50 | + @ServiceConnection |
| 51 | + MongoDBContainer mongoDBContainer() { |
| 52 | + return new MongoDBContainer(DockerImageName.parse("mongodb/mongodb-community-server")); |
| 53 | + } |
| 54 | + } |
| 55 | + |
44 | 56 | @Test
|
45 |
| - public void repositoriesAreAssignedToAppropriateStores() { |
| 57 | + void repositoriesAreAssignedToAppropriateStores() { |
46 | 58 |
|
47 | 59 | var repositories = new Repositories(context);
|
48 | 60 |
|
|
0 commit comments