Hi,
I needed a new JMeter function to be able to access the name of the current
sampler from the Header Manager.
I wanted to share it, maybe you can add it to the development branch:
package org.apache.jmeter.functions;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.functions.AbstractFunction;
import org.apache.jmeter.functions.InvalidVariableException;
import org.apache.jmeter.samplers.SampleResult;
import org.apache.jmeter.samplers.Sampler;
import org.apache.jmeter.threads.JMeterContextService;
/**
* Function to return the name of the current sampler.
*/
public class SamplerName extends AbstractFunction {
private static final String KEY = "__samplerName"; //$NON-NLS-1$
private static final List<String> desc = new LinkedList<String>();
/** {...@inheritdoc} */
@Override
public String execute(SampleResult previousResult, Sampler currentSampler)
throws InvalidVariableException {
return JMeterContextService.getContext().getCurrentSampler().getName();
}
/** {...@inheritdoc} */
@Override
public void setParameters(Collection<CompoundVariable> parameters)
throws InvalidVariableException {
checkParameterCount(parameters, 0, 0);
}
/** {...@inheritdoc} */
@Override
public String getReferenceKey() {
return KEY;
}
/** {...@inheritdoc} */
public List<String> getArgumentDesc() {
return desc;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]