use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class ManagementAddressActuatorApplicationTests method testHome.
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port, Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED);
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class ManagementAddressActuatorApplicationTests method testHealth.
@Test
public void testHealth() throws Exception {
ResponseEntity<String> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.managementPort + "/admin/health", String.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).contains("\"status\":\"UP\"");
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class ManagementPortAndPathSampleActuatorApplicationTests method testHome.
@Test
public void testHome() throws Exception {
@SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate("user", getPassword()).getForEntity("http://localhost:" + this.port, Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody();
assertThat(body.get("message")).isEqualTo("Hello Phil");
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class ManagementPortAndPathSampleActuatorApplicationTests method testErrorPage.
@Test
public void testErrorPage() throws Exception {
@SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.port + "/error", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
@SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody();
assertThat(body.get("status")).isEqualTo(999);
}
use of org.springframework.boot.test.web.client.TestRestTemplate in project spring-boot by spring-projects.
the class ManagementPortAndPathSampleActuatorApplicationTests method testManagementErrorPage.
@Test
public void testManagementErrorPage() throws Exception {
@SuppressWarnings("rawtypes") ResponseEntity<Map> entity = new TestRestTemplate().getForEntity("http://localhost:" + this.managementPort + "/error", Map.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
@SuppressWarnings("unchecked") Map<String, Object> body = entity.getBody();
assertThat(body.get("status")).isEqualTo(999);
}
Aggregations