Use JUnit ExpectedException rule in AntPathMatcherTests
This commit is contained in:
@@ -25,11 +25,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.ExpectedException;
|
||||||
|
|
||||||
|
import static org.hamcrest.CoreMatchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Unit tests for {@link AntPathMatcher}.
|
||||||
|
*
|
||||||
* @author Alef Arendsen
|
* @author Alef Arendsen
|
||||||
* @author Seth Ladd
|
* @author Seth Ladd
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
@@ -41,6 +46,9 @@ public class AntPathMatcherTests {
|
|||||||
|
|
||||||
private AntPathMatcher pathMatcher;
|
private AntPathMatcher pathMatcher;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public ExpectedException exception = ExpectedException.none();
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void createMatcher() {
|
public void createMatcher() {
|
||||||
pathMatcher = new AntPathMatcher();
|
pathMatcher = new AntPathMatcher();
|
||||||
@@ -388,14 +396,9 @@ public class AntPathMatcherTests {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void extractUriTemplateVarsRegexCapturingGroups() {
|
public void extractUriTemplateVarsRegexCapturingGroups() {
|
||||||
try {
|
exception.expect(IllegalArgumentException.class);
|
||||||
pathMatcher.extractUriTemplateVariables("/web/{id:foo(bar)?}", "/web/foobar");
|
exception.expectMessage(containsString("The number of capturing groups in the pattern"));
|
||||||
fail("Expected exception");
|
pathMatcher.extractUriTemplateVariables("/web/{id:foo(bar)?}", "/web/foobar");
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
assertTrue("Expected helpful message on the use of capturing groups",
|
|
||||||
ex.getMessage().contains("The number of capturing groups in the pattern"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -430,8 +433,9 @@ public class AntPathMatcherTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("Disabled until SPR-12998 is resolved")
|
@Ignore("Disabled until SPR-12998 is resolved")
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test
|
||||||
public void combineWithTwoFileExtensionPatterns() {
|
public void combineWithTwoFileExtensionPatterns() {
|
||||||
|
exception.expect(IllegalArgumentException.class);
|
||||||
pathMatcher.combine("/*.html", "/*.txt");
|
pathMatcher.combine("/*.html", "/*.txt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user