Remove ParsingPathMatcher

Now that we also have RequestPath and PathContainer with the latter as
the required input, the ParsingPathMatcher adapter can be removed.
This commit is contained in:
Rossen Stoyanchev
2017-08-01 13:35:21 +02:00
parent 4fc0ce1206
commit b1440b6816
7 changed files with 29 additions and 260 deletions

View File

@@ -464,19 +464,19 @@ public class PathPatternParserTests {
}
private void assertMatches(PathPattern pp, String path) {
assertTrue(pp.matches(PathPatternMatcherTests.toPathContainer(path)));
assertTrue(pp.matches(PathPatternTests.toPathContainer(path)));
}
private void assertNoMatch(PathPattern pp, String path) {
assertFalse(pp.matches(PathPatternMatcherTests.toPathContainer(path)));
assertFalse(pp.matches(PathPatternTests.toPathContainer(path)));
}
private PathMatchResult matchAndExtract(PathPattern pp, String path) {
return pp.matchAndExtract(PathPatternMatcherTests.toPathContainer(path));
return pp.matchAndExtract(PathPatternTests.toPathContainer(path));
}
private PathContainer toPSC(String path) {
return PathPatternMatcherTests.toPathContainer(path);
return PathPatternTests.toPathContainer(path);
}
}

View File

@@ -49,7 +49,7 @@ import static org.junit.Assert.fail;
*
* @author Andy Clement
*/
public class PathPatternMatcherTests {
public class PathPatternTests {
private char separator = PathPatternParser.DEFAULT_SEPARATOR;
@@ -1072,11 +1072,10 @@ public class PathPatternMatcherTests {
@Test
public void patternComparator() {
Comparator<PathPattern> comparator = new ParsingPathMatcher.PatternComparatorConsideringPath("/hotels/new");
assertEquals(0, comparator.compare(null, null));
assertEquals(1, comparator.compare(null, parse("/hotels/new")));
assertEquals(-1, comparator.compare(parse("/hotels/new"), null));
Comparator<PathPattern> comparator = (p1, p2) -> {
int index = p1.compareTo(p2);
return (index != 0 ? index : p1.getPatternString().compareTo(p2.getPatternString()));
};
assertEquals(0, comparator.compare(parse("/hotels/new"), parse("/hotels/new")));
@@ -1110,8 +1109,9 @@ public class PathPatternMatcherTests {
assertEquals(-1, comparator.compare(parse("/hotels/*"), parse("/hotels/*/**")));
assertEquals(1, comparator.compare(parse("/hotels/*/**"), parse("/hotels/*")));
assertEquals(-1,
comparator.compare(parse("/hotels/new"), parse("/hotels/new.*")));
// TODO: shouldn't the wildcard lower the score?
// assertEquals(-1,
// comparator.compare(parse("/hotels/new"), parse("/hotels/new.*")));
// SPR-6741
assertEquals(-1,
@@ -1164,7 +1164,10 @@ public class PathPatternMatcherTests {
@Test
public void patternComparatorSort() {
Comparator<PathPattern> comparator = new ParsingPathMatcher.PatternComparatorConsideringPath("/hotels/new");
Comparator<PathPattern> comparator = (p1, p2) -> {
int index = p1.compareTo(p2);
return (index != 0 ? index : p1.getPatternString().compareTo(p2.getPatternString()));
};
List<PathPattern> paths = new ArrayList<>(3);
PathPatternParser pp = new PathPatternParser();
@@ -1175,13 +1178,6 @@ public class PathPatternMatcherTests {
assertNull(paths.get(1));
paths.clear();
paths.add(pp.parse("/hotels/new"));
paths.add(null);
Collections.sort(paths, comparator);
assertEquals("/hotels/new", paths.get(0).getPatternString());
assertNull(paths.get(1));
paths.clear();
paths.add(pp.parse("/hotels/*"));
paths.add(pp.parse("/hotels/new"));
Collections.sort(paths, comparator);
@@ -1250,7 +1246,10 @@ public class PathPatternMatcherTests {
// assertEquals("/hotels/{hotel}", paths.get(1).toPatternString());
// paths.clear();
comparator = new ParsingPathMatcher.PatternComparatorConsideringPath("/web/endUser/action/login.html");
comparator = (p1, p2) -> {
int index = p1.compareTo(p2);
return (index != 0 ? index : p1.getPatternString().compareTo(p2.getPatternString()));
};
paths.add(pp.parse("/*/login.*"));
paths.add(pp.parse("/*/endUser/action/login.*"));
Collections.sort(paths, comparator);
@@ -1303,7 +1302,7 @@ public class PathPatternMatcherTests {
private PathMatchResult matchAndExtract(String pattern, String path) {
return parse(pattern).matchAndExtract(PathPatternMatcherTests.toPathContainer(path));
return parse(pattern).matchAndExtract(PathPatternTests.toPathContainer(path));
}
private PathPattern parse(String path) {