我正在尝试创建 JMeter 负载测试。我需要测试来获取示例日志文件并更改其名称。我能找到的唯一方法是将文件复制到 BeanShell 预处理器中,但我收到以下错误:
ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: evalSourced file: inline evaluation of: ``import java.nio.file.StandardCopyOption; import java.io.IOException; import java . . . '' : Typed variable declaration : Error in method invocation: Static method get( java.lang.String ) not found in class'java.nio.file.Paths'
我正在使用的代码如下:
import java.nio.file.StandardCopyOption;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Path source = Paths.get(vars.get("filename");
String filename = "/Users/GX1/Desktop/jmeter/tmp/Device_"+vars.get("global_counter")+"_upload_"+vars.get("file_counter")+".csv.gz";
Path target = Paths.get(filename);
Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
vars.put("filename", filename);
filename、global_counter 和 file_counter 是 jmeter 变量。
有谁知道为什么我会收到此错误? beanshell 预处理器是否无法按照我尝试使用的方式工作?
My guess问题是它没有填充 varargs 参数。尝试:
Path target = Paths.get(filename, new String[0]);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)