You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Eric Laverge <ae...@hotmail.com> on 2004/11/26 15:22:45 UTC
Second try on 'AbstractJavaSamplerClient' how-to
Hello,
After reading on JMeter I whanted to create a custom 'Java Request' to
show to my co-worker how we could Load test our JMS application with this
product. I simply cannot get my AbstractJavaSamplerClient class to show up
into the 'Java Request' combo-box.
My class is in Jar under the /lib/ext folder (like in the User doc). What
else should I do to get this thing working ? Any issues with the Classloader
? Do I have to edit a .jmx file ?
After some research, it looks like I am not the only one with this problem :
http://www.javalobby.com/forums/thread.jspa?forumID=16&threadID=11892
http://groups.google.com/groups?q=JMeter+%22Java+Request%22&hl=en&lr=&c2coff=1&selm=fbf4af5e.0307020507.4b33097f%40posting.google.com&rnum=1
Thank you for your Help.
//---------My Sample Java Request
public class HvSampler extends AbstractJavaSamplerClient
{
static private Arguments _arguments;
static
{
_arguments = new Arguments();
_arguments.addArgument("myArg1",",myValue1");
_arguments.addArgument("myArg2",",myValue2");
}
public Arguments getDefaultParameters()
{
return _arguments;
}
public void setupTest(JavaSamplerContext context)
{
System.out.println("inside setUp");
}
public SampleResult runTest(JavaSamplerContext context)
{
System.out.println("inside runTest");
printContext(context);
try
{
Thread.sleep(2000);
}
catch (InterruptedException e){ e.printStackTrace();}
return getSampleResult();
}
public void teardownTest(JavaSamplerContext context)
{
System.out.println("inside teadDown");
}
private SampleResult getSampleResult()
{
SampleResult r = new SampleResult();
r.setSuccessful(true);
r.setResponseMessage("coucou");
return r;
}
private void printContext(JavaSamplerContext ctx)
{
Iterator iterator = ctx.getParameterNamesIterator();
System.out.println("SamplerContext :");
while (iterator.hasNext())
{
String name= (String) iterator.next();
String value = ctx.getParameter(name);
System.out.println(name+ "=" + value);
}
System.out.println("");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
Re: Second try on 'AbstractJavaSamplerClient' how-to
Posted by Peter Lin <wo...@gmail.com>.
by the way, the current HEAD has a JMS sampler, so you don't need to
write your own. Just check out and build it.
you'll need to get jms.jar from here http://java.sun.com/products/jms/docs.html
or if you are using a specific JMS provider, just drop the necessary
jar files in the jmeter/lib/ directory. if you run into problems,
email me.
peter
On Fri, 26 Nov 2004 14:22:45 +0000, Eric Laverge <ae...@hotmail.com> wrote:
> Hello,
>
> After reading on JMeter I whanted to create a custom 'Java Request' to
> show to my co-worker how we could Load test our JMS application with this
> product. I simply cannot get my AbstractJavaSamplerClient class to show up
> into the 'Java Request' combo-box.
> My class is in Jar under the /lib/ext folder (like in the User doc). What
> else should I do to get this thing working ? Any issues with the Classloader
> ? Do I have to edit a .jmx file ?
>
> After some research, it looks like I am not the only one with this problem :
>
> http://www.javalobby.com/forums/thread.jspa?forumID=16&threadID=11892
>
> http://groups.google.com/groups?q=JMeter+%22Java+Request%22&hl=en&lr=&c2coff=1&selm=fbf4af5e.0307020507.4b33097f%40posting.google.com&rnum=1
>
> Thank you for your Help.
>
> //---------My Sample Java Request
>
> public class HvSampler extends AbstractJavaSamplerClient
> {
>
> static private Arguments _arguments;
> static
> {
> _arguments = new Arguments();
> _arguments.addArgument("myArg1",",myValue1");
> _arguments.addArgument("myArg2",",myValue2");
> }
>
> public Arguments getDefaultParameters()
> {
> return _arguments;
> }
> public void setupTest(JavaSamplerContext context)
> {
> System.out.println("inside setUp");
>
> }
>
> public SampleResult runTest(JavaSamplerContext context)
> {
> System.out.println("inside runTest");
> printContext(context);
> try
> {
> Thread.sleep(2000);
> }
> catch (InterruptedException e){ e.printStackTrace();}
> return getSampleResult();
> }
>
> public void teardownTest(JavaSamplerContext context)
> {
> System.out.println("inside teadDown");
> }
> private SampleResult getSampleResult()
> {
> SampleResult r = new SampleResult();
> r.setSuccessful(true);
> r.setResponseMessage("coucou");
> return r;
> }
> private void printContext(JavaSamplerContext ctx)
> {
> Iterator iterator = ctx.getParameterNamesIterator();
> System.out.println("SamplerContext :");
> while (iterator.hasNext())
> {
> String name= (String) iterator.next();
> String value = ctx.getParameter(name);
> System.out.println(name+ "=" + value);
> }
> System.out.println("");
> }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jmeter-user-help@jakarta.apache.org