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


Java HTTPSamplerBase.setProtocol方法代码示例

本文整理汇总了Java中org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.setProtocol方法的典型用法代码示例。如果您正苦于以下问题:Java HTTPSamplerBase.setProtocol方法的具体用法?Java HTTPSamplerBase.setProtocol怎么用?Java HTTPSamplerBase.setProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase的用法示例。


在下文中一共展示了HTTPSamplerBase.setProtocol方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSimpleParse1

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testSimpleParse1() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*/index\\.html");
    config.setProtocol(HTTPConstants.PROTOCOL_HTTPS);
    config.setPort(HTTPConstants.DEFAULT_HTTPS_PORT);
    HTTPSamplerBase context = makeContext("https://www.apache.org/subdir/previous.html");
    String responseText = "<html><head><title>Test page</title></head><body>"
            + "<a href=\"index.html\">Goto index page</a></body></html>";
    HTTPSampleResult result = new HTTPSampleResult();
    jmctx.setCurrentSampler(context);
    jmctx.setCurrentSampler(config);
    result.setResponseData(responseText, null);
    result.setSampleLabel(context.toString());
    result.setSamplerData(context.toString());
    result.setURL(context.getUrl());
    jmctx.setPreviousResult(result);
    parser.process();
    assertEquals("https://www.apache.org/subdir/index.html", config.getUrl().toString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:19,代码来源:TestAnchorModifier.java

示例2: createUrlFromAnchor

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
 * Create a new Sampler based on an HREF string plus a contextual URL
 * object. Given that an HREF string might be of three possible forms, some
 * processing is required.
 */
public static HTTPSamplerBase createUrlFromAnchor(String parsedUrlString, URL context) throws MalformedURLException {
    if (log.isDebugEnabled()) {
        log.debug("Creating URL from Anchor: " + parsedUrlString + ", base: " + context);
    }
    URL url = ConversionUtils.makeRelativeURL(context, parsedUrlString);
    HTTPSamplerBase sampler =HTTPSamplerFactory.newInstance();
    sampler.setDomain(url.getHost());
    sampler.setProtocol(url.getProtocol());
    sampler.setPort(url.getPort());
    sampler.setPath(url.getPath());
    sampler.parseArguments(url.getQuery());

    return sampler;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:20,代码来源:HtmlParsingUtils.java

示例3: testIsAnchorMatched

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testIsAnchorMatched() throws Exception {
    HTTPSamplerBase target=new HTTPNullSampler();
    HTTPSamplerBase pattern=new HTTPNullSampler();

    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));

    target.setProtocol("http:");
    assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));

    pattern.setProtocol(".*");
    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
    
    target.setDomain("a.b.c");
    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));

    pattern.setDomain(".*");
    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
    
    target.setPath("/abc");
    assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));

    pattern.setPath(".*");
    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
    
    target.addArgument("param2", "value2", "=");
    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
    
    pattern.addArgument("param1", ".*", "=");
    assertFalse(HtmlParsingUtils.isAnchorMatched(target, pattern));
    
    target.addArgument("param1", "value1", "=");
    assertTrue(HtmlParsingUtils.isAnchorMatched(target, pattern));
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:34,代码来源:TestHtmlParsingUtils.java

示例4: makeContext

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private HTTPSamplerBase makeContext(String url) throws MalformedURLException {
    URL u = new URL(url);
    HTTPSamplerBase context = new HTTPNullSampler();
    context.setDomain(u.getHost());
    context.setPath(u.getPath());
    context.setPort(u.getPort());
    context.setProtocol(u.getProtocol());
    context.parseArguments(u.getQuery());
    return context;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:11,代码来源:TestAnchorModifier.java

示例5: makeUrlConfig

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private HTTPSamplerBase makeUrlConfig(String path) {
    HTTPSamplerBase config = new HTTPNullSampler();
    config.setDomain("www.apache.org");
    config.setMethod(HTTPConstants.GET);
    config.setPath(path);
    config.setPort(HTTPConstants.DEFAULT_HTTP_PORT);
    config.setProtocol(HTTPConstants.PROTOCOL_HTTP);
    return config;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:10,代码来源:TestAnchorModifier.java

示例6: createSampler

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private HTTPSamplerBase createSampler() {
    HTTPSamplerBase sampler = new HTTPNullSampler();
    sampler.setDomain("server.com");
    sampler.setPath("index.html");
    sampler.setMethod(HTTPConstants.GET);
    sampler.setProtocol("http");
    return sampler;
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:9,代码来源:TestURLRewritingModifier.java

示例7: createUrlFromAnchor

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
 * Create a new Sampler based on an HREF string plus a contextual URL
 * object. Given that an HREF string might be of three possible forms, some
 * processing is required.
 *
 * @param parsedUrlString
 *            the url from the href
 * @param context
 *            the context in which the href was found. This is used to
 *            extract url information that might be missing in
 *            <code>parsedUrlString</code>
 * @return sampler with filled in information about the fully parsed url
 * @throws MalformedURLException
 *             when the given url (<code>parsedUrlString</code> plus
 *             <code>context</code> is malformed)
 */
public static HTTPSamplerBase createUrlFromAnchor(String parsedUrlString, URL context) throws MalformedURLException {
    if (log.isDebugEnabled()) {
        log.debug("Creating URL from Anchor: " + parsedUrlString + ", base: " + context);
    }
    URL url = ConversionUtils.makeRelativeURL(context, parsedUrlString);
    HTTPSamplerBase sampler =HTTPSamplerFactory.newInstance();
    sampler.setDomain(url.getHost());
    sampler.setProtocol(url.getProtocol());
    sampler.setPort(url.getPort());
    sampler.setPath(url.getPath());
    sampler.parseArguments(url.getQuery());

    return sampler;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:31,代码来源:HtmlParsingUtils.java

示例8: computeProtocol

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
/**
 * Set protocol on sampler
 * @param sampler {@link HTTPSamplerBase}
 * @param request {@link HttpRequestHdr}
 */
protected void computeProtocol(HTTPSamplerBase sampler,
        HttpRequestHdr request) {
    sampler.setProtocol(request.getProtocol(sampler));
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:10,代码来源:DefaultSamplerCreator.java


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