Separate out URL path parsing in PathContainer

PathContainer now has separate parsePath and parseUrlPath methods each
creating PathSegment and UrlPathSegment respectively.
This commit is contained in:
Rossen Stoyanchev
2017-07-11 10:06:15 +02:00
parent 1d201a55db
commit 0e370e0703
18 changed files with 149 additions and 103 deletions

View File

@@ -83,7 +83,7 @@ public class ResourceHandlerRegistryTests {
public void mapPathToLocation() throws Exception {
MockServerWebExchange exchange = MockServerHttpRequest.get("").toExchange();
exchange.getAttributes().put(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE,
PathContainer.parse("/testStylesheet.css", StandardCharsets.UTF_8));
PathContainer.parsePath("/testStylesheet.css"));
ResourceWebHandler handler = getHandler("/resources/**");
handler.handle(exchange).block(Duration.ofSeconds(5));

View File

@@ -16,7 +16,6 @@
package org.springframework.web.reactive.resource;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
@@ -75,7 +74,7 @@ public class ResourceUrlProviderTests {
@Test
public void getStaticResourceUrl() {
PathContainer path = PathContainer.parse("/resources/foo.css", StandardCharsets.UTF_8);
PathContainer path = PathContainer.parsePath("/resources/foo.css");
String url = this.urlProvider.getForLookupPath(path).block(Duration.ofSeconds(5));
assertEquals("/resources/foo.css", url);
}
@@ -105,7 +104,7 @@ public class ResourceUrlProviderTests {
resolvers.add(new PathResourceResolver());
this.handler.setResourceResolvers(resolvers);
PathContainer path = PathContainer.parse("/resources/foo.css", StandardCharsets.UTF_8);
PathContainer path = PathContainer.parsePath("/resources/foo.css");
String url = this.urlProvider.getForLookupPath(path).block(Duration.ofSeconds(5));
assertEquals("/resources/foo-e36d2e05253c6c7085a91522ce43a0b4.css", url);
}
@@ -127,7 +126,7 @@ public class ResourceUrlProviderTests {
this.handlerMap.put("/resources/*.css", otherHandler);
this.urlProvider.registerHandlers(this.handlerMap);
PathContainer path = PathContainer.parse("/resources/foo.css", StandardCharsets.UTF_8);
PathContainer path = PathContainer.parsePath("/resources/foo.css");
String url = this.urlProvider.getForLookupPath(path).block(Duration.ofSeconds(5));
assertEquals("/resources/foo-e36d2e05253c6c7085a91522ce43a0b4.css", url);
}

View File

@@ -553,7 +553,7 @@ public class ResourceWebHandlerTests {
private void setPathWithinHandlerMapping(ServerWebExchange exchange, String path) {
exchange.getAttributes().put(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE,
PathContainer.parse(path, StandardCharsets.UTF_8));
PathContainer.parsePath(path));
}
private long resourceLastModified(String resourceName) throws IOException {