@@ -233,9 +233,31 @@ void isServerSslEnabled_defaultsToFalseWithoutKeystore(@TempDir Path target) thr
233233 assertThat (config .isServerSslEnabled ()).isFalse ();
234234 }
235235
236- @ DisplayName ("getManagementHealthProbesEnabled defaults to 'true'" )
236+ @ Test
237+ @ DisplayName ("isManagementHealthProbesEnabled returns true when new property is set" )
237238 void getManagementHealthProbesEnabled () {
238- assertThat (springBootConfiguration .isManagementHealthProbesEnabled ()).isTrue ();
239+ assertThat (springBootConfiguration .isManagementHealthProbesEnabled ()).isTrue ();
240+ }
241+
242+ @ Test
243+ @ DisplayName ("isManagementHealthProbesEnabled returns false when only old property is set (Spring Boot >= 2.3.2)" )
244+ void getManagementHealthProbesEnabled_withOnlyOldProperty (@ TempDir Path target ) throws IOException {
245+ final Properties properties = new Properties ();
246+ properties .put ("management.health.probes.enabled" , "true" );
247+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
248+ properties .store (fos , null );
249+ }
250+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
251+ .properties (properties )
252+ .outputDirectory (target .toFile ())
253+ .dependency (Dependency .builder ()
254+ .groupId ("org.springframework.boot" )
255+ .artifactId ("spring-boot" )
256+ .version ("3.0.0" )
257+ .build ())
258+ .build ());
259+ // Old property should NOT work for Spring Boot >= 2.3.2
260+ assertThat (config .isManagementHealthProbesEnabled ()).isFalse ();
239261 }
240262 }
241263
@@ -254,11 +276,159 @@ void setUp() {
254276 }
255277
256278 @ Test
257- @ DisplayName ("getManagementHealthProbesEnabled defaults to ' true' " )
279+ @ DisplayName ("isManagementHealthProbesEnabled returns true when new property is set " )
258280 void getManagementHealthProbesEnabled () {
259281 assertThat (springBootConfiguration .isManagementHealthProbesEnabled ()).isTrue ();
260282 }
261283
284+ @ Test
285+ @ DisplayName ("isManagementHealthProbesEnabled returns true when only old property is set (Spring Boot 2.0 < 2.3.2)" )
286+ void getManagementHealthProbesEnabled_withOnlyOldProperty (@ TempDir Path target ) throws IOException {
287+ final Properties properties = new Properties ();
288+ properties .put ("management.health.probes.enabled" , "true" );
289+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
290+ properties .store (fos , null );
291+ }
292+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
293+ .properties (properties )
294+ .outputDirectory (target .toFile ())
295+ .dependency (Dependency .builder ()
296+ .groupId ("org.springframework.boot" )
297+ .artifactId ("spring-boot" )
298+ .version ("2.0.0" )
299+ .build ())
300+ .build ());
301+ // Old property should work for Spring Boot < 2.3.2
302+ assertThat (config .isManagementHealthProbesEnabled ()).isTrue ();
303+ }
304+
305+ @ Test
306+ @ DisplayName ("isManagementHealthProbesEnabled returns true when only old property is set (Spring Boot 2.2.x < 2.3.2)" )
307+ void getManagementHealthProbesEnabled_withOnlyOldPropertySpringBoot22 (@ TempDir Path target ) throws IOException {
308+ final Properties properties = new Properties ();
309+ properties .put ("management.health.probes.enabled" , "true" );
310+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
311+ properties .store (fos , null );
312+ }
313+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
314+ .properties (properties )
315+ .outputDirectory (target .toFile ())
316+ .dependency (Dependency .builder ()
317+ .groupId ("org.springframework.boot" )
318+ .artifactId ("spring-boot" )
319+ .version ("2.2.13" )
320+ .build ())
321+ .build ());
322+ // Old property should work for Spring Boot 2.2.x (< 2.3.2)
323+ assertThat (config .isManagementHealthProbesEnabled ()).isTrue ();
324+ }
325+
326+ @ Test
327+ @ DisplayName ("isManagementHealthProbesEnabled returns true when only old property is set (Spring Boot 2.3.0 < 2.3.2)" )
328+ void getManagementHealthProbesEnabled_withOnlyOldPropertySpringBoot230 (@ TempDir Path target ) throws IOException {
329+ final Properties properties = new Properties ();
330+ properties .put ("management.health.probes.enabled" , "true" );
331+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
332+ properties .store (fos , null );
333+ }
334+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
335+ .properties (properties )
336+ .outputDirectory (target .toFile ())
337+ .dependency (Dependency .builder ()
338+ .groupId ("org.springframework.boot" )
339+ .artifactId ("spring-boot" )
340+ .version ("2.3.0" )
341+ .build ())
342+ .build ());
343+ // Old property should work for Spring Boot 2.3.0 and 2.3.1 (< 2.3.2)
344+ assertThat (config .isManagementHealthProbesEnabled ()).isTrue ();
345+ }
346+
347+ @ Test
348+ @ DisplayName ("isManagementHealthProbesEnabled returns true when only old property is set (Spring Boot 2.3.1 < 2.3.2)" )
349+ void getManagementHealthProbesEnabled_withOnlyOldPropertySpringBoot231 (@ TempDir Path target ) throws IOException {
350+ final Properties properties = new Properties ();
351+ properties .put ("management.health.probes.enabled" , "true" );
352+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
353+ properties .store (fos , null );
354+ }
355+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
356+ .properties (properties )
357+ .outputDirectory (target .toFile ())
358+ .dependency (Dependency .builder ()
359+ .groupId ("org.springframework.boot" )
360+ .artifactId ("spring-boot" )
361+ .version ("2.3.1" )
362+ .build ())
363+ .build ());
364+ // Old property should work for Spring Boot 2.3.0 and 2.3.1 (< 2.3.2)
365+ assertThat (config .isManagementHealthProbesEnabled ()).isTrue ();
366+ }
367+
368+ @ Test
369+ @ DisplayName ("isManagementHealthProbesEnabled returns false when only old property is set (Spring Boot 2.3.2 >= 2.3.2)" )
370+ void getManagementHealthProbesEnabled_withOnlyOldPropertySpringBoot232 (@ TempDir Path target ) throws IOException {
371+ final Properties properties = new Properties ();
372+ properties .put ("management.health.probes.enabled" , "true" );
373+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
374+ properties .store (fos , null );
375+ }
376+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
377+ .properties (properties )
378+ .outputDirectory (target .toFile ())
379+ .dependency (Dependency .builder ()
380+ .groupId ("org.springframework.boot" )
381+ .artifactId ("spring-boot" )
382+ .version ("2.3.2" )
383+ .build ())
384+ .build ());
385+ // Old property should NOT work for Spring Boot >= 2.3.2
386+ assertThat (config .isManagementHealthProbesEnabled ()).isFalse ();
387+ }
388+
389+ @ Test
390+ @ DisplayName ("isManagementHealthProbesEnabled returns false when only old property is set (Spring Boot 2.3.3 >= 2.3.2)" )
391+ void getManagementHealthProbesEnabled_withOnlyOldPropertySpringBoot233 (@ TempDir Path target ) throws IOException {
392+ final Properties properties = new Properties ();
393+ properties .put ("management.health.probes.enabled" , "true" );
394+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
395+ properties .store (fos , null );
396+ }
397+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
398+ .properties (properties )
399+ .outputDirectory (target .toFile ())
400+ .dependency (Dependency .builder ()
401+ .groupId ("org.springframework.boot" )
402+ .artifactId ("spring-boot" )
403+ .version ("2.3.3" )
404+ .build ())
405+ .build ());
406+ // Old property should NOT work for Spring Boot >= 2.3.2
407+ assertThat (config .isManagementHealthProbesEnabled ()).isFalse ();
408+ }
409+
410+ @ Test
411+ @ DisplayName ("isManagementHealthProbesEnabled new property takes precedence over old property" )
412+ void getManagementHealthProbesEnabled_newPropertyTakesPrecedence (@ TempDir Path target ) throws IOException {
413+ final Properties properties = new Properties ();
414+ properties .put ("management.health.probes.enabled" , "true" );
415+ properties .put ("management.endpoint.health.probes.enabled" , "false" );
416+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
417+ properties .store (fos , null );
418+ }
419+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
420+ .properties (properties )
421+ .outputDirectory (target .toFile ())
422+ .dependency (Dependency .builder ()
423+ .groupId ("org.springframework.boot" )
424+ .artifactId ("spring-boot" )
425+ .version ("2.0.0" )
426+ .build ())
427+ .build ());
428+ // New property should take precedence
429+ assertThat (config .isManagementHealthProbesEnabled ()).isFalse ();
430+ }
431+
262432 @ Test
263433 @ DisplayName ("getManagementPort defaults to 'management.server.port'" )
264434 void getManagementPort () {
@@ -529,6 +699,27 @@ void isServerSslEnabled_whenExplicitlyTrue(String version) {
529699 assertThat (springBootConfiguration .isServerSslEnabled ()).isTrue ();
530700 }
531701
702+ @ Test
703+ @ DisplayName ("isManagementHealthProbesEnabled returns true when old property is set (Spring Boot 1)" )
704+ void getManagementHealthProbesEnabled_withOldProperty (@ TempDir Path target ) throws IOException {
705+ final Properties properties = new Properties ();
706+ properties .put ("management.health.probes.enabled" , "true" );
707+ try (OutputStream fos = Files .newOutputStream (target .resolve ("application.properties" ))) {
708+ properties .store (fos , null );
709+ }
710+ SpringBootConfiguration config = SpringBootConfiguration .from (JavaProject .builder ()
711+ .properties (properties )
712+ .outputDirectory (target .toFile ())
713+ .dependency (Dependency .builder ()
714+ .groupId ("org.springframework.boot" )
715+ .artifactId ("spring-boot" )
716+ .version ("1.5.0" )
717+ .build ())
718+ .build ());
719+ // Old property should work for Spring Boot 1.x (< 2.3.2)
720+ assertThat (config .isManagementHealthProbesEnabled ()).isTrue ();
721+ }
722+
532723 @ Test
533724 @ DisplayName ("isManagementSslEnabled uses management.ssl.enabled property (Spring Boot 1)" )
534725 void isManagementSslEnabled_withManagementSslEnabled (@ TempDir Path target ) throws IOException {
0 commit comments