>int numLabelsToRequest = __Random(1,maxLabels);
I believe you forget to use ${__Random(1,maxLabels)}

On Thu, Apr 26, 2012 at 12:47 PM, <[email protected]> wrote:

> Comments inline, as I have partially answered my own question, and ran into
> some different problems.
>
> [email protected] wrote on 04/26/2012 02:24:49 PM:
>
> >
> > I have a script I have written in a beanshell processor.
> >
> > What I need to do is select a random integer (we'll call it X) between 1
> > and someVar_matchNr (where someVar is generated by a regex extractor
> > earlier)
> > Then select X random matches from someVar.
> >
> > The code I have is:
> >
>
> Updated code:
>
> int maxLabels = Integer.parseInt( vars.get("otl_Label_List_All_matchNr"));
> int numLabelsToRequest = __Random(1,maxLabels);
>
> for(int i=1; i<=numLabelsToRequest; i++) {
>  sampler.addArgument("selectedLabels", vars.get(__V("otl_Label_List_All_" +
> __Random(1,Integer.parseInt(maxLabels)) + "_g1")));
> }
>
>
> >
> > This code works, as long as I replace all references to "maxLabels" with
> a
> > hard coded number.
>
> It now will not stacktrace as soon as I start the test, but I do see this
> error in my logs now.
>
> 2012/04/26 14:44:07 ERROR - jmeter.util.BeanShellInterpreter: Error
> invoking bsh method: eval       Sourced file: inline evaluation of: ``int
> maxLabels = Integer.parseInt( vars.get("otl_Label_List_All_matchNr")); int
> n . . . '' : Typed variable declaration : Command not found: __Random( int,
> int )
> 2012/04/26 14:44:07 WARN  - jmeter.modifiers.BeanShellPreProcessor: Problem
> in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking
> bsh method: eval        Sourced file: inline evaluation of: ``int
> maxLabels =
> Integer.parseInt( vars.get("otl_Label_List_All_matchNr")); int n . . . '' :
> Typed variable declaration : Command not found: __Random( int, int )
>
> >
> > Is there a different random number generator I should use?
>
> This question, or at least the first part of still stands.
>
>
> > Any suggestions is greatly appreciated.
> >
>
> Lee Lowder
>
> This communication and any attachments are confidential, protected by
> Communications Privacy Act 18 USCS ยง 2510, solely for the use of the
> intended recipient, and may contain legally privileged material. If you are
> not the intended recipient, please return or destroy it immediately. Thank
> you.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to