本文整理汇总了Java中org.apache.jmeter.protocol.http.util.HTTPArgument类的典型用法代码示例。如果您正苦于以下问题:Java HTTPArgument类的具体用法?Java HTTPArgument怎么用?Java HTTPArgument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HTTPArgument类属于org.apache.jmeter.protocol.http.util包,在下文中一共展示了HTTPArgument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sampleTest2
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
@Test
public void sampleTest2() throws Exception {
http2Req.testStarted();
Arguments args = new Arguments();
String text = "{\"header\":{\"applicationId\":\"HJS\"},\"initSession\":{}}";
HTTPArgument arg = new HTTPArgument("", text.replaceAll("\n","\r\n"), false);
arg.setAlwaysEncoded(false);
args.addArgument(arg);
http2Req.setProperty(new TestElementProperty(HTTP2Request.ARGUMENTS, args));
URL url = new URL("https", "www.sprint.com", 443, "/apiservices/framework/initSession");
HTTP2Connection connection = Mockito.mock(HTTP2Connection.class);
Mockito.when(connection.isClosed()).thenReturn(true);
Mockito.doNothing().when(connection).connect(Mockito.any(String.class), Mockito.any(Integer.class));
Mockito.when(connection.getConnectionId()).thenReturn("10www.sprint.com443");
HTTP2SampleResult sampleResult =new HTTP2SampleResult(url, "POST");
http2Req.addConnection("10www.sprint.com443", connection);
http2Req.setConnection(url, sampleResult);
http2Req.setProperty(new BooleanProperty(HTTP2Request.SYNCREQUEST, true));
HTTP2SampleResult sample = http2Req.sample(url, "POST", false, 0, http2Req.getConnection(), sampleResult);
}
示例2: createPostContentTest
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
@Test
public void createPostContentTest() throws Exception {
String text = "{\"header\":{\"applicationId\":\"HJS\"},\"initSession\":{}}";
DataPostContent dataPostExp = new DataPostContent();
dataPostExp.setDataPath("/apiservices/framework/initSession");
dataPostExp.setPayload(text.getBytes());
Arguments args = new Arguments();
HTTPArgument arg = new HTTPArgument("", text.replaceAll("\n","\r\n"), false);
arg.setAlwaysEncoded(false);
args.addArgument(arg);
http2Req.setProperty(new TestElementProperty(HTTP2Request.ARGUMENTS, args));
http2Req.setProperty(HTTP2Request.PATH, "/apiservices/framework/initSession");
DataPostContent dataPostRes = http2Req.createPostContent("POST");
assertEquals(dataPostExp.getDataPath(), dataPostRes.getDataPath());
}
示例3: getSendParameterValuesAsPostBody
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
/**
* Determine if none of the parameters have a name, and if that
* is the case, it means that the parameter values should be sent
* as the entity body
*
* @return true if none of the parameters have a name specified
*/
public boolean getSendParameterValuesAsPostBody() {
if (getPostBodyRaw()) {
return true;
} else {
boolean noArgumentsHasName = true;
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
if (arg.getName() != null && arg.getName().length() > 0) {
noArgumentsHasName = false;
break;
}
}
return noArgumentsHasName;
}
}
示例4: modifyTestElement
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
@Override
public void modifyTestElement(TestElement element) {
configureTestElement(element);
element.setProperty(WebSocketSampler.DOMAIN, domain.getText());
element.setProperty(WebSocketSampler.PATH, path.getText());
element.setProperty(WebSocketSampler.PORT, port.getText());
element.setProperty(WebSocketSampler.PROTOCOL, protocol.getText());
element.setProperty(WebSocketSampler.CONTENT_ENCODING, contentEncoding.getText());
Arguments args = (Arguments) argsPanel.createTestElement();
HTTPArgument.convertArgumentsToHTTP(args);
element.setProperty(new TestElementProperty(WebSocketSampler.ARGUMENTS, args));
element.setProperty(WebSocketSampler.SEND_MESSAGE, sendMessage.getText());
element.setProperty(WebSocketSampler.RECV_MESSAGE, recvMessage.getText());
}
示例5: getSendParameterValuesAsPostBody
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
/**
* Determine if none of the parameters have a name, and if that
* is the case, it means that the parameter values should be sent
* as the entity body
*
* @return true if none of the parameters have a name specified
*/
public boolean getSendParameterValuesAsPostBody() {
if(getPostBodyRaw()) {
return true;
} else {
boolean noArgumentsHasName = true;
PropertyIterator args = getArguments().iterator();
while (args.hasNext()) {
HTTPArgument arg = (HTTPArgument) args.next().getObjectValue();
if(arg.getName() != null && arg.getName().length() > 0) {
noArgumentsHasName = false;
break;
}
}
return noArgumentsHasName;
}
}
示例6: initializeTableModel
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
@Override
protected void initializeTableModel() {
tableModel = new ObjectTableModel(new String[] {
ArgumentsPanel.COLUMN_RESOURCE_NAMES_0, ArgumentsPanel.COLUMN_RESOURCE_NAMES_1, ENCODE_OR_NOT, INCLUDE_EQUALS },
HTTPArgument.class,
new Functor[] {
new Functor("getName"), //$NON-NLS-1$
new Functor("getValue"), //$NON-NLS-1$
new Functor("isAlwaysEncoded"), //$NON-NLS-1$
new Functor("isUseEquals") }, //$NON-NLS-1$
new Functor[] {
new Functor("setName"), //$NON-NLS-1$
new Functor("setValue"), //$NON-NLS-1$
new Functor("setAlwaysEncoded"), //$NON-NLS-1$
new Functor("setUseEquals") }, //$NON-NLS-1$
new Class[] {String.class, String.class, Boolean.class, Boolean.class });
}
示例7: checkArgument
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
private void checkArgument(
HTTPArgument arg,
String expectedName,
String expectedValue,
String expectedEncodedValue,
String contentEncoding,
boolean expectedEncoded) throws IOException {
assertEquals(expectedName, arg.getName());
// System.out.println("expect " + URLEncoder.encode(expectedValue, "UTF-8"));
// System.out.println("actual " + URLEncoder.encode(arg.getValue(), "UTF-8"));
assertEquals(expectedValue, arg.getValue());
if(contentEncoding != null && contentEncoding.length() > 0) {
assertEquals(expectedEncodedValue, arg.getEncodedValue(contentEncoding));
}
else {
// Most browsers use ISO-8859-1 as default encoding, even if spec says UTF-8
assertEquals(expectedEncodedValue, arg.getEncodedValue("ISO-8859-1"));
}
assertEquals(expectedEncoded, arg.isAlwaysEncoded());
}
示例8: configure
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
private void configure(HTTPSamplerBase sampler) throws Exception {
sampler.addArgument("arg1", "val1");
ConfigTestElement config = (ConfigTestElement) new HttpDefaultsGui().createTestElement();
((Arguments) config.getProperty(HTTPSamplerBase.ARGUMENTS).getObjectValue()).addArgument(new HTTPArgument(
"config1", "configValue"));
config.setRunningVersion(true);
sampler.setRunningVersion(true);
sampler.setRunningVersion(true);
sampler.addTestElement(config);
assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
sampler.recoverRunningVersion();
config.recoverRunningVersion();
assertEquals(1, sampler.getArguments().getArgumentCount());
sampler.addTestElement(config);
assertEquals("config1=configValue", sampler.getArguments().getArgument(1).toString());
}
示例9: computePostBody
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
/**
* Compute body data from arguments
* @param arguments {@link Arguments}
* @param crlfToLF whether to convert CRLF to LF
* @return {@link String}
*/
private static String computePostBody(Arguments arguments, boolean crlfToLF) {
StringBuilder postBody = new StringBuilder();
for (JMeterProperty argument : arguments) {
HTTPArgument arg = (HTTPArgument) argument.getObjectValue();
String value = arg.getValue();
if (crlfToLF) {
value = value.replaceAll("\r\n", "\n"); // See modifyTestElement
}
postBody.append(value);
}
return postBody.toString();
}
示例10: modify
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
private void modify(HTTPSamplerBase sampler, String value) {
if (isPathExtension()) {
if (isPathExtensionNoEquals()) {
sampler.setPath(sampler.getPath() + SEMI_COLON + getArgumentName() + value); // $NON-NLS-1$
} else {
sampler.setPath(sampler.getPath() + SEMI_COLON + getArgumentName() + "=" + value); // $NON-NLS-1$ // $NON-NLS-2$
}
} else {
sampler.getArguments().removeArgument(getArgumentName());
sampler.getArguments().addArgument(new HTTPArgument(getArgumentName(), value, !encode()));
}
}
示例11: addNonEncodedArgument
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
/**
* Add a value that is not URL encoded, and make sure it
* appears in the GUI that it will not be encoded when
* the request is sent.
*
* @param name
* @param value
*/
private void addNonEncodedArgument(String name, String value) {
Arguments myArgs = getArguments();
// The value is not encoded
HTTPArgument arg = new HTTPArgument(name, value, false);
// Let the GUI show that it will not be encoded
arg.setAlwaysEncoded(false);
myArgs.addArgument(arg);
}
示例12: getTestElement
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
public TestElement getTestElement() {
Preconditions.checkNotNull(name);
Preconditions.checkNotNull(value);
HTTPArgument httpArgument = new HTTPArgument();
httpArgument.setProperty(TestElement.GUI_CLASS, HTTPArgumentsPanel.class.getName().toString());
httpArgument.setProperty(TestElement.TEST_CLASS, HTTPSamplerProxy.class.getName().toString());
httpArgument.setName(name);
httpArgument.setValue(value);
httpArgument.setMetaData(getOptionalValue(metaData, "="));
httpArgument.setUseEquals(getOptionalValue(useEquals, true));
httpArgument.setAlwaysEncoded(getOptionalValue(setAlwaysEncoded, true));
return httpArgument;
}
示例13: getArgumentsElement
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
private Arguments getArgumentsElement(List<HTTPArgument> httpArguments) {
Arguments arguments = new Arguments();
arguments.setProperty(TestElement.GUI_CLASS, HTTPArgumentsPanel.class.getName());
arguments.setProperty(TestElement.TEST_CLASS, Arguments.class.getName());
arguments.setProperty(TestElement.ENABLED, true);
if (httpArguments != null) {
for (HTTPArgument httpArgument : httpArguments) {
arguments.addArgument(httpArgument);
}
}
return arguments;
}
示例14: addArgument
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
public HTTPSamplerElement addArgument(String name, String value, boolean encode) {
if (arguments == null) arguments = new ArrayList<>();
HTTPArgument argument = (HTTPArgument) HTTPArgumentElement.builder()
.name(name)
.value(value)
.setAlwaysEncoded(encode)
.build()
.getTestElement();
arguments.add(argument);
return this;
}
示例15: modify
import org.apache.jmeter.protocol.http.util.HTTPArgument; //导入依赖的package包/类
private void modify(HTTPSamplerBase sampler, String value) {
if (isPathExtension()) {
if (isPathExtensionNoEquals()) {
sampler.setPath(sampler.getPath() + SEMI_COLON + getArgumentName() + value); // $NON-NLS-1$
} else {
sampler.setPath(sampler.getPath() + SEMI_COLON + getArgumentName() + "=" + value); // $NON-NLS-1$ // $NON-NLS-2$
}
} else {
sampler.getArguments().removeArgument(getArgumentName());
sampler.getArguments().addArgument(new HTTPArgument(getArgumentName(), value, true));
}
}