jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Using Beanshell Assertion to test a JSON value
Date Sat, 21 Dec 2013 01:16:05 GMT
On 21 December 2013 01:01, RL <ladr@mindspring.com> wrote:
> Thanks. That example did have errors. Here's what I just tried:
>
> String blobValue = vars.get("blobValue");

what does vars.get() return if the variable does not exist?

Again, no need to declare variables.

> if (blobValue.length() > 0  && blobValue != 0 ){
>  Failure = true;
>  FailureMessage = "blobValue was " + blobValue + ".";
> }
> else{
>   Failure = false;
> }
>
> When I execute this I get these errors:
>
> 2013/12/20 16:56:04 ERROR - jmeter.util.BeanShellInterpreter: Error
> invoking bsh method: eval    Sourced file: inline evaluation of: ``
> String blobValue = vars.get("blobValue");  if (blobValue.length() > 0  &&
> blo . . . ''
> 2013/12/20 16:56:04 WARN  - jmeter.assertions.BeanShellAssertion:
> org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval
> Sourced file: inline evaluation of: ``   String blobValue =
> vars.get("blobValue");  if (blobValue.length() > 0  && blo . . . ''
>
> I was trying to catch them with the try/catch block.

The Exception is generated by JMeter, not the script.

> The issue is that blobValue may not exist if JSON Path Extractor won't
> create a variable for a null value. So the Beanshell script has to deal
> with the cases where:
>
> - the variable doesn't exist

In which case, what is the value of blobValue?

> - the variable exists and is null
> - the variable exists and is not null
>
> Currently it's crashing on the first case, I think.

Yes.

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


Mime
View raw message