|
6 | 6 | import org.springframework.test.context.DynamicPropertyRegistry; |
7 | 7 | import org.springframework.test.context.DynamicPropertySource; |
8 | 8 | import org.testcontainers.containers.GenericContainer; |
9 | | -import org.testcontainers.containers.MySQLContainer; |
| 9 | +import org.testcontainers.containers.MariaDBContainer; |
10 | 10 | import org.testcontainers.containers.output.Slf4jLogConsumer; |
11 | 11 | import org.testcontainers.junit.jupiter.Testcontainers; |
12 | 12 |
|
13 | 13 | @Testcontainers |
14 | 14 | public abstract class LeagueAbstractIntegrationTest extends AbstractIntegrationTest { |
15 | | - private static final MySQLContainer mySQLContainer; |
| 15 | + private static final MariaDBContainer<?> leagueServiceDBContainer = new MariaDBContainer<>("mariadb:10.6"); |
16 | 16 | protected static GenericContainer<?> leagueServiceContainer = new GenericContainer<>("faforever/faf-league-service:0.1.2"); |
17 | 17 |
|
18 | 18 | static { |
19 | | - mySQLContainer = (MySQLContainer) (new MySQLContainer("mysql:5.7") |
| 19 | + leagueServiceDBContainer |
20 | 20 | .withUsername("faf-league-service") |
21 | 21 | .withPassword("banana") |
22 | 22 | .withDatabaseName("faf-league") |
23 | | - .withReuse(true)); |
24 | | - mySQLContainer.start(); |
| 23 | + .withReuse(true) |
| 24 | + .start(); |
| 25 | + |
| 26 | + final Logger logger = LoggerFactory.getLogger(LeagueAbstractIntegrationTest.class); |
| 27 | + Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(logger); |
25 | 28 |
|
26 | 29 | leagueServiceContainer |
27 | | - .withEnv("DB_SERVER", mySQLContainer.getContainerIpAddress() + ":" + mySQLContainer.getFirstMappedPort().toString()) |
| 30 | + .withEnv("DB_SERVER", leagueServiceDBContainer.getContainerIpAddress() + ":" + leagueServiceDBContainer.getFirstMappedPort().toString()) |
28 | 31 | .withEnv("DB_LOGIN", "faf-league-service") |
29 | 32 | .withEnv("DB_PASSWORD", "banana") |
30 | 33 | .withEnv("DB_NAME", "faf-league") |
31 | 34 | .withEnv("AUTO_APPLY_MIGRATIONS", "1") |
32 | | - .withCommand(); |
33 | | - final Logger logger = LoggerFactory.getLogger(LeagueAbstractIntegrationTest.class); |
34 | | - Slf4jLogConsumer logConsumer = new Slf4jLogConsumer(logger); |
35 | | - leagueServiceContainer.withLogConsumer(logConsumer); |
36 | | - leagueServiceContainer.start(); |
| 35 | + .withCommand() |
| 36 | + .withLogConsumer(logConsumer) |
| 37 | + .start(); |
37 | 38 | } |
38 | 39 |
|
39 | 40 | @DynamicPropertySource |
40 | 41 | public static void setDatasourceProperties(final DynamicPropertyRegistry registry) { |
41 | | - registry.add("spring.league-datasource.url", mySQLContainer::getJdbcUrl); |
42 | | - registry.add("spring.league-datasource.password", mySQLContainer::getPassword); |
43 | | - registry.add("spring.league-datasource.username", mySQLContainer::getUsername); |
| 42 | + registry.add("spring.league-datasource.url", leagueServiceDBContainer::getJdbcUrl); |
| 43 | + registry.add("spring.league-datasource.password", leagueServiceDBContainer::getPassword); |
| 44 | + registry.add("spring.league-datasource.username", leagueServiceDBContainer::getUsername); |
44 | 45 | } |
45 | 46 | } |
0 commit comments