jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mike Buzzetti <mike.buzze...@gmail.com>
Subject Bean Shell
Date Wed, 03 Nov 2004 17:11:45 GMT
I was looking through the JMeter user manual and the Wiki pages and
got very interesed in the Bean Shell Sampler and Assertion.

There is very little informaion on how to use bean shell scripts with jmeter. 
I saw awhile back in the Mailing list, "K.P. Thottam"
<KThottam@Buchanan.com> had an example script. Well I thought I would
give it a try and got the following in my jmeter.log

2004/11/03 11:44:11 WARN  - jmeter.assertions.BeanShellAssertion:
Sourced file: /home/buzzetti/esvt/assertions.script : Command not
found: print( java.lang.String ) : at Line: 6 : in file:
/home/buzzetti/esvt/assertions.script : print ( "the return code is "
+ ResponseCode )


the code that I used 

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 ) ;
            }
 
}




I would really like to see some examples on how to use the Bean Shell
Assertion properly.

Any Ideas ?

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