代码
import java.lang.Math;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.SimpleDateFormat;
import com.alibaba.dubbo.rpc.RpcContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.taocares.naoms.service.AService;
import lrapi.lr;
public class Actions
{
ClassPathXmlApplicationContext context=null;
public int init() throws Throwable {
//配置文件加载--配置文件路径
// ClassPathXmlApplicationContext使用了file前缀是可以使用绝对路径的
context = new ClassPathXmlApplicationContext(new String[] {"file:C:/Users/37868/Desktop/测试/test/doc/dubbo.xml"});
context.start();
return 0;
}//end of init
/**
* 测试接口
*
* @return int
*/
public int action() throws Throwable {
RpcContext.getContext().setAttachment("deptId", "1581");
RpcContext.getContext().setAttachment("id", "1790");
lr.start_transaction("dubbo");
IFimsDynService service = (IFimsDynService) context.getBean("IFimsDynService");
String time = "2018-10-10 03:00:00";//修改的时间
Date adjustTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time);
service.onlyAdjustAlterLanding(1L,adjustTime);
lr.end_transaction("dubbo",lr.PASS);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
问题
问题一
loadRunner11最高只支持jdk1.6,所以如果想用loadRunner只能将接口包降级到1.6才能使用。(博主没有发现其他解决方法,只能降级。欢迎有其他方案的大牛告知。)
问题二
出现Zookeeper is not connected yet!的报错。通过替换dubbo的jar包(原先是2.5.9,更改为2.5.6)