Search in sources :

Example 21 with Argument

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

the class ArgumentsPanel method modifyTestElement.

/* Implements JMeterGUIComponent.modifyTestElement(TestElement) */
@Override
public void modifyTestElement(TestElement args) {
    GuiUtils.stopTableEditing(table);
    if (args instanceof Arguments) {
        Arguments arguments = (Arguments) args;
        arguments.clear();
        // only contains Argument (or HTTPArgument)
        @SuppressWarnings("unchecked") Iterator<Argument> modelData = (Iterator<Argument>) tableModel.iterator();
        while (modelData.hasNext()) {
            Argument arg = modelData.next();
            if (StringUtils.isEmpty(arg.getName()) && StringUtils.isEmpty(arg.getValue())) {
                continue;
            }
            // $NON-NLS-1$
            arg.setMetaData("=");
            arguments.addArgument(arg);
        }
    }
    super.configureTestElement(args);
}
Also used : Argument(org.apache.jmeter.config.Argument) Arguments(org.apache.jmeter.config.Arguments) Iterator(java.util.Iterator)

Example 22 with Argument

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

the class ArgumentsPanel method createArgumentFromClipboard.

protected Argument createArgumentFromClipboard(String[] clipboardCols) {
    Argument argument = makeNewArgument();
    argument.setName(clipboardCols[0]);
    if (clipboardCols.length > 1) {
        argument.setValue(clipboardCols[1]);
        if (clipboardCols.length > 2) {
            argument.setDescription(clipboardCols[2]);
        }
    }
    return argument;
}
Also used : Argument(org.apache.jmeter.config.Argument)

Example 23 with Argument

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

the class AnchorModifier method modifyArgument.

private void modifyArgument(Argument arg, Arguments args) {
    if (log.isDebugEnabled()) {
        log.debug("Modifying argument: " + arg);
    }
    List<Argument> possibleReplacements = new ArrayList<>();
    PropertyIterator iter = args.iterator();
    Argument replacementArg;
    while (iter.hasNext()) {
        replacementArg = (Argument) iter.next().getObjectValue();
        try {
            if (HtmlParsingUtils.isArgumentMatched(replacementArg, arg)) {
                possibleReplacements.add(replacementArg);
            }
        } catch (Exception ex) {
            log.error("Problem adding Argument", ex);
        }
    }
    if (!possibleReplacements.isEmpty()) {
        replacementArg = possibleReplacements.get(ThreadLocalRandom.current().nextInt(possibleReplacements.size()));
        arg.setName(replacementArg.getName());
        arg.setValue(replacementArg.getValue());
        if (log.isDebugEnabled()) {
            log.debug("Just set argument to values: " + arg.getName() + " = " + arg.getValue());
        }
        args.removeArgument(replacementArg);
    }
}
Also used : Argument(org.apache.jmeter.config.Argument) ArrayList(java.util.ArrayList) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator) MalformedURLException(java.net.MalformedURLException)

Example 24 with Argument

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

the class LDAPSampler method getUserAttributes.

/**
     * Collect all the value from the table (Arguments), using this create the
     * basicAttributes. This will create the Basic Attributes for the User
     * defined TestCase for Add Test.
     *
     * @return the BasicAttributes
     */
private BasicAttributes getUserAttributes() {
    //$NON-NLS-1$
    BasicAttribute basicattribute = new BasicAttribute("objectclass");
    //$NON-NLS-1$
    basicattribute.add("top");
    //$NON-NLS-1$
    basicattribute.add("person");
    //$NON-NLS-1$
    basicattribute.add("organizationalPerson");
    //$NON-NLS-1$
    basicattribute.add("inetOrgPerson");
    BasicAttributes attrs = new BasicAttributes(true);
    attrs.put(basicattribute);
    BasicAttribute attr;
    for (JMeterProperty jMeterProperty : getArguments()) {
        Argument item = (Argument) jMeterProperty.getObjectValue();
        attr = getBasicAttribute(item.getName(), item.getValue());
        attrs.put(attr);
    }
    return attrs;
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) JMeterProperty(org.apache.jmeter.testelement.property.JMeterProperty) Argument(org.apache.jmeter.config.Argument)

Example 25 with Argument

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

the class FunctionHelper method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    StringBuilder functionCall = new StringBuilder("${");
    functionCall.append(functionList.getText());
    Arguments args = (Arguments) parameterPanel.createTestElement();
    if (args.getArguments().size() > 0) {
        functionCall.append("(");
        PropertyIterator iter = args.iterator();
        boolean first = true;
        while (iter.hasNext()) {
            Argument arg = (Argument) iter.next().getObjectValue();
            if (!first) {
                functionCall.append(",");
            }
            functionCall.append(arg.getValue());
            first = false;
        }
        functionCall.append(")");
    }
    functionCall.append("}");
    cutPasteFunction.setText(functionCall.toString());
    CompoundVariable function = new CompoundVariable(functionCall.toString());
    resultTextArea.setText(function.execute().trim());
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) Argument(org.apache.jmeter.config.Argument) Arguments(org.apache.jmeter.config.Arguments) PropertyIterator(org.apache.jmeter.testelement.property.PropertyIterator)

Aggregations

Argument (org.apache.jmeter.config.Argument)28 Arguments (org.apache.jmeter.config.Arguments)13 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)11 Test (org.junit.Test)7 PropertyIterator (org.apache.jmeter.testelement.property.PropertyIterator)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 BasicAttribute (javax.naming.directory.BasicAttribute)3 CollectionProperty (org.apache.jmeter.testelement.property.CollectionProperty)3 File (java.io.File)2 BasicAttributes (javax.naming.directory.BasicAttributes)2 JTextField (javax.swing.JTextField)2 HTTPSampleResult (org.apache.jmeter.protocol.http.sampler.HTTPSampleResult)2 HTTPSamplerBase (org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase)2 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)2 HTTPFileArgs (org.apache.jmeter.protocol.http.util.HTTPFileArgs)2 SampleResult (org.apache.jmeter.samplers.SampleResult)2 Sampler (org.apache.jmeter.samplers.Sampler)2 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 BufferedInputStream (java.io.BufferedInputStream)1