dubbo接口测试方法一
测试前准备
git clone https://github.com/goghcrow/dubbo_ab.git
cd dubbo_ab
make
测试例子一:
./dubbo -h10.9.58.51 -p20880 -mcom.zqh.test.TestService.testMethod -a '[{"kdtId":4906,"goodsType":null,"pageNo":1,"pageSize":20}]'
# 返回结果
{
"code": 200,
"data": {
"items": [],
"total": 0
},
"message": "successful",
"success": true
}
测试例子二:
public class ListPointsGoodsRequest{
private Long kdtId;
private List<Long> pointGoodsIdList;
}
./dubbo -h10.9.58.54 -p20880 -mcom.zqh.test.TestService.testMethod -a '[{"kdtId":30081803,"pointGoodsIdList":[119199, 119198]}]'
# 响应结果
{
"code": 200,
"data": [{
"goodsName": "zqh-优惠券",
"id": 119198,
"linkUrl": "http://www.tooopen.com/view/1437298.html",
"pointsPrice": 200,
"remainNum": 3,
"remainPrice": 0,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}, {
"id": 119199,
"linkUrl": "http://www.tooopen.com/view/1437298.html",
"pointsPrice": 2000,
"remainNum": 30,
"remainPrice": 0,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}],
"message": "successful",
"success": true
}
测试例子三
public class FindAvailableRequest{
Long kdtId;
Short goodsType;
Integer pageNo;
Integer pageSize;
}
public class FindSortedAvailableRequest extends FindAvailableRequest {
private Short sortRuleCode;
}
./dubbo -h10.9.58.54 -p20880 -mcom.zqh.test.TestService.testMethod -a '[{"kdtId":30081803,"goodsType":null,"pageNo":1,"pageSize":20, "sortRuleCode":0}]'
# 响应结果
{
"code": 200,
"data": {
"items": [{
"id": 119199,
"linkUrl": "http://www.tooopen.com/view/1437298.html",
"pointsPrice": 2000,
"remainNum": 30,
"remainPrice": 0,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}, {
"goodsName": "zqh-优惠券",
"id": 119198,
"linkUrl": "http://www.tooopen.com/view/1437298.html",
"pointsPrice": 200,
"remainNum": 3,
"remainPrice": 0,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}, {
"id": 119197,
"linkUrl": "http://www.tooopen.com/view/1437298.html",
"pointsPrice": 100,
"remainNum": 34,
"remainPrice": 90,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}],
"total": 3
},
"message": "successful",
"success": true
}
dubbo接口测试方法二
测试前准备
入参:
public class FindAvailableRequest{
Long kdtId;
Short goodsType;
Integer pageNo;
Integer pageSize;
}
$ telnet 127.0.0.1 20880
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
dubbo>
dubbo>ls # 查看所有dubbo服务接口
com.zqh.test.TestService
......
dubbo>ls com.zqh.test.TestService # 查看该接口下方法
testMethod
......
dubbo>invoke com.zqh.test.TestService.testMethod({"kdtId":4906,"goodsType":null,"pageNo":1,"pageSize":20})
# 响应结果
{
"code": 200,
"data": {
"items": [{
"id": 119199,
"pointsPrice": 2000,
"remainNum": 30,
"remainPrice": 0,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}, {
"goodsName": "zqh-优惠券",
"id": 119198,
"pointsPrice": 200,
"remainNum": 3,
"remainPrice": 0,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}, {
"id": 119197,
"pointsPrice": 100,
"remainNum": 34,
"remainPrice": 90,
"thumbUrl": "http://www.tooopen.com/view/1437298.html"
}],
"total": 3
},
"message": "successful",
"success": true
}
备注
- dubbo服务默认端口号:20880