Fix structured logging tests on Windows

See gh-5479
This commit is contained in:
Andy Wilkinson
2024-07-15 14:07:51 +01:00
parent bf2950c045
commit 1ec2a38ea0
2 changed files with 12 additions and 10 deletions

View File

@@ -70,12 +70,13 @@ class LogbackEcsStructuredLoggingFormatterTests extends AbstractStructuredLoggin
.containsAllEntriesOf(map("error.type", "java.lang.RuntimeException", "error.message", "Boom"));
String stackTrace = (String) deserialized.get("error.stack_trace");
assertThat(stackTrace).startsWith(
"""
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException""");
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException"
.formatted());
assertThat(json).contains(
"""
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException""");
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.logback.LogbackEcsStructuredLoggingFormatterTests.shouldFormatException"
.formatted()
.replace("\n", "\\n")
.replace("\r", "\\r"));
}
}

View File

@@ -76,12 +76,13 @@ class LogbackLogstashStructuredLoggingFormatterTests extends AbstractStructuredL
Map<String, Object> deserialized = deserialize(json);
String stackTrace = (String) deserialized.get("stack_trace");
assertThat(stackTrace).startsWith(
"""
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException""");
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException"
.formatted());
assertThat(json).contains(
"""
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException""");
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.logback.LogbackLogstashStructuredLoggingFormatterTests.shouldFormatException"
.formatted()
.replace("\n", "\\n")
.replace("\r", "\\r"));
}
@Test