From 1ec2a38ea074b4441140c1fe68042659892020ca Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 15 Jul 2024 14:07:51 +0100 Subject: [PATCH] Fix structured logging tests on Windows See gh-5479 --- .../LogbackEcsStructuredLoggingFormatterTests.java | 11 ++++++----- ...ogbackLogstashStructuredLoggingFormatterTests.java | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackEcsStructuredLoggingFormatterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackEcsStructuredLoggingFormatterTests.java index eb96faf766..7d8050a424 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackEcsStructuredLoggingFormatterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackEcsStructuredLoggingFormatterTests.java @@ -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")); } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLogstashStructuredLoggingFormatterTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLogstashStructuredLoggingFormatterTests.java index df55d6744b..8943b725c0 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLogstashStructuredLoggingFormatterTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLogstashStructuredLoggingFormatterTests.java @@ -76,12 +76,13 @@ class LogbackLogstashStructuredLoggingFormatterTests extends AbstractStructuredL Map 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