jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Deepak Shetty <shet...@gmail.com>
Subject Re: [JMeter] BeanShell Sampler using a script file
Date Tue, 21 Jul 2009 16:53:46 GMT
hi
If you are only using the function in one place then you can define it
within your script file
e.g.
(1) - Parameters(-> String Parameters and String []bsh.args) : ${MyParam}
(2) - Script file : scripts/getChannelList.bsh
In getChannelList.bsh you would have both the function definition and the
execution code
e.g.

getChannelList(String in){
  return in;
}
//..other stuff
String result = getChannelList(bsh.args[0]); //args[0] is myParam
//other stuff
vars.put("out.updatePackage.channelNames", result);


OR if you need to use this function in multiple places then set the
beanshell.function.init
http://jakarta.apache.org/jmeter/usermanual/functions.html#__BeanShell

Im not entirely sure what you were trying to do in your script below,  You
should not need any post processor.
regards
deepak



On Tue, Jul 21, 2009 at 9:36 AM, annie35 <nie_h@yahoo.fr> wrote:

>
> It doesn't work :-(
>
> I created a "BeanShell Sampler". I fill the following fields of it:
>
> (1) - Parameters(-> String Parameters and String []bsh.args) : ${MyParam}
> (2) - Script file : scripts/getChannelList.bsh
> (3) - Script (see below for variables that are defined) :
>
>     // I invoke my Function like this :
>
> vars.put("out.updatePackage.channelNames",getChannelList(vars.get("in.updatePackage.channelNames")));
>
>
> I read on the JMeter website that the (3)-"script Field" is read only if
> (2)
> is empty, so I create a "Post Processor Beanshell" Where I put in script
> field:
>
>
> vars.put("out.updatePackage.channelNames",getChannelList(vars.get("in.updatePackage.channelNames")));
>
> And call those two JMeter object, but In my JMeter.log, I got an error like
> this :
>
> 2009/07/21 18:14:56 ERROR - jmeter.util.BeanShellInterpreter: Error
> invoking
> bsh method: eval        Sourced : Command not found: getChannelList(
> java.lang.String )
>
> What missing ? Where do I define my Function ? and how?
>
> thanks, I hope it is more clearly
>
> annie35
>
>
> Deepak Shetty wrote:
> >
> > Sorry I think I wasnt clear. You had two options
> >
> > a. Use __Beanshell. So you'd write a script that calls your function
> which
> > does a return getChannelList() or whatever value you want returned and
> > then
> > use ${__BeanShell(source("yourscript.bsh"))} to get this value , (You
> > wouldnt need the beanshell sampler)
> >
> > OR
> >
> > b. Continue using your beanshell sampler, however instead of returning
> the
> > vaue, in the bean shell script do something like
> > vars.put("result",getChannelList());
> > and in your test use ${result}
> >
> > regards
> > deepak
> >
> > On Tue, Jul 21, 2009 at 12:32 AM, annie35 <nie_h@yahoo.fr> wrote:
> >
> >>
> >> Thank you for your answer,
> >> You mean when I call the beanshell function like this :
> >> ${__getChannelList(vars.get("${myparam}"))};  ?
> >>
> >>  if I put this call directly in the script field of the BeanShell
> Sampler
> >> it
> >> doesn't work also when I create a post or a pre beanshell.
> >>
> >> Where can I call the BeanShell ? and how ?
> >>
> >> annie35
> >>
> >>
> >>
> >> Deepak Shetty wrote:
> >> >
> >> > hi
> >> > I dont think you can do what you want directly
> >> > The returned value is used when you call the BeanShell function using
> >> ${*
> >> > __BeanShell*(...)}
> >> > If you want a value stored into the variable use
> vars.put("name",value)
> >> > in
> >> > your function instead of using the return value.
> >> > regards
> >> > deepak
> >> > .
> >> >
> >> >
> >> >
> >> > On Mon, Jul 20, 2009 at 9:18 AM, annie35  wrote:
> >> >
> >> >>
> >> >> Hi,
> >> >>
> >> >> 1- I create an external beanShell which taken a string in param and
> >> >> return
> >> >> a
> >> >> string :
> >> >>
> >> >> getChannelList(String sChannelName){
> >> >> return sChannelName;}
> >> >>
> >> >> 2- I create a BeanShell Sampler with in parameters field: ${myParam}
> >> and
> >> >> in
> >> >> the script file field : scripts/getChannelList.bsh
> >> >>
> >> >> my BSH is recognied, because I don't have any error, but how can I
do
> >> to
> >> >> get
> >> >> the return string value ?
> >> >>
> >> >> thanks to help me
> >> >> annie35
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/-JMeter--BeanShell-Sampler-using-a-script-file-tp24572864p24572864.html
> >> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-JMeter--BeanShell-Sampler-using-a-script-file-tp24572864p24582915.html
> >> Sent from the JMeter - User mailing list archive at Nabble.com.
> >>
> >
> >
> :sleep::sleep:
> --
> View this message in context:
> http://www.nabble.com/-JMeter--BeanShell-Sampler-using-a-script-file-tp24572864p24591196.html
> Sent from the JMeter - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message