Add helper method to ResourceHandlerRegistry
This commit is contained in:
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.web.servlet.config.annotation;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.mock.web.test.MockHttpServletRequest;
|
||||
@@ -29,6 +26,8 @@ import org.springframework.web.servlet.HandlerMapping;
|
||||
import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping;
|
||||
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture with a {@link ResourceHandlerRegistry}.
|
||||
*
|
||||
@@ -84,6 +83,13 @@ public class ResourceHandlerRegistryTests {
|
||||
assertEquals(0, registry.getHandlerMapping().getOrder());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasMappingForPattern() {
|
||||
assertTrue(registry.hasMappingForPattern("/resources/**"));
|
||||
assertFalse(registry.hasMappingForPattern("/whatever"));
|
||||
}
|
||||
|
||||
|
||||
private ResourceHttpRequestHandler getHandler(String pathPattern) {
|
||||
SimpleUrlHandlerMapping handlerMapping = (SimpleUrlHandlerMapping) registry.getHandlerMapping();
|
||||
return (ResourceHttpRequestHandler) handlerMapping.getUrlMap().get(pathPattern);
|
||||
|
||||
Reference in New Issue
Block a user