Skip to content

Commit f10caf6

Browse files
committed
Compare text with system line separator (for Windows compatibility)
See gh-32756
1 parent cf3171d commit f10caf6

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

spring-test/src/test/java/org/springframework/test/http/MediaTypeAssertTests.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.springframework.test.http;
1818

19-
2019
import org.junit.jupiter.api.Test;
2120

2221
import org.springframework.http.MediaType;
@@ -63,11 +62,12 @@ void isEqualWhenDifferentStringShouldFail() {
6362

6463
@Test
6564
void isEqualInvalidStringShouldFail() {
65+
String ls = System.lineSeparator(); // output below is different between Unix and Windows
6666
assertThatExceptionOfType(AssertionError.class)
6767
.isThrownBy(() -> assertThat(mediaType("application/json")).isEqualTo("example of a bad value"))
6868
.withMessageContaining("[Media type]")
69-
.withMessageEndingWith("To be a valid media type but got:\n" +
70-
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"\n");
69+
.withMessageEndingWith("To be a valid media type but got:" + ls +
70+
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"" + ls);
7171
}
7272

7373
@Test
@@ -108,11 +108,12 @@ void isNotEqualWhenSameStringShouldFail() {
108108

109109
@Test
110110
void isNotEqualInvalidStringShouldFail() {
111+
String ls = System.lineSeparator(); // output below is different between Unix and Windows
111112
assertThatExceptionOfType(AssertionError.class)
112113
.isThrownBy(() -> assertThat(mediaType("application/json")).isNotEqualTo("example of a bad value"))
113114
.withMessageContaining("[Media type]")
114-
.withMessageEndingWith("To be a valid media type but got:\n" +
115-
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"\n");
115+
.withMessageEndingWith("To be a valid media type but got:" + ls +
116+
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"" + ls);
116117
}
117118

118119
@Test

spring-web/src/test/java/org/springframework/http/codec/json/Jackson2JsonEncoderTests.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ void encodeNonStreamEmpty() {
152152
.verifyComplete());
153153
}
154154

155-
@Test // gh-29038
155+
@Test // gh-29038
156156
void encodeNonStreamWithErrorAsFirstSignal() {
157157
String message = "I'm a teapot";
158158
Flux<Object> input = Flux.error(new IllegalStateException(message));
@@ -264,8 +264,7 @@ public void jacksonValueUnwrappedBeforeObjectMapperSelection() {
264264

265265
String ls = System.lineSeparator(); // output below is different between Unix and Windows
266266
testEncode(Mono.just(jacksonValue), type, halMediaType, Collections.emptyMap(), step -> step
267-
.consumeNextWith(expectString("{" + ls + " \"withView1\" : \"with\"" + ls + "}")
268-
)
267+
.consumeNextWith(expectString("{" + ls + " \"withView1\" : \"with\"" + ls + "}"))
269268
.verifyComplete()
270269
);
271270
}

0 commit comments

Comments
 (0)