Search in sources :

Example 16 with Arguments

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

the class TestTreeCloner method testCloning.

@Test
public void testCloning() throws Exception {
    ListedHashTree original = new ListedHashTree();
    GenericController controller = new GenericController();
    controller.setName("controller");
    Arguments args = new Arguments();
    args.setName("args");
    TestPlan plan = new TestPlan();
    plan.addParameter("server", "jakarta");
    original.add(controller, args);
    original.add(plan);
    ResultCollector listener = new ResultCollector();
    listener.setName("Collector");
    original.add(controller, listener);
    TreeCloner cloner = new TreeCloner();
    original.traverse(cloner);
    ListedHashTree newTree = cloner.getClonedTree();
    assertTrue(original != newTree);
    assertEquals(original.size(), newTree.size());
    assertEquals(original.getTree(original.getArray()[0]).size(), newTree.getTree(newTree.getArray()[0]).size());
    assertTrue(original.getArray()[0] != newTree.getArray()[0]);
    assertEquals(((GenericController) original.getArray()[0]).getName(), ((GenericController) newTree.getArray()[0]).getName());
    assertSame(original.getTree(original.getArray()[0]).getArray()[1], newTree.getTree(newTree.getArray()[0]).getArray()[1]);
    TestPlan clonedTestPlan = (TestPlan) newTree.getArray()[1];
    clonedTestPlan.setRunningVersion(true);
    clonedTestPlan.recoverRunningVersion();
    assertTrue(!plan.getUserDefinedVariablesAsProperty().isRunningVersion());
    assertTrue(clonedTestPlan.getUserDefinedVariablesAsProperty().isRunningVersion());
    Arguments vars = (Arguments) plan.getUserDefinedVariablesAsProperty().getObjectValue();
    PropertyIterator iter = ((CollectionProperty) vars.getProperty(Arguments.ARGUMENTS)).iterator();
    while (iter.hasNext()) {
        JMeterProperty argProp = iter.next();
        assertTrue(!argProp.isRunningVersion());
        assertTrue(argProp.getObjectValue() instanceof Argument);
        Argument arg = (Argument) argProp.getObjectValue();
        arg.setValue("yahoo");
        assertEquals("yahoo", arg.getValue());
    }
    vars = (Arguments) clonedTestPlan.getUserDefinedVariablesAsProperty().getObjectValue();
    iter = vars.propertyIterator();
    while (iter.hasNext()) {
        assertTrue(iter.next().isRunningVersion());
    }
}
Also used : ListedHashTree(org.apache.jorphan.collections.ListedHashTree) CollectionProperty(org.apache.jmeter.testelement.property.CollectionProperty) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) Argument(org.apache.jmeter.config.Argument) TestPlan(org.apache.jmeter.testelement.TestPlan) Arguments(org.apache.jmeter.config.Arguments) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) GenericController(org.apache.jmeter.control.GenericController) ResultCollector(org.apache.jmeter.reporters.ResultCollector) Test(org.junit.jupiter.api.Test)

Example 17 with Arguments

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

the class PackageTest method testArguments.

@Test
public void testArguments() throws Exception {
    Arguments args = new Arguments();
    args.addArgument("arg1", "val1", "=");
    TestElementProperty prop = new TestElementProperty("args", args);
    ConfigTestElement te = new ConfigTestElement();
    te.addProperty(prop);
    te.setRunningVersion(true);
    Arguments config = new Arguments();
    config.addArgument("config1", "configValue", "=");
    TestElementProperty configProp = new TestElementProperty("args", config);
    ConfigTestElement te2 = new ConfigTestElement();
    te2.addProperty(configProp);
    te.addTestElement(te2);
    assertEquals(2, args.getArgumentCount());
    assertEquals("config1=configValue", args.getArgument(1).toString());
    te.recoverRunningVersion();
    te.addTestElement(te2);
    assertEquals(2, args.getArgumentCount());
    assertEquals("config1=configValue", args.getArgument(1).toString());
}
Also used : TestElementProperty(org.apache.jmeter.testelement.property.TestElementProperty) Arguments(org.apache.jmeter.config.Arguments) ConfigTestElement(org.apache.jmeter.config.ConfigTestElement) Test(org.junit.jupiter.api.Test)

Example 18 with Arguments

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

the class HTTPArgumentsPanel method configure.

@Override
public void configure(TestElement el) {
    super.configure(el);
    if (el instanceof Arguments) {
        tableModel.clearData();
        HTTPArgument.convertArgumentsToHTTP((Arguments) el);
        for (JMeterProperty jMeterProperty : ((Arguments) el).getArguments()) {
            HTTPArgument arg = (HTTPArgument) jMeterProperty.getObjectValue();
            tableModel.addRow(arg);
        }
    }
    checkButtonsStatus();
}
Also used : JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) Arguments(org.apache.jmeter.config.Arguments)

Example 19 with Arguments

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

the class HTTPArgumentsPanel method getUnclonedParameters.

private Arguments getUnclonedParameters() {
    stopTableEditing();
    // only contains Argument (or HTTPArgument)
    @SuppressWarnings("unchecked") Iterator<HTTPArgument> modelData = (Iterator<HTTPArgument>) tableModel.iterator();
    Arguments args = new Arguments();
    while (modelData.hasNext()) {
        HTTPArgument arg = modelData.next();
        args.addArgument(arg);
    }
    return args;
}
Also used : HTTPArgument(org.apache.jmeter.protocol.http.util.HTTPArgument) Iterator(java.util.Iterator) Arguments(org.apache.jmeter.config.Arguments)

Example 20 with Arguments

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

the class UrlConfigGui method configure.

/**
 * Set the text, etc. in the UI.
 *
 * @param el
 *            contains the data to be displayed
 */
public void configure(TestElement el) {
    setName(el.getName());
    Arguments arguments = (Arguments) el.getProperty(HTTPSamplerBase.ARGUMENTS).getObjectValue();
    if (showRawBodyPane) {
        boolean useRaw = el.getPropertyAsBoolean(HTTPSamplerBase.POST_BODY_RAW, HTTPSamplerBase.POST_BODY_RAW_DEFAULT);
        if (useRaw) {
            // Convert CRLF to CR, see modifyTestElement
            String postBody = computePostBody(arguments, true);
            postBodyContent.setInitialText(postBody);
            postBodyContent.setCaretPosition(0);
            argsPanel.clear();
            postContentTabbedPane.setSelectedIndex(tabRawBodyIndex, false);
        } else {
            postBodyContent.setInitialText("");
            argsPanel.configure(arguments);
            postContentTabbedPane.setSelectedIndex(TAB_PARAMETERS, false);
        }
    }
    if (showFileUploadPane) {
        filesPanel.configure(el);
    }
    domain.setText(el.getPropertyAsString(HTTPSamplerBase.DOMAIN));
    String portString = el.getPropertyAsString(HTTPSamplerBase.PORT);
    // Only display the port number if it is meaningfully specified
    if (portString.equals(HTTPSamplerBase.UNSPECIFIED_PORT_AS_STRING)) {
        // $NON-NLS-1$
        port.setText("");
    } else {
        port.setText(portString);
    }
    protocol.setText(el.getPropertyAsString(HTTPSamplerBase.PROTOCOL));
    contentEncoding.setText(el.getPropertyAsString(HTTPSamplerBase.CONTENT_ENCODING));
    path.setText(el.getPropertyAsString(HTTPSamplerBase.PATH));
    if (notConfigOnly) {
        method.setText(el.getPropertyAsString(HTTPSamplerBase.METHOD));
        followRedirects.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.FOLLOW_REDIRECTS));
        autoRedirects.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.AUTO_REDIRECTS));
        useKeepAlive.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.USE_KEEPALIVE));
        useMultipart.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.DO_MULTIPART_POST));
        useBrowserCompatibleMultipartMode.setSelected(el.getPropertyAsBoolean(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART, HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT));
    }
}
Also used : Arguments(org.apache.jmeter.config.Arguments)

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