You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sebb <se...@gmail.com> on 2004/11/18 15:38:22 UTC

Re: Using BeanShell

On Thu, 18 Nov 2004 18:35:57 +1100, Sonam Chauhan
<so...@ce.com.au> wrote:
> Thanks for the tips guys. I have BeanShell working and it's pretty neat...
> and it's better than sliced bread!
> 
> I used this tiny bsh script into a JMX:
> -------------
> a = JButton("click me")
> Frame (a);
> -------------
> Then I ran the JMX in non-GUI mode.
> Lo and behold - JMeter tests now pop up a _custom_ GUI. Wow!
> 
> Two questions:
> 
> 1. I see that the BeanShell sampler and BeanShell assertion can access
> certain special variables (e.g.: 'ResponseCode'). Can the BeanShell
> components access JMeter classes? (Something like the bsh "class browser",
> but for JMeter classes.)

BSH can "import" any packages it wants - see some of the BSH scripts
in extras and bin.

Now sure about browsing JMeter packages. The BSH documentation might
give some clues.

> 
> 2. Can JMeter BeanShell samplers components access JMeter "${XXX}")
> variables?

I'd assumed that any variables that were needed could be passed in as
parameters to the script - or embedded in it, if using the script
panel (rather than using a file name. JMeter variables embedded in
files are not interpreted, as the file is passed directly to BSH).

However one could import the appropriate JMeter packages and define a
shortcut method to access them.  See for example extras/startup.bsh.

If this was found to be generally useful, get and set methods could be
provided by the classes that instantiate the interpreter, in much the
same way that access to responseData etc is currently provided.

> 
> Please educate me if I am missing some obvious documentation somewhere that
> answers all this.
> 

Well, there's the BSH documentation, some BSH scripts in bin and
extras, and there's always the JMeter Wiki if you want to add some
details to it!

> With regards,
> Sonam Chauhan
> --
[...]

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