jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sebb <seb...@gmail.com>
Subject Re: Using User variables in BeanShell
Date Mon, 08 Aug 2005 12:17:17 GMT
Difficult to say what the problem is without more information:

What version of JMeter?
What Exceptions?
Which of the BeanShell elements are you using - Sampler, Function,
Response Assertion?
Any messages in jmeter.log?


[There may also be some useful information in the jmeter user mailing
list archives ...]

S.
On 08/08/05, Miklos Tverdota <tverdota@axelero.hu> wrote:
> Hallo,
> 
> I would like to write some User Variables to log on certain conditions.
> 
> Unfortunately I was not able to find out how to get the values of User
> Variables in BeanShell.
> 
> 
> This is my try:
> 
> import org.apache.jmeter.threads.JMeterContext;
> import org.apache.jmeter.threads.JMeterContextService;
> import org.apache.jmeter.threads.JMeterVariables;
> 
> // write erro message to log
> if ( ResponseCode != null && ResponseCode.equals("200") == false )
> {
>  Failure=true ;
>  FailureMessage = "response code was not 200 reponse code it was " +
> ResponseCode + "." ;
>  log.warn("the return code is " + ResponseCode);
> }
> print ( "variable  " + ResponseCode);   // OK
> -----------------------------------------------------------------------------------------------------------------------------------------
> 
> // How to use user variables in BeanShell ?
> 
> // In java code from BeanShell:
> // Add variables for access to context and variables  (dut it does not work)
> //     JMeterContext jmctx = JMeterContextService.getContext();
> //     JMeterVariables vars = jmctx.getVariables();
> //     bshInterpreter.set("ctx",jmctx);  //$NON-NLS-1$
> //     bshInterpreter.set("vars",vars);//$NON-NLS-1$
> 
> // Does not work
> print ( "variable  " + ctx);    // return void
> print ( "variable  " + vars);  // return void
> 
> // Cause exception
> print ( "variable  "  + vars.get("myVariable"));           // cause
> exception
> JMeterVariables jmvars = (JMeterVariables) vars;  // cause exception
> JMeterVariables jmvars = ctx.getVariables();          // cause exception
> 
> Thanks for your help.
> 
> Miklos
> 
> 
> ---------------------------------------------------------------------
> 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