Search in sources :

Example 66 with Arguments

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

the class ArgumentsPanel method createTestElement.

/* Implements JMeterGUIComponent.createTestElement() */
@Override
public TestElement createTestElement() {
    Arguments args = new Arguments();
    modifyTestElement(args);
    return args;
}
Also used : Arguments(org.apache.jmeter.config.Arguments)

Example 67 with Arguments

use of org.apache.jmeter.config.Arguments 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 68 with Arguments

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

the class HTTPArgumentsPanel method createTestElement.

@Override
public TestElement createTestElement() {
    Arguments args = getUnclonedParameters();
    super.configureTestElement(args);
    return (TestElement) args.clone();
}
Also used : Arguments(org.apache.jmeter.config.Arguments) TestElement(org.apache.jmeter.testelement.TestElement)

Example 69 with Arguments

use of org.apache.jmeter.config.Arguments 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)

Example 70 with Arguments

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

the class JavaSampler method sample.

/**
     * Performs a test sample.
     *
     * The <code>sample()</code> method retrieves the reference to the Java
     * client and calls its <code>runTest()</code> method.
     *
     * @see JavaSamplerClient#runTest(JavaSamplerContext)
     *
     * @param entry
     *            the Entry for this sample
     * @return test SampleResult
     */
@Override
public SampleResult sample(Entry entry) {
    Arguments args = getArguments();
    // Allow Sampler access
    args.addArgument(TestElement.NAME, getName());
    // to test element name
    context = new JavaSamplerContext(args);
    if (javaClient == null) {
        log.debug(whoAmI() + "\tCreating Java Client");
        javaClient = createJavaClient();
        javaClient.setupTest(context);
    }
    SampleResult result = javaClient.runTest(context);
    // Only set the default label if it has not been set
    if (result != null && result.getSampleLabel().length() == 0) {
        result.setSampleLabel(getName());
    }
    return result;
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult)

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