Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1590e4d

Browse files
committed
Fix broken assertions on Windows
See gh-46334
1 parent 7a5e77f commit 1590e4d

File tree

3 files changed

+23
-24
lines changed

3 files changed

+23
-24
lines changed

‎core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/ElasticCommonSchemaStructuredLogFormatterTests.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,14 @@ void shouldFormatException() {
101101
expectedError.put("message", "Boom");
102102
assertThat(error).containsAllEntriesOf(expectedError);
103103
String stackTrace = (String) error.get("stack_trace");
104-
assertThat(stackTrace).startsWith(
105-
"""
106-
java.lang.RuntimeException: Boom
107-
\tat org.springframework.boot.logging.log4j2.ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException""");
108-
assertThat(json).contains(
109-
"""
110-
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException""");
104+
assertThat(stackTrace)
105+
.startsWith(String.format("java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2."
106+
+ "ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException"));
107+
assertThat(json).contains(String
108+
.format("java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2."
109+
+ "ElasticCommonSchemaStructuredLogFormatterTests.shouldFormatException")
110+
.replace("\n", "\\n")
111+
.replace("\r", "\\r"));
111112
}
112113

113114
@Test

‎core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/GraylogExtendedLogFormatStructuredLogFormatterTests.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -136,21 +136,18 @@ void shouldFormatException() {
136136
String fullMessage = (String) deserialized.get("full_message");
137137
String stackTrace = (String) deserialized.get("_error_stack_trace");
138138
assertThat(fullMessage).startsWith(
139-
"""
140-
message
141-
142-
java.lang.RuntimeException: Boom
143-
\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
144-
assertThat(stackTrace).startsWith(
145-
"""
146-
java.lang.RuntimeException: Boom
147-
\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
148-
139+
"message\n\njava.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
140+
.formatted());
149141
assertThat(deserialized)
150142
.containsAllEntriesOf(map("_error_type", "java.lang.RuntimeException", "_error_message", "Boom"));
143+
assertThat(stackTrace).startsWith(
144+
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
145+
.formatted());
151146
assertThat(json).contains(
152-
"""
153-
message\\n\\njava.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException""");
147+
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2.GraylogExtendedLogFormatStructuredLogFormatterTests.shouldFormatException"
148+
.formatted()
149+
.replace("\n", "\\n")
150+
.replace("\r", "\\r"));
154151
}
155152

156153
@Test

‎core/spring-boot/src/test/java/org/springframework/boot/logging/log4j2/LogstashStructuredLogFormatterTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ void shouldFormatException() {
8080
Map<String, Object> deserialized = deserialize(json);
8181
String stackTrace = (String) deserialized.get("stack_trace");
8282
assertThat(stackTrace).startsWith(
83-
"""
84-
java.lang.RuntimeException: Boom
85-
\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException""");
83+
"java.lang.RuntimeException: Boom%n\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException"
84+
.formatted());
8685
assertThat(json).contains(
87-
"""
88-
java.lang.RuntimeException: Boom\\n\\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException""");
86+
"java.lang.RuntimeException: Boom%n\\tat org.springframework.boot.logging.log4j2.LogstashStructuredLogFormatterTests.shouldFormatException"
87+
.formatted()
88+
.replace("\n", "\\n")
89+
.replace("\r", "\\r"));
8990
}
9091

9192
@Test

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /