Use PathPatternParser in function.server

Use new PathPatternParser instead of PathMatcher in
web.reactive.function.server.
This commit is contained in:
Arjen Poutsma
2017-02-13 10:18:12 +01:00
parent a31429be2b
commit febed19bf4
3 changed files with 36 additions and 23 deletions

View File

@@ -18,11 +18,13 @@ package org.springframework.web.reactive.function.server;
import java.net.URI;
import java.util.Collections;
import java.util.function.Function;
import org.junit.Test;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.web.util.patterns.PathPatternParser;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -94,6 +96,18 @@ public class RequestPredicatesTests {
assertFalse(predicate.test(request));
}
@Test
public void pathPredicates() throws Exception {
PathPatternParser parser = new PathPatternParser();
parser.setCaseSensitive(false);
Function<String, RequestPredicate> pathPredicates = RequestPredicates.pathPredicates(parser);
URI uri = URI.create("http://localhost/path");
RequestPredicate predicate = pathPredicates.apply("/P*");
MockServerRequest request = MockServerRequest.builder().uri(uri).build();
assertTrue(predicate.test(request));
}
@Test
public void headers() throws Exception {
String name = "MyHeader";