Commit 9b33ae7c authored by Su-Yi's avatar Su-Yi

修改回调逻辑、tku

parent ef1cf337
......@@ -2,22 +2,19 @@ package com.kjj.qa.cases;
import static com.kjj.qa.config.BasicConfig.*;
import com.google.inject.internal.asm.$TypePath;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.codehaus.groovy.antlr.UnicodeEscapingReader;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
public class Article {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
String sid = ""; // 加密的销售ID
String articleContentId = ""; // 文章的contentId
String scid = ""; // getScid后的文章id
......
package com.kjj.qa.cases;
import com.google.inject.internal.asm.$TypePath;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.IExpectedExceptionsAnnotation;
import org.testng.annotations.Test;
import org.testng.remote.strprotocol.IMessage;
import java.io.IOException;
import java.util.Collections;
......@@ -20,7 +17,7 @@ import static com.kjj.qa.config.BasicConfig.*;
import static com.kjj.qa.config.BasicConfig.BOSS_USERINFO;
public class Boss {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
String sellerId = "";
String usellerId ="";
......@@ -39,8 +36,8 @@ public class Boss {
Response response = network.getResponse(BOSS_VERSIONINFO);
int userVersion = response.jsonPath().getInt("data.find {it.openType == 1}.userVersion");//判断是否为保险版:1是通用版 2是保险版
Assert.assertEquals(userVersion, 2,network.message(BOSS_VERSIONINFO,"获取版本有误 此版本为非保险版",response.body().asString()));
// boolean isVip = response.jsonPath().getBoolean("data.find {it.openType == 1}.vip");//判断是否为会员
// Assert.assertTrue(isVip,network.message(BOSS_VERSIONINFO,"会员判断错误 为非会员",response.body().asString()));
boolean isVip = response.jsonPath().getBoolean("data.find {it.openType == 1}.vip"); //判断是否为会员
Assert.assertTrue(isVip,network.message(BOSS_VERSIONINFO,"会员判断错误 为非会员",response.body().asString()));
}
//获取info接口的代理人id
......
package com.kjj.qa.cases;
import com.google.inject.internal.asm.$TypePath;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.apache.commons.lang3.ObjectUtils;
import org.codehaus.groovy.antlr.UnicodeEscapingReader;
import org.testng.Assert;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -20,7 +16,7 @@ import static com.kjj.qa.config.BasicConfig.*;
public class CircleFriends {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
int firstTagId = 0;
String contentId = "";
String tagId = "";
......
package com.kjj.qa.cases;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
......@@ -14,7 +14,7 @@ import java.util.Map;
import static com.kjj.qa.config.BasicConfig.*;
public class GreetingCard {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
int tagId = 0;
String greetingName = "";
String contentId = "";
......
package com.kjj.qa.cases;
import com.kjj.qa.utils.NetworkUtil;
import io.restassured.response.Response;
import org.testng.Assert;
import com.kjj.qa.utils.NetworkUtils;
import org.testng.annotations.*;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Home {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
......
package com.kjj.qa.cases;
import static com.kjj.qa.config.BasicConfig.*;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
......@@ -16,7 +16,7 @@ import java.util.Map;
public class Novice {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
......
......@@ -3,10 +3,8 @@ package com.kjj.qa.cases;
import static com.kjj.qa.config.BasicConfig.*;
import static io.restassured.RestAssured.given;
import com.kjj.qa.utils.ManagerUtil;
import com.kjj.qa.utils.NetworkUtil;
import io.restassured.http.ContentType;
import io.restassured.http.Cookies;
import com.kjj.qa.utils.ManagerUtils;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
......@@ -14,14 +12,13 @@ import org.testng.annotations.Test;
import java.io.IOException;
import java.net.CookieStore;
import java.util.HashMap;
import java.util.Map;
public class Pay {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public static void setUp() {
......@@ -155,7 +152,7 @@ public class Pay {
apiCount += 7;
// 切换为保险版vip
ManagerUtil.switchvip();
ManagerUtils.switchvip();
//延迟2秒
Thread.sleep(2000);
......
package com.kjj.qa.cases;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import static com.kjj.qa.config.BasicConfig.*;
import io.restassured.response.Response;
import org.testng.Assert;
......@@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.Map;
public class SellerCard {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
private String scid = "";
private String sellerId = "";
......
package com.kjj.qa.cases;
import static com.kjj.qa.config.BasicConfig.*;
import com.kjj.qa.utils.NetworkUtil;
import com.kjj.qa.utils.NetworkUtils;
import io.restassured.response.Response;
import org.testng.Assert;
import org.testng.annotations.*;
......@@ -13,7 +13,7 @@ import java.util.HashMap;
import java.util.Map;
public class Upload {
private static final NetworkUtil network = NetworkUtil.getInstance();
private static final NetworkUtils network = NetworkUtils.getInstance();
@BeforeClass
public void setUp() {
......
......@@ -46,6 +46,9 @@ public class BasicConfig {
// *************** 公共 ***************
public static final String CREATE_USER = HOST + "/kjy/mp/autotest/create/user";
public static final String VERSION_INFO = HOST + "/kjy/mp/version/info";
public static final String ISVIPSUBSCRIBE = HOST + "/kjy/mp/seller/isVipSubscribe";
......
......@@ -14,7 +14,7 @@ import org.testng.xml.XmlSuite;
import java.io.File;
import java.util.*;
import com.kjj.qa.utils.DingTalkUtil;
import com.kjj.qa.utils.DingTalkUtils;
public class ExtentTestNGIReporterListener implements IReporter {
// 生成的路径以及文件名
......@@ -103,7 +103,7 @@ public class ExtentTestNGIReporterListener implements IReporter {
String context = String.format("通过的用例数: %s\n失败的用例数: %s\n跳过的用例数: %s\n", suitePassSize, suiteFailSize, suiteSkipSize);
try {
DingTalkUtil.sendVal(context);
DingTalkUtils.sendVal(context);
} catch (Exception e) {
e.printStackTrace();
}
......
package com.kjj.qa.utils;
import io.restassured.response.Response;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.qa.config.BasicConfig.*;
public class AccountUtils {
private static final NetworkUtils network = NetworkUtils.getInstance();
public static void changeTku(){
Map<String, Object> params = new HashMap<String, Object>();
params.put("openId","osi5w5ucTy5jRR0zw7hLNJm1S3xY");
params.put("password","gh_3b9884c7b0ee");
Response response = network.getResponse(params,CREATE_USER);
response.body().prettyPrint();
}
public static void main(String[] args) {
changeTku();
}
}
......@@ -3,7 +3,7 @@ import static com.kjj.qa.config.BasicConfig.*;
import java.util.HashMap;
import java.util.Map;
public class DingTalkUtil {
public class DingTalkUtils {
//通过钉钉机器人发送消息到钉钉群中
public static void sendVal(String context)throws Exception{
......@@ -26,7 +26,7 @@ public class DingTalkUtil {
//发起dingding机器人通知
if (isPushReport){
NetworkUtil network = NetworkUtil.getInstance();
NetworkUtils network = NetworkUtils.getInstance();
network.dingTalkRobot(params);
}
......
package com.kjj.qa.utils;
import com.alibaba.fastjson.JSONArray;
import io.restassured.http.Cookies;
import io.restassured.response.Response;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.math3.ml.neuralnet.Network;
import static com.kjj.qa.config.BasicConfig.*;
......@@ -12,11 +8,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.kjj.qa.config.BasicConfig.*;
import static io.restassured.RestAssured.given;
public class ManagerUtil {
private static final NetworkUtil network = NetworkUtil.getInstance();
public class ManagerUtils {
private static final NetworkUtils network = NetworkUtils.getInstance();
private static int PROMOTION_CODE = 398;
// 登录管理后台
......@@ -122,7 +115,7 @@ public class ManagerUtil {
long deadline = response.jsonPath().getLong("data.deadline");
deadline = (deadline - System.currentTimeMillis()) / (1000*60*60*24); //到期时间
// 修改截止日期
// 检测日期是否快到期,若到期修改截止日期
if (deadline < 5)
{
modifyPromotionCode(0);
......@@ -146,14 +139,10 @@ public class ManagerUtil {
}
public static void modifyPromotionCode(int addNum){
Map<String, Object> params = new HashMap<String, Object>();
params.put("addNum", Math.max(addNum, 0)); // 如果addNum > 0,则返回大的那个值
params.put("startTime",System.currentTimeMillis());
params.put("deadline",System.currentTimeMillis() + 1000*60*60*24*30L);
params.put("addNum",addNum);
params.put("city","杭州");
params.put("codeTotal",200);
params.put("comboId","1");
......@@ -165,7 +154,6 @@ public class ManagerUtil {
params.put("userVersion",2);
Response response = network.postResponse(params,MANAGER_PROMOTIONBATCHMODIFY);
response.body().prettyPrint();
}
......
......@@ -7,11 +7,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MysqlUtil {
public class MysqlUtils {
private static final String PREFIX = "dbseccode";
private static final String secret = "CNxgrtFG2nYQUfu";
private static Map<String,MysqlUtil> pool=new HashMap<>();
private static Map<String, MysqlUtils> pool=new HashMap<>();
//数据库用户名
private String USERNAME;// = "root";
//数据库密码
......@@ -24,11 +24,11 @@ public class MysqlUtil {
private PreparedStatement pstmt;
private ResultSet resultSet;
private MysqlUtil(String username,String password,String url){
private MysqlUtils(String username, String password, String url){
USERNAME = username;
PASSWORD = decode(password);
URL = url;
MysqlUtil mu = pool.get(url);
MysqlUtils mu = pool.get(url);
if(mu!=null){
System.out.println("--------exists");
connection = mu.connection;
......@@ -57,7 +57,7 @@ public class MysqlUtil {
* @param port 端口号
* @param databaseName 数据库名
*/
public MysqlUtil(String username,String password,String ip,String port,String databaseName){
public MysqlUtils(String username, String password, String ip, String port, String databaseName){
this(username,password,"jdbc:mysql://"+ip+":"+port+"/"+databaseName);
}
......@@ -65,12 +65,12 @@ public class MysqlUtil {
* 阿里云数据库连接
* @param databaseName 数据库名字
*/
public MysqlUtil(String databaseName){
public MysqlUtils(String databaseName){
this("tuia_test","dbseccode2CJMouQ2xyuEXnhe4vBzGtrDpaDbuK8Lt","47.111.157.152","3306",databaseName);
}
public static MysqlUtil mysqlDuiba(String databaseName){
return new MysqlUtil("tuia_test","dbseccode2CJMouQ2xyuEXnhe4vGtrDpavyDbuK8Lt","47.111.157.152","3306",databaseName);
public static MysqlUtils mysqlDuiba(String databaseName){
return new MysqlUtils("tuia_test","dbseccode2CJMouQ2xyuEXnhe4vGtrDpavyDbuK8Lt","47.111.157.152","3306",databaseName);
}
/**
......@@ -223,7 +223,7 @@ public class MysqlUtil {
//
// Map<String, Object> map = jdbc.findSimpleResult("select * from t_user where USER_ID='1'", null);
MysqlUtil jdbcUtils = new MysqlUtil("tuia_adver");
MysqlUtils jdbcUtils = new MysqlUtils("tuia_adver");
jdbcUtils.getConnection();
Map<String, Object> map = jdbcUtils.findSimpleResult("select * from account where company_name=?","对吧科技有限公司");
jdbcUtils.releaseConn();
......
......@@ -3,7 +3,6 @@ import static com.kjj.qa.config.BasicConfig.*;
import static io.restassured.RestAssured.*;
import com.alibaba.fastjson.JSONObject;
import io.restassured.http.Cookies;
import io.restassured.response.Response;
import java.io.File;
......@@ -12,7 +11,7 @@ import java.util.HashMap;
import java.util.Map;
public class NetworkUtil {
public class NetworkUtils {
// 代理人的 cookies和headers
public Map<String, Object> agentCookies = new HashMap<String, Object>();
......@@ -32,10 +31,10 @@ public class NetworkUtil {
public Map<String, Object> getDingTalkHeaders() { return dingTalkHeaders; }
public void setDingTalkHeaders(Map<String, Object> dingTalkHeaders) { this.dingTalkHeaders = dingTalkHeaders; }
private volatile static NetworkUtil network;
private volatile static NetworkUtils network;
// 构造函数 初始化tku、content-type
private NetworkUtil (){
private NetworkUtils(){
//cookies中的tku
agentCookies.put("tku",AGENT_TKU);
//json类型的headers
......@@ -50,11 +49,11 @@ public class NetworkUtil {
//通过设置同步代码块,使用DCL双检查锁机制
//使用双检查锁机制成功的解决了单例模式的懒汉实现的线程不安全问题和效率问题
//DCL 也是大多数多线程结合单例模式使用的解决方案
public static NetworkUtil getInstance() {
public static NetworkUtils getInstance() {
if (network == null) {
synchronized (NetworkUtil.class) {
synchronized (NetworkUtils.class) {
if (network == null) {
network = new NetworkUtil();
network = new NetworkUtils();
}
}
}
......
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