Merge branch '3.0.x' into 3.1.x
Closes gh-36276
This commit is contained in:
@@ -197,7 +197,7 @@ class JerseyWebEndpointManagementContextConfiguration {
|
||||
JerseyHealthEndpointAdditionalPathResourceFactory resourceFactory = new JerseyHealthEndpointAdditionalPathResourceFactory(
|
||||
WebServerNamespace.MANAGEMENT, this.groups);
|
||||
Collection<Resource> endpointResources = resourceFactory
|
||||
.createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false)
|
||||
.createEndpointResources(mapping, Collections.singletonList(this.endpoint))
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
|
||||
@@ -162,7 +162,7 @@ class HealthEndpointWebExtensionConfiguration {
|
||||
JerseyHealthEndpointAdditionalPathResourceFactory resourceFactory = new JerseyHealthEndpointAdditionalPathResourceFactory(
|
||||
WebServerNamespace.SERVER, this.groups);
|
||||
Collection<Resource> endpointResources = resourceFactory
|
||||
.createEndpointResources(mapping, Collections.singletonList(this.endpoint), null, null, false)
|
||||
.createEndpointResources(mapping, Collections.singletonList(this.endpoint))
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatNoException;
|
||||
|
||||
/**
|
||||
* Abstract base class for health groups with an additional path.
|
||||
*
|
||||
@@ -52,6 +54,18 @@ abstract class AbstractHealthEndpointAdditionalPathIntegrationTests<T extends Ab
|
||||
.run(withWebTestClient(this::testResponse, "local.server.port"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void multipleGroupsAreAvailableAtAdditionalPaths() {
|
||||
this.runner
|
||||
.withPropertyValues("management.endpoint.health.group.one.include=diskSpace",
|
||||
"management.endpoint.health.group.two.include=diskSpace",
|
||||
"management.endpoint.health.group.one.additional-path=server:/alpha",
|
||||
"management.endpoint.health.group.two.additional-path=server:/bravo",
|
||||
"management.endpoint.health.group.one.show-components=always",
|
||||
"management.endpoint.health.group.two.show-components=always")
|
||||
.run(withWebTestClient((client) -> testResponses(client, "/alpha", "/bravo"), "local.server.port"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void groupIsAvailableAtAdditionalPathWithoutSlash() {
|
||||
this.runner
|
||||
@@ -125,17 +139,24 @@ abstract class AbstractHealthEndpointAdditionalPathIntegrationTests<T extends Ab
|
||||
}
|
||||
|
||||
private void testResponse(WebTestClient client) {
|
||||
client.get()
|
||||
.uri("/healthz")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isOk()
|
||||
.expectBody()
|
||||
.jsonPath("status")
|
||||
.isEqualTo("UP")
|
||||
.jsonPath("components.diskSpace")
|
||||
.exists();
|
||||
testResponses(client, "/healthz");
|
||||
}
|
||||
|
||||
private void testResponses(WebTestClient client, String... paths) {
|
||||
for (String path : paths) {
|
||||
assertThatNoException().as(path)
|
||||
.isThrownBy(() -> client.get()
|
||||
.uri(path)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.exchange()
|
||||
.expectStatus()
|
||||
.isOk()
|
||||
.expectBody()
|
||||
.jsonPath("status")
|
||||
.isEqualTo("UP")
|
||||
.jsonPath("components.diskSpace")
|
||||
.exists());
|
||||
}
|
||||
}
|
||||
|
||||
private ContextConsumer<A> withWebTestClient(Consumer<WebTestClient> consumer, String property) {
|
||||
|
||||
Reference in New Issue
Block a user