Search in sources :

Example 51 with Arguments

use of org.apache.jmeter.config.Arguments in project ACS by ACS-Community.

the class T24Sampler method getDefaultParameters.

/**
	 * Provide a list of parameters which this test supports.  Any
	 * parameter names and associated values returned by this method
	 * will appear in the GUI by default so the user doesn't have
	 * to remember the exact names.  The user can add other parameters
	 * which are not listed here.  If this method returns null then
	 * no parameters will be listed.  If the value for some parameter
	 * is null then that parameter will be listed in the GUI with
	 * an empty value.
	 *
	 * @return  a specification of the parameters used by this
	 *           test which should be listed in the GUI, or null
	 *           if no parameters should be listed.
	 */
public Arguments getDefaultParameters() {
    Arguments params = new Arguments();
    params.addArgument("ThreadNum", "${__threadNum}");
    params.addArgument(TEST_PREFIX, TEST);
    params.addArgument("LogCount", String.valueOf(LOG_COUNT));
    params.addArgument("LogSize", String.valueOf(LOG_SIZE));
    params.addArgument("ErrorIterations", String.valueOf(ERR_ITR));
    return params;
}
Also used : Arguments(org.apache.jmeter.config.Arguments)

Example 52 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class UrlConfigGui method modifyTestElement.

/**
     * Save the GUI values in the sampler.
     *
     * @param element {@link TestElement} to modify
     */
public void modifyTestElement(TestElement element) {
    boolean useRaw = postContentTabbedPane.getSelectedIndex() == tabRawBodyIndex;
    Arguments args;
    if (useRaw) {
        args = new Arguments();
        String text = postBodyContent.getText();
        /*
             * Textfield uses \n (LF) to delimit lines; we need to send CRLF.
             * Rather than change the way that arguments are processed by the
             * samplers for raw data, it is easier to fix the data.
             * On retrieval, CRLF is converted back to LF for storage in the text field.
             * See
             */
        HTTPArgument arg = new HTTPArgument("", text.replaceAll("\n", "\r\n"), false);
        arg.setAlwaysEncoded(false);
        args.addArgument(arg);
    } else {
        args = (Arguments) argsPanel.createTestElement();
        HTTPArgument.convertArgumentsToHTTP(args);
        if (showFileUploadPane) {
            filesPanel.modifyTestElement(element);
        }
    }
    element.setProperty(HTTPSamplerBase.POST_BODY_RAW, useRaw, HTTPSamplerBase.POST_BODY_RAW_DEFAULT);
    element.setProperty(new TestElementProperty(HTTPSamplerBase.ARGUMENTS, args));
    element.setProperty(HTTPSamplerBase.DOMAIN, domain.getText());
    element.setProperty(HTTPSamplerBase.PORT, port.getText());
    element.setProperty(HTTPSamplerBase.PROTOCOL, protocol.getText());
    element.setProperty(HTTPSamplerBase.CONTENT_ENCODING, contentEncoding.getText());
    element.setProperty(HTTPSamplerBase.PATH, path.getText());
    if (notConfigOnly) {
        element.setProperty(HTTPSamplerBase.METHOD, method.getText());
        element.setProperty(new BooleanProperty(HTTPSamplerBase.FOLLOW_REDIRECTS, followRedirects.isSelected()));
        element.setProperty(new BooleanProperty(HTTPSamplerBase.AUTO_REDIRECTS, autoRedirects.isSelected()));
        element.setProperty(new BooleanProperty(HTTPSamplerBase.USE_KEEPALIVE, useKeepAlive.isSelected()));
        element.setProperty(new BooleanProperty(HTTPSamplerBase.DO_MULTIPART_POST, useMultipartForPost.isSelected()));
        element.setProperty(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART, useBrowserCompatibleMultipartMode.isSelected(), HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);
    }
}
Also used : HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) BooleanProperty(org.apache.jmeter.testelement.property.BooleanProperty) Arguments(org.apache.jmeter.config.Arguments)

Example 53 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class MultipartUrlConfig method addArgument.

public void addArgument(String name, String value, String metadata) {
    Arguments myArgs = this.getArguments();
    myArgs.addArgument(new HTTPArgument(name, value, metadata));
}
Also used : HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) Arguments(org.apache.jmeter.config.Arguments)

Example 54 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class MultipartUrlConfig method addNonEncodedArgument.

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

Example 55 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter by apache.

the class TestHttpRequestHdr method testGetRequestEncodings.

private void testGetRequestEncodings(String url) throws Exception {
    // A HTTP GET request, with encoding not known
    String contentEncoding = "";
    String param1Value = "yes";
    String param2Value = "0+5 -Å쎅%C3%85";
    String param2ValueEncoded = URLEncoder.encode(param2Value, "UTF-8");
    String testGetRequest = "GET " + url + "?param1=" + param1Value + "&param2=" + param2ValueEncoded + " " + "HTTP/1.1\r\n\r\n";
    // Use null for url and contentEncoding, to simulate that HttpRequestHdr do not
    // know the encoding for the page
    HTTPSamplerBase s = getSamplerForRequest(null, testGetRequest, null);
    assertEquals(HTTPConstants.GET, s.getMethod());
    assertEquals(contentEncoding, s.getContentEncoding());
    // Check arguments
    Arguments arguments = s.getArguments();
    assertEquals(2, arguments.getArgumentCount());
    checkArgument((HTTPArgument) arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
    // When the encoding is not known, the argument will get the encoded value, and the "encode?" set to false
    checkArgument((HTTPArgument) arguments.getArgument(1), "param2", param2ValueEncoded, param2ValueEncoded, contentEncoding, false);
    // A HTTP GET request, with UTF-8 encoding
    contentEncoding = "UTF-8";
    param1Value = "yes";
    param2Value = "0+5 -|⪡♪œ₡ĕͤÅ⁒쎅%C3%85";
    param2ValueEncoded = URLEncoder.encode(param2Value, contentEncoding);
    testGetRequest = "GET " + url + "?param1=" + param1Value + "&param2=" + param2ValueEncoded + " " + "HTTP/1.1\r\n\r\n";
    s = getSamplerForRequest(url, testGetRequest, contentEncoding);
    assertEquals(HTTPConstants.GET, s.getMethod());
    assertEquals(contentEncoding, s.getContentEncoding());
    // Check arguments
    arguments = s.getArguments();
    assertEquals(2, arguments.getArgumentCount());
    checkArgument((HTTPArgument) arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
    checkArgument((HTTPArgument) arguments.getArgument(1), "param2", param2Value, param2ValueEncoded, contentEncoding, true);
    // A HTTP GET request, with ISO-8859-1 encoding
    contentEncoding = "ISO-8859-1";
    param1Value = "yes";
    param2Value = "0+5 -Å%C3%85";
    param2ValueEncoded = URLEncoder.encode(param2Value, contentEncoding);
    testGetRequest = "GET " + url + "?param1=" + param1Value + "&param2=" + param2ValueEncoded + " " + "HTTP/1.1\r\n\r\n";
    s = getSamplerForRequest(url, testGetRequest, contentEncoding);
    assertEquals(HTTPConstants.GET, s.getMethod());
    assertEquals(contentEncoding, s.getContentEncoding());
    // Check arguments
    arguments = s.getArguments();
    assertEquals(2, arguments.getArgumentCount());
    checkArgument((HTTPArgument) arguments.getArgument(0), "param1", param1Value, param1Value, contentEncoding, false);
    checkArgument((HTTPArgument) arguments.getArgument(1), "param2", param2Value, param2ValueEncoded, contentEncoding, true);
}
Also used : Arguments(org.apache.jmeter.config.Arguments) HTTPSamplerBase(org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)

Aggregations

Arguments (org.apache.jmeter.config.Arguments)75 Test (org.junit.Test)27 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)18 SampleResult (org.apache.jmeter.samplers.SampleResult)15 Argument (org.apache.jmeter.config.Argument)13 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)9 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)7 ConfigTestElement (org.apache.jmeter.config.ConfigTestElement)5 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)5 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)3 TestElement (org.apache.jmeter.testelement.TestElement)3 TestPlan (org.apache.jmeter.testelement.TestPlan)3 TestElementProperty (org.apache.jmeter.testelement.property.TestElementProperty)3 File (java.io.File)2 Iterator (java.util.Iterator)2 InvalidVariableException (org.apache.jmeter.functions.InvalidVariableException)2 HTTPFileArgs (org.apache.jmeter.protocol.http.util.HTTPFileArgs)2 ResultCollector (org.apache.jmeter.reporters.ResultCollector)2 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)2 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)2