mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 13:25:49 +00:00
Updating using GitHub API 2025-06-19-15:31
This commit is contained in:
parent
f07727b6f3
commit
8d02dd678e
1 changed files with 6 additions and 4 deletions
|
@ -50,6 +50,8 @@ import org.springframework.http.ResponseEntity;
|
||||||
properties = { "server.error.include-message=ALWAYS", "management.endpoints.enabled-by-default=false" })
|
properties = { "server.error.include-message=ALWAYS", "management.endpoints.enabled-by-default=false" })
|
||||||
class CrashControllerIntegrationTests {
|
class CrashControllerIntegrationTests {
|
||||||
|
|
||||||
|
private static final String OUPS_PATH = "/oups";
|
||||||
|
|
||||||
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,
|
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,
|
||||||
DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
|
DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class })
|
||||||
static class TestConfiguration {
|
static class TestConfiguration {
|
||||||
|
@ -65,7 +67,7 @@ class CrashControllerIntegrationTests {
|
||||||
@Test
|
@Test
|
||||||
void testTriggerExceptionJson() {
|
void testTriggerExceptionJson() {
|
||||||
ResponseEntity<Map<String, Object>> resp = rest.exchange(
|
ResponseEntity<Map<String, Object>> resp = rest.exchange(
|
||||||
RequestEntity.get("http://localhost:" + port + "/oups").build(),
|
RequestEntity.get("http://localhost:" + port + OUPS_PATH).build(),
|
||||||
new ParameterizedTypeReference<Map<String, Object>>() {
|
new ParameterizedTypeReference<Map<String, Object>>() {
|
||||||
});
|
});
|
||||||
assertThat(resp).isNotNull();
|
assertThat(resp).isNotNull();
|
||||||
|
@ -75,14 +77,14 @@ class CrashControllerIntegrationTests {
|
||||||
assertThat(resp.getBody()).containsKey("error");
|
assertThat(resp.getBody()).containsKey("error");
|
||||||
assertThat(resp.getBody()).containsEntry("message",
|
assertThat(resp.getBody()).containsEntry("message",
|
||||||
"Expected: controller used to showcase what happens when an exception is thrown");
|
"Expected: controller used to showcase what happens when an exception is thrown");
|
||||||
assertThat(resp.getBody()).containsEntry("path", "/oups");
|
assertThat(resp.getBody()).containsEntry("path", OUPS_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testTriggerExceptionHtml() {
|
void testTriggerExceptionHtml() {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.setAccept(List.of(MediaType.TEXT_HTML));
|
headers.setAccept(List.of(MediaType.TEXT_HTML));
|
||||||
ResponseEntity<String> resp = rest.exchange("http://localhost:" + port + "/oups", HttpMethod.GET,
|
ResponseEntity<String> resp = rest.exchange("http://localhost:" + port + OUPS_PATH, HttpMethod.GET,
|
||||||
new HttpEntity<>(headers), String.class);
|
new HttpEntity<>(headers), String.class);
|
||||||
assertThat(resp).isNotNull();
|
assertThat(resp).isNotNull();
|
||||||
assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
|
|
Loading…
Reference in a new issue