Commit 4743ddb3 authored by 赵然's avatar 赵然

zr

parent e72d248a
...@@ -61,19 +61,32 @@ public class 答题_答对题数抽奖_DuibaTest extends AbstractTestNGSpringCon ...@@ -61,19 +61,32 @@ public class 答题_答对题数抽奖_DuibaTest extends AbstractTestNGSpringCon
Assert.assertEquals(submitResponse.jsonPath().getString("message"),message); Assert.assertEquals(submitResponse.jsonPath().getString("message"),message);
} else { } else {
Assert.assertEquals(submitResponse.jsonPath().getInt("rightCount"),rightCount); Assert.assertEquals(submitResponse.jsonPath().getInt("rightCount"),rightCount);
for (int i =1; i <= 5; i++) { // for (int i =1; i <= 5; i++) {
//获取中奖结果,校验中奖结果 // //获取中奖结果,校验中奖结果
Response lotterysResponse = activityCtrlService.getOrderStatus(orderId); // Response lotterysResponse = activityCtrlService.getOrderStatus(orderId);
int result = lotterysResponse.jsonPath().getInt("result"); // int result = lotterysResponse.jsonPath().getInt("result");
if(result != 0) { // if(result != 0) {
Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success")); // Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success"));
// Assert.assertEquals(lotterysResponse.jsonPath().getString("lottery.type"),prize); // // Assert.assertEquals(lotterysResponse.jsonPath().getString("lottery.type"),prize);
Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type"))); // Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type")));
break; // break;
} // }
Thread.sleep(500); // Thread.sleep(500);
// }
Thread.sleep(2000);
Response lotterysResponse = activityCtrlService.getOrderStatus(orderId);
String result = lotterysResponse.jsonPath().getString("result");
int i= 30;
while(i>0&&(result.equals("0"))){
Thread.sleep(1000);
lotterysResponse = activityCtrlService.getOrderStatus(orderId);
result = lotterysResponse.jsonPath().getString("result");
i--;
lotterysResponse.prettyPrint();
} }
Assert.assertFalse(false,caseDesc+" 测试失败,轮询5次未请求到中奖结果"); Assert.assertTrue(lotterysResponse.jsonPath().getBoolean("success"));
Assert.assertTrue(prize.contains(lotterysResponse.jsonPath().getString("lottery.type")));
// Assert.assertFalse(false,caseDesc+" 测试失败,轮询5次未请求到中奖结果");
} }
} }
......
...@@ -48,8 +48,8 @@ public class ActivityCtrlService { ...@@ -48,8 +48,8 @@ public class ActivityCtrlService {
params.put("actId",actId); params.put("actId",actId);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/ajaxElement"); .post(activityHost+"/hdtool/ajaxElement");
logger.info("请求/newActivity/ajaxElement接口,响应结果:"+response.asString()); logger.info("请求/hdtool/ajaxElement接口,响应结果:"+response.asString());
return response; return response;
} }
...@@ -58,8 +58,8 @@ public class ActivityCtrlService { ...@@ -58,8 +58,8 @@ public class ActivityCtrlService {
params.put("activityId",activityId); params.put("activityId",activityId);
params.put("token",token); params.put("token",token);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/doJoin"); .post(activityHost+"/hdtool/doJoin");
logger.info("请求/newActivity/doJoin接口,响应结果:"+response.asString()); logger.info("请求/hdtool/doJoin接口,响应结果:"+response.asString());
return response; return response;
} }
...@@ -84,8 +84,8 @@ public class ActivityCtrlService { ...@@ -84,8 +84,8 @@ public class ActivityCtrlService {
params.put("answerData",answerData); params.put("answerData",answerData);
params.put("token",token); params.put("token",token);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(params)
.post(activityHost+"/newActivity/submit"); .post(activityHost+"/hdtool/submit");
logger.info("请求/newActivity/submit接口,响应结果:"+response.asString()); logger.info("请求/hdtool/submit接口,响应结果:"+response.asString());
return response; return response;
} }
...@@ -96,14 +96,14 @@ public class ActivityCtrlService { ...@@ -96,14 +96,14 @@ public class ActivityCtrlService {
*/ */
public Response getOrderStatus(long orderId) throws Exception{ public Response getOrderStatus(long orderId) throws Exception{
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).param("orderId",orderId) Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).param("orderId",orderId)
.post(activityHost+"/newActivity/getOrderStatus"); .post(activityHost+"/hdtool/getOrderStatus");
logger.info("请求/newActivity/getOrderStatus接口,响应结果:"+response.asString()); logger.info("请求/hdtool/getOrderStatus接口,响应结果:"+response.asString());
try{ try{
Assert.assertEquals(response.jsonPath().getString("success"),"true"); Assert.assertEquals(response.jsonPath().getString("success"),"true");
}catch(Exception e){ }catch(Exception e){
throw new Exception("/newActivity/getOrderStatus接口失败,返回信息:"+response.asString()); throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
}catch(Error er){ }catch(Error er){
throw new Exception("/newActivity/getOrderStatus接口失败,返回信息:"+response.asString()); throw new Exception("/hdtool/getOrderStatus接口失败,返回信息:"+response.asString());
} }
return response; return response;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment