-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add spring boot testcontainers support for local development
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
relay-store-service/src/test/java/com/relay/AppWithTestContainers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.relay; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
|
||
public class AppWithTestContainers { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(RelaySystemApplication::main).with(TestContainersConfiguration.class).run(args); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
relay-store-service/src/test/java/com/relay/TestContainersConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.relay; | ||
|
||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class TestContainersConfiguration { | ||
|
||
@Bean | ||
@ServiceConnection | ||
public PostgreSQLContainer postgresqlContainer() { | ||
return new PostgreSQLContainer(); | ||
} | ||
|
||
} |