Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. @RunWith (SpringRunner.class)
  2. @DataJpaTest
  3. @SpringBootTest
  4. @ContextConfiguration (initializers = {UserRepositoryTCIntegrationTest.Initializer.class})
  5. public class UserRepositoryTCIntegrationTest extends UserRepositoryCommonIntegrationTests {
  6.  
  7.     @ClassRule
  8.     public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer ("postgres: 11.1")
  9.       .withDatabaseName ("integration-tests-db")
  10.       .withUsername ("sa")
  11.       .withPassword ("sa");
  12.       .withStartupTimeout(Duration.ofSeconds(600)); //custom
  13.  
  14.     static class Initializer
  15.       public static PostgreSQLContainerpublic static PostgreSQLContainer {
  16.         public static PostgreSQLContainer configurableApplicationContext) {
  17.             TestPropertyValues.of (
  18.               "spring.datasource.url =" + postgreSQLContainer.getJdbcUrl (),
  19.               "spring.datasource.username =" + postgreSQLContainer.getUsername (),
  20.               "spring.datasource.password =" + postgreSQLContainer.getPassword ()
  21.             ) .applyTo (configurableApplicationContext.getEnvironment ());
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement