Advertisement
Guest User

Untitled

a guest
Mar 27th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. @SpringJUnitConfig
  2. @ContextConfiguration(classes = { StormTrackerApplication.class }, initializers = ITStormRepo.Initializer.class)
  3. @TestPropertySource("classpath:application.properties")
  4. @TestMethodOrder(OrderAnnotation.class)
  5. public class ITStormRepo {
  6.  
  7. public static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
  8. @Override
  9. public void initialize(ConfigurableApplicationContext applicationContext) {
  10. TestPropertyValues.of("spring.datasource.url=jdbc:tc:postgresql:11.2://arbitrary/arbitrary", //
  11. "spring.datasource.username=test", //
  12. "spring.datasource.password=test", //
  13. "spring.datasource.driver-class-name=org.testcontainers.jdbc.ContainerDatabaseDriver")//
  14. .applyTo(applicationContext);
  15. }
  16. }
  17.  
  18. @Autowired
  19. private StormRepo repo;
  20.  
  21. @Test
  22. @Order(1)
  23. public void testReadFromStormsTable() {
  24. assertThat(repo.count()).isEqualTo(2);
  25. }
  26.  
  27. @Test
  28. public void testWriteToStormsTable() {
  29. Storm savedStorm = repo.save(new Storm("03-17-2019", "03-20-2019", "South Atlantic", "Knoxville, Tennesee",
  30. "Tropical Depression", 3));
  31. assertThat(savedStorm.getId()).isEqualTo(12);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement