本文整理汇总了Java中org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getDomain方法的典型用法代码示例。如果您正苦于以下问题:Java HTTPSamplerBase.getDomain方法的具体用法?Java HTTPSamplerBase.getDomain怎么用?Java HTTPSamplerBase.getDomain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase
的用法示例。
在下文中一共展示了HTTPSamplerBase.getDomain方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterUrl
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
boolean filterUrl(HTTPSamplerBase sampler) {
String domain = sampler.getDomain();
if (domain == null || domain.length() == 0) {
return false;
}
String url = generateMatchUrl(sampler);
CollectionProperty includePatterns = getIncludePatterns();
if (includePatterns.size() > 0) {
if (!matchesPatterns(url, includePatterns)) {
return false;
}
}
CollectionProperty excludePatterns = getExcludePatterns();
if (excludePatterns.size() > 0) {
if (matchesPatterns(url, excludePatterns)) {
return false;
}
}
return true;
}
示例2: computeContentEncoding
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
* Compute content encoding
* @param sampler {@link HTTPSamplerBase}
* @param request {@link HttpRequestHdr}
* @param pageEncodings Map<String, String>
* @param formEncodings Map<String, String>
* @throws MalformedURLException
*/
protected void computeContentEncoding(HTTPSamplerBase sampler,
HttpRequestHdr request, Map<String, String> pageEncodings,
Map<String, String> formEncodings) throws MalformedURLException {
URL pageUrl = null;
if(sampler.isProtocolDefaultPort()) {
pageUrl = new URL(sampler.getProtocol(), sampler.getDomain(), request.getPath());
}
else {
pageUrl = new URL(sampler.getProtocol(), sampler.getDomain(),
sampler.getPort(), request.getPath());
}
String urlWithoutQuery = request.getUrlWithoutQuery(pageUrl);
String contentEncoding = computeContentEncoding(request, pageEncodings,
formEncodings, urlWithoutQuery);
// Set the content encoding
if(!StringUtils.isEmpty(contentEncoding)) {
sampler.setContentEncoding(contentEncoding);
}
}
示例3: filterUrl
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private boolean filterUrl(HTTPSamplerBase sampler)
{
String domain = sampler.getDomain();
if (domain == null || domain.length() == 0)
{
return false;
}
String url = generateMatchUrl(sampler);
CollectionProperty includePatterns = getIncludePatterns();
if (includePatterns.size() > 0)
{
if (!matchesPatterns(url, includePatterns))
{
return false;
}
}
CollectionProperty excludePatterns = getExcludePatterns();
if (excludePatterns.size() > 0)
{
if (matchesPatterns(url, excludePatterns))
{
return false;
}
}
return true;
}
示例4: generateMatchUrl
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private String generateMatchUrl(HTTPSamplerBase sampler)
{
StringBuilder buf = new StringBuilder(sampler.getDomain());
buf.append(':'); // $NON-NLS-1$
buf.append(sampler.getPort());
buf.append(sampler.getPath());
if (sampler.getQueryString().length() > 0)
{
buf.append('?'); // $NON-NLS-1$
buf.append(sampler.getQueryString());
}
return buf.toString();
}
示例5: generateMatchUrl
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private String generateMatchUrl(HTTPSamplerBase sampler) {
StringBuilder buf = new StringBuilder(sampler.getDomain());
buf.append(':'); // $NON-NLS-1$
buf.append(sampler.getPort());
buf.append(sampler.getPath());
if (sampler.getQueryString().length() > 0) {
buf.append('?'); // $NON-NLS-1$
buf.append(sampler.getQueryString());
}
return buf.toString();
}
示例6: isAnchorMatched
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的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;
}
示例7: isAnchorMatched
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的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;
}