On 21 September 2010 08:35, Jens Müller <[email protected]> wrote: > > 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:
Code additions are normally provided via the bug-tracking system, i.e. Bugzilla. https://issues.apache.org/bugzilla/enter_bug.cgi?product=JMeter If you create an enhancement request you can add the code to it as an attachment. If you do so, please include the standard AL header in the file. Thanks! > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
