我已經編寫了一個代碼,使用 org.apache.commons.io.FileUtils和Set操作在Java/Eclipse中執行兩個文本文件的DIFF。代碼工作正常。 但是相同的代碼在JMeter的BeanShell聲明中不起作用。 設置操作給出錯誤的行。 代碼:JMeter BeanShell Assertion無法識別FileUtil方法
import org.apache.commons.io.FileUtils;
import java.io.*;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.concurrent.TimeUnit;
import java.util.ArrayList;
import java.util.Collection;
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
Date startdate = new Date();
Date enddate = null;
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("C://Work//JMeter//Logs//D2MDS.txt")));
out.println("Automated ETL Validator -- START -- " + dateFormat.format(startdate));
out.println("=========================================================================");
try {
Set<String> Slines = new TreeSet<String>(FileUtils.readLines(new File ("C://Work//JMeter//Data//SourceSQLLog.csv")));
//Set<String> Tlines = new TreeSet<String>(FileUtils.readLines(new File ("C://Work//JMeter//Data//TargetSQLLog.csv")));
//Slines.removeAll(Tlines);
//out.println(Slines);
}
catch (Exception e) {
out.println(ExceptionUtils.getStackTrace(e));
}
Date enddate = new Date();
enddate = new Date();
long duration = enddate.getTime() - startdate.getTime();
long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
out.println("=========================================================================");
out.println("Automated ETL Validator -- END -- " + dateFormat.format(enddate));
out.println("\n\n\n*************************************************************************");
out.println("EXECUTION SUMMARY");
out.println("====================");
out.println("Total Lines in Extract File: " + ${__V(ret_val_#)});
out.println("Total Failures in Extract File: " + fail_cnt);
out.println("Failed Lines of Extract File = " + fail_ln);
out.println("Extract Validation -- END -- " + dateFormat.format(enddate) + " -- Duration: " + diffInMinutes + " Minutes");
out.close();
的BeanShell斷言拋出令人費解的錯誤:
Assertion failure message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval In file: inline evaluation of: ``import org.apache.commons.io.FileUtils; import java.io.*; import java.util.Date; . . . '' Encountered "=" at line 18, column 20.
5 Jar文件都存在裏面JMeter的/ lib文件夾。如何讓JMeter識別Set方法。
感謝