1、把应用jar包放到一个目录下,在lr中,引用导入系统里
2、新建java vuser,写入脚本
import com.alibaba.fastjson.JSONArray;
import com.jd.jmi.order.api.domain.JmiOrderDetail;
import com.jd.jmi.order.api.service.JmiOrderQueryService;
import com.jd.jmi.order.client.jsf.exceptions.JmiException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import lrapi.lr;
public class Actions
{
static JmiOrderQueryService jmiOrderQueryService;
private static ApplicationContext act;
static {
act = new ClassPathXmlApplicationContext("spring-config-jsf.xml");
jmiOrderQueryService = act.getBean("jmiOrderQueryService",JmiOrderQueryService.class);
}
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
lr.start_transaction("QueryByOrderId");
try {
JmiOrderDetail detail = this.jmiOrderQueryService.queryByOrderId(Long.valueOf(lr.eval_string("<OrderId>")), "eeeee");
if (detail != null) {
lr.end_transaction("QueryByOrderId", lr.PASS);
//System.out.println(JSONArray.toJSONString("++++++++++++++++"+detail));
}else{
lr.end_transaction("QueryByOrderId", lr.FAIL);
}
} catch (JmiException e) {
e.printStackTrace();
}
return 0;
}
public int end() throws Throwable {
return 0;
}//end of end
}