Search in sources :

Example 31 with Arguments

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);
}
Also used : HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) Arguments(org.apache.jmeter.config.Arguments)

Example 32 with Arguments

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));
}
Also used : HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) Arguments(org.apache.jmeter.config.Arguments) HTTPFileArg(org.apache.jmeter.protocol.http.util.HTTPFileArg) URLConnection(java.net.URLConnection) Test(org.junit.jupiter.api.Test)

Example 33 with Arguments

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());
}
Also used : Argument(org.apache.jmeter.config.Argument) Arguments(org.apache.jmeter.config.Arguments) Test(org.junit.jupiter.api.Test)

Example 34 with Arguments

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());
}
Also used : GraphQLRequestParams(org.apache.jmeter.protocol.http.config.GraphQLRequestParams) Arguments(org.apache.jmeter.config.Arguments) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 35 with Arguments

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());
}
Also used : CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) Arguments(org.apache.jmeter.config.Arguments) Test(org.junit.jupiter.api.Test)

Aggregations

Arguments (org.apache.jmeter.config.Arguments)96 Test (org.junit.jupiter.api.Test)32 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)18 SampleResult (org.apache.jmeter.samplers.SampleResult)17 Argument (org.apache.jmeter.config.Argument)15 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)10 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)8 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)6 TestElement (org.apache.jmeter.testelement.TestElement)6 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)5 Test (org.junit.Test)5 HTTPFileArgs (org.apache.jmeter.protocol.http.util.HTTPFileArgs)4 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)4 IOException (java.io.IOException)3 URL (java.net.URL)3 Iterator (java.util.Iterator)3 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)3 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)3