通过本文主要向大家介绍了beanshell,jmeter beanshell,beanshell sampler,jmeter配置beanshell,beanshell断言等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
说明
1.通过脚本语言让JAVA执行动态代码
2.用Spring可以将脚本语言代理成Java接口的实现类
3.Spring2.5.6中支持三种脚本语言ruby,Groovy,BeanShell
4.示例中为spring与beanshell结合
5.依赖spring2.5.6,bsh-2.0b4
import bsh.EvalError;
public class TestBeanShell {
@Test
public void testShell() {
String srciptText = "say(name){ return \"hello,\"+name;}";
SayHello sh;
try {
sh = (SayHello) BshScriptUtils.createBshObject(srciptText, new Class[] { SayHello.class });
String res=sh.say("vidy");
System.out.println(res);
} catch (EvalError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
interface SayHello {
public String say(String name);
}
</div>