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 1807a12939..c2652e3afd 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 @@ -124,7 +124,7 @@ public class EndpointDocumentation { public void setLogger() throws Exception { this.mockMvc .perform(post("/loggers/org.springframework.boot") - .contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON) + .contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON) .content("{\"configuredLevel\": \"DEBUG\"}")) .andExpect(status().isOk()).andDo(document("set-logger")); } @@ -133,7 +133,7 @@ public class EndpointDocumentation { public void auditEvents() throws Exception { this.mockMvc .perform(get("/auditevents").param("after", "2016-11-01T10:00:00+0000") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document("auditevents")); } @@ -142,7 +142,7 @@ public class EndpointDocumentation { this.mockMvc .perform(get("/auditevents").param("principal", "admin") .param("after", "2016-11-01T10:00:00+0000") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()) .andDo(document("auditevents/filter-by-principal")); } @@ -153,7 +153,7 @@ public class EndpointDocumentation { .perform(get("/auditevents").param("principal", "admin") .param("after", "2016-11-01T10:00:00+0000") .param("type", "AUTHENTICATION_SUCCESS") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()) .andDo(document("auditevents/filter-by-principal-and-type")); } @@ -172,7 +172,7 @@ public class EndpointDocumentation { output = output.length() > 0 ? output : "./"; this.mockMvc .perform(get(endpointPath) - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .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 7f7601ab46..3ee568ddce 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 @@ -52,7 +52,7 @@ public class HealthEndpointDocumentation { public void health() throws Exception { this.mockMvc .perform(get("/health") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .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 224a8acb71..4f8ca1d8ba 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 @@ -53,7 +53,7 @@ public class HypermediaEndpointDocumentation { public void beans() throws Exception { this.mockMvc .perform(get("/beans") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()).andDo(document("beans/hypermedia")); } @@ -61,7 +61,7 @@ public class HypermediaEndpointDocumentation { public void metrics() throws Exception { this.mockMvc .perform(get("/metrics") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$._links.self.href") .value("http://localhost:8080/metrics")) @@ -72,7 +72,7 @@ public class HypermediaEndpointDocumentation { public void home() throws Exception { this.mockMvc .perform(get("/actuator") - .accept(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON)) + .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/EndpointWebMvcHypermediaManagementContextConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java index f4f6712c54..1aca690d5c 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java @@ -250,7 +250,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration { if (messageConverter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) { List supportedMediaTypes = new ArrayList<>( messageConverter.getSupportedMediaTypes()); - supportedMediaTypes.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON); + supportedMediaTypes.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON); ((AbstractHttpMessageConverter) messageConverter) .setSupportedMediaTypes(supportedMediaTypes); } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorGetMapping.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorGetMapping.java index 8f534e8076..30e9bbbf8b 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorGetMapping.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorGetMapping.java @@ -38,7 +38,7 @@ import org.springframework.web.bind.annotation.RequestMethod; @Retention(RetentionPolicy.RUNTIME) @Documented @RequestMapping(method = RequestMethod.GET, produces = { - ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, + ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @interface ActuatorGetMapping { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorMediaTypes.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorMediaTypes.java index 5018921a64..6817a398a3 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorMediaTypes.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorMediaTypes.java @@ -22,6 +22,7 @@ import org.springframework.http.MediaType; * {@link MediaType MediaTypes} that can be consumed and produced by Actuator endpoints. * * @author Andy Wilkinson + * @author Madhura Bhave * @since 1.5.0 */ public final class ActuatorMediaTypes { @@ -31,12 +32,23 @@ public final class ActuatorMediaTypes { */ public static final String APPLICATION_ACTUATOR_V1_JSON_VALUE = "application/vnd.spring-boot.actuator.v1+json"; + /** + * {@link String} equivalent of {@link #APPLICATION_ACTUATOR_V2_JSON}. + */ + public static final String APPLICATION_ACTUATOR_V2_JSON_VALUE = "application/vnd.spring-boot.actuator.v2+json"; + /** * The {@code application/vnd.spring-boot.actuator.v1+json} media type. */ public static final MediaType APPLICATION_ACTUATOR_V1_JSON = MediaType .valueOf(APPLICATION_ACTUATOR_V1_JSON_VALUE); + /** + * The {@code application/vnd.spring-boot.actuator.v2+json} media type. + */ + public static final MediaType APPLICATION_ACTUATOR_V2_JSON = MediaType + .valueOf(APPLICATION_ACTUATOR_V2_JSON_VALUE); + private ActuatorMediaTypes() { } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorPostMapping.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorPostMapping.java index 4ec79ed793..ff4746ba2d 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorPostMapping.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ActuatorPostMapping.java @@ -40,9 +40,9 @@ import org.springframework.web.bind.annotation.RequestMethod; @Retention(RetentionPolicy.RUNTIME) @Documented @RequestMapping(method = RequestMethod.POST, consumes = { - ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, + ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }, produces = { - ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, + ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @interface ActuatorPostMapping { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java index ddb887b58d..6424d102b0 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java @@ -38,7 +38,7 @@ public class ShutdownMvcEndpoint extends EndpointMvcAdapter { super(delegate); } - @PostMapping(produces = { ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, + @PostMapping(produces = { ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE }) @ResponseBody @Override 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 c42a2c3687..8e32949342 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 @@ -73,10 +73,10 @@ public class AuditEventsMvcEndpointTests { } @Test - public void contentTypeDefaultsToActuatorV1Json() throws Exception { + public void contentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/auditevents")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test 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 a1f13eace7..41558077e2 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 @@ -79,10 +79,10 @@ public class EnvironmentMvcEndpointTests { } @Test - public void homeContentTypeDefaultsToActuatorV1Json() throws Exception { + public void homeContentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/env")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test @@ -94,10 +94,10 @@ public class EnvironmentMvcEndpointTests { } @Test - public void subContentTypeDefaultsToActuatorV1Json() throws Exception { + public void subContentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/env/foo")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test 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 94f294bd05..6c909fc78b 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 @@ -83,10 +83,10 @@ public class InfoMvcEndpointTests { } @Test - public void contentTypeDefaultsToActuatorV1Json() throws Exception { + public void contentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/info")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test 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 0d3025a23d..82e573a788 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 @@ -130,10 +130,10 @@ public class LoggersMvcEndpointTests { } @Test - public void contentTypeForGetDefaultsToActuatorV1Json() throws Exception { + public void contentTypeForGetDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/loggers")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test @@ -152,9 +152,9 @@ public class LoggersMvcEndpointTests { } @Test - public void setLoggerUsingActuatorV1JsonShouldSetLogLevel() throws Exception { + public void setLoggerUsingActuatorV2JsonShouldSetLogLevel() throws Exception { this.mvc.perform(post("/loggers/ROOT") - .contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON) + .contentType(ActuatorMediaTypes.APPLICATION_ACTUATOR_V2_JSON) .content("{\"configuredLevel\":\"debug\"}")).andExpect(status().isOk()); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); } 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 aa6937ef9d..603c083541 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 @@ -83,10 +83,10 @@ public class MetricsMvcEndpointTests { } @Test - public void homeContentTypeDefaultsToActuatorV1Json() throws Exception { + public void homeContentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/metrics")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test @@ -98,10 +98,10 @@ public class MetricsMvcEndpointTests { } @Test - public void specificMetricContentTypeDefaultsToActuatorV1Json() throws Exception { + public void specificMetricContentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(get("/metrics/foo")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); } @Test 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 3eb5bacc17..3c289ac353 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 @@ -74,10 +74,10 @@ public class ShutdownMvcEndpointTests { } @Test - public void contentTypeDefaultsToActuatorV1Json() throws Exception { + public void contentTypeDefaultsToActuatorV2Json() throws Exception { this.mvc.perform(post("/shutdown")).andExpect(status().isOk()) .andExpect(header().string("Content-Type", - "application/vnd.spring-boot.actuator.v1+json;charset=UTF-8")); + "application/vnd.spring-boot.actuator.v2+json;charset=UTF-8")); assertThat(this.context.getBean(CountDownLatch.class).await(30, TimeUnit.SECONDS)) .isTrue(); }