jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: simple sample for using beanshell assertion
Date Wed, 08 Sep 2004 13:42:52 GMT
Thanks, very useful.

Would it be OK to add this to the JMeter distribution?

S.
On Mon, 30 Aug 2004 10:20:09 -0500, K.P. Thottam <kthottam@buchanan.com> wrote:
> Hi All ,
> 
> I was looking around for a sample for BeanShell assertion but could not
> find one . Anyway I dug around and got a better understanding and here
> is a sample for anyone else looking for it :
> 
> if (ResponseCode != null && ResponseCode.equals ("200") == false )
> {
>            // this is standard stuff
>            Failure=true ;
>            FailureMessage ="Response code was not a 200 response code
> it was " + ResponseCode  ;
>            print ( "the return code is " + ResponseCode ) ;
> }
> else
> {
> 
>            try
>            {
>            // non standard stuff where BeanShell assertion will be
> really powerful .
> // in my example I just test the size , but you could extend it further
> to actually test the content against another file .
>                         byte [] arr = (byte[]) ResponseData ;
>                        // print  ( arr.length ) ; // use this to
> determin the size
>                        if (arr != null && arr.length != 25218)
>                        {
>                                    Failure= true ;
>                                    FailureMessage = "The response data
> size was not as expected" ;
>                        }
>                        else if ( arr == null )
>                        {
>                                    Failure= true ;
>                                    FailureMessage = "The response data
> size was null"  ;
> 
>                        }
>            }
>            catch ( Throwable t )
>            {
>                        print ( t ) ;
>            }
> 
> }
>

---------------------------------------------------------------------
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