jmeter-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miklos Tverdota <tverd...@axelero.hu>
Subject Using User variables in BeanShell
Date Mon, 08 Aug 2005 11:27:56 GMT
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


Mime
View raw message