You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by Pavel Gouchtchine <gu...@gmail.com> on 2006/04/10 20:40:27 UTC

Re: initialize Variables

Hi All.
Can you, please, clarify how to use refName_matchNr?

My reg exp processor has the following params:

Reference Name: GROUPID
Reqular Exrpression: .value=\'(.*)\';
Tamplate: $1$
Match No: 1
Default value: ERROR_GROUPID

The response can bring me different number of ids. I am trying to get
group count via beanShell :

String groups_count = vars.get("GROUPID_matchNr");
print ( "Groups found "+goups_count);


return "Groups found "+goups_count;

It returns void all the time.

Please, help.

Thanks.
Pavel

On 3/7/06, Yiping Yang <Yi...@icims.com> wrote:
> That's cool. Thank you, Bennett.
>
> -----Original Message-----
> From: Bennett McElwee [mailto:Bennett.McElwee@telecom.co.nz]
> Sent: Tuesday, March 07, 2006 3:38 PM
> To: JMeter Users List
> Subject: RE: initialize Variables
>
> On 07/03/06, Yiping Yang <Yi...@icims.com> wrote:
> > I'm wondering where I can look up these kind of
> > information by myself? Sometimes, JMeter user
> > manual just gives very brief instructions.
>
> For API stuff like the use of the vars collection, you should look at
> the JMeter API specification: http://jakarta.apache.org/jmeter/api/
>
> After a bit of poking around you may determine that vars is an instance
> of class JMeterVariables. Its Javadoc would tell you about the remove()
> method:
> http://jakarta.apache.org/jmeter/api/org/apache/jmeter/threads/JMeterVar
> iables.html
>
> I've found this API doc very helpful when using BeanShell in JMeter, and
> it's quicker than reading the code. :)
>
> Cheerio,
> Bennett.
> --
> Bennett McElwee
>
> -----Original Message-----
> From: sebb [mailto:sebbaz@gmail.com]
> Sent: Wednesday, 8 March 2006 7:59 am
> To: JMeter Users List
> Subject: Re: initialize Variables
>
> I'm afraid the answer is to read the code.
>
> S.
> On 07/03/06, Yiping Yang <Yi...@icims.com> wrote:
> > Hi sebb,
> > Vars.remove();
> > That's what I struggle for days to try to find out. I really
> appreciate your
> > help. Thank you so much.
> > I'm wondering where I can look up these kind of information by myself?
> > Sometimes, Jmeter user manual just gives very brief instructions.
> >
> > Thanks,
> > yiping
> >
> >
> >
> > -----Original Message-----
> > From: sebb [mailto:sebbaz@gmail.com]
> > Sent: Tuesday, March 07, 2006 12:29 PM
> > To: JMeter Users List
> > Subject: Re: initialize Variables
> >
> > It's important to use different "reference names" to each variable
> > set, otherwise there will be problems with nested For Loops.
> >
> > If you are using vars.put(name, value) to create the variables, you
> > can use vars.remove(name) to remove a variable.
> >
> > In the case of the ForEach Controller, it stops processing as soon as
> > it encounters a null variable, so you just need to make sure that you
> > remove "Var_3" (in your example).
> >
> >
> > On 07/03/06, Yiping Yang <Yi...@icims.com> wrote:
> > > Hi sebb,
> > >
> > > It's version 2.1.1.
> > > Actually, I use BeanShell to assign value to Var_1, Var_2,
> Var_3.....;
> >
> > > Then I want to use For each sampler, I can easily get all variables
> in Var
> > > by specify this in for each sampler: "Input variable prefix: Var"
> > >
> > > In my script, there is another loop out of the for each loop.
> > > The schema is like
> > >
> > > For Each Controller(outer)
> > > User Defined Variable (define var)
> > > BeanShell(assign var_1, Var_2, Var_3)
> > >
> > >   For Each Controller(inner)
> > >    Get Var_1, Var_2.....
> > >
> > > Can I do something to clean up the Var before I assign values to
> them.
> > > As I mentioned, if in the first outer loop there are three
> variables,
> > var_1,
> > > var_2, var_3. while, in the second outer loop, only two variables,
> var_1,
> > > var_2 will be assigned the new value.  But Var_3 is still accessible
> by
> > the
> > > inner For each.
> > >
> > >
> > > -----Original Message-----
> > > From: sebb [mailto:sebbaz@gmail.com]
> > > Sent: Tuesday, March 07, 2006 11:16 AM
> > > To: JMeter Users List
> > > Subject: Re: initialize Variables
> > >
> > > On 07/03/06, Yiping Yang <Yi...@icims.com> wrote:
> > > > As we know in Regular Expression, if the match number is set to a
> > negative
> > > > number, then all the possible matches in the sampler data are
> processed.
> > > The
> > > > variables are set as:
> > > >
> > > >
> > > >
> > > > Var_1="23"
> > > >
> > > > Var_2 ="cd"
> > > >
> > > > Var_3="db"
> > > >
> > > > ......
> > > >
> > > >
> > > >
> > > > After I got these variables, I need to use BeanShell Sample to
> > manipulate
> > > > these variables.
> > > >
> > > >
> > > >
> > > > I got this values in a loop, the different iteration, the number
> of the
> > > > variable may different. Say in the first loop, I got three
> variables,
> > > > Var_1, Var_2, Var_3
> > > >
> > > >
> > > >
> > > > In the next iteration, I got only to Var_1, Var_2. values of Var_1
> and
> > > Var_2
> > > > are replace by new values.  But the problem is the Var_3 is still
> there.
> > > >
> > >
> > > Which version of JMeter is this?
> > >
> > > >
> > > > How can I delete the Var_3. Or initialize these variables before
> each
> > > loop?
> > > >
> > >
> > > Why not just use Var_matchNr - this gives you the number of
> variables
> > > that are valid.
> > >
> > > >
> > > > I found some thing in Jmeter doc.
> > > >
> > > >
> > > >
> > > > *       refName_matchNr - the number of matches found; could be 0
> > > > *       refName_n, where n = 1,2,3 etc - the strings as generated
> by the
> > > > template
> > > > *       refName_n_gm, where m=0,1,2 - the groups for match n
> > > > *       refName - always set to the default value
> > > > *       refName_gn - not set
> > > >
> > > > I tried but I can't figure out how to use them.
> > > >
> > > >
> > > >
> > > > Any help will be greatly appreciated.
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Thanks,
> > > >
> > > > yiping
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> ---------------------------------------------------------------------
> > > 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
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jmeter-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: jmeter-user-help@jakarta.apache.org
>
>
>
> This communication, including any attachments, is confidential. If you are
> not the intended recipient, you should not read it - please contact me
> immediately, destroy it, and do not copy or use any part of this
> communication or disclose anything about it. Thank you. Please note that
> this communication does not designate an information system for the purposes
> of the Electronic Transactions Act 2002.
>
>
> ---------------------------------------------------------------------
> 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
>
>

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


Re: initialize Variables

Posted by sebb <se...@gmail.com>.
On 10/04/06, Pavel Gouchtchine <gu...@gmail.com> wrote:
> Hi All.
> Can you, please, clarify how to use refName_matchNr?

The answer is in the manual:

http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Regular_Expression_Extractor


> My reg exp processor has the following params:
>
> Reference Name: GROUPID
> Reqular Exrpression: .value=\'(.*)\';
> Tamplate: $1$
> Match No: 1
> Default value: ERROR_GROUPID
>
> The response can bring me different number of ids. I am trying to get
> group count via beanShell :
>
> String groups_count = vars.get("GROUPID_matchNr");
> print ( "Groups found "+goups_count);
>
>
> return "Groups found "+goups_count;
>
> It returns void all the time.
>
> Please, help.

Read the manual ...

matchNR is not set for Match No = 1

S.
P.S. Please start a new thread when asking a new question

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