Commit e432c402 by 左磊磊

12028更新鲁班工程

parent bdfc5d0c
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
package com.lemon.cases;
import com.alibaba.fastjson.JSONObject;
import io.qameta.allure.Description;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.Logger;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* @program: 鲁班工程-测评配置化b端,走token
* @description:
* @author: ray
* @create: 2023-10-09 13:20
**/
public class EvaluationConfigurationBCase extends BaseCase {
private CookieStore cooki;
public static Logger log = Logger.getLogger(BaseCase.class);
public static final Map<String, String> envPro = new HashMap<>();
public void envPro(Map<String, String> envPro) {
log.info(envPro);
}
// 登录接口
@Test(dataProvider = "data")
@Description("6.0编辑端登录接口")
public void testAAALogin(int id, String caseName, String url, String json) throws Exception {
HttpPost post = new HttpPost(url);
post.setHeader("Content-Type", "application/json");
post.setEntity(new StringEntity(json));
DefaultHttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(post);
Header[] header = response.getAllHeaders(); // 响应头
int status = response.getStatusLine().getStatusCode();
System.out.print("状态码:::" + status + "\n");
HttpEntity entity = response.getEntity(); // 响应体
String str = EntityUtils.toString(entity);
JSONObject body = JSONObject.parseObject(str);
System.out.print("响应结果: " + body + "\n");
if (body != null) { //如果body不为空
String strData = body.getString("data"); //获取body中的data
JSONObject data = JSONObject.parseObject(strData); //将strData转换为JSON类型data
if (data != null) {
String token = data.getString("token"); //获取token
if (token != null) { //如果token不为空
envPro.put("token", token.toString()); //将Token存储到环境变量envPro
System.out.println("token:" + envPro.get("token"));
}
}
}
}
@DataProvider(name = "data")
public Object[][] data() {
//Object[m][n] m代表执行次数,n代表参数个数
Object[][] datas = {
{1, "6.0编辑端登录", "https://adviser.5rs.me/usercenter/v1.0/user/login", "{\"userName\":\"17343351051\",\"pwd\":\"35ebb6d482ad63360193a060154f3884\",\"isRemember\":1,\"systemCode\":\"adviser\"}"},
};
return datas;
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -49,6 +49,7 @@ public class ServerCase extends BaseCase {
System.out.println("B-sql: " + cas.getCheckBSQL());
Thread.sleep(1000 * 30); //验证B段SQL的休眠时间60秒
Object afterBSqlResult = SqlUtils.querySingle(cas.getCheckBSQL());
//7-1、A段数据库断言
boolean sqlAFlag = assertSql(cas.getaExpectValue(), beforeASqlResult == null ? null : beforeASqlResult.toString(), afterASqlResult == null ? null : afterASqlResult.toString());
String assertSqlAFlag = (sqlAFlag) ? "Pass" : "Fail";
......
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