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


Java HTTPSamplerBase.setMethod方法代码示例

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


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

示例1: addFormUrls

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private void addFormUrls(Document html, HTTPSampleResult result, HTTPSamplerBase config, 
        List<HTTPSamplerBase> potentialLinks) {
    NodeList rootList = html.getChildNodes();
    List<HTTPSamplerBase> urls = new LinkedList<>();
    for (int x = 0; x < rootList.getLength(); x++) {
        urls.addAll(HtmlParsingUtils.createURLFromForm(rootList.item(x), result.getURL()));
    }
    for (HTTPSamplerBase newUrl : urls) {
        newUrl.setMethod(HTTPConstants.POST);
        if (log.isDebugEnabled()) {
            log.debug("Potential Form match: " + newUrl.toString());
        }
        if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
            log.debug("Matched!");
            potentialLinks.add(newUrl);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:19,代码来源:AnchorModifier.java

示例2: addFormUrls

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private void addFormUrls(Document html, HTTPSampleResult result, HTTPSamplerBase config, 
        List<HTTPSamplerBase> potentialLinks) {
    NodeList rootList = html.getChildNodes();
    List<HTTPSamplerBase> urls = new LinkedList<HTTPSamplerBase>();
    for (int x = 0; x < rootList.getLength(); x++) {
        urls.addAll(HtmlParsingUtils.createURLFromForm(rootList.item(x), result.getURL()));
    }
    for (HTTPSamplerBase newUrl : urls) {
        newUrl.setMethod(HTTPConstants.POST);
        if (log.isDebugEnabled()) {
            log.debug("Potential Form match: " + newUrl.toString());
        }
        if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
            log.debug("Matched!");
            potentialLinks.add(newUrl);
        }
    }
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:19,代码来源:AnchorModifier.java

示例3: testSimpleFormParse

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testSimpleFormParse() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*index.html");
    config.addArgument("test", "g.*");
    config.setMethod(HTTPConstants.POST);
    HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
    String responseText = "<html><head><title>Test page</title></head><body>"
            + "<form action=\"index.html\" method=\"POST\">" + "<input type=\"checkbox\" name=\"test\""
            + " value=\"goto\">Goto index page</form></body></html>";
    HTTPSampleResult result = new HTTPSampleResult();
    result.setResponseData(responseText, null);
    result.setSampleLabel(context.toString());
    result.setURL(context.getUrl());
    jmctx.setCurrentSampler(context);
    jmctx.setCurrentSampler(config);
    jmctx.setPreviousResult(result);
    parser.process();
    assertEquals("http://www.apache.org/subdir/index.html", config.getUrl().toString());
    assertEquals("test=goto", config.getQueryString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:20,代码来源:TestAnchorModifier.java

示例4: testBadCharParse

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testBadCharParse() throws Exception {
    HTTPSamplerBase config = makeUrlConfig(".*index.html");
    config.addArgument("te$st", "g.*");
    config.setMethod(HTTPConstants.POST);
    HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
    String responseText = "<html><head><title>Test page</title></head><body>"
            + "<form action=\"index.html\" method=\"POST\">" + "<input type=\"checkbox\" name=\"te$st\""
            + " value=\"goto\">Goto index page</form></body></html>";
    HTTPSampleResult result = new HTTPSampleResult();
    result.setResponseData(responseText, null);
    result.setSampleLabel(context.toString());
    result.setURL(context.getUrl());
    jmctx.setCurrentSampler(context);
    jmctx.setCurrentSampler(config);
    jmctx.setPreviousResult(result);
    parser.process();
    assertEquals("http://www.apache.org/subdir/index.html", config.getUrl().toString());
    assertEquals("te%24st=goto", config.getQueryString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:20,代码来源:TestAnchorModifier.java

示例5: testSpecialCharParse

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testSpecialCharParse() throws Exception {
  String specialChars = "-_.!~*'()%25";// These are some of the special characters
  String htmlEncodedFixture = URLEncoder.encode(specialChars, "UTF-8");
  
  HTTPSamplerBase config = makeUrlConfig(".*index.html");
  config.addArgument("test", ".*");
  config.setMethod(HTTPConstants.POST);
  HTTPSamplerBase context = makeContext("http://www.apache.org/subdir/previous.html");
  String responseText = "<html><head><title>Test page</title></head><body>"
      + "<form action=\"index.html\" method=\"POST\">" + "<input type=\"hidden\" name=\"test\""
      + " value=\"" + htmlEncodedFixture + "\">Goto index page</form></body></html>";
  
  HTTPSampleResult result = new HTTPSampleResult();
  result.setResponseData(responseText, null);
  result.setSampleLabel(context.toString());
  result.setURL(context.getUrl());
  jmctx.setCurrentSampler(context);
  jmctx.setCurrentSampler(config);
  jmctx.setPreviousResult(result);
  parser.process();
  assertEquals("http://www.apache.org/subdir/index.html", config.getUrl().toString());
  assertEquals("test=" + htmlEncodedFixture, config.getQueryString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:24,代码来源:TestAnchorModifier.java

示例6: addAnchorUrls

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private void addAnchorUrls(Document html, HTTPSampleResult result, HTTPSamplerBase config, 
        List<HTTPSamplerBase> potentialLinks) {
    String base = "";
    NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$
    if (baseList.getLength() > 0) {
        base = baseList.item(0).getAttributes().getNamedItem("href").getNodeValue(); // $NON-NLS-1$
    }
    NodeList nodeList = html.getElementsByTagName("a"); // $NON-NLS-1$
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node tempNode = nodeList.item(i);
        NamedNodeMap nnm = tempNode.getAttributes();
        Node namedItem = nnm.getNamedItem("href"); // $NON-NLS-1$
        if (namedItem == null) {
            continue;
        }
        String hrefStr = namedItem.getNodeValue();
        if (hrefStr.startsWith("javascript:")) { // $NON-NLS-1$
            continue; // No point trying these
        }
        try {
            HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(hrefStr, ConversionUtils.makeRelativeURL(result.getURL(), base));
            newUrl.setMethod(HTTPConstants.GET);
            if (log.isDebugEnabled()) {
                log.debug("Potential <a href> match: " + newUrl);
            }
            if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
                log.debug("Matched!");
                potentialLinks.add(newUrl);
            }
        } catch (MalformedURLException e) {
            log.warn("Bad URL "+e);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:35,代码来源:AnchorModifier.java

示例7: addFramesetUrls

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
private void addFramesetUrls(Document html, HTTPSampleResult result,
    HTTPSamplerBase config, List<HTTPSamplerBase> potentialLinks) {
    String base = "";
    NodeList baseList = html.getElementsByTagName("base"); // $NON-NLS-1$
    if (baseList.getLength() > 0) {
        base = baseList.item(0).getAttributes().getNamedItem("href") // $NON-NLS-1$
                .getNodeValue();
    }
    NodeList nodeList = html.getElementsByTagName("frame"); // $NON-NLS-1$
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node tempNode = nodeList.item(i);
        NamedNodeMap nnm = tempNode.getAttributes();
        Node namedItem = nnm.getNamedItem("src"); // $NON-NLS-1$
        if (namedItem == null) {
            continue;
        }
        String hrefStr = namedItem.getNodeValue();
        try {
            HTTPSamplerBase newUrl = HtmlParsingUtils.createUrlFromAnchor(
                    hrefStr, ConversionUtils.makeRelativeURL(result.getURL(), base));
            newUrl.setMethod(HTTPConstants.GET);
            if (log.isDebugEnabled()) {
                log.debug("Potential <frame src> match: " + newUrl);
            }
            if (HtmlParsingUtils.isAnchorMatched(newUrl, config)) {
                log.debug("Matched!");
                potentialLinks.add(newUrl);
            }
        } catch (MalformedURLException e) {
            log.warn("Bad URL "+e);
        }
    }
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:34,代码来源:AnchorModifier.java

示例8: testSendCookie

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testSendCookie() throws Exception {
    man.add(new Cookie("id", "value", "jakarta.apache.org", "/", false, 9999999999L));
    HTTPSamplerBase sampler = new HTTPNullSampler();
    sampler.setDomain("jakarta.apache.org");
    sampler.setPath("/index.html");
    sampler.setMethod(HTTPConstants.GET);
    assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:9,代码来源:TestCookieManager.java

示例9: testSendCookie2

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testSendCookie2() throws Exception {
    man.add(new Cookie("id", "value", ".apache.org", "/", false, 9999999999L));
    HTTPSamplerBase sampler = new HTTPNullSampler();
    sampler.setDomain("jakarta.apache.org");
    sampler.setPath("/index.html");
    sampler.setMethod(HTTPConstants.GET);
    assertNotNull(man.getCookieHeaderForURL(sampler.getUrl()));
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:9,代码来源:TestCookieManager.java

示例10: 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

示例11: 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

示例12: computeMethod

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


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