Test v3 actuator API with loggers endpoint

Update `LoggersEndpointWebIntegrationTests` to ensure that the new
v3 media type can be used.

See gh-17929
pull/18371/head
Phillip Webb 5 years ago
parent deb9d67cef
commit cd1b7c1a9c

@ -132,6 +132,15 @@ class LoggersEndpointWebIntegrationTests {
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
} }
@WebEndpointTest
void setLoggerUsingActuatorV3JsonShouldSetLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V3_JSON))
.bodyValue(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus()
.isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG);
}
@WebEndpointTest @WebEndpointTest
void setLoggerGroupUsingActuatorV2JsonShouldSetLogLevel() { void setLoggerGroupUsingActuatorV2JsonShouldSetLogLevel() {
this.client.post().uri("/actuator/loggers/test") this.client.post().uri("/actuator/loggers/test")
@ -162,7 +171,7 @@ class LoggersEndpointWebIntegrationTests {
@WebEndpointTest @WebEndpointTest
void setLoggerWithNullLogLevel() { void setLoggerWithNullLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT") this.client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)) .contentType(MediaType.parseMediaType(ActuatorMediaType.V3_JSON))
.bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); .bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null); verify(this.loggingSystem).setLogLevel("ROOT", null);
} }
@ -170,7 +179,7 @@ class LoggersEndpointWebIntegrationTests {
@WebEndpointTest @WebEndpointTest
void setLoggerWithNoLogLevel() { void setLoggerWithNoLogLevel() {
this.client.post().uri("/actuator/loggers/ROOT") this.client.post().uri("/actuator/loggers/ROOT")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)).bodyValue(Collections.emptyMap()) .contentType(MediaType.parseMediaType(ActuatorMediaType.V3_JSON)).bodyValue(Collections.emptyMap())
.exchange().expectStatus().isNoContent(); .exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("ROOT", null); verify(this.loggingSystem).setLogLevel("ROOT", null);
} }
@ -178,7 +187,7 @@ class LoggersEndpointWebIntegrationTests {
@WebEndpointTest @WebEndpointTest
void setLoggerGroupWithNullLogLevel() { void setLoggerGroupWithNullLogLevel() {
this.client.post().uri("/actuator/loggers/test") this.client.post().uri("/actuator/loggers/test")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)) .contentType(MediaType.parseMediaType(ActuatorMediaType.V3_JSON))
.bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); .bodyValue(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("test.member1", null); verify(this.loggingSystem).setLogLevel("test.member1", null);
verify(this.loggingSystem).setLogLevel("test.member2", null); verify(this.loggingSystem).setLogLevel("test.member2", null);
@ -187,7 +196,7 @@ class LoggersEndpointWebIntegrationTests {
@WebEndpointTest @WebEndpointTest
void setLoggerGroupWithNoLogLevel() { void setLoggerGroupWithNoLogLevel() {
this.client.post().uri("/actuator/loggers/test") this.client.post().uri("/actuator/loggers/test")
.contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)).bodyValue(Collections.emptyMap()) .contentType(MediaType.parseMediaType(ActuatorMediaType.V3_JSON)).bodyValue(Collections.emptyMap())
.exchange().expectStatus().isNoContent(); .exchange().expectStatus().isNoContent();
verify(this.loggingSystem).setLogLevel("test.member1", null); verify(this.loggingSystem).setLogLevel("test.member1", null);
verify(this.loggingSystem).setLogLevel("test.member2", null); verify(this.loggingSystem).setLogLevel("test.member2", null);

Loading…
Cancel
Save