Skip to content

Commit 8456cd1

Browse files
committed
Polish contribution
See gh-35587
1 parent 7699b4a commit 8456cd1

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

spring-web/src/test/java/org/springframework/web/method/annotation/ExceptionHandlerMethodResolverTests.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.IOException;
2121
import java.net.BindException;
2222
import java.net.SocketException;
23+
import java.util.Set;
2324

2425
import jakarta.servlet.http.HttpServletRequest;
2526
import jakarta.servlet.http.HttpServletResponse;
@@ -110,20 +111,20 @@ void shouldThrowExceptionWhenNoExceptionMapping() {
110111
new ExceptionHandlerMethodResolver(NoExceptionController.class));
111112
}
112113

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+
113121
@Test
114122
void shouldResolveMethodWithMediaType() {
115123
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class);
116124
assertThat(resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.APPLICATION_JSON).getHandlerMethod().getName()).isEqualTo("handleJson");
117125
assertThat(resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.TEXT_HTML).getHandlerMethod().getName()).isEqualTo("handleHtml");
118126
}
119127

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-
127128
@Test
128129
void shouldResolveMethodWithCompatibleMediaType() {
129130
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class);

0 commit comments

Comments
 (0)