import org.junit.Test;
import org.springframework.scripting.bsh.BshScriptUtils;
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);
}