本文整理汇总了Java中org.apache.jmeter.util.JMeterUtils.getPatternCache方法的典型用法代码示例。如果您正苦于以下问题:Java JMeterUtils.getPatternCache方法的具体用法?Java JMeterUtils.getPatternCache怎么用?Java JMeterUtils.getPatternCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.util.JMeterUtils
的用法示例。
在下文中一共展示了JMeterUtils.getPatternCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isAnchorMatched
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
/**
* Check if anchor matches by checking against:
* - protocol
* - domain
* - path
* - parameter names
*
* @param newLink target to match
* @param config pattern to match against
*
* @return true if target URL matches pattern URL
*/
public static boolean isAnchorMatched(HTTPSamplerBase newLink, HTTPSamplerBase config)
{
String query = null;
try {
query = URLDecoder.decode(newLink.getQueryString(), "UTF-8"); // $NON-NLS-1$
} catch (UnsupportedEncodingException e) {
// UTF-8 unsupported? You must be joking!
log.error("UTF-8 encoding not supported!");
throw new Error("Should not happen: " + e.toString(), e);
}
final Arguments arguments = config.getArguments();
final Perl5Matcher matcher = JMeterUtils.getMatcher();
final PatternCacheLRU patternCache = JMeterUtils.getPatternCache();
if (!isEqualOrMatches(newLink.getProtocol(), config.getProtocol(), matcher, patternCache)){
return false;
}
final String domain = config.getDomain();
if (domain != null && domain.length() > 0) {
if (!isEqualOrMatches(newLink.getDomain(), domain, matcher, patternCache)){
return false;
}
}
final String path = config.getPath();
if (!newLink.getPath().equals(path)
&& !matcher.matches(newLink.getPath(), patternCache.getPattern("[/]*" + path, // $NON-NLS-1$
Perl5Compiler.READ_ONLY_MASK))) {
return false;
}
for (JMeterProperty argument : arguments) {
Argument item = (Argument) argument.getObjectValue();
final String name = item.getName();
if (!query.contains(name + "=")) { // $NON-NLS-1$
if (!(matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK)))) {
return false;
}
}
}
return true;
}
示例2: isAnchorMatched
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
/**
* Check if anchor matches by checking against:
* - protocol
* - domain
* - path
* - parameter names
*
* @param newLink target to match
* @param config pattern to match against
*
* @return true if target URL matches pattern URL
*/
public static boolean isAnchorMatched(HTTPSamplerBase newLink, HTTPSamplerBase config)
{
String query = null;
try {
query = URLDecoder.decode(newLink.getQueryString(), "UTF-8"); // $NON-NLS-1$
} catch (UnsupportedEncodingException e) {
// UTF-8 unsupported? You must be joking!
log.error("UTF-8 encoding not supported!");
throw new Error("Should not happen: " + e.toString(), e);
}
final Arguments arguments = config.getArguments();
final Perl5Matcher matcher = JMeterUtils.getMatcher();
final PatternCacheLRU patternCache = JMeterUtils.getPatternCache();
if (!isEqualOrMatches(newLink.getProtocol(), config.getProtocol(), matcher, patternCache)){
return false;
}
final String domain = config.getDomain();
if (domain != null && domain.length() > 0) {
if (!isEqualOrMatches(newLink.getDomain(), domain, matcher, patternCache)){
return false;
}
}
final String path = config.getPath();
if (!newLink.getPath().equals(path)
&& !matcher.matches(newLink.getPath(), patternCache.getPattern("[/]*" + path, // $NON-NLS-1$
Perl5Compiler.READ_ONLY_MASK))) {
return false;
}
PropertyIterator iter = arguments.iterator();
while (iter.hasNext()) {
Argument item = (Argument) iter.next().getObjectValue();
final String name = item.getName();
if (query.indexOf(name + "=") == -1) { // $NON-NLS-1$
if (!(matcher.contains(query, patternCache.getPattern(name, Perl5Compiler.READ_ONLY_MASK)))) {
return false;
}
}
}
return true;
}
示例3: isArgumentMatched
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
/**
* Arguments match if the input name matches the corresponding pattern name
* and the input value matches the pattern value, where the matching is done
* first using String equals, and then Regular Expression matching if the equals test fails.
*
* @param arg - input Argument
* @param patternArg - pattern to match against
* @return true if both name and value match
*/
public static boolean isArgumentMatched(Argument arg, Argument patternArg) {
final Perl5Matcher matcher = JMeterUtils.getMatcher();
final PatternCacheLRU patternCache = JMeterUtils.getPatternCache();
return
isEqualOrMatches(arg.getName(), patternArg.getName(), matcher, patternCache)
&&
isEqualOrMatches(arg.getValue(), patternArg.getValue(), matcher, patternCache);
}