Fix "Used nested format for ECS structure logging" test on Windows

See gh-45063
This commit is contained in:
Phillip Webb
2025-04-14 16:15:29 -07:00
parent 34a43c1f87
commit e3610eaf0c

View File

@@ -94,14 +94,13 @@ class ElasticCommonSchemaStructuredLogFormatterTests extends AbstractStructuredL
expectedError.put("message", "Boom");
assertThat(error).containsAllEntriesOf(expectedError);
String stackTrace = (String) error.get("stack_trace");
assertThat(stackTrace)
.startsWith(String.format("java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2."
+ "ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException"));
assertThat(json).contains(String
.format("java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2."
+ "ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException")
.replace("\n", "\\n")
.replace("\r", "\\r"));
assertThat(stackTrace).startsWith(
"""
java.lang.RuntimeException: Boom
\tat org.springframework.boot.logging.log4j2.ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException""");
assertThat(json).contains(
"""
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException""");
}
@Test