SHARE
TWEET

Untitled

a guest Jun 16th, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @SpringBootTest(classes = MyAppApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
  2. @ActiveProfiles("test")
  3. public abstract class AbstractIntegrationTest {
  4.  
  5.     static {
  6.         PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer().withPassword("password")
  7.                 .withUsername("postgres").withDatabaseName("MyApp");
  8.         postgreSQLContainer.start();
  9.  
  10.         System.setProperty("spring.datasource.url", postgreSQLContainer.getJdbcUrl());
  11.         System.setProperty("spring.datasource.password", postgreSQLContainer.getPassword());
  12.         System.setProperty("spring.datasource.username", postgreSQLContainer.getUsername());
  13.  
  14.     }
  15.      
  16. public class moreTests extends AbstractIntegrationTest {
  17.  
  18.     TestRestTemplate restTemplate = new TestRestTemplate("my-user", "password");
  19.     HttpHeaders headers = new HttpHeaders();
  20.  
  21.     @Test
  22.     public void SimpleHealthCheck() {    
  23.         HttpEntity<String> entity = new HttpEntity<String>(null, headers);    
  24.         ResponseEntity<String> response = restTemplate.exchange(
  25.                 createURLWithPort("/api/v1/healthcheck"),
  26.                 HttpMethod.GET, entity, String.class);    
  27.         assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));
  28.     }
  29.  
  30.     @Test
  31.     public void GetInst() {    
  32.         HttpEntity<String> entity = new HttpEntity<String>(null, headers);    
  33.         ResponseEntity<String> response = restTemplate.exchange(
  34.                 createURLWithPort("/api/v1/institutions"),
  35.                 HttpMethod.GET, entity, String.class);
  36.         assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));    
  37.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top