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);
}
}
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();
}
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));
}
}
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;
}
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());
}
}
Aggregations