use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class Env method execute.
/**
* {@inheritDoc}
*/
@Override
public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
String propertyName = values[0].execute();
String propertyDefault = propertyName;
if (values.length > 2) {
// We have a 3rd parameter
propertyDefault = values[2].execute();
}
String propertyValue = JMeterPluginsUtils.getEnvDefault(propertyName, propertyDefault);
if (values.length > 1) {
String variableName = values[1].execute();
if (variableName.length() > 0) {
// Allow for empty name
final JMeterVariables variables = getVariables();
if (variables != null) {
variables.put(variableName, propertyValue);
}
}
}
return propertyValue;
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class IsDefined method execute.
/**
* {@inheritDoc}
*/
@Override
public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
JMeterVariables vars = getVariables();
String res = ((CompoundVariable) values[0]).execute().trim();
if (vars != null) {
Object var = vars.getObject(res);
if (var != null) {
return "1";
}
}
return "0";
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class LowerCase method execute.
/**
* {@inheritDoc}
*/
@Override
public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
JMeterVariables vars = getVariables();
String res = ((CompoundVariable) values[0]).execute().toLowerCase();
if (vars != null && values.length > 1) {
String varName = ((CompoundVariable) values[1]).execute().trim();
vars.put(varName, res);
}
return res;
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class StrLen method execute.
/**
* {@inheritDoc}
*/
@Override
public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
JMeterVariables vars = getVariables();
Integer len = ((CompoundVariable) values[0]).execute().length();
if (vars != null && values.length > 1) {
String varName = ((CompoundVariable) values[1]).execute().trim();
vars.put(varName, len.toString());
}
return len.toString();
}
use of org.apache.jmeter.threads.JMeterVariables in project jmeter-plugins by undera.
the class StrReplace method execute.
@Override
public synchronized String execute(SampleResult previousResult, Sampler currentSampler) throws InvalidVariableException {
String totalString = getParameter(0).replace(getParameter(1), getParameter(2));
JMeterVariables vars = getVariables();
if (values.length > 3) {
String varName = getParameter(3);
if (vars != null && varName != null && varName.length() > 0) {
// vars will be null on TestPlan
vars.put(varName, totalString);
}
}
return totalString;
}
Aggregations