Polish
This commit is contained in:
@@ -54,6 +54,7 @@ import org.springframework.web.servlet.HandlerMapping;
|
||||
* @author Keith Donald
|
||||
* @author Jeremy Grelle
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class ResourceHttpRequestHandlerTests {
|
||||
|
||||
@@ -244,6 +245,27 @@ public class ResourceHttpRequestHandlerTests {
|
||||
assertEquals("h1 { color:red; }", this.response.getContentAsString());
|
||||
}
|
||||
|
||||
@Test // SPR-13658
|
||||
public void getResourceWithRegisteredMediaTypeDefaultStrategy() throws Exception {
|
||||
ContentNegotiationManagerFactoryBean factory = new ContentNegotiationManagerFactoryBean();
|
||||
factory.setFavorPathExtension(false);
|
||||
factory.setDefaultContentType(new MediaType("foo", "bar"));
|
||||
factory.afterPropertiesSet();
|
||||
ContentNegotiationManager manager = factory.getObject();
|
||||
|
||||
List<Resource> paths = Collections.singletonList(new ClassPathResource("test/", getClass()));
|
||||
this.handler = new ResourceHttpRequestHandler();
|
||||
this.handler.setLocations(paths);
|
||||
this.handler.setContentNegotiationManager(manager);
|
||||
this.handler.afterPropertiesSet();
|
||||
|
||||
this.request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, "foo.css");
|
||||
this.handler.handleRequest(this.request, this.response);
|
||||
|
||||
assertEquals("foo/bar", this.response.getContentType());
|
||||
assertEquals("h1 { color:red; }", this.response.getContentAsString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidPath() throws Exception {
|
||||
for (HttpMethod method : HttpMethod.values()) {
|
||||
|
||||
Reference in New Issue
Block a user