Consistently list supported media types
Add constructors to HttpMediaTypeNotSupportedException and UnsupportedMediaTypeStatusException for a parse error that also accept the list of supported media types to include in the response headers. Closes gh-28062
This commit is contained in:
@@ -176,6 +176,15 @@ class RequestMappingInfoHandlerMappingTests {
|
||||
testHttpMediaTypeNotSupportedException(mapping, "/person/1.json");
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest // gh-28062
|
||||
void getHandlerMethodTypeNotSupportedWithParseError(TestRequestMappingInfoHandlerMapping mapping) {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/person/1");
|
||||
request.setContentType("This string");
|
||||
assertThatExceptionOfType(HttpMediaTypeNotSupportedException.class)
|
||||
.isThrownBy(() -> mapping.getHandler(request))
|
||||
.satisfies(ex -> assertThat(ex.getSupportedMediaTypes()).containsExactly(MediaType.APPLICATION_XML));
|
||||
}
|
||||
|
||||
@PathPatternsParameterizedTest
|
||||
void getHandlerHttpOptions(TestRequestMappingInfoHandlerMapping mapping) throws Exception {
|
||||
testHttpOptions(mapping, "/foo", "GET,HEAD,OPTIONS", null);
|
||||
|
||||
Reference in New Issue
Block a user