當我嘗試在BeanShell預處理器腳本中使用__FileToString內置函數時,似乎無法越過BeanShellInterpreter。 FileContents變量確實被填充,但腳本失敗,我無法使用它。下面是代碼和錯誤信息......jmeter內部函數失敗BeanSHellInterpreter
try {
Integer count=vars.get("SessionId").length()-5;
vars.put("vAuth", vars.get("v_username") + vars.get("SessionId").substring(count) + ":");
log.info("Writing a info message");
${__FileToString(C:/tmp/DeltaConnectDemoTool_3_2_0S1_5515/bin/request.txt,,FileContents)};
log.info("Writing a second info message");
}
catch (Throwable ex) {
log.error("Failed to do this or that", ex);
}
錯誤是
二○一六年十一月一十七日15點52分18秒錯誤 - jmeter.util.BeanShellInterpreter:錯誤調用BSH方法:eval在文件中:內聯評估:``try {Integer count = vars.get(「SessionId」)。length() - 5; vars.put(「vAuth」,vars.get ...「遇到」:「在第5行第8列。
2016/11/17 15:52:18 WARN - jmeter.modifiers.BeanShellPreProcessor:Problem在BeanShell腳本中org.apache.jorphan.util.JMeterException:調用bsh方法時出錯:eval在文件中:內聯評估:try {Integer count = vars.get(「SessionId」).length() - 5; vars。把( 「vAuth」,vars.get'遇到。 「:」 在第5行,列8
我不認爲選擇1會爲我工作,我有多個要打開的文件(我打算爲每個RESTAPI調用一個,選項2的工作方式類似於一個魅力......謝謝!PS:文檔說在哪裏不要在腳本主體中使用內置函數(以防萬一其中有其他指針爲了我)? –