Create a new Virtual User in the current project. You are going to create one action for each RMI call, as this will allow you to retrieve access time statistics for each call.
connect
" ,"getStockQuoteUSD
", and "getStockQuoteEur
".connect
var sampleClient = Packages.com.neotys.test.rmi.client.SampleClient();
sampleClient.connect();
context.currentVU.put("sampleClient", sampleClient);
logger.debug("sampleClient connected");
The script creates an instance of the SampleClient class and makes the connection to the server. The sampleClient
instance is stored within the Virtual User instance, for use by the subsequent requests. Thus, you have one instance of SampleClient per Virtual User instance throughout the test.
getStockQuoteUSD
var sampleClient = context.currentVU.get("sampleClient");
var stockSymbol = context.variableManager.getValue("stockSymbols.symbol");
logger.debug("stockSymbol=" + stockSymbol);
sampleClient.getStockQuoteUSD(stockSymbol);
The script retrieves the sampleClient
instance stored by the previous script, then interprets the "stockSymbols
" variable created previously. The getStockQuoteUSD
method makes the RMI call that retrieves the price for the stock whose symbol is taken from the CSV file. The dollar value is stored within the SampleClient
, to be used as an argument in the following call.
getStockQuoteEuro
var sampleClient = context.currentVU.get("sampleClient");
var stockValueEuro = sampleClient.getStockQuoteEUR();
logger.debug("Stock price €" + stockValueEuro);
context.variableManager.setValue("stockPriceEUR", stockValueEuro);
The script retrieves the sampleClient
instance stored by the first script, then makes the call to the RMI method that allows the previously-stored dollar value to be converted into Euros. The call to the VariableManager
allows the value retrieved by RMI to be injected into a NeoLoad variable. This value may then be used in NeoLoad, for example as a classic HTTP request parameter. This is outside the scope of this example however.