Commit fc1ee83e by shuai

2018-11-29

parent 0b14555c
......@@ -49,7 +49,7 @@ public class RequestDataUtils {
}
//不带token的post请求
public static Response Post_headers(HashMap<String, Object> data, String serviceURL,String zgl_clienttype) {
public static Response Post_headers_token(HashMap<String, Object> data, String serviceURL,String zgl_clienttype,String Salesman_token) {
// 设置参数格式
String Parameter = (String) data.get("parameter");
......@@ -64,7 +64,7 @@ public class RequestDataUtils {
while (state < 5) {
try {
state++;
re = rdu.getRMEnv(tem).given()
re = rdu.getRMEnv(tem).given().header("Authorization","Bearer "+ Salesman_token)
.header("zgl-systemtype", "Windows")
.header("zgl-clienttype", zgl_clienttype)
.contentType(JSON).body("{"+Parameter+"}").when()
......@@ -99,36 +99,32 @@ public class RequestDataUtils {
int state = 0;
Response re = null;
RequestDataUtils rdu = new RequestDataUtils();
// System.out.println("laravel_session:"+XYZB.laravel_session);
// System.out.println("XSRF_token:"+XYZB.XSRF_token);
// System.out.println("请求参数:"+Parameter);
boolean b=false;
if("创建房间流程测试_3".equals(data.get("TCNO").toString()) || "创建房间流程测试_7".equals(data.get("TCNO").toString())){
b=true;
}
while (state < 5) {
try {
state++;
if("/web/member".equals(serviceURL)){
// Cookie cookie1 = Cookie.Builder("username", "John").setComment("comment 1").build();
// Cookie cookie2 = Cookie.Builder("token", 1234).setComment("comment 2").build();
// Cookies cookies = new Cookies(cookie1, cookie2);
re = rdu.getRMEnv(tem).given()
// .header("laravel_session", XYZB.laravel_session)
// .header("XSRF-TOKEN", XYZB.XSRF_token)
.cookie("laravel_session", XYZB.laravel_session)
.cookie("XSRF-TOKEN", XYZB.XSRF_token)
// .cookie("domain", ".live.offcncloud.com")
.contentType(JSON).body("{"+Parameter+"}").when()
.post(serviceURL).thenReturn();
// System.out.println(re.getStatusCode()+"............................");
// System.out.println(re.asString());
// Headers headers=re.getHeaders();
// System.out.println(headers.toString());
// System.out.println(re.getSessionId());
// System.out.println(re.getStatusCode());
// JsonPath jp = re.body().jsonPath();
if (!"200".equals(re.getStatusCode()+"")) {
Log.logError("请求返回:" +re.getStatusCode()+",第"+ state + "次。");
Thread.sleep(1000);
}else if(b){
if(!re.asString().contains("<html")){
return re;
}
} else {
return re;
}
......@@ -287,7 +283,7 @@ public class RequestDataUtils {
state++;
if(parameter != null && !"".equals(parameter)) {
re = rdu.getRMEnv(tem).given().header("Authorization","Bearer "+ token).get(serviceURL + "?" + parameter).andReturn();
re = rdu.getRMEnv(tem).given().header("system_type","Windows").header("Authorization","Bearer "+ token).get(serviceURL + "?" + parameter).andReturn();
}else {
re = rdu.getRMEnv(tem).given().header("Authorization","Bearer "+ token).get(serviceURL).andReturn();
}
......@@ -523,10 +519,13 @@ public class RequestDataUtils {
// .formParam("area", "东城区").
when().put(serviceURL).thenReturn();
JsonPath jp = re.body().jsonPath();
// System.out.println(StringUtils.decodeUnicode(re.asString()));
// System.out.println(re.getStatusCode());
if ("500".equals(jp.getString("status"))) {
Log.logError("请求返回500," + state + "次。");
Thread.sleep(1000);
} else {
}else {
return re;
}
} catch (Exception e) {
......
......@@ -26,7 +26,9 @@ import sun.misc.BASE64Decoder;
public class aliOCR {
public static void main(String[] args) {
// getYZM(6,"d:\\a1.jpg");
getYZM(4,"d:\\t1.jpg");
// getYZM(4,"d:\\t1.jpg");
// getYZM(4,"温爽看到了吗 11");
System.out.println(new String(Base64.encodeBase64("温爽看到了吗 11".getBytes())));
}
public static String getYZM(int count,String imagePath){
String host = "http://ali-checkcode.showapi.com";
......
......@@ -50,7 +50,6 @@ public class banned_status extends XYZB implements API {
parameter = MapUtil.getValue("parameter", data);
is_banned = MapUtil.getParameter(parameter, "is_banned").trim();
is_banned=MapUtil.killQuotes(is_banned, "\"");
return data;
}
......
......@@ -256,7 +256,7 @@ public class edit extends XYZB implements API {
+ jp.getString("msg") + ".";
}
if(data.get("custom") != null && jp.getString("data").length()>4){
if(data.get("custom") != null && jp.getString("data")!=null && jp.getString("data").length()>4){
String custom=data.get("custom").toString();
String[] ArrayString=StringUtils.getArrayString(custom,",");
if(!StringUtils.VerificationString(jp.getString("data"),ArrayString)){
......
......@@ -57,6 +57,7 @@ public class getUser extends XYZB implements API {
parameter = Current_uuid;
parameter = MapUtil.killQuotes(parameter, "\"");//去掉双引号的parameter
parameter = parameter;
data.put("parameter", parameter);
return data;
}
......
......@@ -99,6 +99,7 @@ public class member extends XYZB implements API {
return data;
}
@Override
public Response SendRequest(HashMap<String, Object> data, String Url,
String Request) {
......@@ -183,7 +184,7 @@ public class member extends XYZB implements API {
" xyu_users x ",
" x.name = '" + name + "' ");
rs_bankcard.last();
System.out.println(rs_bankcard.getRow());
if (rs_bankcard.getRow() < 1) {
result = result && false;
failReason = failReason + "xyu_users info is not in DB;";
......@@ -204,6 +205,7 @@ public class member extends XYZB implements API {
} else {
Log.logInfo("xyu_users info in DB is correct;");
}
}
} catch (Exception e) {
result = result && false;
......
......@@ -48,7 +48,9 @@ public class questions extends XYZB implements API {
public HashMap<String, Object> handleInput(HashMap<String, Object> data) {
user_id=Current_user_id;
parameter = MapUtil.getValue("parameter", data);
name = MapUtil.getParameter(parameter, "name").trim();
if(parameter.length()>7){
name = parameter.substring(7);
}
if(Current_password.contains("Not_started")){
room_id=ReadProperties.GetinformationByKey("Not_started_xyzbid");
}else if(Current_password.contains("Running_xyzb")){
......
......@@ -36,15 +36,12 @@ import net.sf.json.JSONObject;
*/
public class update extends XYZB implements API {
public String parameter;//参数集合
public String name;//房间名称
public String phone;//房间名称
public String room_num;//房间名称
public String identity;
public String id;
@Override
public void initialize(HashMap<String, Object> data) {
}
......
......@@ -110,7 +110,7 @@ public class users extends XYZB implements API {
parameter = parameter.replace("\"uuid\":random", "\"uuid\":\""+ Current_uuid + "\"");
}
parameter = parameter+",\"system_type\":\"Windows\"";
// 替换原来的parameter
data.put("parameter", parameter);
return data;
......@@ -120,7 +120,7 @@ public class users extends XYZB implements API {
public Response SendRequest(HashMap<String, Object> data, String Url,
String Request) {
// Response re = RequestDataUtils.Post_NOToken(data, Url);
Response re = RequestDataUtils.Post_headers(data, Url,zgl_clienttype);
Response re = RequestDataUtils.Post_headers_token(data, Url,zgl_clienttype,Salesman_token);
return re;
}
......
......@@ -25,24 +25,6 @@ import net.sf.json.JSONObject;
public abstract class BasicsGM {
// //数据提取
// public static HashMap<String, Object> data_ext=new HashMap<String, Object>();
//
// //用户验证码<电话号码,验证码>
// public static HashMap<String, String> verifyCode=new HashMap<String, String>();
//
// public static List<String> cust_ids = new ArrayList<String>();//客户表id,
//
// public static List<String> contractId_dd = new ArrayList<String>();//任买合同id,
//
// public static List<String> prod_ids = new ArrayList<String>();//商品信息表id
//
// public static List<String> order_ids = new ArrayList<String>();//订单表id
//
// public static HashMap<String, String> thirdBusi = new HashMap<String, String>();//子商户表id
//
// public static List<String> rulesEngine_ids = new ArrayList<String>();//决策引擎customer表 id
//
public static Connection conn = null;
public static Statement stmt = null;
//
......@@ -102,274 +84,7 @@ public abstract class BasicsGM {
}
// 如果cust_ids集合有值,则循环删除map_table集合内,表名=KEY,列名=value,值=cust_ids得遍历结果
public void cleanCustomerInfo() {
HashMap<String, String> map_table = new HashMap<String, String>();
//用户验证所需的表格
map_table.put("bestbuy_third_user", "cust_id");//任买外接第三方用户表
map_table.put("bestbuy_customer", "id");//用户表
//工作族基本信息
map_table.put("bestbuy_doc", "rela_id");//用户身份证照片
map_table.put("bestbuy_customer_info", "customer_id");//用户信息表
map_table.put("bestbuy_bankcard", "customer_id");//银行卡信息表
map_table.put("bestbuy_customer_book", "customer_id");//用户电话簿信息表
map_table.put("bestbuy_customer_licensesinfo", "customer_id");//用户第三方授权信息表
map_table.put("bestbuy_module_auth", "cust_id");//用户授权表
map_table.put("bestbuy_audit_record", "cust_id");//人工信审工单处理记录表
/*
map_table.put("bestbuy_customer_auth", "customer_id");//用户授权表 ---APP端
map_table.put("bestbuy_bank_record", "customer_id");//绑卡记录表
*/
map_table.put("bestbuy_customer_com", "customer_id");//客户公司信息表
map_table.put("bestbuy_customer_location", "customer_id");//客户地址信息
map_table.put("bestbuy_relationship", "customer_id");//用户关系表
map_table.put("bestbuy_order", "customer_id");//订单表
//合同表bestbuy_contract,暂时不清除,因为需要orderid,并且合同表关联到保理业务。。
// Iterator<String> it_cust = cust_ids.iterator();//客户表id
//
// while (it_cust.hasNext()) {
// Iterator<Entry<String, String>> it_table = map_table.entrySet().iterator();
// String cust = it_cust.next();
// while (it_table.hasNext()) {
// Map.Entry<String, String> entry = (Map.Entry<String, String>) it_table.next();
// try {
// this.deleteFromDB(entry.getKey(), entry.getValue(), cust);
// } catch (Exception e) {
// System.out.println("Fail to clean customer info!");
// }
// }
// }
// cust_ids.clear();
}
//
// //按照customer_id删除决策引擎中用户的数据-预授信模式
// public void cleanStreamingCustomerInfo(String customer_id) {
// HashMap<String, String> map_table = new HashMap<String, String>();
// map_table.put("streaming.customer", "id");//决策引擎用户表
// map_table.put("streaming.customer_info", "customer_id");//决策引擎用户表
// map_table.put("streaming.customer_data_info", "customer_id");//决策引擎用户数据表
// map_table.put("streaming.customer_limit_account_log", "customer_id");//用户身份证照片
// map_table.put("streaming.customer_limit_account", "customer_id");//客户额度账户表
// map_table.put("streaming.customer_merchant_info", "customer_id");//商户信息表
//
// Iterator<Entry<String, String>> it_table = map_table.entrySet().iterator();
// while (it_table.hasNext()) {
// Map.Entry<String, String> entry = (Map.Entry<String, String>) it_table.next();
// try {
// this.deleteFromDB(entry.getKey(), entry.getValue(), customer_id);
// } catch (Exception e) {
// System.out.println("Fail to clean customer info!");
// }
// }
// }
//
// //按照streaming_process_info_id删除决策引擎中用户的数据-订单模式
// public void cleanStreamingOrder(String id) {
// HashMap<String, String> map_table = new HashMap<String, String>();
// map_table.put("streaming.third_ylzc_advanced_data", "id");//决策引擎用户表
// map_table.put("streaming.third_ylzc_base_data", "id");//决策引擎用户数据表
// map_table.put("streaming.third_ylzc_basic_data_past_all_month", "id");//用户身份证照片
// map_table.put("streaming.third_ylzc_basic_data_recent_1_3_month", "id");//客户额度账户表
// map_table.put("streaming.third_ylzc_basic_data_recent_12_month", "id");//商户信息表
// map_table.put("streaming.third_ylzc_basic_data_recent_6_month", "id");//商户信息表
// map_table.put("streaming.third_ylzc_classical_data", "id");//商户信息表
// map_table.put("streaming.third_ylzc_customized_data", "id");//商户信息表
// map_table.put("streaming.streaming_customer_licensesinfo", "work_id");//用户授权信息表
// map_table.put("streaming.streaming_process_info", "id");//流程信息
//
// Iterator<Entry<String, String>> it_table = map_table.entrySet().iterator();
// while (it_table.hasNext()) {
// Map.Entry<String, String> entry = (Map.Entry<String, String>) it_table.next();
// try {
// this.deleteFromDB(entry.getKey(), entry.getValue(), id);
// } catch (Exception e) {
// System.out.println("Fail to clean customer info!");
// }
// }
// }
//
//
//
//
//
//
// //清除list集合prod_ids,表名"bestbuy_goods",列名id,值prod_ids得遍历结果
//
//
// public void cleanProductsFromDB() {
// Iterator<String> it_prod = prod_ids.iterator();
//
// while (it_prod.hasNext()) {
// try {
// this.deleteFromDB("bestbuy_goods", "id", it_prod.next());
// } catch (Exception e) {
// System.out.println("Fail to clean product info!");
// }
//
// }
// prod_ids.clear();
//
// }
//
// //清除list集合order_ids,表名"bestbuy_order",列名id,值order_ids得遍历结果
//
// public void cleanOrdersFromDB() {
// Iterator<String> it_order = order_ids.iterator();
//
// while (it_order.hasNext()) {
// try {
// this.deleteFromDB("bestbuy_order", "id", it_order.next());
// } catch (Exception e) {
// System.out.println("Fail to clean order info!");
// }
//
// }
// order_ids.clear();
//
// }
//
// //清除list集合order_ids,表名"bestbuy_order",列名id,值order_ids得遍历结果
//
// public void cleanRulesEngine_idsFromDB() {
// Iterator<String> it_rulesEngine = rulesEngine_ids.iterator();
//
// Statement stmt_RulesEngine =null;
//
// while (it_rulesEngine.hasNext()) {
// try {
// stmt_RulesEngine = conn.createStatement();
// String sql = "delete from " + "streaming.customer" + " where " + "id_no" + " like '" + it_rulesEngine.next() + "'";
// System.out.println("sql==="+sql);
// int result = stmt_RulesEngine.executeUpdate(sql);
// System.out.println("result==="+result);
// if (result == -1) {
// System.out.println("Clean failed!");
// }
// } catch (Exception e) {
// System.out.println("Fail to clean order info!");
// }finally{
// if (stmt_RulesEngine != null){
// try {
// stmt_RulesEngine.close();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
// }
// }
//
// rulesEngine_ids.clear();
//
// }
//
//
// //从thirdBusi这个map集合中,往huimai.bestbuy_sub_busi这个表添加信息
//
// public void addTestThirdBusiInfoFromDB() {
// Statement stmt;
// try {
// stmt = conn.createStatement();
//
// String sql = "insert into huimai.bestbuy_sub_busi (busi_id,sub_busi_name,busi_id_third,create_time) "
// + "values('999','" + thirdBusi.get("busiName") + "','" + thirdBusi.get("busiId") + "', NOW())";
// // System.out.println(sql);
// int result = stmt.executeUpdate(sql);//
// if (result == -1) {
// System.out.println("Insert failed!");
// }
// } catch (SQLException e) {
// System.out.println("Insert failed!");
// }
//
// }
//
// //从thirdBusi这个map集合中,在huimai.bestbuy_sub_busi这个表删除信息
//
// public void cleanTestThirdBusiInfoFromDB() {
// Statement stmt;
// try {
// stmt = conn.createStatement();
//
// String sql = "delete from huimai.bestbuy_sub_busi where " + "sub_busi_name ='"
// + thirdBusi.get("busiName") + "' and busi_id_third='" + thirdBusi.get("busiId") + "'";
// // System.out.println(sql);
// int result = stmt.executeUpdate(sql);//
// if (result == -1) {
// System.out.println("clean busi info failed!");
// }
// } catch (SQLException e) {
// System.out.println("clean busi info failed!");
// }
//
// }
//
//
// //更改
//
// public void updateTableValueWithCondition(String table, String setStatement, String whereStatement) {
// Statement stmt;
// try {
// stmt = conn.createStatement();
//
// String sql = "update "+table+" set "+setStatement+" where "+whereStatement;
//// System.out.println(sql);
// int result = stmt.executeUpdate(sql);//
// if (result == -1) {
// System.out.println("update table value failed!");
// }
// } catch (SQLException e) {
// System.out.println("update table value failed!");
// }
// }
//
//
// // 字符串转换成时间类型
//
// public Date convertStrToDate(String dateStr) {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
// Date date = null;
// try {
// date = sdf.parse(dateStr);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return date;
//
// }
//
// //时间转换成字符串类型
// public String convertDateToStr(Date date) {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
// String dateStr = null;
// try {
// dateStr = sdf.format(date);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return dateStr;
//
// }
//
// public String getContractId(){
// for(int i=0;i<contractId_dd.size();i++){
// if(contractId_dd.get(i)!=null){
// return contractId_dd.get(i);
// }
// }
// return null;
// }
//
//判断字符串是否是空或者是“”
public boolean StringIsNull(String str){
......@@ -429,44 +144,4 @@ public abstract class BasicsGM {
}
return "";
}
//
// //加解密
// public HashMap<String, Object> EncryptionAnddecryption(HashMap<String, Object> data) {
// // 获取parameter对应的内容
// String parameter="";//参数集合
// String list="";//参数集合
// String phone="";//电话
// String idNo="";//身份证号
//
// parameter = MapUtil.getValue("parameter", data);
// phone = MapUtil.getParameter(parameter, "phone").trim();
// phone = MapUtil.killQuotes(phone, "\"");
// idNo = MapUtil.getParameter(parameter, "idNo").trim();
// idNo = MapUtil.killQuotes(idNo, "\"");
// list = MapUtil.getParameter(parameter, "\"list\":").trim();
//
//
// if (phone != null && !"".equals(phone)) {
// parameter = parameter.replace(phone, EncryptionUtil.encrypt(phone));
// }
// if (idNo != null && !"".equals(idNo)) {
// parameter = parameter.replace(idNo, EncryptionUtil.encrypt(idNo));
// }
//
// if (list != null && !"".equals(list)) {
// JSONArray ja = JSONArray.fromObject(list);
// Iterator<?> it = ja.iterator();
//
// while (it.hasNext()) {
// JSONObject jo = (JSONObject) it.next();
// phone = jo.has("phone") ? jo.getString("phone") : "";
// if (phone != null && !"".equals(phone)) {
// parameter = parameter.replace(phone, EncryptionUtil.encrypt(phone));
// }
// }
// }
// // 替换原来的data
// data.put("parameter", parameter);
// return data;
// }
}
package com.offcn.test;
import io.restassured.response.Response;
import java.sql.SQLException;
import java.util.HashMap;
import net.sf.json.JSONObject;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import com.offcn.TestData.offcn_api_testData;
import com.offcn.TestUnti.Log;
import com.offcn.TestUnti.Mail;
import com.offcn.TestUnti.MapUtil;
import com.offcn.TestUnti.OAuthTokenUnti;
import com.offcn.TestUnti.ReadProperties;
import com.offcn.TestUnti.Reflect_api;
import com.offcn.TestUnti.SheetUtils;
......@@ -25,7 +19,6 @@ import com.offcn.listener.ProcessTestng;
import com.offcn.listener.ResultTestng;
import com.offcn.process.BasicsGM;
import com.offcn.process.XYZB;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
......@@ -37,6 +30,10 @@ public class APITest extends XYZB{
Log.logInfo(data.get("TCNO").toString() + " Step " + data.get("Description").toString() + " is running......");
if("冒烟测试_70".equals(data.get("TCNO").toString())){
System.out.println(123);
}
API obj = new Reflect_api().Reflections(data);
BasicsGM.map=new XMLread().getSystem();
......@@ -96,12 +93,15 @@ public class APITest extends XYZB{
String Expect1=data.get("code")==null?"":data.get("code").toString();
String Expect2=data.get("msg")==null?"":data.get("msg").toString();
String Expect3=data.get("custom")==null?"":data.get("custom").toString();
// System.out.println("Expect1:"+Expect1);
// System.out.println("Expect2:"+Expect2);
// System.out.println("Expect3:"+Expect3);
// System.out.println("Expect4:"+StringUtils.decodeUnicode(body));
Assert.assertEquals(StringUtils.decodeUnicode(body),Expect1+","+Expect2+","+Expect3);
}else{
Assert.assertTrue(true);
}
// OAuthTokenUnti.token=null;
}
@AfterClass
......@@ -121,13 +121,6 @@ public class APITest extends XYZB{
} catch (SQLException e) {
e.printStackTrace();
}
// //发送邮件
// try {
// Mail.POP3();
// } catch (Exception e) {
// Log.logError("邮件发送失败");
// e.printStackTrace();
// }
}
Log.logInfo("========测试结束========");
......
xls=DataAll.xls
sheet=TestCase2
sheet=TestCase1
mysql_local_Online=Online
\ No newline at end of file
......@@ -4,7 +4,7 @@
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter" />
<listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
</listeners> <!-- -->
</listeners> <!--org.uncommons.reportng.HTMLReporter -->
<test name="Test">
<classes>
......
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