diff --git a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerIntegrationTests.java b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerIntegrationTests.java index 3cdca47bf..83a58bec2 100644 --- a/src/test/java/org/springframework/samples/petclinic/system/CrashControllerIntegrationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/system/CrashControllerIntegrationTests.java @@ -50,6 +50,8 @@ import org.springframework.http.ResponseEntity; properties = { "server.error.include-message=ALWAYS", "management.endpoints.enabled-by-default=false" }) class CrashControllerIntegrationTests { + private static final String OUPS_PATH = "/oups"; + @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) static class TestConfiguration { @@ -65,7 +67,7 @@ class CrashControllerIntegrationTests { @Test void testTriggerExceptionJson() { ResponseEntity> resp = rest.exchange( - RequestEntity.get("http://localhost:" + port + "/oups").build(), + RequestEntity.get("http://localhost:" + port + OUPS_PATH).build(), new ParameterizedTypeReference>() { }); assertThat(resp).isNotNull(); @@ -75,14 +77,14 @@ class CrashControllerIntegrationTests { assertThat(resp.getBody()).containsKey("error"); assertThat(resp.getBody()).containsEntry("message", "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 void testTriggerExceptionHtml() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(List.of(MediaType.TEXT_HTML)); - ResponseEntity resp = rest.exchange("http://localhost:" + port + "/oups", HttpMethod.GET, + ResponseEntity resp = rest.exchange("http://localhost:" + port + OUPS_PATH, HttpMethod.GET, new HttpEntity<>(headers), String.class); assertThat(resp).isNotNull(); assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); @@ -96,4 +98,4 @@ class CrashControllerIntegrationTests { "This application has no explicit mapping for"); } -} +} \ No newline at end of file