本文整理汇总了Java中org.apache.jmeter.util.JMeterUtils.getPattern方法的典型用法代码示例。如果您正苦于以下问题:Java JMeterUtils.getPattern方法的具体用法?Java JMeterUtils.getPattern怎么用?Java JMeterUtils.getPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.util.JMeterUtils
的用法示例。
在下文中一共展示了JMeterUtils.getPattern方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBoundaryStringFromContentType
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private String getBoundaryStringFromContentType(String requestHeaders) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
String regularExpression = "^" + HTTPConstants.HEADER_CONTENT_TYPE + ": multipart/form-data; boundary=(.+)$";
Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
if(localMatcher.contains(requestHeaders, pattern)) {
MatchResult match = localMatcher.getMatch();
String matchString = match.group(1);
// Header may contain ;charset= , regexp extracts it so computed boundary is wrong
int indexOf = matchString.indexOf(';');
if(indexOf>=0) {
return matchString.substring(0, indexOf);
} else {
return matchString;
}
}
else {
return null;
}
}
示例2: getRequestHeaderValue
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private static String getRequestHeaderValue(String requestHeaders, String headerName) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
// We use multi-line mask so can prefix the line with ^
String expression = "^" + headerName + ":\\s+([^\\r\\n]+)"; // $NON-NLS-1$ $NON-NLS-2$
Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
if(localMatcher.contains(requestHeaders, pattern)) {
// The value is in the first group, group 0 is the whole match
// System.out.println("Found:'"+localMatcher.getMatch().group(1)+"'");
// System.out.println("in: '"+localMatcher.getMatch().group(0)+"'");
return localMatcher.getMatch().group(1);
}
else {
return null;
}
}
示例3: getPositionOfBody
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private static int getPositionOfBody(String stringToCheck) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
// The headers and body are divided by a blank line (the \r is to allow for the CR before LF)
String regularExpression = "^\\r$"; // $NON-NLS-1$
Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
if(localMatcher.contains(input, pattern)) {
MatchResult match = localMatcher.getMatch();
return match.beginOffset(0);
}
// No divider was found
return -1;
}
示例4: getHeaderValue
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private String getHeaderValue(String headerName, String multiPart) {
String regularExpression = headerName + "\\s*:\\s*(.*)$"; //$NON-NLS-1$
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
if(localMatcher.contains(multiPart, pattern)) {
return localMatcher.getMatch().group(1).trim();
}
else {
return null;
}
}
示例5: getSentRequestHeaderValue
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private String getSentRequestHeaderValue(String requestHeaders, String headerName) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
String expression = ".*" + headerName + ": (\\d*).*";
Pattern pattern = JMeterUtils.getPattern(expression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK);
if(localMatcher.matches(requestHeaders, pattern)) {
// The value is in the first group, group 0 is the whole match
return localMatcher.getMatch().group(1);
}
return null;
}
示例6: getPositionOfBody
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private int getPositionOfBody(String stringToCheck) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
// The headers and body are divided by a blank line
String regularExpression = "^.$";
Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.MULTILINE_MASK);
PatternMatcherInput input = new PatternMatcherInput(stringToCheck);
while(localMatcher.contains(input, pattern)) {
MatchResult match = localMatcher.getMatch();
return match.beginOffset(0);
}
// No divider was found
return -1;
}
示例7: checkRegularExpression
import org.apache.jmeter.util.JMeterUtils; //导入方法依赖的package包/类
private boolean checkRegularExpression(String stringToCheck, String regularExpression) {
Perl5Matcher localMatcher = JMeterUtils.getMatcher();
Pattern pattern = JMeterUtils.getPattern(regularExpression, Perl5Compiler.READ_ONLY_MASK | Perl5Compiler.CASE_INSENSITIVE_MASK | Perl5Compiler.SINGLELINE_MASK);
return localMatcher.contains(stringToCheck, pattern);
}