mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-20 20:59:07 +00:00
Improve parameter-based content negotiation
Closes gh-36925
This commit is contained in:
+10
-1
@@ -49,7 +49,7 @@ class MappingContentNegotiationStrategyTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveMediaTypesViaMediaTypeFactory() throws Exception {
|
||||
void resolveMediaTypesViaFactory() throws Exception {
|
||||
Map<String, MediaType> mapping = null;
|
||||
TestMappingContentNegotiationStrategy strategy = new TestMappingContentNegotiationStrategy("xml", mapping);
|
||||
|
||||
@@ -68,6 +68,15 @@ class MappingContentNegotiationStrategyTests {
|
||||
.isInstanceOf(HttpMediaTypeNotAcceptableException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveMediaTypesInvalidKey() {
|
||||
Map<String, MediaType> mapping = null;
|
||||
TestMappingContentNegotiationStrategy strategy = new TestMappingContentNegotiationStrategy("not.json", mapping);
|
||||
|
||||
assertThatThrownBy(() -> strategy.resolveMediaTypes(null))
|
||||
.isInstanceOf(HttpMediaTypeNotAcceptableException.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void resolveMediaTypesNullKey() throws Exception {
|
||||
Map<String, MediaType> mapping = Collections.singletonMap("json", MediaType.APPLICATION_JSON);
|
||||
|
||||
+2
@@ -75,6 +75,8 @@ class MappingMediaTypeFileExtensionResolverTests {
|
||||
map.put("jSoN", MediaType.APPLICATION_JSON);
|
||||
|
||||
MappingMediaTypeFileExtensionResolver resolver = new MappingMediaTypeFileExtensionResolver(map);
|
||||
map.forEach(resolver::addMapping);
|
||||
|
||||
assertThat(resolver.getAllFileExtensions()).containsExactly("json");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user