[英]JMeter Bean Shell Sampler error “…Static method get( java.lang.String ) not found in class'java.nio.file.Paths” when copying files
[英]JMeter - Static method get( java.lang.String ) not found in class'java.nio.file.Paths'
我正在尝试创建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预处理器不能像我尝试使用它那样工作吗?
我的猜测是问题是它没有填充varargs参数。 尝试:
Path target = Paths.get(filename, new String[0]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.