Skip to content

Commit 1ec2a38

Browse files
committed
Fix structured logging tests on Windows
See gh-5479
1 parent bf2950c commit 1ec2a38

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackEcsStructuredLoggingFormatterTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ void shouldFormatException() {
7070
.containsAllEntriesOf(map("error.type", "java.lang.RuntimeException", "error.message", "Boom"));
7171
String stackTrace = (String) deserialized.get("error.stack_trace");
7272
assertThat(stackTrace).startsWith(
73-
"""
74-
java.lang.RuntimeException: Boom
75-
\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException""");
73+
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException"
74+
.formatted());
7675
assertThat(json).contains(
77-
"""
78-
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException""");
76+
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException"
77+
.formatted()
78+
.replace("\n", "\\n")
79+
.replace("\r", "\\r"));
7980
}
8081

8182
}

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLogstashStructuredLoggingFormatterTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ void shouldFormatException() {
7676
Map<String, Object> deserialized = deserialize(json);
7777
String stackTrace = (String) deserialized.get("stack_trace");
7878
assertThat(stackTrace).startsWith(
79-
"""
80-
java.lang.RuntimeException: Boom
81-
\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException""");
79+
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException"
80+
.formatted());
8281
assertThat(json).contains(
83-
"""
84-
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException""");
82+
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException"
83+
.formatted()
84+
.replace("\n", "\\n")
85+
.replace("\r", "\\r"));
8586
}
8687

8788
@Test

0 commit comments

Comments
 (0)