mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-10-08 18:41:37 +00:00
Fix broken assertions on Windows
See gh-46334
This commit is contained in:
+8
-7
@@ -101,13 +101,14 @@ class ElasticCommonSchemaStructuredLogFormatterTests extends AbstractStructuredL
|
||||
expectedError.put("message", "Boom");
|
||||
assertThat(error).containsAllEntriesOf(expectedError);
|
||||
String stackTrace = (String) error.get("stack_trace");
|
||||
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""");
|
||||
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"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+9
-12
@@ -136,21 +136,18 @@ class GraylogExtendedLogFormatStructuredLogFormatterTests extends AbstractStruct
|
||||
String fullMessage = (String) deserialized.get("full_message");
|
||||
String stackTrace = (String) deserialized.get("_error_stack_trace");
|
||||
assertThat(fullMessage).startsWith(
|
||||
"""
|
||||
message
|
||||
|
||||
java.lang.RuntimeException: Boom
|
||||
\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
|
||||
assertThat(stackTrace).startsWith(
|
||||
"""
|
||||
java.lang.RuntimeException: Boom
|
||||
\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
|
||||
|
||||
"message\n\njava.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
|
||||
.formatted());
|
||||
assertThat(deserialized)
|
||||
.containsAllEntriesOf(map("_error_type", "java.lang.RuntimeException", "_error_message", "Boom"));
|
||||
assertThat(stackTrace).startsWith(
|
||||
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
|
||||
.formatted());
|
||||
assertThat(json).contains(
|
||||
"""
|
||||
message\\n\\njava.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
|
||||
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
|
||||
.formatted()
|
||||
.replace("\n", "\\n")
|
||||
.replace("\r", "\\r"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+6
-5
@@ -80,12 +80,13 @@ class LogstashStructuredLogFormatterTests extends AbstractStructuredLoggingTests
|
||||
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.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException""");
|
||||
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException"
|
||||
.formatted());
|
||||
assertThat(json).contains(
|
||||
"""
|
||||
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException""");
|
||||
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException"
|
||||
.formatted()
|
||||
.replace("\n", "\\n")
|
||||
.replace("\r", "\\r"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user