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


Java HTTPSamplerBase.addArgument方法代码示例

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


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

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

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

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

示例4: testCloneSampler

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testCloneSampler() throws Exception {
	if(GraphicsEnvironment.isHeadless()) {
		System.out.println("Skipping test:"+getClass().getName()+"#testCloneSampler"+", cannot run in Headless mode");
		log.warn("Skipping test:"+getClass().getName()+"#testCloneSampler"+", cannot run in Headless mode");
		return;
	}
	HTTPSamplerBase sampler = (HTTPSamplerBase) gui.createTestElement();
    sampler.addArgument("param", "value");
    HTTPSamplerBase clonedSampler = (HTTPSamplerBase) sampler.clone();
    clonedSampler.setRunningVersion(true);
    sampler.getArguments().getArgument(0).setValue("new value");
    assertEquals("Sampler didn't clone correctly", "new value", sampler.getArguments().getArgument(0)
            .getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:15,代码来源:TestHttpTestSampleGui.java

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

示例6: testGrabSessionId

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionId() throws Exception {
    String html = "location: http://server.com/index.html" + "?session_id=jfdkjdkf%20jddkfdfjkdjfdf%22;";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session_id");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session_id", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
            .getValue());
    assertEquals("http://server.com/index.html?" + "session_id=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:TestURLRewritingModifier.java

示例7: testGrabSessionId5

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionId5() throws Exception {
    String html = "location: http://server.com/index.html" + "?session[33]=jfdkjdkf%20jddkfdfjkdjfdf%22;";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("session[33]");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("session[33]", "adfasdfdsafasdfasd");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("jfdkjdkf jddkfdfjkdjfdf\"", ((Argument) args.getArguments().get(0).getObjectValue())
            .getValue());
    assertEquals("http://server.com/index.html?session%5B33%5D=jfdkjdkf+jddkfdfjkdjfdf%22", sampler.toString());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:TestURLRewritingModifier.java

示例8: testGrabSessionIdURLinJSON

import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase; //导入方法依赖的package包/类
public void testGrabSessionIdURLinJSON() throws Exception {
    String html = 
        "<a href=\"#\" onclick=\"$(\'frame\').src=\'/index?param1=bla&sessionid=xyzxyzxyz\\'";
    response = new SampleResult();
    response.setResponseData(html, null);
    mod.setArgumentName("sessionid");
    HTTPSamplerBase sampler = createSampler();
    sampler.addArgument("sessionid", "xyzxyzxyz");
    context.setCurrentSampler(sampler);
    context.setPreviousResult(response);
    mod.process();
    Arguments args = sampler.getArguments();
    assertEquals("xyzxyzxyz", ((Argument) args.getArguments().get(0).getObjectValue())
            .getValue());
}
 
开发者ID:botelhojp,项目名称:apache-jmeter-2.10,代码行数:16,代码来源:TestURLRewritingModifier.java


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