parent
f4f89aa2a4
commit
9e1ef83669
|
|
@ -251,7 +251,7 @@ public abstract class AbstractEncoderTests<E extends Encoder<?>> extends Abstrac
|
||||||
return dataBuffer -> {
|
return dataBuffer -> {
|
||||||
String actual = dataBuffer.toString(UTF_8);
|
String actual = dataBuffer.toString(UTF_8);
|
||||||
release(dataBuffer);
|
release(dataBuffer);
|
||||||
assertThat(actual).isEqualTo(expected);
|
assertThat(actual).isEqualToNormalizingNewlines(expected);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,10 @@ class MediaTypeAssertTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isEqualInvalidStringShouldFail() {
|
void isEqualInvalidStringShouldFail() {
|
||||||
String ls = System.lineSeparator(); // output below is different between Unix and Windows
|
|
||||||
assertThatExceptionOfType(AssertionError.class)
|
assertThatExceptionOfType(AssertionError.class)
|
||||||
.isThrownBy(() -> assertThat(mediaType("application/json")).isEqualTo("example of a bad value"))
|
.isThrownBy(() -> assertThat(mediaType("application/json")).isEqualTo("example of a bad value"))
|
||||||
.withMessageContaining("[Media type]")
|
.withMessageContainingAll("[Media type]", "To be a valid media type but got:",
|
||||||
.withMessageEndingWith("To be a valid media type but got:" + ls +
|
"\"Invalid mime type \"example of a bad value\": does not contain '/'\"");
|
||||||
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"" + ls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -108,12 +106,10 @@ class MediaTypeAssertTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void isNotEqualInvalidStringShouldFail() {
|
void isNotEqualInvalidStringShouldFail() {
|
||||||
String ls = System.lineSeparator(); // output below is different between Unix and Windows
|
|
||||||
assertThatExceptionOfType(AssertionError.class)
|
assertThatExceptionOfType(AssertionError.class)
|
||||||
.isThrownBy(() -> assertThat(mediaType("application/json")).isNotEqualTo("example of a bad value"))
|
.isThrownBy(() -> assertThat(mediaType("application/json")).isNotEqualTo("example of a bad value"))
|
||||||
.withMessageContaining("[Media type]")
|
.withMessageContainingAll("[Media type]", "To be a valid media type but got:",
|
||||||
.withMessageEndingWith("To be a valid media type but got:" + ls +
|
"\"Invalid mime type \"example of a bad value\": does not contain '/'\"");
|
||||||
" \"Invalid mime type \"example of a bad value\": does not contain '/'\"" + ls);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -169,7 +165,7 @@ class MediaTypeAssertTests {
|
||||||
void isCompatibleWithStringAndEmptyExpected() {
|
void isCompatibleWithStringAndEmptyExpected() {
|
||||||
assertThatExceptionOfType(AssertionError.class)
|
assertThatExceptionOfType(AssertionError.class)
|
||||||
.isThrownBy(() -> assertThat(mediaType("application/json")).isCompatibleWith(""))
|
.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");
|
"'mimeType' must not be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -262,9 +262,11 @@ class Jackson2JsonEncoderTests extends AbstractEncoderTests<Jackson2JsonEncoder>
|
||||||
ObjectMapper mapper = new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
|
ObjectMapper mapper = new ObjectMapper().configure(SerializationFeature.INDENT_OUTPUT, true);
|
||||||
this.encoder.registerObjectMappersForType(JacksonViewBean.class, map -> map.put(halMediaType, mapper));
|
this.encoder.registerObjectMappersForType(JacksonViewBean.class, map -> map.put(halMediaType, mapper));
|
||||||
|
|
||||||
String ls = System.lineSeparator(); // output below is different between Unix and Windows
|
|
||||||
testEncode(Mono.just(jacksonValue), type, halMediaType, Collections.emptyMap(), step -> step
|
testEncode(Mono.just(jacksonValue), type, halMediaType, Collections.emptyMap(), step -> step
|
||||||
.consumeNextWith(expectString("{" + ls + " \"withView1\" : \"with\"" + ls + "}"))
|
.consumeNextWith(expectString("""
|
||||||
|
{
|
||||||
|
\s "withView1" : "with"
|
||||||
|
}"""))
|
||||||
.verifyComplete()
|
.verifyComplete()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,8 +63,6 @@ import static org.assertj.core.api.Assertions.within;
|
||||||
*/
|
*/
|
||||||
class MappingJackson2HttpMessageConverterTests {
|
class MappingJackson2HttpMessageConverterTests {
|
||||||
|
|
||||||
protected static final String NEWLINE_SYSTEM_PROPERTY = System.lineSeparator();
|
|
||||||
|
|
||||||
private final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
private final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -369,8 +367,10 @@ class MappingJackson2HttpMessageConverterTests {
|
||||||
this.converter.writeInternal(bean, null, outputMessage);
|
this.converter.writeInternal(bean, null, outputMessage);
|
||||||
String result = outputMessage.getBodyAsString(StandardCharsets.UTF_8);
|
String result = outputMessage.getBodyAsString(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
assertThat(result).isEqualTo(("{" + NEWLINE_SYSTEM_PROPERTY +
|
assertThat(result).isEqualToNormalizingNewlines("""
|
||||||
" \"name\" : \"Jason\"" + NEWLINE_SYSTEM_PROPERTY + "}"));
|
{
|
||||||
|
\s "name" : "Jason"
|
||||||
|
}""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,6 @@ import static org.springframework.web.testfixture.method.ResolvableMethod.on;
|
||||||
*/
|
*/
|
||||||
class ResponseEntityResultHandlerTests {
|
class ResponseEntityResultHandlerTests {
|
||||||
|
|
||||||
private static final String NEWLINE_SYSTEM_PROPERTY = System.lineSeparator();
|
|
||||||
|
|
||||||
private final ResponseEntityResultHandler resultHandler = createHandler();
|
private final ResponseEntityResultHandler resultHandler = createHandler();
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -458,10 +456,10 @@ class ResponseEntityResultHandlerTests {
|
||||||
handler.handleResult(exchange, result).block();
|
handler.handleResult(exchange, result).block();
|
||||||
|
|
||||||
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(halMediaType);
|
assertThat(exchange.getResponse().getHeaders().getContentType()).isEqualTo(halMediaType);
|
||||||
assertThat(exchange.getResponse().getBodyAsString().block()).isEqualTo(
|
assertThat(exchange.getResponse().getBodyAsString().block()).isEqualToNormalizingNewlines("""
|
||||||
"{" + NEWLINE_SYSTEM_PROPERTY +
|
{
|
||||||
" \"name\" : \"Jason\"" + NEWLINE_SYSTEM_PROPERTY +
|
\s "name" : "Jason"
|
||||||
"}");
|
}""");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // gh-24539
|
@Test // gh-24539
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue