jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Eckhart <Steve.Eckh...@wausaufs.com>
Subject RE: Help With a Null Variable
Date Thu, 12 Nov 2009 20:41:01 GMT
Deepak,

The following works:
	if(vars.get("BatchLink_g3") == null)
	{
	   vars.put("loopBatch","0");
	} 
	else
	{
	       vars.put("loopBatch", vars.get("BatchLink_g3"));
	}

Thanks for your help!

Steve

-----Original Message-----
From: Deepak Shetty [mailto:shettyd@gmail.com] 
Sent: Thursday, November 12, 2009 1:39 PM
To: JMeter Users List
Subject: Re: Help With a Null Variable

hi
that wont work both values get replaced . What i meant was that since your
variable might be a number or a sting (the literal string ${loopBatch} , you
need to use it as  a string everywhere

Something like this
//first condition is check not null
("${loopBatch}".indexOf("$") != -1) && (rest of condition like parse and
check the value)

I vaguely remember another way to do this , but ill need to go through some
of my notes and check.
regards
deepak


On Thu, Nov 12, 2009 at 11:17 AM, Steve Eckhart
<Steve.Eckhart@wausaufs.com>wrote:

> Deepak,
>
> I tried setting the If Controller to
>        ${loopBatch} != "${loopBatch}"
> and checking the Interpret Condition as Variable Expression? checkbox.
>
> I no longer get the error when loopBatch is null. However, when
> loopBatch=132, I would expect the condition to evaluate to true and execute
> the steps in the If. Unfortunately, it didn't and continued with the steps
> after the if.
>
> What am I missing?
>
> -----Original Message-----
> From: Deepak Shetty [mailto:shettyd@gmail.com]
> Sent: Thursday, November 12, 2009 12:01 PM
> To: JMeter Users List
> Subject: Re: Help With a Null Variable
>
> hi
> you could do this at the beanshell level
> //check the number of brackets , this is pseudo code, also check that
> loopBatch always has a value that is the string //representation of an
> integer or an integer
>
> if(vars.get("BatchLink_g3")) == null ||
> "".equals(vars.get("BatchLink_g3")).trim())){
>   vars.put("loopBatch","0");
> } else {
>       vars.put("loopBatch", vars.get("BatchLink_g3"));
> }
>
>
> OR
>  You could do it as a javascript funtion (null means the value remains as
> ${loopBatch} and you'd have to pass it as a string so there be quotes
> around
> the ${loopBatch}
>
>
>
> regards
> deepak
>
>
>
>
> On Thu, Nov 12, 2009 at 9:38 AM, Steve Eckhart
> <Steve.Eckhart@wausaufs.com>wrote:
>
> > I have a Regular Expression which is reading a variable from a web page.
>  I
> > need to test this value to see if I should perform the next step or
> perform
> > another search.
> >
> > Currently, I have the following in a BeanShell PostProcessor to set the
> > value of the variable:
> >
> >        vars.put("loopBatch", vars.get("BatchLink_g3"));
> >
> > If my search returned no results, a Debut PostProcessor will report
> > loopBatch=null. Then, the If Controller ${loopBatch} > 0 generates an
> error:
> >
> >        ERROR - jmeter.control.IfController: missing ) after argument list
> > (<cmd>#1)
> >
> > How can I test using a variable which might be null? I found a method of
> > the Class Abstract Property getIntValue() which would give me what I want
> (0
> > when the value is null), but I don't understand how to use getIntValue()
> in
> > a JMeter script.
> >
> > Is this the right way to proceed? Am I missing something? I don't know
> much
> > about the BeanShell command.
> >
> > Thank you for any help.
> >
> > ---------------------------------------------------------------------
> > 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


Mime
View raw message