本文整理汇总了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());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
示例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());
}
示例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());
}
示例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());
}