java - Parsing string to integer in BeanShell Sampler in JMeter -
i'm trying parse string integer in jmeter failed due following error. if try print strings returned vars.get, good.
2014/06/28 00:08:52 warn - jmeter.assertions.beanshellassertion: org.apache.jorphan.util.jmeterexception: error invoking bsh method: eval sourced file: inline evaluation of: ``if (responsecode != null && responsecode.equals ("200") == false ) { int = in . . . '' : typed variable declaration : method invocation integer.parseint following code
if (responsecode != null && responsecode.equals ("200") == false ) { int = integer.parseint(vars.get("currentpmcount")); int j = integer.parseint(vars.get("pmviolationmaxcount")); if( > j ){ log.warn("pm count on server greater max allowed count."); } log.warn( "the return code " + responsecode); // goes jmeter log file } else { failure=true ; failuremessage = "the response data size not expected" ; }
your code looks can problem currentpmcount and/or pmviolationmaxcount variables.
if , integers , don't exceed maximum/minimum values of integer can try following:
make sure there no "space" characters around number value leading or trailing space cause conversion failure. perhaps invoking
trim()method on variable can help:int = integer.parseint(vars.get("currentpmcount").trim());- if store script file , provide path file in beanshell assertion you'll "problematic" line number
my favourite: surround code try/catch block follows:
try{ //your code here } catch (exception ex){ log.warn("error in script", ex); throw ex; // elsewise jmeter "swallow" above exception }
this way you'll more informative stacktrace instead of lousy error invoking bsh methodmessage tells nothing.
see how use beanshell: jmeter's favorite built-in component guide more tips , tricks.
Comments
Post a Comment