Reputation: 291
I want to delete the data in redis
before taking the sample so I put the code in Beanshell Preprocessor. But the code is not running,just like the Beanshell can not recognize the Set ,part of my code is below:
import redis.clients.jedis.Jedis;
import java.util.Set;
String new_pattern = "*WITHDRAW_RISK_CONTROL_*";
Set<String> keysSet = null;
System.out.println("here****************");
and Set<String> keySet =null
is not working.I have imported Set import java.util.Set;
Is this Jmeter problem? or any reason?
The second question is :it can recognize the class Jedis
in Jedis jar.But it can not support Jedis JedisPoolConfig ,why?
Upvotes: 5
Views: 1850
Reputation: 1
You could use "Object keysSet" instead of "Set keysSet". It solved my problem.
Upvotes: 0
Reputation: 168002
So it is expected that Java 7 features are not supported by quite an outdated Beanshell interpreter. It should work if you remove <String>
bit.
I expect the problem lives somewhere else. In order to debug your Beanshell script you can try out the following approaches:
debug();
directive at the very beginning of your script. It will trigger debugging information output to STDOUT (where you expect your here****************
line)Wrap "suspicious" code in try/catch block like
try {
// your Beanshell
// code here
} catch (Throwable ex) {
log.info("Something went wrong", ex);
}
Inspect jmeter.log file for failure details.
See How to use BeanShell: JMeter's favorite built-in component guide for advanced information on Beanshell scripting in JMeter.
Upvotes: 2
Reputation: 34516
Beanshell does not support Generics.
You should use instead JSR223PreProcessor + Groovy instead:
Note that there is a Redis DataSet if that's your request:
Upvotes: 3