当前位置: 首页>>代码示例>>Java>>正文


Java HTTPSamplerBase.getDomain方法代码示例

本文整理汇总了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;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:ProxyControl.java

示例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);
    } 
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:31,代码来源:DefaultSamplerCreator.java

示例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;
}
 
开发者ID:d0k1,项目名称:jsflight,代码行数:30,代码来源:JMeterProxyControl.java

示例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();
}
 
开发者ID:d0k1,项目名称:jsflight,代码行数:14,代码来源:JMeterProxyControl.java

示例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();
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:12,代码来源:ProxyControl.java

示例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;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:59,代码来源:HtmlParsingUtils.java

示例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;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:60,代码来源:HtmlParsingUtils.java


注:本文中的org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getDomain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。