You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jmeter.apache.org by sebb <se...@gmail.com> on 2004/09/08 15:42:52 UTC

Re: simple sample for using beanshell assertion

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 <kt...@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