From bcd79dd992043ea62476b4691f330f5bb54b37bd Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Thu, 13 Oct 2016 10:32:38 -0700 Subject: [PATCH] Move all actuators under `/application` Context path can be configured via `management.context-path`. Closes gh-6886 --- .../hypermedia/EndpointDocumentation.java | 16 +++--- .../HealthEndpointDocumentation.java | 2 +- .../HypermediaEndpointDocumentation.java | 8 +-- .../ManagementServerProperties.java | 2 +- .../endpoint/mvc/HalJsonMvcEndpoint.java | 2 +- .../BootCuriesHrefIntegrationTests.java | 20 +++---- .../EndpointMvcIntegrationTests.java | 4 +- ...iaManagementContextConfigurationTests.java | 10 ++-- ...vcManagementContextConfigurationTests.java | 2 +- .../ManagementServerPropertiesTests.java | 2 +- ...mentWebSecurityAutoConfigurationTests.java | 8 +-- .../mvc/AuditEventsMvcEndpointTests.java | 12 ++-- .../mvc/EnvironmentMvcEndpointTests.java | 20 +++---- ...vcEndpointBrowserPathIntegrationTests.java | 8 +-- ...erMvcEndpointDisabledIntegrationTests.java | 10 ++-- ...ointServerContextPathIntegrationTests.java | 12 ++-- ...MvcEndpointServerPortIntegrationTests.java | 8 +-- ...ointServerServletPathIntegrationTests.java | 12 ++-- ...serMvcEndpointVanillaIntegrationTests.java | 20 +++---- .../endpoint/mvc/HalJsonMvcEndpointTests.java | 56 +++++++++++++++++++ ...HeapdumpMvcEndpointSecureOptionsTests.java | 2 +- .../mvc/HeapdumpMvcEndpointTests.java | 10 ++-- .../endpoint/mvc/InfoMvcEndpointTests.java | 6 +- ...vcEndpointWithNoInfoContributorsTests.java | 2 +- .../JolokiaMvcEndpointIntegrationTests.java | 6 +- .../endpoint/mvc/LoggersMvcEndpointTests.java | 22 ++++---- .../endpoint/mvc/MetricsMvcEndpointTests.java | 26 ++++----- .../mvc/MvcEndpointCorsIntegrationTests.java | 18 +++--- .../mvc/MvcEndpointIntegrationTests.java | 16 +++--- ...rityHealthMvcEndpointIntegrationTests.java | 4 +- .../mvc/ShutdownMvcEndpointTests.java | 4 +- .../SampleActuatorLog4J2ApplicationTests.java | 2 +- .../SampleActuatorUiApplicationPortTests.java | 4 +- .../ui/SampleActuatorUiApplicationTests.java | 2 +- ...agementSampleActuatorApplicationTests.java | 2 +- ...entPortSampleActuatorApplicationTests.java | 4 +- .../actuator/NonSensitiveHealthTests.java | 2 +- .../SampleActuatorApplicationTests.java | 20 +++---- ...nsecureSampleActuatorApplicationTests.java | 2 +- ...letPathSampleActuatorApplicationTests.java | 2 +- ...hutdownSampleActuatorApplicationTests.java | 2 +- .../SampleHypermediaGsonApplicationTests.java | 8 +-- ...pleHypermediaUiSecureApplicationTests.java | 8 +-- .../SampleHypermediaUiApplicationTests.java | 4 +- ...pleHypermediaApplicationHomePageTests.java | 4 +- ...eSecureOAuth2ActuatorApplicationTests.java | 6 +- .../SampleMethodSecurityApplicationTests.java | 6 +- 47 files changed, 242 insertions(+), 186 deletions(-) create mode 100644 spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpointTests.java diff --git a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java index c2652e3afd..9b8e35c06f 100644 --- a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java +++ b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/EndpointDocumentation.java @@ -97,7 +97,7 @@ public class EndpointDocumentation { @Test public void logfile() throws Exception { - this.mockMvc.perform(get("/logfile").accept(MediaType.TEXT_PLAIN)) + this.mockMvc.perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN)) .andExpect(status().isOk()).andDo(document("logfile")); } @@ -106,7 +106,7 @@ public class EndpointDocumentation { FileCopyUtils.copy(getClass().getResourceAsStream("log.txt"), new FileOutputStream(LOG_FILE)); this.mockMvc - .perform(get("/logfile").accept(MediaType.TEXT_PLAIN) + .perform(get("/application/logfile").accept(MediaType.TEXT_PLAIN) .header(HttpHeaders.RANGE, "bytes=0-1024")) .andExpect(status().isPartialContent()) .andDo(document("partial-logfile")); @@ -115,7 +115,7 @@ public class EndpointDocumentation { @Test public void singleLogger() throws Exception { this.mockMvc - .perform(get("/loggers/org.springframework.boot") + .perform(get("/application/loggers/org.springframework.boot") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andDo(document("single-logger")); } @@ -123,7 +123,7 @@ public class EndpointDocumentation { @Test public void setLogger() throws Exception { this.mockMvc - .perform(post("/loggers/org.springframework.boot") + .perform(post("/application/loggers/org.springframework.boot") .contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON) .content("{\"configuredLevel\": \"DEBUG\"}")) .andExpect(status().isOk()).andDo(document("set-logger")); @@ -132,7 +132,7 @@ public class EndpointDocumentation { @Test public void auditEvents() throws Exception { this.mockMvc - .perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000") + .perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document("auditevents")); } @@ -140,7 +140,7 @@ public class EndpointDocumentation { @Test public void auditEventsByPrincipal() throws Exception { this.mockMvc - .perform(get("/auditevents").param("principal", "admin") + .perform(get("/application/auditevents").param("principal", "admin") .param("after", "2016-11-01T10:00:00+0000") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()) @@ -150,7 +150,7 @@ public class EndpointDocumentation { @Test public void auditEventsByPrincipalAndType() throws Exception { this.mockMvc - .perform(get("/auditevents").param("principal", "admin") + .perform(get("/application/auditevents").param("principal", "admin") .param("after", "2016-11-01T10:00:00+0000") .param("type", "AUTHENTICATION_SUCCESS") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) @@ -171,7 +171,7 @@ public class EndpointDocumentation { String output = endpointPath.substring(1); output = output.length() > 0 ? output : "./"; this.mockMvc - .perform(get(endpointPath) + .perform(get("/application" + endpointPath) .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document(output)) .andDo(new ResultHandler() { diff --git a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HealthEndpointDocumentation.java b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HealthEndpointDocumentation.java index 3ee568ddce..2c42e85f82 100644 --- a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HealthEndpointDocumentation.java +++ b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HealthEndpointDocumentation.java @@ -51,7 +51,7 @@ public class HealthEndpointDocumentation { @Test public void health() throws Exception { this.mockMvc - .perform(get("/health") + .perform(get("/application/health") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document("health/insensitive")); } diff --git a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HypermediaEndpointDocumentation.java b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HypermediaEndpointDocumentation.java index 4f8ca1d8ba..cd73232449 100644 --- a/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HypermediaEndpointDocumentation.java +++ b/spring-boot-actuator-docs/src/restdoc/java/org/springframework/boot/actuate/hypermedia/HypermediaEndpointDocumentation.java @@ -52,7 +52,7 @@ public class HypermediaEndpointDocumentation { @Test public void beans() throws Exception { this.mockMvc - .perform(get("/beans") + .perform(get("/application/beans") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document("beans/hypermedia")); } @@ -60,18 +60,18 @@ public class HypermediaEndpointDocumentation { @Test public void metrics() throws Exception { this.mockMvc - .perform(get("/metrics") + .perform(get("/application/metrics") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$._links.self.href") - .value("http://localhost:8080/metrics")) + .value("http://localhost:8080/application/metrics")) .andDo(document("metrics/hypermedia")); } @Test public void home() throws Exception { this.mockMvc - .perform(get("/actuator") + .perform(get("/application") .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document("admin")); } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java index a78a9e45f5..b8b1016974 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java @@ -79,7 +79,7 @@ public class ManagementServerProperties implements SecurityPrerequisite { /** * Management endpoint context-path. */ - private String contextPath = ""; + private String contextPath = "/application"; /** * Add the "X-Application-Context" HTTP header in each response. diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpoint.java index 0c4fd44911..415aaceeac 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpoint.java @@ -44,7 +44,7 @@ public class HalJsonMvcEndpoint extends AbstractNamedMvcEndpoint { if (StringUtils.hasText(managementServletContext.getContextPath())) { return ""; } - return "/actuator"; + return "/application"; } @ActuatorGetMapping diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/BootCuriesHrefIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/BootCuriesHrefIntegrationTests.java index 8dc3f1bd6d..b440a80f39 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/BootCuriesHrefIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/BootCuriesHrefIntegrationTests.java @@ -49,35 +49,35 @@ public class BootCuriesHrefIntegrationTests { @Test public void basicCuriesHref() { int port = load("endpoints.docs.curies.enabled:true", "server.port:0"); - assertThat(getCurieHref("http://localhost:" + port + "/actuator")).isEqualTo( - "http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}"); + assertThat(getCurieHref("http://localhost:" + port + "/application")).isEqualTo( + "http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}"); } @Test public void curiesHrefWithCustomContextPath() { int port = load("endpoints.docs.curies.enabled:true", "server.port:0", "server.servlet.context-path:/context"); - assertThat(getCurieHref("http://localhost:" + port + "/context/actuator")) + assertThat(getCurieHref("http://localhost:" + port + "/context/application")) .isEqualTo("http://localhost:" + port - + "/context/docs/#spring_boot_actuator__{rel}"); + + "/context/application/docs/#spring_boot_actuator__{rel}"); } @Test public void curiesHrefWithCustomServletPath() { int port = load("endpoints.docs.curies.enabled:true", "server.port:0", "server.servlet.path:/servlet"); - assertThat(getCurieHref("http://localhost:" + port + "/servlet/actuator")) + assertThat(getCurieHref("http://localhost:" + port + "/servlet/application")) .isEqualTo("http://localhost:" + port - + "/servlet/docs/#spring_boot_actuator__{rel}"); + + "/servlet/application/docs/#spring_boot_actuator__{rel}"); } @Test public void curiesHrefWithCustomServletAndContextPaths() { int port = load("endpoints.docs.curies.enabled:true", "server.port:0", "server.servlet.context-path:/context", "server.servlet.path:/servlet"); - assertThat(getCurieHref("http://localhost:" + port + "/context/servlet/actuator")) + assertThat(getCurieHref("http://localhost:" + port + "/context/servlet/application")) .isEqualTo("http://localhost:" + port - + "/context/servlet/docs/#spring_boot_actuator__{rel}"); + + "/context/servlet/application/docs/#spring_boot_actuator__{rel}"); } @Test @@ -95,8 +95,8 @@ public class BootCuriesHrefIntegrationTests { int port = load("endpoints.docs.curies.enabled:true", "server.port:0", "server.servlet.context-path:/context", "server.servlet.path:/servlet", "management.port:0"); - assertThat(getCurieHref("http://localhost:" + port + "/actuator/")).isEqualTo( - "http://localhost:" + port + "/docs/#spring_boot_actuator__{rel}"); + assertThat(getCurieHref("http://localhost:" + port + "/application/")).isEqualTo( + "http://localhost:" + port + "/application/docs/#spring_boot_actuator__{rel}"); } @Test diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java index 83623c0e27..95b3b5b5bc 100755 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java @@ -85,7 +85,7 @@ public class EndpointMvcIntegrationTests { @Test public void envEndpointNotHidden() throws InterruptedException { String body = new TestRestTemplate().getForObject( - "http://localhost:" + this.port + "/env/foo.bar", String.class); + "http://localhost:" + this.port + "/application/env/foo.bar", String.class); assertThat(body).isNotNull().contains("\"baz\""); assertThat(this.interceptor.invoked()).isTrue(); } @@ -93,7 +93,7 @@ public class EndpointMvcIntegrationTests { @Test public void healthEndpointNotHidden() throws InterruptedException { String body = new TestRestTemplate() - .getForObject("http://localhost:" + this.port + "/health", String.class); + .getForObject("http://localhost:" + this.port + "/application/health", String.class); assertThat(body).isNotNull().contains("status"); assertThat(this.interceptor.invoked()).isTrue(); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfigurationTests.java index 37e4e95f69..2bd7e20793 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfigurationTests.java @@ -80,28 +80,28 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests { public void curiesEnabledWithDefaultPorts() { load("endpoints.docs.curies.enabled:true"); assertThat(getCurieHref()) - .isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}"); + .isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}"); } @Test public void curiesEnabledWithRandomPorts() { load("endpoints.docs.curies.enabled:true", "server.port:0", "management.port:0"); assertThat(getCurieHref()) - .isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}"); + .isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}"); } @Test public void curiesEnabledWithSpecificServerPort() { load("endpoints.docs.curies.enabled:true", "server.port:8080"); assertThat(getCurieHref()) - .isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}"); + .isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}"); } @Test public void curiesEnabledWithSpecificManagementPort() { load("endpoints.docs.curies.enabled:true", "management.port:8081"); assertThat(getCurieHref()) - .isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}"); + .isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}"); } @Test @@ -109,7 +109,7 @@ public class EndpointWebMvcHypermediaManagementContextConfigurationTests { load("endpoints.docs.curies.enabled:true", "server.port:8080", "management.port:8081"); assertThat(getCurieHref()) - .isEqualTo("http://localhost/docs/#spring_boot_actuator__{rel}"); + .isEqualTo("http://localhost/application/docs/#spring_boot_actuator__{rel}"); } private void load(String... properties) { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java index 031fa2863b..625583360c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfigurationTests.java @@ -74,7 +74,7 @@ public class EndpointWebMvcManagementContextConfigurationTests { this.context.refresh(); EndpointHandlerMapping mapping = this.context.getBean("endpointHandlerMapping", EndpointHandlerMapping.class); - assertThat(mapping.getPrefix()).isEmpty(); + assertThat(mapping.getPrefix()).isEqualTo("/application"); MvcEndpointSecurityInterceptor securityInterceptor = (MvcEndpointSecurityInterceptor) ReflectionTestUtils .getField(mapping, "securityInterceptor"); Object secure = ReflectionTestUtils.getField(securityInterceptor, "secure"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesTests.java index c2b1913f6c..daddfc5024 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementServerPropertiesTests.java @@ -46,7 +46,7 @@ public class ManagementServerPropertiesTests { public void defaultManagementServerProperties() { ManagementServerProperties properties = new ManagementServerProperties(); assertThat(properties.getPort()).isNull(); - assertThat(properties.getContextPath()).isEqualTo(""); + assertThat(properties.getContextPath()).isEqualTo("/application"); assertThat(properties.getAddApplicationContextHeader()).isEqualTo(false); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfigurationTests.java index bdc0b58eba..88337e8a45 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementWebSecurityAutoConfigurationTests.java @@ -97,10 +97,10 @@ public class ManagementWebSecurityAutoConfigurationTests { FilterChainProxy filterChainProxy = this.context.getBean(FilterChainProxy.class); // 1 for static resources, one for management endpoints and one for the rest assertThat(filterChainProxy.getFilterChains()).hasSize(3); - assertThat(filterChainProxy.getFilters("/beans")).isNotEmpty(); - assertThat(filterChainProxy.getFilters("/beans/")).isNotEmpty(); - assertThat(filterChainProxy.getFilters("/beans.foo")).isNotEmpty(); - assertThat(filterChainProxy.getFilters("/beans/foo/bar")).isNotEmpty(); + assertThat(filterChainProxy.getFilters("/application/beans")).isNotEmpty(); + assertThat(filterChainProxy.getFilters("/application/beans/")).isNotEmpty(); + assertThat(filterChainProxy.getFilters("/application/beans.foo")).isNotEmpty(); + assertThat(filterChainProxy.getFilters("/application/beans/foo/bar")).isNotEmpty(); } @Test diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java index 8e32949342..ab9f485968 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/AuditEventsMvcEndpointTests.java @@ -74,14 +74,14 @@ public class AuditEventsMvcEndpointTests { @Test public void contentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/auditevents")).andExpect(status().isOk()) + this.mvc.perform(get("/application/auditevents")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test public void contentTypeCanBeApplicationJson() throws Exception { - this.mvc.perform(get("/auditevents").header(HttpHeaders.ACCEPT, + this.mvc.perform(get("/application/auditevents").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()) .andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); @@ -90,20 +90,20 @@ public class AuditEventsMvcEndpointTests { @Test public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception { this.context.getBean(AuditEventsMvcEndpoint.class).setEnabled(false); - this.mvc.perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000")) + this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T10:00:00+0000")) .andExpect(status().isNotFound()); } @Test public void invokeFilterByDateAfter() throws Exception { - this.mvc.perform(get("/auditevents").param("after", "2016-11-01T13:00:00+0000")) + this.mvc.perform(get("/application/auditevents").param("after", "2016-11-01T13:00:00+0000")) .andExpect(status().isOk()) .andExpect(content().string("{\"events\":[]}")); } @Test public void invokeFilterByPrincipalAndDateAfter() throws Exception { - this.mvc.perform(get("/auditevents").param("principal", "user").param("after", + this.mvc.perform(get("/application/auditevents").param("principal", "user").param("after", "2016-11-01T10:00:00+0000")) .andExpect(status().isOk()) .andExpect(content().string( @@ -113,7 +113,7 @@ public class AuditEventsMvcEndpointTests { @Test public void invokeFilterByPrincipalAndDateAfterAndType() throws Exception { - this.mvc.perform(get("/auditevents").param("principal", "admin") + this.mvc.perform(get("/application/auditevents").param("principal", "admin") .param("after", "2016-11-01T10:00:00+0000").param("type", "logout")) .andExpect(status().isOk()) .andExpect(content().string( diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java index 25222f621c..cb0473a32c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java @@ -80,7 +80,7 @@ public class EnvironmentMvcEndpointTests { @Test public void homeContentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/env")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @@ -88,21 +88,21 @@ public class EnvironmentMvcEndpointTests { @Test public void homeContentTypeCanBeApplicationJson() throws Exception { this.mvc.perform( - get("/env").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)) + get("/application/env").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()).andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); } @Test public void subContentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/env/foo")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env/foo")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test public void subContentTypeCanBeApplicationJson() throws Exception { - this.mvc.perform(get("/env/foo").header(HttpHeaders.ACCEPT, + this.mvc.perform(get("/application/env/foo").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()) .andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); @@ -110,20 +110,20 @@ public class EnvironmentMvcEndpointTests { @Test public void home() throws Exception { - this.mvc.perform(get("/env")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env")).andExpect(status().isOk()) .andExpect(content().string(containsString("systemProperties"))); } @Test public void sub() throws Exception { - this.mvc.perform(get("/env/foo")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env/foo")).andExpect(status().isOk()) .andExpect(content().string("{\"foo\":\"bar\"}")); } @Test public void subWhenDisabled() throws Exception { this.context.getBean(EnvironmentEndpoint.class).setEnabled(false); - this.mvc.perform(get("/env/foo")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/env/foo")).andExpect(status().isNotFound()); } @Test @@ -132,7 +132,7 @@ public class EnvironmentMvcEndpointTests { map.put("food", null); ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() .addFirst(new MapPropertySource("null-value", map)); - this.mvc.perform(get("/env/foo.*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env/foo.*")).andExpect(status().isOk()) .andExpect(content().string(containsString("\"foo\":\"bar\""))) .andExpect(content().string(containsString("\"fool\":\"baz\""))); } @@ -144,7 +144,7 @@ public class EnvironmentMvcEndpointTests { map.put("my.foo", "${my.bar}"); ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() .addFirst(new MapPropertySource("unresolved-placeholder", map)); - this.mvc.perform(get("/env/my.*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env/my.*")).andExpect(status().isOk()) .andExpect(content().string(containsString("\"my.foo\":\"${my.bar}\""))); } @@ -155,7 +155,7 @@ public class EnvironmentMvcEndpointTests { map.put("my.password", "hello"); ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() .addFirst(new MapPropertySource("placeholder", map)); - this.mvc.perform(get("/env/my.*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/env/my.*")).andExpect(status().isOk()) .andExpect(content().string(containsString("\"my.foo\":\"******\""))); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointBrowserPathIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointBrowserPathIntegrationTests.java index 20ea1a3626..268ecd6179 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointBrowserPathIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointBrowserPathIntegrationTests.java @@ -61,16 +61,16 @@ public class HalBrowserMvcEndpointBrowserPathIntegrationTests { @Test public void requestWithTrailingSlashIsRedirectedToBrowserHtml() throws Exception { - this.mockMvc.perform(get("/actuator/").accept(MediaType.TEXT_HTML)) + this.mockMvc.perform(get("/application/actuator/").accept(MediaType.TEXT_HTML)) .andExpect(status().isFound()).andExpect(header().string( - HttpHeaders.LOCATION, "http://localhost/actuator/browser.html")); + HttpHeaders.LOCATION, "http://localhost/application/actuator/browser.html")); } @Test public void requestWithoutTrailingSlashIsRedirectedToBrowserHtml() throws Exception { - this.mockMvc.perform(get("/actuator").accept(MediaType.TEXT_HTML)) + this.mockMvc.perform(get("/application/actuator").accept(MediaType.TEXT_HTML)) .andExpect(status().isFound()).andExpect(header().string("location", - "http://localhost/actuator/browser.html")); + "http://localhost/application/actuator/browser.html")); } @MinimalActuatorHypermediaApplication diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java index 63a203cd9c..a08a5045a1 100755 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java @@ -67,26 +67,26 @@ public class HalBrowserMvcEndpointDisabledIntegrationTests { @Test public void linksOnActuator() throws Exception { - this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$._links").exists()) .andExpect(header().doesNotExist("cache-control")); } @Test public void browserRedirect() throws Exception { - this.mockMvc.perform(get("/actuator/").accept(MediaType.TEXT_HTML)) + this.mockMvc.perform(get("/application/").accept(MediaType.TEXT_HTML)) .andExpect(status().isFound()).andExpect(header().string( - HttpHeaders.LOCATION, "http://localhost/actuator/browser.html")); + HttpHeaders.LOCATION, "http://localhost/application/browser.html")); } @Test public void endpointsDoNotHaveLinks() throws Exception { for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) { String path = endpoint.getPath(); - if ("/actuator".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) { + if ("".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) { continue; } - path = path.length() > 0 ? path : "/"; + path = "/application" + (path.length() > 0 ? path : "/"); MockHttpServletRequestBuilder requestBuilder = get(path); if (endpoint instanceof AuditEventsMvcEndpoint) { requestBuilder.param("after", "2016-01-01T12:00:00+00:00"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java index df026566a7..58d8ed7cc0 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerContextPathIntegrationTests.java @@ -74,11 +74,11 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator/", HttpMethod.GET, + "http://localhost:" + this.port + "/spring/application/", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create( - "http://localhost:" + this.port + "/spring/actuator/browser.html")); + "http://localhost:" + this.port + "/spring/application/browser.html")); } @Test @@ -86,10 +86,10 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator/browser.html", + "http://localhost:" + this.port + "/spring/application/browser.html", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).contains("entryPoint: '/spring/actuator'"); + assertThat(entity.getBody()).contains("entryPoint: '/spring/application'"); } @Test @@ -97,7 +97,7 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator", HttpMethod.GET, + "http://localhost:" + this.port + "/spring/application", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"_links\":"); @@ -108,7 +108,7 @@ public class HalBrowserMvcEndpointServerContextPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator/", HttpMethod.GET, + "http://localhost:" + this.port + "/spring/application/", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"_links\":"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerPortIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerPortIntegrationTests.java index b2de9c1b87..982c95b441 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerPortIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerPortIntegrationTests.java @@ -63,7 +63,7 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/actuator", HttpMethod.GET, + "http://localhost:" + this.port + "/application", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"_links\":"); @@ -75,7 +75,7 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/actuator/", HttpMethod.GET, + "http://localhost:" + this.port + "/application/", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"_links\":"); @@ -87,11 +87,11 @@ public class HalBrowserMvcEndpointServerPortIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/actuator/", HttpMethod.GET, + "http://localhost:" + this.port + "/application/", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); assertThat(entity.getHeaders().getLocation()).isEqualTo( - URI.create("http://localhost:" + this.port + "/actuator/browser.html")); + URI.create("http://localhost:" + this.port + "/application/browser.html")); } @MinimalActuatorHypermediaApplication diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerServletPathIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerServletPathIntegrationTests.java index 735dbf8536..4f23492ffb 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerServletPathIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointServerServletPathIntegrationTests.java @@ -74,11 +74,11 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator/", HttpMethod.GET, + "http://localhost:" + this.port + "/spring/application/", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FOUND); assertThat(entity.getHeaders().getLocation()).isEqualTo(URI.create( - "http://localhost:" + this.port + "/spring/actuator/browser.html")); + "http://localhost:" + this.port + "/spring/application/browser.html")); } @Test @@ -86,10 +86,10 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator/browser.html", + "http://localhost:" + this.port + "/spring/application/browser.html", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - assertThat(entity.getBody()).contains("entryPoint: '/spring/actuator'"); + assertThat(entity.getBody()).contains("entryPoint: '/spring/application'"); } @Test @@ -97,7 +97,7 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator", HttpMethod.GET, + "http://localhost:" + this.port + "/spring/application", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"_links\":"); @@ -108,7 +108,7 @@ public class HalBrowserMvcEndpointServerServletPathIntegrationTests { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); ResponseEntity entity = new TestRestTemplate().exchange( - "http://localhost:" + this.port + "/spring/actuator/", HttpMethod.GET, + "http://localhost:" + this.port + "/spring/application/", HttpMethod.GET, new HttpEntity(null, headers), String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"_links\":"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java index 96003d610a..e4e863554e 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java @@ -70,35 +70,35 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests { @Test public void links() throws Exception { - this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$._links").exists()) .andExpect(header().doesNotExist("cache-control")); } @Test public void linksWithTrailingSlash() throws Exception { - this.mockMvc.perform(get("/actuator/").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application/").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$._links").exists()) .andExpect(header().doesNotExist("cache-control")); } @Test public void browser() throws Exception { - this.mockMvc.perform(get("/actuator/").accept(MediaType.TEXT_HTML)) + this.mockMvc.perform(get("/application/").accept(MediaType.TEXT_HTML)) .andExpect(status().isFound()).andExpect(header().string( - HttpHeaders.LOCATION, "http://localhost/actuator/browser.html")); + HttpHeaders.LOCATION, "http://localhost/application/browser.html")); } @Test public void trace() throws Exception { - this.mockMvc.perform(get("/trace").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application/trace").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$._links").doesNotExist()) .andExpect(jsonPath("$").isArray()); } @Test public void envValue() throws Exception { - this.mockMvc.perform(get("/env/user.home").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application/env/user.home").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$._links").doesNotExist()); } @@ -107,11 +107,11 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests { public void endpointsAllListed() throws Exception { for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) { String path = endpoint.getPath(); - if ("/actuator".equals(path)) { + if ("/application".equals(path)) { continue; } path = path.startsWith("/") ? path.substring(1) : path; - this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$._links.%s.href", path).exists()); } @@ -126,10 +126,10 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests { if (collections.contains(path)) { continue; } - path = path.length() > 0 ? path : "/"; + path = "/application" + (path.length() > 0 ? path : "/"); this.mockMvc.perform(get(path).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$._links.self.href") - .value("http://localhost" + endpoint.getPath())); + .value("http://localhost/application" + endpoint.getPath())); } } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpointTests.java new file mode 100644 index 0000000000..1362b98e7a --- /dev/null +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalJsonMvcEndpointTests.java @@ -0,0 +1,56 @@ +/* + * Copyright 2012-2016 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.actuate.endpoint.mvc; + + +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link HalJsonMvcEndpoint}. + * + * @author Madhura Bhave + */ +public class HalJsonMvcEndpointTests { + + @Mock + ManagementServletContext managementServletContext; + + @Before + public void setup() { + MockitoAnnotations.initMocks(this); + } + + @Test + public void halJsonEndpointPathWhenManagementContextPathPresent() throws Exception { + Mockito.when(this.managementServletContext.getContextPath()).thenReturn("my-app"); + HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(this.managementServletContext); + assertThat(endpoint.getPath()).isEqualTo(""); + } + + @Test + public void halJsonEndpointPathWhenManagementContextPathNotPresent() throws Exception { + Mockito.when(this.managementServletContext.getContextPath()).thenReturn(""); + HalJsonMvcEndpoint endpoint = new HalJsonMvcEndpoint(this.managementServletContext); + assertThat(endpoint.getPath()).isEqualTo("/application"); + } +} diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointSecureOptionsTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointSecureOptionsTests.java index 845bd7b4ff..bb496b6119 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointSecureOptionsTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointSecureOptionsTests.java @@ -73,7 +73,7 @@ public class HeapdumpMvcEndpointSecureOptionsTests { @Test public void invokeOptionsShouldReturnSize() throws Exception { - this.mvc.perform(options("/heapdump")).andExpect(status().isOk()); + this.mvc.perform(options("/application/heapdump")).andExpect(status().isOk()); } @Import({ JacksonAutoConfiguration.class, diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointTests.java index b73e0e024c..1be0ac258f 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HeapdumpMvcEndpointTests.java @@ -82,26 +82,26 @@ public class HeapdumpMvcEndpointTests { @Test public void invokeWhenDisabledShouldReturnNotFoundStatus() throws Exception { this.endpoint.setEnabled(false); - this.mvc.perform(get("/heapdump")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/heapdump")).andExpect(status().isNotFound()); } @Test public void invokeWhenNotAvailableShouldReturnServiceUnavailableStatus() throws Exception { this.endpoint.setAvailable(false); - this.mvc.perform(get("/heapdump")).andExpect(status().isServiceUnavailable()); + this.mvc.perform(get("/application/heapdump")).andExpect(status().isServiceUnavailable()); } @Test public void invokeWhenLockedShouldReturnTooManyRequestsStatus() throws Exception { this.endpoint.setLocked(true); - this.mvc.perform(get("/heapdump")).andExpect(status().isTooManyRequests()); + this.mvc.perform(get("/application/heapdump")).andExpect(status().isTooManyRequests()); assertThat(Thread.interrupted()).isTrue(); } @Test public void invokeShouldReturnGzipContent() throws Exception { - MvcResult result = this.mvc.perform(get("/heapdump")).andExpect(status().isOk()) + MvcResult result = this.mvc.perform(get("/application/heapdump")).andExpect(status().isOk()) .andReturn(); byte[] bytes = result.getResponse().getContentAsByteArray(); GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(bytes)); @@ -111,7 +111,7 @@ public class HeapdumpMvcEndpointTests { @Test public void invokeOptionsShouldReturnSize() throws Exception { - this.mvc.perform(options("/heapdump")).andExpect(status().isOk()); + this.mvc.perform(options("/application/heapdump")).andExpect(status().isOk()); } @Import({ JacksonAutoConfiguration.class, AuditAutoConfiguration.class, diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointTests.java index 6c909fc78b..73910b4289 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointTests.java @@ -75,7 +75,7 @@ public class InfoMvcEndpointTests { @Test public void home() throws Exception { - this.mvc.perform(get("/info")).andExpect(status().isOk()) + this.mvc.perform(get("/application/info")).andExpect(status().isOk()) .andExpect(content().string(containsString( "\"beanName1\":{\"key11\":\"value11\",\"key12\":\"value12\"}"))) .andExpect(content().string(containsString( @@ -84,7 +84,7 @@ public class InfoMvcEndpointTests { @Test public void contentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/info")).andExpect(status().isOk()) + this.mvc.perform(get("/application/info")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @@ -92,7 +92,7 @@ public class InfoMvcEndpointTests { @Test public void contentTypeCanBeApplicationJson() throws Exception { this.mvc.perform( - get("/info").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)) + get("/application/info").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)) .andExpect(status().isOk()).andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointWithNoInfoContributorsTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointWithNoInfoContributorsTests.java index 6a17f01467..2246076a8e 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointWithNoInfoContributorsTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/InfoMvcEndpointWithNoInfoContributorsTests.java @@ -65,7 +65,7 @@ public class InfoMvcEndpointWithNoInfoContributorsTests { @Test public void home() throws Exception { - this.mvc.perform(get("/info")).andExpect(status().isOk()); + this.mvc.perform(get("/application/info")).andExpect(status().isOk()); } @Import({ JacksonAutoConfiguration.class, AuditAutoConfiguration.class, diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpointIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpointIntegrationTests.java index b4f3af0ae0..d759021acb 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpointIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/JolokiaMvcEndpointIntegrationTests.java @@ -79,20 +79,20 @@ public class JolokiaMvcEndpointIntegrationTests { @Test public void search() throws Exception { - this.mvc.perform(get("/jolokia/search/java.lang:*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/jolokia/search/java.lang:*")).andExpect(status().isOk()) .andExpect(content().string(containsString("GarbageCollector"))); } @Test public void read() throws Exception { - this.mvc.perform(get("/jolokia/read/java.lang:type=Memory")) + this.mvc.perform(get("/application/jolokia/read/java.lang:type=Memory")) .andExpect(status().isOk()) .andExpect(content().string(containsString("NonHeapMemoryUsage"))); } @Test public void list() throws Exception { - this.mvc.perform(get("/jolokia/list/java.lang/type=Memory/attr")) + this.mvc.perform(get("/application/jolokia/list/java.lang/type=Memory/attr")) .andExpect(status().isOk()) .andExpect(content().string(containsString("NonHeapMemoryUsage"))); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java index 83f824851e..5f2309f2f5 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpointTests.java @@ -99,21 +99,21 @@ public class LoggersMvcEndpointTests { .singletonList(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG))); String expected = "{\"levels\":[\"OFF\",\"FATAL\",\"ERROR\",\"WARN\",\"INFO\",\"DEBUG\",\"TRACE\"]," + "\"loggers\":{\"ROOT\":{\"configuredLevel\":null,\"effectiveLevel\":\"DEBUG\"}}}"; - this.mvc.perform(get("/loggers")).andExpect(status().isOk()) + this.mvc.perform(get("/application/loggers")).andExpect(status().isOk()) .andExpect(content().json(expected)); } @Test public void getLoggersWhenDisabledShouldReturnNotFound() throws Exception { this.context.getBean(LoggersEndpoint.class).setEnabled(false); - this.mvc.perform(get("/loggers")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/loggers")).andExpect(status().isNotFound()); } @Test public void getLoggerShouldReturnLogLevels() throws Exception { given(this.loggingSystem.getLoggerConfiguration("ROOT")) .willReturn(new LoggerConfiguration("ROOT", null, LogLevel.DEBUG)); - this.mvc.perform(get("/loggers/ROOT")).andExpect(status().isOk()) + this.mvc.perform(get("/application/loggers/ROOT")).andExpect(status().isOk()) .andExpect(content().string(equalTo( "{\"configuredLevel\":null," + "\"effectiveLevel\":\"DEBUG\"}"))); } @@ -121,25 +121,25 @@ public class LoggersMvcEndpointTests { @Test public void getLoggersRootWhenDisabledShouldReturnNotFound() throws Exception { this.context.getBean(LoggersEndpoint.class).setEnabled(false); - this.mvc.perform(get("/loggers/ROOT")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/loggers/ROOT")).andExpect(status().isNotFound()); } @Test public void getLoggersWhenLoggerNotFoundShouldReturnNotFound() throws Exception { - this.mvc.perform(get("/loggers/com.does.not.exist")) + this.mvc.perform(get("/application/loggers/com.does.not.exist")) .andExpect(status().isNotFound()); } @Test public void contentTypeForGetDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/loggers")).andExpect(status().isOk()) + this.mvc.perform(get("/application/loggers")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test public void contentTypeForGetCanBeApplicationJson() throws Exception { - this.mvc.perform(get("/loggers").header(HttpHeaders.ACCEPT, + this.mvc.perform(get("/application/loggers").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()) .andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); @@ -147,14 +147,14 @@ public class LoggersMvcEndpointTests { @Test public void setLoggerUsingApplicationJsonShouldSetLogLevel() throws Exception { - this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) + this.mvc.perform(post("/application/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) .content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk()); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); } @Test public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception { - this.mvc.perform(post("/loggers/ROOT") + this.mvc.perform(post("/application/loggers/ROOT") .contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON) .content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk()); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); @@ -163,7 +163,7 @@ public class LoggersMvcEndpointTests { @Test public void setLoggerWhenDisabledShouldReturnNotFound() throws Exception { this.context.getBean(LoggersEndpoint.class).setEnabled(false); - this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) + this.mvc.perform(post("/application/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) .content("{\"configuredLevel\":\"DEBUG\"}")) .andExpect(status().isNotFound()); verifyZeroInteractions(this.loggingSystem); @@ -171,7 +171,7 @@ public class LoggersMvcEndpointTests { @Test public void setLoggerWithWrongLogLevel() throws Exception { - this.mvc.perform(post("/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) + this.mvc.perform(post("/application/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) .content("{\"configuredLevel\":\"other\"}")) .andExpect(status().is4xxClientError()); verifyZeroInteractions(this.loggingSystem); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpointTests.java index 603c083541..a9cce63b76 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpointTests.java @@ -78,20 +78,20 @@ public class MetricsMvcEndpointTests { @Test public void home() throws Exception { - this.mvc.perform(get("/metrics")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics")).andExpect(status().isOk()) .andExpect(content().string(containsString("\"foo\":1"))); } @Test public void homeContentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/metrics")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test public void homeContentTypeCanBeApplicationJson() throws Exception { - this.mvc.perform(get("/metrics").header(HttpHeaders.ACCEPT, + this.mvc.perform(get("/application/metrics").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()) .andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); @@ -99,14 +99,14 @@ public class MetricsMvcEndpointTests { @Test public void specificMetricContentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(get("/metrics/foo")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics/foo")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test public void specificMetricContentTypeCanBeApplicationJson() throws Exception { - this.mvc.perform(get("/metrics/foo").header(HttpHeaders.ACCEPT, + this.mvc.perform(get("/application/metrics/foo").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()) .andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); @@ -115,50 +115,50 @@ public class MetricsMvcEndpointTests { @Test public void homeWhenDisabled() throws Exception { this.context.getBean(MetricsEndpoint.class).setEnabled(false); - this.mvc.perform(get("/metrics")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/metrics")).andExpect(status().isNotFound()); } @Test public void specificMetric() throws Exception { - this.mvc.perform(get("/metrics/foo")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics/foo")).andExpect(status().isOk()) .andExpect(content().string(equalTo("{\"foo\":1}"))); } @Test public void specificMetricWhenDisabled() throws Exception { this.context.getBean(MetricsEndpoint.class).setEnabled(false); - this.mvc.perform(get("/metrics/foo")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/metrics/foo")).andExpect(status().isNotFound()); } @Test public void specificMetricThatDoesNotExist() throws Exception { - this.mvc.perform(get("/metrics/bar")).andExpect(status().isNotFound()); + this.mvc.perform(get("/application/metrics/bar")).andExpect(status().isNotFound()); } @Test public void regexAll() throws Exception { String expected = "\"foo\":1,\"group1.a\":1,\"group1.b\":1,\"group2.a\":1,\"group2_a\":1"; - this.mvc.perform(get("/metrics/.*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics/.*")).andExpect(status().isOk()) .andExpect(content().string(containsString(expected))); } @Test public void regexGroupDot() throws Exception { String expected = "\"group1.a\":1,\"group1.b\":1,\"group2.a\":1"; - this.mvc.perform(get("/metrics/group[0-9]+\\..*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics/group[0-9]+\\..*")).andExpect(status().isOk()) .andExpect(content().string(containsString(expected))); } @Test public void regexGroup1() throws Exception { String expected = "\"group1.a\":1,\"group1.b\":1"; - this.mvc.perform(get("/metrics/group1\\..*")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics/group1\\..*")).andExpect(status().isOk()) .andExpect(content().string(containsString(expected))); } @Test public void specificMetricWithDot() throws Exception { - this.mvc.perform(get("/metrics/group2.a")).andExpect(status().isOk()) + this.mvc.perform(get("/application/metrics/group2.a")).andExpect(status().isOk()) .andExpect(content().string(containsString("1"))); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointCorsIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointCorsIntegrationTests.java index 772eb3ee69..674231b7b2 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointCorsIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointCorsIntegrationTests.java @@ -62,7 +62,7 @@ public class MvcEndpointCorsIntegrationTests { @Test public void corsIsDisabledByDefault() throws Exception { createMockMvc() - .perform(options("/beans").header("Origin", "foo.example.com") + .perform(options("/application/beans").header("Origin", "foo.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")) .andExpect( header().doesNotExist(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN)); @@ -73,7 +73,7 @@ public class MvcEndpointCorsIntegrationTests { EnvironmentTestUtils.addEnvironment(this.context, "endpoints.cors.allowed-origins:foo.example.com"); createMockMvc() - .perform(options("/beans").header("Origin", "bar.example.com") + .perform(options("/application/beans").header("Origin", "bar.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")) .andExpect(status().isForbidden()); performAcceptedCorsRequest(); @@ -101,7 +101,7 @@ public class MvcEndpointCorsIntegrationTests { EnvironmentTestUtils.addEnvironment(this.context, "endpoints.cors.allowed-origins:foo.example.com"); createMockMvc() - .perform(options("/beans").header("Origin", "foo.example.com") + .perform(options("/application/beans").header("Origin", "foo.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Alpha")) .andExpect(status().isForbidden()); @@ -113,7 +113,7 @@ public class MvcEndpointCorsIntegrationTests { "endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-headers:Alpha,Bravo"); createMockMvc() - .perform(options("/beans").header("Origin", "foo.example.com") + .perform(options("/application/beans").header("Origin", "foo.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_HEADERS, "Alpha")) .andExpect(status().isOk()).andExpect(header() @@ -125,7 +125,7 @@ public class MvcEndpointCorsIntegrationTests { EnvironmentTestUtils.addEnvironment(this.context, "endpoints.cors.allowed-origins:foo.example.com"); createMockMvc() - .perform(options("/health").header(HttpHeaders.ORIGIN, "foo.example.com") + .perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "PATCH")) .andExpect(status().isForbidden()); } @@ -136,7 +136,7 @@ public class MvcEndpointCorsIntegrationTests { "endpoints.cors.allowed-origins:foo.example.com", "endpoints.cors.allowed-methods:GET,HEAD"); createMockMvc() - .perform(options("/health").header(HttpHeaders.ORIGIN, "foo.example.com") + .perform(options("/application/health").header(HttpHeaders.ORIGIN, "foo.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "HEAD")) .andExpect(status().isOk()).andExpect(header() .string(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS, "GET,HEAD")); @@ -165,10 +165,10 @@ public class MvcEndpointCorsIntegrationTests { EnvironmentTestUtils.addEnvironment(this.context, "endpoints.cors.allowed-origins:foo.example.com"); createMockMvc() - .perform(options("/jolokia").header("Origin", "bar.example.com") + .perform(options("/application/jolokia").header("Origin", "bar.example.com") .header(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET")) .andExpect(status().isForbidden()); - performAcceptedCorsRequest("/jolokia"); + performAcceptedCorsRequest("/application/jolokia"); } private MockMvc createMockMvc() { @@ -177,7 +177,7 @@ public class MvcEndpointCorsIntegrationTests { } private ResultActions performAcceptedCorsRequest() throws Exception { - return performAcceptedCorsRequest("/beans"); + return performAcceptedCorsRequest("/application/beans"); } private ResultActions performAcceptedCorsRequest(String url) throws Exception { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointIntegrationTests.java index 92e1799edc..f8cc421362 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointIntegrationTests.java @@ -72,7 +72,7 @@ public class MvcEndpointIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); MockMvc mockMvc = createSecureMockMvc(); - mockMvc.perform(get("/mappings")).andExpect(content().string(startsWith("{\""))); + mockMvc.perform(get("/application/mappings")).andExpect(content().string(startsWith("{\""))); } @Test @@ -97,7 +97,7 @@ public class MvcEndpointIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(DefaultConfiguration.class); MockMvc mockMvc = createMockMvc(); - mockMvc.perform(get("/beans.cmd")).andExpect(status().isNotFound()); + mockMvc.perform(get("/application/beans.cmd")).andExpect(status().isNotFound()); } @Test @@ -107,7 +107,7 @@ public class MvcEndpointIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); MockMvc mockMvc = createSecureMockMvc(); - mockMvc.perform(get("/beans.json")).andExpect(status().isOk()); + mockMvc.perform(get("/application/beans.json")).andExpect(status().isOk()); } @Test @@ -115,8 +115,8 @@ public class MvcEndpointIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); MockMvc mockMvc = createSecureMockMvc(); - mockMvc.perform(get("/info")).andExpect(status().isOk()); - mockMvc.perform(get("/actuator")).andExpect(status().isOk()); + mockMvc.perform(get("/application/info")).andExpect(status().isOk()); + mockMvc.perform(get("/application")).andExpect(status().isOk()); } @Test @@ -136,7 +136,7 @@ public class MvcEndpointIntegrationTests { this.context = new AnnotationConfigWebApplicationContext(); this.context.register(SecureConfiguration.class); MockMvc mockMvc = createSecureMockMvc(); - mockMvc.perform(get("/beans")).andExpect(status().isUnauthorized()); + mockMvc.perform(get("/application/beans")).andExpect(status().isUnauthorized()); } @Test @@ -194,7 +194,7 @@ public class MvcEndpointIntegrationTests { EnvironmentTestUtils.addEnvironment(this.context, "management.security.enabled:false"); MockMvc mockMvc = createSecureMockMvc(); - mockMvc.perform(get("/beans")).andExpect(status().isOk()); + mockMvc.perform(get("/application/beans")).andExpect(status().isOk()); } private void assertIndentedJsonResponse(Class configuration) throws Exception { @@ -205,7 +205,7 @@ public class MvcEndpointIntegrationTests { EnvironmentTestUtils.addEnvironment(this.context, "spring.jackson.serialization.indent-output:true"); MockMvc mockMvc = createSecureMockMvc(); - mockMvc.perform(get("/mappings")) + mockMvc.perform(get("/application/mappings")) .andExpect(content().string(startsWith("{" + LINE_SEPARATOR))); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java index f388a1d997..873a72af50 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java @@ -74,7 +74,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests { this.context.register(TestConfiguration.class); this.context.refresh(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); - mockMvc.perform(get("/health").with(getRequestPostProcessor())) + mockMvc.perform(get("/application/health").with(getRequestPostProcessor())) .andExpect(status().isOk()) .andExpect(content().string("{\"status\":\"UP\"}")); } @@ -88,7 +88,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests { "management.security.enabled:false"); this.context.refresh(); MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build(); - mockMvc.perform(get("/health")).andExpect(status().isOk()) + mockMvc.perform(get("/application/health")).andExpect(status().isOk()) .andExpect(content().string(containsString( "\"status\":\"UP\",\"test\":{\"status\":\"UP\",\"hello\":\"world\"}"))); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java index 3c289ac353..908c73f704 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpointTests.java @@ -75,7 +75,7 @@ public class ShutdownMvcEndpointTests { @Test public void contentTypeDefaultsToActuatorV2Json() throws Exception { - this.mvc.perform(post("/shutdown")).andExpect(status().isOk()) + this.mvc.perform(post("/application/shutdown")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); assertThat(this.context.getBean(CountDownLatch.class).await(30, TimeUnit.SECONDS)) @@ -84,7 +84,7 @@ public class ShutdownMvcEndpointTests { @Test public void contentTypeCanBeApplicationJson() throws Exception { - this.mvc.perform(post("/shutdown").header(HttpHeaders.ACCEPT, + this.mvc.perform(post("/application/shutdown").header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()) .andExpect(header().string("Content-Type", MediaType.APPLICATION_JSON_UTF8_VALUE)); diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/test/java/sample/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/test/java/sample/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java index 20f2fdd0c9..2af0bb52d6 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/test/java/sample/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/test/java/sample/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java @@ -63,7 +63,7 @@ public class SampleActuatorLog4J2ApplicationTests { @Test public void validateLoggersEndpoint() throws Exception { - this.mvc.perform(get("/loggers/org.apache.coyote.http11.Http11NioProtocol")) + this.mvc.perform(get("/application/loggers/org.apache.coyote.http11.Http11NioProtocol")) .andExpect(status().isOk()) .andExpect(content().string(equalTo("{\"configuredLevel\":\"WARN\"," + "\"effectiveLevel\":\"WARN\"}"))); diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java b/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java index ea96355ed7..1021585365 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationPortTests.java @@ -61,14 +61,14 @@ public class SampleActuatorUiApplicationPortTests { public void testMetrics() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity entity = new TestRestTemplate().getForEntity( - "http://localhost:" + this.managementPort + "/metrics", Map.class); + "http://localhost:" + this.managementPort + "/application//metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } @Test public void testHealth() throws Exception { ResponseEntity entity = new TestRestTemplate().getForEntity( - "http://localhost:" + this.managementPort + "/health", String.class); + "http://localhost:" + this.managementPort + "/application//health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).isEqualTo("{\"status\":\"UP\"}"); } diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationTests.java index a72f62f86c..ef856c4e3f 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/test/java/sample/actuator/ui/SampleActuatorUiApplicationTests.java @@ -71,7 +71,7 @@ public class SampleActuatorUiApplicationTests { @Test public void testMetrics() throws Exception { @SuppressWarnings("rawtypes") - ResponseEntity entity = this.restTemplate.getForEntity("/metrics", + ResponseEntity entity = this.restTemplate.getForEntity("/application/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/InsecureManagementSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/InsecureManagementSampleActuatorApplicationTests.java index 9e5a6208bb..d0c95692d1 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/InsecureManagementSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/InsecureManagementSampleActuatorApplicationTests.java @@ -69,7 +69,7 @@ public class InsecureManagementSampleActuatorApplicationTests { // ignore; } @SuppressWarnings("rawtypes") - ResponseEntity entity = this.restTemplate.getForEntity("/metrics", + ResponseEntity entity = this.restTemplate.getForEntity("/application/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java index cdeb1e2107..6084e28b7f 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ManagementPortSampleActuatorApplicationTests.java @@ -71,14 +71,14 @@ public class ManagementPortSampleActuatorApplicationTests { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity entity = new TestRestTemplate().getForEntity( - "http://localhost:" + this.managementPort + "/metrics", Map.class); + "http://localhost:" + this.managementPort + "/application/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } @Test public void testHealth() throws Exception { ResponseEntity entity = new TestRestTemplate().getForEntity( - "http://localhost:" + this.managementPort + "/health", String.class); + "http://localhost:" + this.managementPort + "/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); } diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NonSensitiveHealthTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NonSensitiveHealthTests.java index e17fb524b2..5c368d5a85 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NonSensitiveHealthTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/NonSensitiveHealthTests.java @@ -46,7 +46,7 @@ public class NonSensitiveHealthTests { @Test public void testSecureHealth() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/health", + ResponseEntity entity = this.restTemplate.getForEntity("/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).doesNotContain("\"hello\":1"); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java index 2b27eb869d..4f2a3f6432 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/SampleActuatorApplicationTests.java @@ -98,7 +98,7 @@ public class SampleActuatorApplicationTests { testHome(); // makes sure some requests have been made @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/metrics", Map.class); + .withBasicAuth("user", getPassword()).getForEntity("/application/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map body = entity.getBody(); @@ -109,7 +109,7 @@ public class SampleActuatorApplicationTests { public void testEnv() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/env", Map.class); + .withBasicAuth("user", getPassword()).getForEntity("/application/env", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map body = entity.getBody(); @@ -118,7 +118,7 @@ public class SampleActuatorApplicationTests { @Test public void testHealth() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/health", + ResponseEntity entity = this.restTemplate.getForEntity("/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); @@ -129,14 +129,14 @@ public class SampleActuatorApplicationTests { public void testSecureHealth() throws Exception { ResponseEntity entity = this.restTemplate .withBasicAuth("user", getPassword()) - .getForEntity("/health", String.class); + .getForEntity("/application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"hello\":1"); } @Test public void testInfo() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/info", + ResponseEntity entity = this.restTemplate.getForEntity("/application/info", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()) @@ -176,7 +176,7 @@ public class SampleActuatorApplicationTests { this.restTemplate.getForEntity("/health", String.class); @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/trace", List.class); + .withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") List> list = entity.getBody(); @@ -189,10 +189,10 @@ public class SampleActuatorApplicationTests { @Test public void traceWithParameterMap() throws Exception { - this.restTemplate.getForEntity("/health?param1=value1", String.class); + this.restTemplate.getForEntity("/application/health?param1=value1", String.class); @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/trace", List.class); + .withBasicAuth("user", getPassword()).getForEntity("/application/trace", List.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") List> list = entity.getBody(); @@ -219,7 +219,7 @@ public class SampleActuatorApplicationTests { public void testBeans() throws Exception { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate - .withBasicAuth("user", getPassword()).getForEntity("/beans", List.class); + .withBasicAuth("user", getPassword()).getForEntity("/application/beans", List.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).hasSize(1); Map body = (Map) entity.getBody().get(0); @@ -231,7 +231,7 @@ public class SampleActuatorApplicationTests { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate .withBasicAuth("user", getPassword()) - .getForEntity("/configprops", Map.class); + .getForEntity("/application/configprops", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map body = entity.getBody(); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathInsecureSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathInsecureSampleActuatorApplicationTests.java index 749cca860f..cc3a44b6a3 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathInsecureSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathInsecureSampleActuatorApplicationTests.java @@ -62,7 +62,7 @@ public class ServletPathInsecureSampleActuatorApplicationTests { @Test public void testMetricsIsSecure() throws Exception { @SuppressWarnings("rawtypes") - ResponseEntity entity = this.restTemplate.getForEntity("/spring/metrics", + ResponseEntity entity = this.restTemplate.getForEntity("/spring//application/metrics", Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathSampleActuatorApplicationTests.java index b694fe2421..31bbc9bdaa 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ServletPathSampleActuatorApplicationTests.java @@ -60,7 +60,7 @@ public class ServletPathSampleActuatorApplicationTests { @Test public void testHealth() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/spring/health", + ResponseEntity entity = this.restTemplate.getForEntity("/spring//application/health", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(entity.getBody()).contains("\"status\":\"UP\""); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java index b512888173..80c7c2e5c8 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/test/java/sample/actuator/ShutdownSampleActuatorApplicationTests.java @@ -65,7 +65,7 @@ public class ShutdownSampleActuatorApplicationTests { @SuppressWarnings("rawtypes") ResponseEntity entity = this.restTemplate .withBasicAuth("user", getPassword()) - .postForEntity("/shutdown", null, Map.class); + .postForEntity("/application/shutdown", null, Map.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); @SuppressWarnings("unchecked") Map body = entity.getBody(); diff --git a/spring-boot-samples/spring-boot-sample-hypermedia-gson/src/test/java/sample/hypermedia/gson/SampleHypermediaGsonApplicationTests.java b/spring-boot-samples/spring-boot-sample-hypermedia-gson/src/test/java/sample/hypermedia/gson/SampleHypermediaGsonApplicationTests.java index ef4702e13b..18d9c4ca24 100644 --- a/spring-boot-samples/spring-boot-sample-hypermedia-gson/src/test/java/sample/hypermedia/gson/SampleHypermediaGsonApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-hypermedia-gson/src/test/java/sample/hypermedia/gson/SampleHypermediaGsonApplicationTests.java @@ -50,22 +50,22 @@ public class SampleHypermediaGsonApplicationTests { @Test public void health() throws Exception { - this.mockMvc.perform(get("/health").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application/health").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) - .andExpect(jsonPath("$.links[0].href").value("http://localhost/health")) + .andExpect(jsonPath("$.links[0].href").value("http://localhost/application/health")) .andExpect(jsonPath("$.content.status").exists()); } @Test public void trace() throws Exception { - this.mockMvc.perform(get("/trace").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application/trace").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$.links").doesNotExist()) .andExpect(jsonPath("$").isArray()); } @Test public void envValue() throws Exception { - this.mockMvc.perform(get("/env/user.home").accept(MediaType.APPLICATION_JSON)) + this.mockMvc.perform(get("/application/env/user.home").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$._links").doesNotExist()); } diff --git a/spring-boot-samples/spring-boot-sample-hypermedia-ui-secure/src/test/java/sample/hypermedia/ui/secure/SampleHypermediaUiSecureApplicationTests.java b/spring-boot-samples/spring-boot-sample-hypermedia-ui-secure/src/test/java/sample/hypermedia/ui/secure/SampleHypermediaUiSecureApplicationTests.java index 651f87980f..57495667ff 100644 --- a/spring-boot-samples/spring-boot-sample-hypermedia-ui-secure/src/test/java/sample/hypermedia/ui/secure/SampleHypermediaUiSecureApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-hypermedia-ui-secure/src/test/java/sample/hypermedia/ui/secure/SampleHypermediaUiSecureApplicationTests.java @@ -38,16 +38,16 @@ public class SampleHypermediaUiSecureApplicationTests { @Test public void links() { - String response = this.restTemplate.getForObject("/actuator", String.class); + String response = this.restTemplate.getForObject("/application", String.class); assertThat(response).contains("\"_links\":"); } @Test public void testInsecureNestedPath() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/env", + ResponseEntity entity = this.restTemplate.getForEntity("/application/env", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); - ResponseEntity user = this.restTemplate.getForEntity("/env/foo", + ResponseEntity user = this.restTemplate.getForEntity("/application/env/foo", String.class); assertThat(user.getStatusCode()).isEqualTo(HttpStatus.OK); assertThat(user.getBody()).contains("{\"foo\":"); @@ -55,7 +55,7 @@ public class SampleHypermediaUiSecureApplicationTests { @Test public void testSecurePath() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/metrics", + ResponseEntity entity = this.restTemplate.getForEntity("/application/metrics", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } diff --git a/spring-boot-samples/spring-boot-sample-hypermedia-ui/src/test/java/sample/hypermedia/ui/SampleHypermediaUiApplicationTests.java b/spring-boot-samples/spring-boot-sample-hypermedia-ui/src/test/java/sample/hypermedia/ui/SampleHypermediaUiApplicationTests.java index 84dd325a74..c482095f2f 100644 --- a/spring-boot-samples/spring-boot-sample-hypermedia-ui/src/test/java/sample/hypermedia/ui/SampleHypermediaUiApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-hypermedia-ui/src/test/java/sample/hypermedia/ui/SampleHypermediaUiApplicationTests.java @@ -50,7 +50,7 @@ public class SampleHypermediaUiApplicationTests { @Test public void links() { - String response = this.restTemplate.getForObject("/actuator", String.class); + String response = this.restTemplate.getForObject("/application", String.class); assertThat(response).contains("\"_links\":"); } @@ -58,7 +58,7 @@ public class SampleHypermediaUiApplicationTests { public void linksWithJson() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); - ResponseEntity response = this.restTemplate.exchange("/actuator", + ResponseEntity response = this.restTemplate.exchange("/application", HttpMethod.GET, new HttpEntity(headers), String.class); assertThat(response.getBody()).contains("\"_links\":"); } diff --git a/spring-boot-samples/spring-boot-sample-hypermedia/src/test/java/sample/hypermedia/SampleHypermediaApplicationHomePageTests.java b/spring-boot-samples/spring-boot-sample-hypermedia/src/test/java/sample/hypermedia/SampleHypermediaApplicationHomePageTests.java index 1c8395a3fb..703338d879 100644 --- a/spring-boot-samples/spring-boot-sample-hypermedia/src/test/java/sample/hypermedia/SampleHypermediaApplicationHomePageTests.java +++ b/spring-boot-samples/spring-boot-sample-hypermedia/src/test/java/sample/hypermedia/SampleHypermediaApplicationHomePageTests.java @@ -51,7 +51,7 @@ public class SampleHypermediaApplicationHomePageTests { public void linksWithJson() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); - ResponseEntity response = this.restTemplate.exchange("/actuator", + ResponseEntity response = this.restTemplate.exchange("/application", HttpMethod.GET, new HttpEntity(headers), String.class); assertThat(response.getBody()).contains("\"_links\":"); } @@ -60,7 +60,7 @@ public class SampleHypermediaApplicationHomePageTests { public void halWithHtml() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.TEXT_HTML)); - ResponseEntity response = this.restTemplate.exchange("/actuator/", + ResponseEntity response = this.restTemplate.exchange("/application/", HttpMethod.GET, new HttpEntity(headers), String.class); assertThat(response.getBody()).contains("HAL Browser"); } diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java index 55338463c4..4c1ff5e6dc 100644 --- a/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-secure-oauth2-actuator/src/test/java/sample/secure/oauth2/actuator/SampleSecureOAuth2ActuatorApplicationTests.java @@ -70,19 +70,19 @@ public class SampleSecureOAuth2ActuatorApplicationTests { @Test public void healthAvailable() throws Exception { - this.mvc.perform(get("/health")).andExpect(status().isOk()).andDo(print()); + this.mvc.perform(get("/application/health")).andExpect(status().isOk()).andDo(print()); } @Test public void envSecuredWithBasic() throws Exception { - this.mvc.perform(get("/env")).andExpect(status().isUnauthorized()) + this.mvc.perform(get("/application/env")).andExpect(status().isUnauthorized()) .andExpect(header().string("WWW-Authenticate", containsString("Basic"))) .andDo(print()); } @Test public void envWithPassword() throws Exception { - this.mvc.perform(get("/env").header("Authorization", + this.mvc.perform(get("/application/env").header("Authorization", "Basic " + Base64Utils.encodeToString("user:password".getBytes()))) .andExpect(status().isOk()).andDo(print()); } diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/security/method/SampleMethodSecurityApplicationTests.java b/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/security/method/SampleMethodSecurityApplicationTests.java index ec34d73637..818f729f12 100644 --- a/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/security/method/SampleMethodSecurityApplicationTests.java +++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/test/java/sample/security/method/SampleMethodSecurityApplicationTests.java @@ -105,7 +105,7 @@ public class SampleMethodSecurityApplicationTests { @Test public void testManagementProtected() throws Exception { - ResponseEntity entity = this.restTemplate.getForEntity("/beans", + ResponseEntity entity = this.restTemplate.getForEntity("/application/beans", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.UNAUTHORIZED); } @@ -116,7 +116,7 @@ public class SampleMethodSecurityApplicationTests { "admin", "admin"); this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor); try { - ResponseEntity entity = this.restTemplate.getForEntity("/beans", + ResponseEntity entity = this.restTemplate.getForEntity("/application/beans", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK); } @@ -132,7 +132,7 @@ public class SampleMethodSecurityApplicationTests { "user", "user"); this.restTemplate.getRestTemplate().getInterceptors().add(basicAuthInterceptor); try { - ResponseEntity entity = this.restTemplate.getForEntity("/beans", + ResponseEntity entity = this.restTemplate.getForEntity("/application/beans", String.class); assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.FORBIDDEN); }