Skip to content

Commit 56760ea

Browse files
committed
Merge branch '3.4.x'
Closes gh-45804
2 parents 0866461 + 954ae30 commit 56760ea

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfigurationTests.java

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import reactor.core.publisher.Mono;
2525

2626
import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
27+
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.WithTestEndpointOutcomeExposureContributor;
2728
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
2829
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointConfiguration.HealthEndpointGroupMembershipValidator.NoSuchHealthContributorException;
2930
import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointReactiveWebExtensionConfiguration.WebFluxAdditionalHealthEndpointPathsConfiguration;
@@ -32,6 +33,7 @@
3233
import org.springframework.boot.actuate.endpoint.ApiVersion;
3334
import org.springframework.boot.actuate.endpoint.SecurityContext;
3435
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
36+
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
3537
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
3638
import org.springframework.boot.actuate.health.CompositeHealthContributor;
3739
import org.springframework.boot.actuate.health.DefaultHealthContributorRegistry;
@@ -53,7 +55,9 @@
5355
import org.springframework.boot.actuate.health.StatusAggregator;
5456
import org.springframework.boot.actuate.health.SystemHealth;
5557
import org.springframework.boot.autoconfigure.AutoConfigurations;
58+
import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener;
5659
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
60+
import org.springframework.boot.logging.LogLevel;
5761
import org.springframework.boot.test.context.FilteredClassLoader;
5862
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
5963
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
@@ -343,42 +347,56 @@ void runWithReactiveContextAndIndicatorsInParentContextFindsIndicators() {
343347
}
344348

345349
@Test
350+
@WithTestEndpointOutcomeExposureContributor
346351
void additionalHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed() {
347352
this.contextRunner
348353
.withConfiguration(AutoConfigurations.of(DispatcherServletAutoConfiguration.class,
349354
EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class))
350355
.withPropertyValues("management.endpoints.web.exposure.exclude=*",
351-
"management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry")
356+
"management.endpoints.test.exposure.include=*")
352357
.run((context) -> {
353-
assertThat(context).hasSingleBean(MvcAdditionalHealthEndpointPathsConfiguration.class);
354358
assertThat(context).hasNotFailed();
359+
assertThat(context).hasSingleBean(HealthEndpoint.class);
360+
assertThat(context).hasSingleBean(HealthEndpointWebExtension.class);
361+
assertThat(context.getBean(WebEndpointsSupplier.class).getEndpoints()).isEmpty();
362+
assertThat(context).hasSingleBean(MvcAdditionalHealthEndpointPathsConfiguration.class);
355363
});
356364
}
357365

358366
@Test
367+
@WithTestEndpointOutcomeExposureContributor
359368
void additionalJerseyHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed() {
360369
this.contextRunner
361370
.withConfiguration(
362371
AutoConfigurations.of(EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class))
363-
.withClassLoader(new FilteredClassLoader(DispatcherServlet.class))
372+
.withClassLoader(
373+
new FilteredClassLoader(Thread.currentThread().getContextClassLoader(), DispatcherServlet.class))
374+
.withInitializer(ConditionEvaluationReportLoggingListener.forLogLevel(LogLevel.INFO))
364375
.withPropertyValues("management.endpoints.web.exposure.exclude=*",
365-
"management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry")
376+
"management.endpoints.test.exposure.include=*")
366377
.run((context) -> {
367-
assertThat(context).hasSingleBean(JerseyAdditionalHealthEndpointPathsConfiguration.class);
368378
assertThat(context).hasNotFailed();
379+
assertThat(context).hasSingleBean(HealthEndpoint.class);
380+
assertThat(context).hasSingleBean(HealthEndpointWebExtension.class);
381+
assertThat(context.getBean(WebEndpointsSupplier.class).getEndpoints()).isEmpty();
382+
assertThat(context).hasSingleBean(JerseyAdditionalHealthEndpointPathsConfiguration.class);
369383
});
370384
}
371385

372386
@Test
387+
@WithTestEndpointOutcomeExposureContributor
373388
void additionalReactiveHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed() {
374389
this.reactiveContextRunner
375390
.withConfiguration(
376391
AutoConfigurations.of(EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class))
377392
.withPropertyValues("management.endpoints.web.exposure.exclude=*",
378-
"management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry")
393+
"management.endpoints.test.exposure.include=*")
379394
.run((context) -> {
380-
assertThat(context).hasSingleBean(WebFluxAdditionalHealthEndpointPathsConfiguration.class);
381395
assertThat(context).hasNotFailed();
396+
assertThat(context).hasSingleBean(HealthEndpoint.class);
397+
assertThat(context).hasSingleBean(ReactiveHealthEndpointWebExtension.class);
398+
assertThat(context.getBean(WebEndpointsSupplier.class).getEndpoints()).isEmpty();
399+
assertThat(context).hasSingleBean(WebFluxAdditionalHealthEndpointPathsConfiguration.class);
382400
});
383401
}
384402

@@ -505,4 +523,9 @@ public HealthEndpointGroups postProcessHealthEndpointGroups(HealthEndpointGroups
505523

506524
}
507525

526+
@Configuration(proxyBeanMethods = false)
527+
static class UnconditionalHealthEndpointWebExtensionConfiguration extends HealthEndpointWebExtensionConfiguration {
528+
529+
}
530+
508531
}

0 commit comments

Comments
 (0)