|
|
|
|
@ -63,14 +63,48 @@ public class SampleWebMustacheApplicationTests {
@@ -63,14 +63,48 @@ public class SampleWebMustacheApplicationTests {
|
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); |
|
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(headers); |
|
|
|
|
|
|
|
|
|
ResponseEntity<String> responseEntity = new TestRestTemplate().exchange( |
|
|
|
|
"http://localhost:" + this.port + "/does-not-exist", HttpMethod.GET, |
|
|
|
|
requestEntity, String.class); |
|
|
|
|
|
|
|
|
|
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND); |
|
|
|
|
assertThat(responseEntity.getBody()) |
|
|
|
|
.contains("Something went wrong: 404 Not Found"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void test503HtmlResource() throws Exception { |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); |
|
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(headers); |
|
|
|
|
ResponseEntity<String> entity = new TestRestTemplate().exchange( |
|
|
|
|
"http://localhost:" + this.port + "/serviceUnavailable", HttpMethod.GET, |
|
|
|
|
requestEntity, String.class); |
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE); |
|
|
|
|
assertThat(entity.getBody()).contains("I'm a 503"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void test5xxHtmlResource() throws Exception { |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); |
|
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(headers); |
|
|
|
|
ResponseEntity<String> entity = new TestRestTemplate().exchange( |
|
|
|
|
"http://localhost:" + this.port + "/bang", HttpMethod.GET, requestEntity, |
|
|
|
|
String.class); |
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); |
|
|
|
|
assertThat(entity.getBody()).contains("I'm a 5xx"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void test507Template() throws Exception { |
|
|
|
|
HttpHeaders headers = new HttpHeaders(); |
|
|
|
|
headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); |
|
|
|
|
HttpEntity<String> requestEntity = new HttpEntity<String>(headers); |
|
|
|
|
ResponseEntity<String> entity = new TestRestTemplate().exchange( |
|
|
|
|
"http://localhost:" + this.port + "/insufficientStorage", HttpMethod.GET, |
|
|
|
|
requestEntity, String.class); |
|
|
|
|
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.INSUFFICIENT_STORAGE); |
|
|
|
|
assertThat(entity.getBody()).contains("I'm a 507"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|