jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Jain <eric.j...@gmail.com>
Subject Custom function is not picked up
Date Tue, 03 Jul 2012 18:56:42 GMT
I created a function like the one below, and put the class file into a
new jar file in JMeter's lib/ext. But when I use ${__Json()} (e.g. for
the POST body of an HTTP request sampler), I always end up with
'${__Json()}' instead of '{"x":42}'. Built-in functions such as
${__Random(1,10)} work fine. Do I need to register custom functions
somewhere?


package testing;

import java.util.Collection;
import java.util.Collections;
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;

public class RandomEventFunction extends AbstractFunction {

	private static final String KEY = "__Json";

	@Override
	public List<String> getArgumentDesc() {
		return Collections.emptyList();
	}

	@Override
	public String execute(SampleResult previouResult, Sampler sampler) {
		return "{\"x\":42}";
	}

	@Override
	public String getReferenceKey() {
		return KEY;
	}

	@Override
	public void setParameters(Collection<CompoundVariable> variable) {

	}
}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org
For additional commands, e-mail: user-help@jmeter.apache.org


Mime
View raw message