Class UrlRegexRequestMatcher
- java.lang.Object
- org.springframework.test.web.servlet.htmlunit.UrlRegexRequestMatcher
- All Implemented Interfaces:
WebRequestMatcher
public final class UrlRegexRequestMatcher extends Object implements WebRequestMatcher
AWebRequestMatcherthat allows matching onWebRequest#getUrl().toExternalForm()using a regular expression.For example, if you would like to match on the domain
code.jquery.com, you might want to use the following.WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");- Since:
- 4.2
- Author:
- Rob Winch, Sam Brannen
- See Also:
DelegatingWebConnection
Constructor Summary
Constructors Constructor Description UrlRegexRequestMatcher(String regex)UrlRegexRequestMatcher(Pattern pattern)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanmatches(com.gargoylesoftware.htmlunit.WebRequest request)Whether this matcher matches on the supplied web request.
Constructor Detail
UrlRegexRequestMatcher
public UrlRegexRequestMatcher(String regex)
UrlRegexRequestMatcher
public UrlRegexRequestMatcher(Pattern pattern)
Method Detail
matches
public boolean matches(com.gargoylesoftware.htmlunit.WebRequest request)
Description copied from interface:WebRequestMatcherWhether this matcher matches on the supplied web request.- Specified by:
matchesin interfaceWebRequestMatcher- Parameters:
request- theWebRequestto attempt to match on- Returns:
trueif this matcher matches on theWebRequest