Return-Path: X-Original-To: apmail-jmeter-user-archive@www.apache.org Delivered-To: apmail-jmeter-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0CF159554 for ; Tue, 3 Jul 2012 20:22:55 +0000 (UTC) Received: (qmail 2123 invoked by uid 500); 3 Jul 2012 20:22:54 -0000 Delivered-To: apmail-jmeter-user-archive@jmeter.apache.org Received: (qmail 1980 invoked by uid 500); 3 Jul 2012 20:22:54 -0000 Mailing-List: contact user-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JMeter Users List" Delivered-To: mailing list user@jmeter.apache.org Received: (qmail 1971 invoked by uid 99); 3 Jul 2012 20:22:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jul 2012 20:22:54 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FSL_RCVD_USER,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 209.85.213.171 as permitted sender) Received: from [209.85.213.171] (HELO mail-yx0-f171.google.com) (209.85.213.171) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jul 2012 20:22:48 +0000 Received: by yenq11 with SMTP id q11so5962543yen.2 for ; Tue, 03 Jul 2012 13:22:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=XudQljrzkVBkAi6JKDYAq8DixNGr5AsyE/TpPUXmx14=; b=wR1R33JndSC53NnLhM9iPSFQ3PjICvMkGY+w+SYTsKhJqYS0+WY0Us6cFPD4qOzbea d5PmeLLVgAhwADyGpf0Nuu3G8myZIOe+qifSv+aocVjOWQP/1SLgWynh6yougqlYdZFF ZHhWYnuX259HcvycHTqHUzK9IcMABW7GSlG9lReuXVRtmcAVcu5E3dfjfIwirds7/Et/ Fyow12vNK8Mldm4YKbxKTyKTWErswJlhTQW9rFYVxlAxE4Sg/RvV00xuRxYxmPY7OQ3l xFTk7wrTE0ANv4LEyH754Bg6Uhw6MY0IjscqM2B5CsgRsOpoD2Ha0NhP2gnG1RoAX4yY kuwA== MIME-Version: 1.0 Received: by 10.60.10.99 with SMTP id h3mr19975769oeb.72.1341346947359; Tue, 03 Jul 2012 13:22:27 -0700 (PDT) Received: by 10.182.71.199 with HTTP; Tue, 3 Jul 2012 13:22:27 -0700 (PDT) In-Reply-To: References: Date: Tue, 3 Jul 2012 21:22:27 +0100 Message-ID: Subject: Re: Custom function is not picked up From: sebb To: JMeter Users List Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On 3 July 2012 19:56, Eric Jain wrote: > 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? No, but they do need to be in a package with a specific naming convention See the classfinder.functions. definitions in jmeter.properties (and in the jmeter.log file) > > 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 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 variable) { > > } > } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org > For additional commands, e-mail: user-help@jmeter.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@jmeter.apache.org For additional commands, e-mail: user-help@jmeter.apache.org