Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith (SpringRunner.class)
- @DataJpaTest
- @SpringBootTest
- @ContextConfiguration (initializers = {UserRepositoryTCIntegrationTest.Initializer.class})
- public class UserRepositoryTCIntegrationTest extends UserRepositoryCommonIntegrationTests {
- @ClassRule
- public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer ("postgres: 11.1")
- .withDatabaseName ("integration-tests-db")
- .withUsername ("sa")
- .withPassword ("sa");
- .withStartupTimeout(Duration.ofSeconds(600)); //custom
- static class Initializer
- public static PostgreSQLContainerpublic static PostgreSQLContainer {
- public static PostgreSQLContainer configurableApplicationContext) {
- TestPropertyValues.of (
- "spring.datasource.url =" + postgreSQLContainer.getJdbcUrl (),
- "spring.datasource.username =" + postgreSQLContainer.getUsername (),
- "spring.datasource.password =" + postgreSQLContainer.getPassword ()
- ) .applyTo (configurableApplicationContext.getEnvironment ());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement