Removing remaining use of PathPattern with String path
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.reactive.handler;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -28,6 +29,7 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.web.util.pattern.PathPattern;
|
||||
import org.springframework.web.util.pattern.PathPatternParser;
|
||||
import org.springframework.web.util.pattern.PatternParseException;
|
||||
@@ -73,14 +75,17 @@ public class PathPatternRegistryTests {
|
||||
|
||||
this.registry.register("/fo?", new Object());
|
||||
this.registry.register("/f?o", new Object());
|
||||
Set<PathMatchResult<Object>> matches = this.registry.findMatches("/foo");
|
||||
|
||||
PathContainer path = PathContainer.parse("/foo", StandardCharsets.UTF_8);
|
||||
Set<PathMatchResult<Object>> matches = this.registry.findMatches(path);
|
||||
assertThat(toPatterns(matches), contains(pattern("/f?o"), pattern("/fo?")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findNoMatch() {
|
||||
this.registry.register("/foo/{bar}", new Object());
|
||||
assertThat(this.registry.findMatches("/other"), hasSize(0));
|
||||
PathContainer path = PathContainer.parse("/other", StandardCharsets.UTF_8);
|
||||
assertThat(this.registry.findMatches(path), hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -88,7 +93,8 @@ public class PathPatternRegistryTests {
|
||||
this.registry.register("/foo/{*baz}", new Object());
|
||||
this.registry.register("/foo/bar/baz", new Object());
|
||||
this.registry.register("/foo/bar/{baz}", new Object());
|
||||
Set<PathMatchResult<Object>> matches = this.registry.findMatches("/foo/bar/baz");
|
||||
PathContainer path = PathContainer.parse("/foo/bar/baz", StandardCharsets.UTF_8);
|
||||
Set<PathMatchResult<Object>> matches = this.registry.findMatches(path);
|
||||
assertThat(toPatterns(matches), contains(pattern("/foo/bar/baz"), pattern("/foo/bar/{baz}"),
|
||||
pattern("/foo/{*baz}")));
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.web.reactive.resource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -32,6 +33,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.http.server.reactive.PathContainer;
|
||||
import org.springframework.mock.http.server.reactive.test.MockServerHttpRequest;
|
||||
import org.springframework.mock.web.test.MockServletContext;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
@@ -73,7 +75,8 @@ public class ResourceUrlProviderTests {
|
||||
|
||||
@Test
|
||||
public void getStaticResourceUrl() {
|
||||
String url = this.urlProvider.getForLookupPath("/resources/foo.css").block(Duration.ofSeconds(5));
|
||||
PathContainer path = PathContainer.parse("/resources/foo.css", StandardCharsets.UTF_8);
|
||||
String url = this.urlProvider.getForLookupPath(path).block(Duration.ofSeconds(5));
|
||||
assertEquals("/resources/foo.css", url);
|
||||
}
|
||||
|
||||
@@ -102,7 +105,8 @@ public class ResourceUrlProviderTests {
|
||||
resolvers.add(new PathResourceResolver());
|
||||
this.handler.setResourceResolvers(resolvers);
|
||||
|
||||
String url = this.urlProvider.getForLookupPath("/resources/foo.css").block(Duration.ofSeconds(5));
|
||||
PathContainer path = PathContainer.parse("/resources/foo.css", StandardCharsets.UTF_8);
|
||||
String url = this.urlProvider.getForLookupPath(path).block(Duration.ofSeconds(5));
|
||||
assertEquals("/resources/foo-e36d2e05253c6c7085a91522ce43a0b4.css", url);
|
||||
}
|
||||
|
||||
@@ -123,7 +127,8 @@ public class ResourceUrlProviderTests {
|
||||
this.handlerMap.put("/resources/*.css", otherHandler);
|
||||
this.urlProvider.setHandlerMap(this.handlerMap);
|
||||
|
||||
String url = this.urlProvider.getForLookupPath("/resources/foo.css").block(Duration.ofSeconds(5));
|
||||
PathContainer path = PathContainer.parse("/resources/foo.css", StandardCharsets.UTF_8);
|
||||
String url = this.urlProvider.getForLookupPath(path).block(Duration.ofSeconds(5));
|
||||
assertEquals("/resources/foo-e36d2e05253c6c7085a91522ce43a0b4.css", url);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user