39
39
import static org .assertj .core .api .Assertions .assertThat ;
40
40
41
41
/**
42
- * Tests for {@link HealthEndpointAutoConfiguration} when running in a Cloud Foundry environment.
42
+ * Tests for {@link HealthEndpointAutoConfiguration} when running in a Cloud Foundry
43
+ * environment.
43
44
*
44
45
* This class isolates Cloud Foundry-specific behavior to avoid coupling such concerns
45
46
* with general auto-configuration tests.
49
50
class CloudFoundryHealthEndpointConfigurationTests {
50
51
51
52
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner ()
52
- .withUserConfiguration (HealthIndicatorsConfiguration .class )
53
- .withConfiguration (
54
- AutoConfigurations .of (HealthContributorAutoConfiguration .class , HealthEndpointAutoConfiguration .class ));
53
+ .withUserConfiguration (HealthIndicatorsConfiguration .class )
54
+ .withConfiguration (
55
+ AutoConfigurations .of (HealthContributorAutoConfiguration .class , HealthEndpointAutoConfiguration .class ));
55
56
56
57
private final ReactiveWebApplicationContextRunner reactiveContextRunner = new ReactiveWebApplicationContextRunner ()
57
- .withUserConfiguration (HealthIndicatorsConfiguration .class )
58
- .withConfiguration (
59
- AutoConfigurations .of (HealthContributorAutoConfiguration .class , HealthEndpointAutoConfiguration .class ,
60
- WebEndpointAutoConfiguration .class , EndpointAutoConfiguration .class ));
61
-
58
+ .withUserConfiguration (HealthIndicatorsConfiguration .class )
59
+ .withConfiguration (
60
+ AutoConfigurations .of (HealthContributorAutoConfiguration .class , HealthEndpointAutoConfiguration .class ,
61
+ WebEndpointAutoConfiguration .class , EndpointAutoConfiguration .class ));
62
62
63
63
@ Test
64
64
void additionalHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed () {
65
65
this .contextRunner
66
- .withConfiguration (AutoConfigurations .of (DispatcherServletAutoConfiguration .class ,
67
- EndpointAutoConfiguration .class , WebEndpointAutoConfiguration .class ))
68
- .withPropertyValues ("management.endpoints.web.exposure.exclude=*" ,
69
- "management.endpoints.cloudfoundry.exposure.include=*" , "spring.main.cloud-platform=cloud_foundry" )
70
- .run ((context ) -> {
71
- assertThat (context ).hasSingleBean (MvcAdditionalHealthEndpointPathsConfiguration .class );
72
- assertThat (context ).hasNotFailed ();
73
- });
66
+ .withConfiguration (AutoConfigurations .of (DispatcherServletAutoConfiguration .class ,
67
+ EndpointAutoConfiguration .class , WebEndpointAutoConfiguration .class ))
68
+ .withPropertyValues ("management.endpoints.web.exposure.exclude=*" ,
69
+ "management.endpoints.cloudfoundry.exposure.include=*" , "spring.main.cloud-platform=cloud_foundry" )
70
+ .run ((context ) -> {
71
+ assertThat (context ).hasSingleBean (MvcAdditionalHealthEndpointPathsConfiguration .class );
72
+ assertThat (context ).hasNotFailed ();
73
+ });
74
74
}
75
75
76
76
@ Test
77
77
void additionalJerseyHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed () {
78
78
this .contextRunner
79
- .withConfiguration (
80
- AutoConfigurations .of (EndpointAutoConfiguration .class , WebEndpointAutoConfiguration .class ))
81
- .withClassLoader (new FilteredClassLoader (DispatcherServlet .class ))
82
- .withPropertyValues ("management.endpoints.web.exposure.exclude=*" ,
83
- "management.endpoints.cloudfoundry.exposure.include=*" , "spring.main.cloud-platform=cloud_foundry" )
84
- .run ((context ) -> {
85
- assertThat (context ).hasSingleBean (JerseyAdditionalHealthEndpointPathsConfiguration .class );
86
- assertThat (context ).hasNotFailed ();
87
- });
79
+ .withConfiguration (
80
+ AutoConfigurations .of (EndpointAutoConfiguration .class , WebEndpointAutoConfiguration .class ))
81
+ .withClassLoader (new FilteredClassLoader (DispatcherServlet .class ))
82
+ .withPropertyValues ("management.endpoints.web.exposure.exclude=*" ,
83
+ "management.endpoints.cloudfoundry.exposure.include=*" , "spring.main.cloud-platform=cloud_foundry" )
84
+ .run ((context ) -> {
85
+ assertThat (context ).hasSingleBean (JerseyAdditionalHealthEndpointPathsConfiguration .class );
86
+ assertThat (context ).hasNotFailed ();
87
+ });
88
88
}
89
89
90
90
@ Test
91
91
void additionalReactiveHealthEndpointsPathsTolerateHealthEndpointThatIsNotWebExposed () {
92
92
this .reactiveContextRunner
93
- .withConfiguration (
94
- AutoConfigurations .of (EndpointAutoConfiguration .class , WebEndpointAutoConfiguration .class ))
95
- .withPropertyValues ("management.endpoints.web.exposure.exclude=*" ,
96
- "management.endpoints.cloudfoundry.exposure.include=*" , "spring.main.cloud-platform=cloud_foundry" )
97
- .run ((context ) -> {
98
- assertThat (context ).hasSingleBean (WebFluxAdditionalHealthEndpointPathsConfiguration .class );
99
- assertThat (context ).hasNotFailed ();
100
- });
93
+ .withConfiguration (
94
+ AutoConfigurations .of (EndpointAutoConfiguration .class , WebEndpointAutoConfiguration .class ))
95
+ .withPropertyValues ("management.endpoints.web.exposure.exclude=*" ,
96
+ "management.endpoints.cloudfoundry.exposure.include=*" , "spring.main.cloud-platform=cloud_foundry" )
97
+ .run ((context ) -> {
98
+ assertThat (context ).hasSingleBean (WebFluxAdditionalHealthEndpointPathsConfiguration .class );
99
+ assertThat (context ).hasNotFailed ();
100
+ });
101
101
}
102
102
103
103
@ Configuration (proxyBeanMethods = false )
@@ -119,4 +119,5 @@ ReactiveHealthIndicator reactiveHealthIndicator() {
119
119
}
120
120
121
121
}
122
+
122
123
}
0 commit comments