Search in sources :

Example 91 with Arguments

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

the class BackendListener method sampleOccurred.

@Override
public void sampleOccurred(SampleEvent event) {
    Arguments args = getArguments();
    BackendListenerContext context = new BackendListenerContext(args);
    SampleResult sr = listenerClientData.client.createSampleResult(context, event.getResult());
    if (sr == null) {
        if (log.isDebugEnabled()) {
            log.debug("{} => Dropping SampleResult: {}", getName(), event.getResult());
        }
        return;
    }
    try {
        if (!listenerClientData.queue.offer(sr)) {
            // we failed to add the element first time
            listenerClientData.queueWaits.add(1L);
            long t1 = System.nanoTime();
            listenerClientData.queue.put(sr);
            long t2 = System.nanoTime();
            listenerClientData.queueWaitTime.add(t2 - t1);
        }
    } catch (Exception err) {
        log.error("sampleOccurred, failed to queue the sample", err);
    }
}
Also used : Arguments(org.apache.jmeter.config.Arguments) SampleResult(org.apache.jmeter.samplers.SampleResult)

Example 92 with Arguments

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

the class FunctionHelper method initParameterPanel.

/**
 * @throws InstantiationException if function instantiation fails
 * @throws IllegalAccessException if function instantiation fails
 */
protected void initParameterPanel() throws InstantiationException, IllegalAccessException {
    Arguments args = new Arguments();
    Function function;
    String functionName = getFunctionName(functionList.getText());
    try {
        function = CompoundVariable.getFunctionClass(functionName).getDeclaredConstructor().newInstance();
    } catch (InvocationTargetException | NoSuchMethodException e) {
        InstantiationException ex = new InstantiationException("Unable to instantiate " + functionName);
        ex.initCause(e instanceof InvocationTargetException ? e.getCause() : e);
        throw ex;
    }
    List<String> argumentDesc = function.getArgumentDesc();
    for (String help : argumentDesc) {
        // $NON-NLS-1$
        args.addArgument(help, "");
    }
    parameterPanel.configure(args);
    parameterPanel.revalidate();
}
Also used : Function(org.apache.jmeter.functions.Function) Arguments(org.apache.jmeter.config.Arguments) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 93 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) {
    String actionCommand = e.getActionCommand();
    if (GENERATE.equals(actionCommand)) {
        String functionName = getFunctionName(functionList.getText());
        Arguments args = (Arguments) parameterPanel.createTestElement();
        String functionCall = buildFunctionCallString(functionName, args);
        cutPasteFunction.setText(functionCall);
        cutPasteFunction.setEnabled(true);
        GuiUtils.copyTextToClipboard(cutPasteFunction.getText());
        CompoundVariable function = new CompoundVariable(functionCall);
        JMeterContext threadContext = JMeterContextService.getContext();
        threadContext.setVariables(jMeterVariables);
        threadContext.setThreadNum(1);
        threadContext.getVariables().put(JMeterThread.LAST_SAMPLE_OK, "true");
        ThreadGroup threadGroup = new ThreadGroup();
        threadGroup.setName("FunctionHelper-Dialog-ThreadGroup");
        threadContext.setThreadGroup(threadGroup);
        try {
            resultTextArea.setText(function.execute().trim());
        } catch (Exception ex) {
            log.error("Error calling function {}", functionCall, ex);
            resultTextArea.setText(ex.getMessage() + ", \nstacktrace:\n " + ExceptionUtils.getStackTrace(ex));
            resultTextArea.setCaretPosition(0);
        }
        variablesTextArea.setText(variablesToString(jMeterVariables));
    } else {
        jMeterVariables = new JMeterVariables();
        variablesTextArea.setText(variablesToString(jMeterVariables));
    }
}
Also used : CompoundVariable(org.apache.jmeter.engine.util.CompoundVariable) JMeterVariables(org.apache.jmeter.threads.JMeterVariables) JMeterContext(org.apache.jmeter.threads.JMeterContext) Arguments(org.apache.jmeter.config.Arguments) ThreadGroup(org.apache.jmeter.threads.ThreadGroup) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Example 94 with Arguments

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

the class MyJavaSamplerDemo method getDefaultParameters.

@Override
public Arguments getDefaultParameters() {
    Arguments arguments = new Arguments();
    arguments.addArgument("Name", "World");
    return arguments;
}
Also used : Arguments(org.apache.jmeter.config.Arguments)

Example 95 with Arguments

use of org.apache.jmeter.config.Arguments in project jmeter-plugins by undera.

the class SetVariablesAction method processVariables.

private void processVariables() {
    final Arguments args1 = (Arguments) this.getUserDefinedVariablesAsProperty().getObjectValue();
    Arguments args = (Arguments) args1.clone();
    final JMeterVariables vars = JMeterContextService.getContext().getVariables();
    Iterator<Map.Entry<String, String>> it = args.getArgumentsAsMap().entrySet().iterator();
    Map.Entry<String, String> var;
    while (it.hasNext()) {
        var = it.next();
        if (log.isDebugEnabled()) {
            log.debug("Setting " + var.getKey() + "=" + var.getValue());
        }
        vars.put(var.getKey(), var.getValue());
    }
}
Also used : JMeterVariables(org.apache.jmeter.threads.JMeterVariables) Entry(org.apache.jmeter.samplers.Entry) Arguments(org.apache.jmeter.config.Arguments) Map(java.util.Map)

Aggregations

Arguments (org.apache.jmeter.config.Arguments)102 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 JMeterProperty (org.apache.jmeter.testelement.property.JMeterProperty)11 HTTPArgument (org.apache.jmeter.protocol.http.util.HTTPArgument)10 Test (org.junit.Test)10 HTTPFileArg (org.apache.jmeter.protocol.http.util.HTTPFileArg)7 JMeterVariables (org.apache.jmeter.threads.JMeterVariables)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 HTTPFileArgs (org.apache.jmeter.protocol.http.util.HTTPFileArgs)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