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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to