File tree Expand file tree Collapse file tree 3 files changed +44
-2
lines changed
spring-boot-project/spring-boot-actuator-autoconfigure/src
main/java/org/springframework/boot/actuate/autoconfigure/web/servlet
test/java/org/springframework/boot/actuate/autoconfigure/web Expand file tree Collapse file tree 3 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 3939import org .springframework .boot .autoconfigure .condition .ConditionalOnWebApplication .Type ;
4040import org .springframework .boot .autoconfigure .condition .SearchStrategy ;
4141import org .springframework .boot .autoconfigure .web .ServerProperties ;
42- import org .springframework .boot .context .properties .EnableConfigurationProperties ;
4342import org .springframework .boot .web .embedded .jetty .JettyServletWebServerFactory ;
4443import org .springframework .boot .web .embedded .tomcat .TomcatServletWebServerFactory ;
4544import org .springframework .boot .web .embedded .undertow .UndertowServletWebServerFactory ;
6766 */
6867@ ManagementContextConfiguration (value = ManagementContextType .CHILD , proxyBeanMethods = false )
6968@ ConditionalOnWebApplication (type = Type .SERVLET )
70- @ EnableConfigurationProperties (ManagementServerProperties .class )
7169class ServletManagementChildContextConfiguration {
7270
7371 @ Bean
Original file line number Diff line number Diff line change 1919import org .junit .jupiter .api .Test ;
2020
2121import org .springframework .boot .actuate .autoconfigure .web .reactive .ReactiveManagementChildContextConfiguration .AccessLogCustomizer ;
22+ import org .springframework .boot .actuate .autoconfigure .web .server .ManagementServerProperties ;
23+ import org .springframework .boot .test .context .runner .ReactiveWebApplicationContextRunner ;
2224
2325import static org .assertj .core .api .Assertions .assertThat ;
2426
@@ -46,4 +48,24 @@ void accessLogCustomizerWithNullPrefix() {
4648 assertThat (customizer .customizePrefix ("existing" )).isEqualTo ("existing" );
4749 }
4850
51+ @ Test
52+ // gh-45857
53+ void failsWithoutManagementServerPropertiesBeanFromParent () {
54+ new ReactiveWebApplicationContextRunner ().run ((parent ) -> {
55+ new ReactiveWebApplicationContextRunner ().withParent (parent )
56+ .withUserConfiguration (ReactiveManagementChildContextConfiguration .class )
57+ .run ((context ) -> assertThat (context ).hasFailed ());
58+ });
59+ }
60+
61+ @ Test
62+ // gh-45857
63+ void succeedsWithManagementServerPropertiesBeanFromParent () {
64+ new ReactiveWebApplicationContextRunner ().withBean (ManagementServerProperties .class ).run ((parent ) -> {
65+ new ReactiveWebApplicationContextRunner ().withParent (parent )
66+ .withUserConfiguration (ReactiveManagementChildContextConfiguration .class )
67+ .run ((context ) -> assertThat (context ).hasNotFailed ());
68+ });
69+ }
70+
4971}
Original file line number Diff line number Diff line change 1818
1919import org .junit .jupiter .api .Test ;
2020
21+ import org .springframework .boot .actuate .autoconfigure .web .server .ManagementServerProperties ;
2122import org .springframework .boot .actuate .autoconfigure .web .servlet .ServletManagementChildContextConfiguration .AccessLogCustomizer ;
23+ import org .springframework .boot .test .context .runner .WebApplicationContextRunner ;
2224
2325import static org .assertj .core .api .Assertions .assertThat ;
2426
@@ -46,4 +48,24 @@ void accessLogCustomizerWithNullPrefix() {
4648 assertThat (customizer .customizePrefix ("existing" )).isEqualTo ("existing" );
4749 }
4850
51+ @ Test
52+ // gh-45857
53+ void failsWithoutManagementServerPropertiesBeanFromParent () {
54+ new WebApplicationContextRunner ().run ((parent ) -> {
55+ new WebApplicationContextRunner ().withParent (parent )
56+ .withUserConfiguration (ServletManagementChildContextConfiguration .class )
57+ .run ((context ) -> assertThat (context ).hasFailed ());
58+ });
59+ }
60+
61+ @ Test
62+ // gh-45857
63+ void succeedsWithManagementServerPropertiesBeanFromParent () {
64+ new WebApplicationContextRunner ().withBean (ManagementServerProperties .class ).run ((parent ) -> {
65+ new WebApplicationContextRunner ().withParent (parent )
66+ .withUserConfiguration (ServletManagementChildContextConfiguration .class )
67+ .run ((context ) -> assertThat (context ).hasNotFailed ());
68+ });
69+ }
70+
4971}
You can’t perform that action at this time.
0 commit comments