use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class PostWriterTest method setupFormData.
private void setupFormData(HTTPSampler httpSampler, boolean isEncoded, String titleValue, String descriptionValue) {
Arguments args = new Arguments();
HTTPArgument argument1 = new HTTPArgument("title", titleValue, isEncoded);
HTTPArgument argument2 = new HTTPArgument("description", descriptionValue, isEncoded);
args.addArgument(argument1);
args.addArgument(argument2);
httpSampler.setArguments(args);
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class PutWriterTest method testSetHeadersWithParams.
@Test
public void testSetHeadersWithParams() throws Exception {
URLConnection uc = new NullURLConnection();
HTTPSampler sampler = new HTTPSampler();
sampler.setHTTPFiles(new HTTPFileArg[] { new HTTPFileArg("file2", "param2", "mime2") });
Arguments arguments = new Arguments();
arguments.addArgument(new HTTPArgument("", "parameter with no name"));
sampler.setArguments(arguments);
PutWriter pw = new PutWriter();
pw.setHeaders(uc, sampler);
assertEquals("mime2", uc.getRequestProperty(HTTPConstants.HEADER_CONTENT_TYPE));
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestHTTPSamplers method testParseArguments.
// Parse arguments singly
@Test
public void testParseArguments() {
HTTPSamplerBase sampler = new HTTPNullSampler();
Arguments args;
Argument arg;
args = sampler.getArguments();
assertEquals(0, args.getArgumentCount());
assertEquals(0, sampler.getHTTPFileCount());
sampler.parseArguments("");
args = sampler.getArguments();
assertEquals(0, args.getArgumentCount());
assertEquals(0, sampler.getHTTPFileCount());
sampler.parseArguments("name1");
args = sampler.getArguments();
assertEquals(1, args.getArgumentCount());
arg = args.getArgument(0);
assertEquals("name1", arg.getName());
assertEquals("", arg.getMetaData());
assertEquals("", arg.getValue());
assertEquals(0, sampler.getHTTPFileCount());
sampler.parseArguments("name2=");
args = sampler.getArguments();
assertEquals(2, args.getArgumentCount());
arg = args.getArgument(1);
assertEquals("name2", arg.getName());
assertEquals("=", arg.getMetaData());
assertEquals("", arg.getValue());
assertEquals(0, sampler.getHTTPFileCount());
sampler.parseArguments("name3=value3");
args = sampler.getArguments();
assertEquals(3, args.getArgumentCount());
arg = args.getArgument(2);
assertEquals("name3", arg.getName());
assertEquals("=", arg.getMetaData());
assertEquals("value3", arg.getValue());
assertEquals(0, sampler.getHTTPFileCount());
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestGraphQLRequestParamUtils method testToGraphQLRequestParamsWithHttpArguments.
@Test
void testToGraphQLRequestParamsWithHttpArguments() throws Exception {
Arguments args = new Arguments();
args.addArgument(new HTTPArgument("query", "query { droid { id }}", "=", false));
GraphQLRequestParams params = GraphQLRequestParamUtils.toGraphQLRequestParams(args, null);
assertNull(params.getOperationName());
assertEquals("query { droid { id }}", params.getQuery());
assertNull(params.getVariables());
args = new Arguments();
args.addArgument(new HTTPArgument("operationName", "op1", "=", false));
args.addArgument(new HTTPArgument("query", "query { droid { id }}", "=", false));
args.addArgument(new HTTPArgument("variables", "{\"id\":123}", "=", false));
params = GraphQLRequestParamUtils.toGraphQLRequestParams(args, null);
assertEquals("op1", params.getOperationName());
assertEquals("query { droid { id }}", params.getQuery());
assertEquals("{\"id\":123}", params.getVariables());
args = new Arguments();
args.addArgument(new HTTPArgument("query", "query+%7B+droid+%7B+id+%7D%7D", "=", true));
params = GraphQLRequestParamUtils.toGraphQLRequestParams(args, null);
assertNull(params.getOperationName());
assertEquals("query { droid { id }}", params.getQuery());
assertNull(params.getVariables());
args = new Arguments();
args.addArgument(new HTTPArgument("query", "query%20%7B%20droid%20%7B%20id%20%7D%7D", "=", true));
params = GraphQLRequestParamUtils.toGraphQLRequestParams(args, null);
assertNull(params.getOperationName());
assertEquals("query { droid { id }}", params.getQuery());
assertNull(params.getVariables());
}
use of org.apache.jmeter.config.Arguments in project jmeter by apache.
the class TestHTTPArgument method testConversion.
@Test
public void testConversion() throws Exception {
Arguments args = new Arguments();
args.addArgument("name.?", "value_ here");
args.addArgument("name$of property", "value_.+");
HTTPArgument.convertArgumentsToHTTP(args);
CollectionProperty argList = args.getArguments();
HTTPArgument httpArg = (HTTPArgument) argList.get(0).getObjectValue();
assertEquals("name.%3F", httpArg.getEncodedName());
assertEquals("value_+here", httpArg.getEncodedValue());
httpArg = (HTTPArgument) argList.get(1).getObjectValue();
assertEquals("name%24of+property", httpArg.getEncodedName());
assertEquals("value_.%2B", httpArg.getEncodedValue());
}
Aggregations