|
24 | 24 | import reactor.core.publisher.Mono; |
25 | 25 |
|
26 | 26 | import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; |
| 27 | +import org.springframework.boot.actuate.autoconfigure.endpoint.condition.WithTestEndpointOutcomeExposureContributor; |
27 | 28 | import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; |
28 | 29 | import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointConfiguration.HealthEndpointGroupMembershipValidator.NoSuchHealthContributorException; |
29 | 30 | import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointReactiveWebExtensionConfiguration.WebFluxAdditionalHealthEndpointPathsConfiguration; |
|
32 | 33 | import org.springframework.boot.actuate.endpoint.ApiVersion; |
33 | 34 | import org.springframework.boot.actuate.endpoint.SecurityContext; |
34 | 35 | import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse; |
| 36 | +import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier; |
35 | 37 | import org.springframework.boot.actuate.endpoint.web.WebServerNamespace; |
36 | 38 | import org.springframework.boot.actuate.health.CompositeHealthContributor; |
37 | 39 | import org.springframework.boot.actuate.health.DefaultHealthContributorRegistry; |
|
53 | 55 | import org.springframework.boot.actuate.health.StatusAggregator; |
54 | 56 | import org.springframework.boot.actuate.health.SystemHealth; |
55 | 57 | import org.springframework.boot.autoconfigure.AutoConfigurations; |
| 58 | +import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener; |
56 | 59 | import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration; |
| 60 | +import org.springframework.boot.logging.LogLevel; |
57 | 61 | import org.springframework.boot.test.context.FilteredClassLoader; |
58 | 62 | import org.springframework.boot.test.context.runner.ApplicationContextRunner; |
59 | 63 | import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; |
@@ -343,42 +347,56 @@ void runWithReactiveContextAndIndicatorsInParentContextFindsIndicators() { |
343 | 347 | } |
344 | 348 |
|
345 | 349 | @Test |
| 350 | + @WithTestEndpointOutcomeExposureContributor |
346 | 351 | void additionalHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed() { |
347 | 352 | this.contextRunner |
348 | 353 | .withConfiguration(AutoConfigurations.of(DispatcherServletAutoConfiguration.class, |
349 | 354 | EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class)) |
350 | 355 | .withPropertyValues("management.endpoints.web.exposure.exclude=*", |
351 | | - "management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry") |
| 356 | + "management.endpoints.test.exposure.include=*") |
352 | 357 | .run((context) -> { |
353 | | - assertThat(context).hasSingleBean(MvcAdditionalHealthEndpointPathsConfiguration.class); |
354 | 358 | 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); |
355 | 363 | }); |
356 | 364 | } |
357 | 365 |
|
358 | 366 | @Test |
| 367 | + @WithTestEndpointOutcomeExposureContributor |
359 | 368 | void additionalJerseyHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed() { |
360 | 369 | this.contextRunner |
361 | 370 | .withConfiguration( |
362 | 371 | 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)) |
364 | 375 | .withPropertyValues("management.endpoints.web.exposure.exclude=*", |
365 | | - "management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry") |
| 376 | + "management.endpoints.test.exposure.include=*") |
366 | 377 | .run((context) -> { |
367 | | - assertThat(context).hasSingleBean(JerseyAdditionalHealthEndpointPathsConfiguration.class); |
368 | 378 | 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); |
369 | 383 | }); |
370 | 384 | } |
371 | 385 |
|
372 | 386 | @Test |
| 387 | + @WithTestEndpointOutcomeExposureContributor |
373 | 388 | void additionalReactiveHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed() { |
374 | 389 | this.reactiveContextRunner |
375 | 390 | .withConfiguration( |
376 | 391 | AutoConfigurations.of(EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class)) |
377 | 392 | .withPropertyValues("management.endpoints.web.exposure.exclude=*", |
378 | | - "management.endpoints.cloudfoundry.exposure.include=*", "spring.main.cloud-platform=cloud_foundry") |
| 393 | + "management.endpoints.test.exposure.include=*") |
379 | 394 | .run((context) -> { |
380 | | - assertThat(context).hasSingleBean(WebFluxAdditionalHealthEndpointPathsConfiguration.class); |
381 | 395 | 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); |
382 | 400 | }); |
383 | 401 | } |
384 | 402 |
|
@@ -505,4 +523,9 @@ public HealthEndpointGroups postProcessHealthEndpointGroups(HealthEndpointGroups |
505 | 523 |
|
506 | 524 | } |
507 | 525 |
|
| 526 | + @Configuration(proxyBeanMethods = false) |
| 527 | + static class UnconditionalHealthEndpointWebExtensionConfiguration extends HealthEndpointWebExtensionConfiguration { |
| 528 | + |
| 529 | + } |
| 530 | + |
508 | 531 | } |
0 commit comments