From 1f17e0125db8ed57c1e27da94561f7c6a765151a Mon Sep 17 00:00:00 2001 From: Johnny Lim Date: Sat, 30 Nov 2024 14:56:11 +0900 Subject: [PATCH 1/2] Fix property name in OnEnabledLoggingExportConditionTests See gh-43331 --- .../logging/OnEnabledLoggingExportConditionTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java index 1bca2e10715a..61dca50d6e14 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java @@ -90,7 +90,7 @@ void shouldMatchIfExporterPropertyIsTrue() { void exporterPropertyShouldOverrideGlobalPropertyIfTrue() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext( - Map.of("management.logging.enabled", "false", "management.otlp.logging.export.enabled", "true")), + Map.of("management.logging.export.enabled", "false", "management.otlp.logging.export.enabled", "true")), mockMetadata("otlp")); assertThat(outcome.isMatch()).isTrue(); assertThat(outcome.getMessage()) @@ -101,7 +101,7 @@ void exporterPropertyShouldOverrideGlobalPropertyIfTrue() { void exporterPropertyShouldOverrideGlobalPropertyIfFalse() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext( - Map.of("management.logging.enabled", "true", "management.otlp.logging.export.enabled", "false")), + Map.of("management.logging.export.enabled", "true", "management.otlp.logging.export.enabled", "false")), mockMetadata("otlp")); assertThat(outcome.isMatch()).isFalse(); assertThat(outcome.getMessage()) From d5344e3f1b54d7df9de82d52b96254fa78a6727b Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Mon, 2 Dec 2024 13:52:01 +0100 Subject: [PATCH 2/2] Polish "Fix property name in OnEnabledLoggingExportConditionTests" See gh-43331 --- .../OnEnabledLoggingExportConditionTests.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java index 61dca50d6e14..3148e39453dc 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/logging/OnEnabledLoggingExportConditionTests.java @@ -38,6 +38,10 @@ */ class OnEnabledLoggingExportConditionTests { + private static final String GLOBAL_PROPERTY_NAME = "management.logging.export.enabled"; + + private static final String OTLP_PROPERTY_NAME = "management.otlp.logging.export.enabled"; + @Test void shouldMatchIfNoPropertyIsSet() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); @@ -49,8 +53,8 @@ void shouldMatchIfNoPropertyIsSet() { @Test void shouldNotMatchIfGlobalPropertyIsFalse() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); - ConditionOutcome outcome = condition.getMatchOutcome( - mockConditionContext(Map.of("management.logging.export.enabled", "false")), mockMetadata("")); + ConditionOutcome outcome = condition + .getMatchOutcome(mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "false")), mockMetadata("")); assertThat(outcome.isMatch()).isFalse(); assertThat(outcome.getMessage()) .isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is false"); @@ -59,8 +63,8 @@ void shouldNotMatchIfGlobalPropertyIsFalse() { @Test void shouldMatchIfGlobalPropertyIsTrue() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); - ConditionOutcome outcome = condition.getMatchOutcome( - mockConditionContext(Map.of("management.logging.export.enabled", "true")), mockMetadata("")); + ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "true")), + mockMetadata("")); assertThat(outcome.isMatch()).isTrue(); assertThat(outcome.getMessage()) .isEqualTo("@ConditionalOnEnabledLoggingExport management.logging.export.enabled is true"); @@ -69,8 +73,8 @@ void shouldMatchIfGlobalPropertyIsTrue() { @Test void shouldNotMatchIfExporterPropertyIsFalse() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); - ConditionOutcome outcome = condition.getMatchOutcome( - mockConditionContext(Map.of("management.otlp.logging.export.enabled", "false")), mockMetadata("otlp")); + ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(OTLP_PROPERTY_NAME, "false")), + mockMetadata("otlp")); assertThat(outcome.isMatch()).isFalse(); assertThat(outcome.getMessage()) .isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is false"); @@ -79,8 +83,8 @@ void shouldNotMatchIfExporterPropertyIsFalse() { @Test void shouldMatchIfExporterPropertyIsTrue() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); - ConditionOutcome outcome = condition.getMatchOutcome( - mockConditionContext(Map.of("management.otlp.logging.export.enabled", "true")), mockMetadata("otlp")); + ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext(Map.of(OTLP_PROPERTY_NAME, "true")), + mockMetadata("otlp")); assertThat(outcome.isMatch()).isTrue(); assertThat(outcome.getMessage()) .isEqualTo("@ConditionalOnEnabledLoggingExport management.otlp.logging.export.enabled is true"); @@ -89,8 +93,8 @@ void shouldMatchIfExporterPropertyIsTrue() { @Test void exporterPropertyShouldOverrideGlobalPropertyIfTrue() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); - ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext( - Map.of("management.logging.export.enabled", "false", "management.otlp.logging.export.enabled", "true")), + ConditionOutcome outcome = condition.getMatchOutcome( + mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "false", OTLP_PROPERTY_NAME, "true")), mockMetadata("otlp")); assertThat(outcome.isMatch()).isTrue(); assertThat(outcome.getMessage()) @@ -100,8 +104,8 @@ void exporterPropertyShouldOverrideGlobalPropertyIfTrue() { @Test void exporterPropertyShouldOverrideGlobalPropertyIfFalse() { OnEnabledLoggingExportCondition condition = new OnEnabledLoggingExportCondition(); - ConditionOutcome outcome = condition.getMatchOutcome(mockConditionContext( - Map.of("management.logging.export.enabled", "true", "management.otlp.logging.export.enabled", "false")), + ConditionOutcome outcome = condition.getMatchOutcome( + mockConditionContext(Map.of(GLOBAL_PROPERTY_NAME, "true", OTLP_PROPERTY_NAME, "false")), mockMetadata("otlp")); assertThat(outcome.isMatch()).isFalse(); assertThat(outcome.getMessage())