-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
48 additions
and
12 deletions.
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
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
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
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
40 changes: 40 additions & 0 deletions
40
src/test/java/de/focusshift/zeiterfassung/TestPostgreSQLContainer.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,40 @@ | ||
package de.focusshift.zeiterfassung; | ||
|
||
import org.springframework.test.context.DynamicPropertyRegistry; | ||
import org.springframework.test.context.DynamicPropertySource; | ||
import org.testcontainers.containers.PostgreSQLContainer; | ||
|
||
public class TestPostgreSQLContainer extends PostgreSQLContainer<TestPostgreSQLContainer> { | ||
|
||
private static final String VERSION = "16.1"; | ||
|
||
public TestPostgreSQLContainer() { | ||
super(IMAGE + ":" + VERSION); | ||
this.withDatabaseName("zeiterfassung"); | ||
this.withCommand("--max_connections=1000", "--shared_buffers=240MB"); | ||
this.withInitScript("init-user-db.sql"); | ||
} | ||
|
||
/** | ||
* Sets the spring datasource configuration properties. | ||
* | ||
* <p>Usage:</p> | ||
* <pre><code> | ||
* static final TestPostgreContainer postgre = new TestPostgreContainer(); | ||
* @DynamicPropertySource | ||
* static void setupDataSource(DynamicPropertySource registry) { | ||
* postgre.start(); | ||
* postgre.configureSpringDataSource(registry); | ||
* } | ||
* </code> | ||
* </pre> | ||
* | ||
* @param registry | ||
*/ | ||
public void configureSpringDataSource(DynamicPropertyRegistry registry) { | ||
registry.add("spring.datasource.url", this::getJdbcUrl); | ||
registry.add("spring.liquibase.parameters.database", this::getDatabaseName); | ||
registry.add("admin.datasource.username", this::getUsername); | ||
registry.add("admin.datasource.password", this::getPassword); | ||
} | ||
} |
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