Permalink
Browse files

Added test cases for SPR-8683

  • Loading branch information...
1 parent 7b8501f commit 4332c1bb16ebae12602775a4d9780c75db12ea3e @dsyer dsyer committed Sep 12, 2011
Showing with 103 additions and 0 deletions.
  1. +62 −0 SPR-8683/pom.xml
  2. +41 −0 SPR-8683/src/test/java/org/springframework/issues/ReproTests.java
View
@@ -0,0 +1,62 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.springframework.issues</groupId>
+ <artifactId>SPR-8683</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>3.1.0.BUILD-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <repositories>
+ <repository>
+ <id>spring-maven-snapshot</id>
+ <name>Springframework Maven Snapshot Repository</name>
+ <url>http://maven.springframework.org/snapshot</url>
+ <snapshots><enabled>true</enabled></snapshots>
+ </repository>
+ </repositories>
+ <properties>
+ <project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.7.2</version>
+ <configuration>
+ <includes>
+ <include>**/*Tests.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/*Abstract*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
+
@@ -0,0 +1,41 @@
+package org.springframework.issues;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Comparator;
+
+import org.junit.Test;
+import org.springframework.util.AntPathMatcher;
+
+// Negative means we prefer the first argument when both patterns match
+public class ReproTests {
+
+ @Test
+ public void patternComparatorWithHierarchicalMatchAccidentalPass() {
+ Comparator<String> comparator = new AntPathMatcher().getPatternComparator("/hotels/new");
+ // This passes accidentally: the order is correct but for the wrong reason
+ assertTrue(comparator.compare("/hotels/{hotel}", "/hotels/**") < 0);
+ }
+
+ @Test
+ public void patternComparatorWithHierarchicalMatchBracketsPreferred() {
+ Comparator<String> comparator = new AntPathMatcher().getPatternComparator("/hotels/new/123");
+ // This passes accidentally: the order is correct but for the wrong reason
+ assertTrue(comparator.compare("/hotels/{hotel}/{booking}", "/hotels/**") < 0);
+ }
+
+ @Test
+ public void patternComparatorWithHierarchicalMatch() {
+ Comparator<String> comparator = new AntPathMatcher().getPatternComparator("/hotels/new/123");
+ // This fails, even though the first path is clearly more specific
+ assertTrue(comparator.compare("/hotels/{hotel}/**", "/**") < 0);
+ }
+
+ @Test
+ public void patternComparatorWithHierarchicalMatchWithWorkaround() {
+ Comparator<String> comparator = new AntPathMatcher().getPatternComparator("/hotels/new/123");
+ // This is a workaround
+ assertTrue(comparator.compare("/hotels/{hotel}/**", "/**/**") < 0);
+ }
+
+}

0 comments on commit 4332c1b

Please sign in to comment.