I am currently working on a jmeter JDBC scripts which involves executing huge queries on the DB to setup data for test.
Its a bit of a complex script where I need to validate and extract specific filed from the result set and then write it all in the file and use in the next thread group
I written a Beanshell code as below to validate a particulat condition
FileWriter fWriter = new FileWriter ("C:/UserPath/Number.csv", true);
BufferedWriter buff = new BufferedWriter(fWriter);
if (${JMeterThread.last_sample_ok} == true)
{
buff.write(vars.get("p_PI_ID") + "," + vars.get("p_AC_Number"));
buff.write(System.getProperty("line.separator"));
log.info(vars.get("Update_Assertion"));
}
buff.close();
The condition is I want the data to be written to the file when the JMeterThread.last_sample_ok= true
I have tried various combination to write this up but this code write to the file no matter what the condition is. So far I have tried the below conditions
if (${JMeterThread.last_sample_ok} == true)
if (${JMeterThread.last_sample_ok} != false)
if (!${JMeterThread.last_sample_ok} == false)
I did also try to use some other logics to no success, the thing is this code works fine with other validation I am doing, not sure what is wrong here
I have also tried to place the beanshell post processor outside the JDBC sample which should then capture the state of the sampler execution as True or false.
Thanks for reading though.

