|
20 | 20 | import java.io.IOException; |
21 | 21 | import java.net.BindException; |
22 | 22 | import java.net.SocketException; |
| 23 | +import java.util.Set; |
23 | 24 |
|
24 | 25 | import jakarta.servlet.http.HttpServletRequest; |
25 | 26 | import jakarta.servlet.http.HttpServletResponse; |
@@ -110,20 +111,20 @@ void shouldThrowExceptionWhenNoExceptionMapping() { |
110 | 111 | new ExceptionHandlerMethodResolver(NoExceptionController.class)); |
111 | 112 | } |
112 | 113 |
|
| 114 | + @Test // gh-35587 |
| 115 | + void shouldRetainOriginalOrderOfProducibleMediaTypes() { |
| 116 | + ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class); |
| 117 | + Set<MediaType> producibleTypes = resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.TEXT_HTML).getProducibleTypes(); |
| 118 | + assertThat(MediaType.toString(producibleTypes)).isEqualTo("text/html, */*"); |
| 119 | + } |
| 120 | + |
113 | 121 | @Test |
114 | 122 | void shouldResolveMethodWithMediaType() { |
115 | 123 | ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class); |
116 | 124 | assertThat(resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.APPLICATION_JSON).getHandlerMethod().getName()).isEqualTo("handleJson"); |
117 | 125 | assertThat(resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.TEXT_HTML).getHandlerMethod().getName()).isEqualTo("handleHtml"); |
118 | 126 | } |
119 | 127 |
|
120 | | - @Test |
121 | | - void shouldKeepProduceMediaTypesOrder() { |
122 | | - ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class); |
123 | | - assertThat(resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.TEXT_HTML).getProducibleTypes().toString()).isEqualTo("[text/html, */*]"); |
124 | | - } |
125 | | - |
126 | | - |
127 | 128 | @Test |
128 | 129 | void shouldResolveMethodWithCompatibleMediaType() { |
129 | 130 | ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class); |
|
0 commit comments