File tree Expand file tree Collapse file tree
springqpro-backend/src/test/java/com/springqprobackend/springqpro/testcontainers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package com .springqprobackend .springqpro .testcontainers ;
2+
3+ import org .testcontainers .containers .GenericContainer ;
4+ import org .testcontainers .containers .PostgreSQLContainer ;
5+ import org .testcontainers .containers .wait .strategy .Wait ;
6+ import org .testcontainers .junit .jupiter .Testcontainers ;
7+
8+ @ Testcontainers
9+ public abstract class ContainerTestBase {
10+
11+ protected static final PostgreSQLContainer <?> POSTGRES =
12+ new PostgreSQLContainer <>("postgres:18" )
13+ .withDatabaseName ("springqpro" )
14+ .withUsername ("springqpro" )
15+ .withPassword ("springqpro" );
16+
17+ protected static final GenericContainer <?> REDIS =
18+ new GenericContainer <>("redis:7-alpine" )
19+ .withExposedPorts (6379 )
20+ .waitingFor (Wait .forListeningPort ());
21+
22+ static {
23+ POSTGRES .start ();
24+ REDIS .start ();
25+ }
26+ }
Original file line number Diff line number Diff line change 2323*/
2424//public abstract class IntegrationTestBase extends BasePostgresContainer {
2525@ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT , properties = "spring.main.allow-bean-definition-overriding=true" )
26- @ Testcontainers
2726@ ActiveProfiles ("test" )
2827@ Sql (
2928 scripts = "/cleanup.sql" ,
3029 executionPhase = Sql .ExecutionPhase .BEFORE_TEST_METHOD
3130)
32- public abstract class IntegrationTestBase {
31+ public abstract class IntegrationTestBase extends ContainerTestBase {
3332
34- @ Container
33+ /* @Container
3534 static final PostgreSQLContainer<?> POSTGRES =
3635 new PostgreSQLContainer<>("postgres:18")
3736 .withDatabaseName("springqpro")
@@ -45,7 +44,7 @@ public abstract class IntegrationTestBase {
4544 new GenericContainer<>("redis:7-alpine")
4645 .withExposedPorts(6379)
4746 .withReuse(false);
48- //.withReuse(true);
47+ //.withReuse(true);*/
4948
5049 @ DynamicPropertySource
5150 static void registerDynamicProps (DynamicPropertyRegistry registry ) {
You can’t perform that action at this time.
0 commit comments