Fix failing test
This commit is contained in:
parent
f8e1f06d08
commit
c01f45fa59
|
@ -17,6 +17,7 @@
|
||||||
package org.springframework.web.servlet.config.annotation;
|
package org.springframework.web.servlet.config.annotation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -321,8 +322,11 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public ResourceUrlGenerator resourceUrlGenerator() {
|
public ResourceUrlGenerator resourceUrlGenerator() {
|
||||||
SimpleUrlHandlerMapping hm = (SimpleUrlHandlerMapping) resourceHandlerMapping();
|
Map<String, ?> handlerMap = Collections.<String, Object>emptyMap();
|
||||||
return new ResourceUrlGenerator(hm.getUrlMap());
|
if (resourceHandlerMapping() instanceof SimpleUrlHandlerMapping) {
|
||||||
|
handlerMap = ((SimpleUrlHandlerMapping) resourceHandlerMapping()).getUrlMap();
|
||||||
|
}
|
||||||
|
return new ResourceUrlGenerator(handlerMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.springframework.web.servlet.resource;
|
package org.springframework.web.servlet.resource;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
|
@ -26,7 +25,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.mock.web.test.MockFilterChain;
|
import org.springframework.mock.web.test.MockFilterChain;
|
||||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||||
|
@ -36,7 +34,6 @@ import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
|
||||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
@ -120,6 +117,7 @@ public class ResourceUrlFilterTests {
|
||||||
@Configuration
|
@Configuration
|
||||||
static class WebConfig extends WebMvcConfigurationSupport {
|
static class WebConfig extends WebMvcConfigurationSupport {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||||
|
|
||||||
|
@ -131,14 +129,6 @@ public class ResourceUrlFilterTests {
|
||||||
.addResourceLocations("classpath:org/springframework/web/servlet/resource/test/")
|
.addResourceLocations("classpath:org/springframework/web/servlet/resource/test/")
|
||||||
.setResourceResolvers(resourceResolvers);
|
.setResourceResolvers(resourceResolvers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
public ResourceUrlGenerator resourceUrlGenerator() {
|
|
||||||
ResourceUrlGenerator generator = new ResourceUrlGenerator();
|
|
||||||
SimpleUrlHandlerMapping handlerMapping = (SimpleUrlHandlerMapping) resourceHandlerMapping();
|
|
||||||
generator.setResourceHandlerMappings(Collections.singletonList(handlerMapping));
|
|
||||||
return generator;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestServlet extends HttpServlet {
|
private static class TestServlet extends HttpServlet {
|
||||||
|
|
Loading…
Reference in New Issue