嘿,我正在为jmeter中的Web应用程序做一些beanhell脚本。我已经编写了很多嵌入了beanshell的jmeter脚本,并且出于某种原因,这个脚本一直给我错误的Integer.parseInt()方法调用。
这是错误:
2014/06/27 10:08:58错误 - jmeter.util.BeanShellInterpreter:调用bsh方法时出错:eval源文件:内联评估:
import java.io.*; import java.util.*; int containerCount = 0; int secondVal = . . . '' : Method Invocation Integer.parseInt 2014/06/27 10:08:58 WARN - jmeter.modifiers.BeanShellPreProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of:
import java.io. ; import java.util。; int containerCount = 0; int secondVal =。 。 。 '' :方法调用Integer.parseInt
下面列出了我的所有Integer.parseInt()调用,如果有人是豆壳专家并且可以帮助我识别错误,那么它们对我来说似乎都是合法的,这真是太棒了,谢谢!
int containerCount = 0;
int secondVal = 0;
int BPNumSelected = 0; //Branch Plant only is in response page with more than one container, in the site shipment but must be initialized to something here.
boolean mult = false; //Boolean to see if the site shipment has more than one container
String ScontainerCount= vars.get("availableQty_matchNr");
String SsecondVal = vars.get("secondVal");
if(ScontainerCount!=null)
containerCount = Integer.parseInt(ScontainerCount); //refers to the number of containers in that site shipment
if(SsecondVal!=null)
secondVal = Integer.parseInt(SsecondVal); //A weird value that is passed in the parameter name after selectedLotID,
if(vars.get("BPNumSelected")==null){
vars.put("BPNumSelected","0");
}
if(containerCount>1){
String SBPNumSelected = vars.get("BPNumSelected");
BPNumSelected = Integer.parseInt(SBPNumSelected); //gets the branch plant ID if more than one container
mult = true;
}
还有...
SlocPackedQtyValue = vars.get("locPackedQtyValue");
SavailQtyNoComma = vars.get("availQtyNoComma");
if(vars.get("locPackedQtyValue")!=null)
packedQtyVal = Integer.parseInt(SlocPackedQtyValue);
if(vars.get("availQtyNoComma")!=null)
availableRoom = Integer.parseInt(SavailQtyNoComma);
答案 0 :(得分:1)
尝试仅使用packedQtyVal = ${locPackedQtyValue}
而不使用Integer.parseInt()
方法。它适用于BeanShell和BSF处理器中的Jmeter 2.11。
答案 1 :(得分:0)
您可以使用valueOf()而不是parseInt()
String getNoofOrdersCount = vars.get("getTotalNumberOfOrders");
int ngetNoofOrdersCount = Integer.valueOf(getNoofOrdersCount).intValue();