Avoid issues with system line separator in tests

See f10caf6aa6
This commit is contained in:
Sam Brannen
2024-06-05 12:16:12 +02:00
parent f4f89aa2a4
commit 9e1ef83669
5 changed files with 18 additions and 22 deletions

View File

@@ -62,12 +62,10 @@ class MediaTypeAssertTests {
@Test
void isEqualInvalidStringShouldFail() {
String ls = System.lineSeparator(); // output below is different between Unix and Windows
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(mediaType("application/json")).isEqualTo("example of a bad value"))
.withMessageContaining("[Media type]")
.withMessageEndingWith("To be a valid media type but got:" + ls +
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"" + ls);
.withMessageContainingAll("[Media type]", "To be a valid media type but got:",
"\"Invalid mime type \"example of a bad value\": does not contain '/'\"");
}
@Test
@@ -108,12 +106,10 @@ class MediaTypeAssertTests {
@Test
void isNotEqualInvalidStringShouldFail() {
String ls = System.lineSeparator(); // output below is different between Unix and Windows
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(mediaType("application/json")).isNotEqualTo("example of a bad value"))
.withMessageContaining("[Media type]")
.withMessageEndingWith("To be a valid media type but got:" + ls +
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"" + ls);
.withMessageContainingAll("[Media type]", "To be a valid media type but got:",
"\"Invalid mime type \"example of a bad value\": does not contain '/'\"");
}
@Test
@@ -169,7 +165,7 @@ class MediaTypeAssertTests {
void isCompatibleWithStringAndEmptyExpected() {
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(mediaType("application/json")).isCompatibleWith(""))
.withMessageContainingAll("Expecting:", "", "To be a valid media type but got:",
.withMessageContainingAll("Expecting:", "To be a valid media type but got:",
"'mimeType' must not be empty");
}