mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Merge branch '6.2.x'
This commit is contained in:
+16
-8
@@ -20,6 +20,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.net.BindException;
|
||||
import java.net.SocketException;
|
||||
import java.util.Set;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@@ -100,14 +101,21 @@ class ExceptionHandlerMethodResolverTests {
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenAmbiguousExceptionMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(AmbiguousController.class));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(AmbiguousController.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenNoExceptionMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(NoExceptionController.class));
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(NoExceptionController.class));
|
||||
}
|
||||
|
||||
@Test // gh-35587
|
||||
void shouldRetainOriginalOrderOfProducibleMediaTypes() {
|
||||
ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(MediaTypeController.class);
|
||||
Set<MediaType> producibleTypes = resolver.resolveExceptionMapping(new IllegalArgumentException(), MediaType.TEXT_HTML).getProducibleTypes();
|
||||
assertThat(MediaType.toString(producibleTypes)).isEqualTo("text/html, */*");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -131,15 +139,15 @@ class ExceptionHandlerMethodResolverTests {
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenInvalidMediaTypeMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(InvalidMediaTypeController.class))
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(InvalidMediaTypeController.class))
|
||||
.withMessageContaining("Invalid media type [invalid-mediatype] declared on @ExceptionHandler");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldThrowExceptionWhenAmbiguousMediaTypeMapping() {
|
||||
assertThatIllegalStateException().isThrownBy(() ->
|
||||
new ExceptionHandlerMethodResolver(AmbiguousMediaTypeController.class))
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> new ExceptionHandlerMethodResolver(AmbiguousMediaTypeController.class))
|
||||
.withMessageContaining("Ambiguous @ExceptionHandler method mapped for [ExceptionHandler{exceptionType=java.lang.IllegalArgumentException, mediaType=application/json}]")
|
||||
.withMessageContaining("AmbiguousMediaTypeController.handleJson()")
|
||||
.withMessageContaining("AmbiguousMediaTypeController.handleJsonToo()");
|
||||
|
||||
Reference in New Issue
Block a user