Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95b9a1b31d | ||
|
|
ff3d3296dc | ||
|
|
3c0c559a9b | ||
|
|
6eab0afc65 |
@@ -17,6 +17,37 @@
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.houbb</groupId>
|
||||
<artifactId>junitperf</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
<!--工行SDK-->
|
||||
<dependency>
|
||||
<groupId>com.icbc</groupId>
|
||||
<artifactId>icbc-api-sdk-cop-io</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.icbc</groupId>
|
||||
<artifactId>icbc-api-sdk-cop</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.icbc</groupId>
|
||||
<artifactId>icbc-ca</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.icbc</groupId>
|
||||
<artifactId>hsm-software-share</artifactId>
|
||||
<version>1.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.icbc</groupId>
|
||||
<artifactId>proguard</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
|
||||
@@ -37,29 +37,29 @@ public class DataFactory {
|
||||
|
||||
ArrayList list = new ArrayList(totalCount);
|
||||
|
||||
String[] amounts = newAmounts(totalCount,totalAmount.multiply(new BigDecimal("100.00")).toBigInteger().intValue(),1);
|
||||
String[] amounts = randomAmounts(totalCount,totalAmount.multiply(new BigDecimal("100.00")).toBigInteger().intValue(),1);
|
||||
|
||||
for(int i=0;i<totalCount;i++) {
|
||||
|
||||
int rand = RandomUtil.randomInt(0,2);
|
||||
int rand = RandomUtil.randomInt(0,3);
|
||||
|
||||
switch (rand)
|
||||
{
|
||||
/** 招行测试数据 */
|
||||
case 0: {
|
||||
Pair<String,String> card = pickCmbCardRandomly();
|
||||
list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(pickRefIdRandomly()).build());
|
||||
Pair<String,String> card = randomCmbCard();
|
||||
list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(randomRefId()).build());
|
||||
break;
|
||||
}
|
||||
/** 工行测试数据 */
|
||||
case 1: {
|
||||
Pair<String,String> card = pickIcbcCardRandomly();
|
||||
list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(pickRefIdRandomly()).build());
|
||||
Pair<String,String> card = randomIcbcCard();
|
||||
list.add(RequestDiskRow.builder().acctName(card.getValue()).acctNo(card.getKey()).amount(amounts[i]).refId(randomRefId()).build());
|
||||
break;
|
||||
}
|
||||
/** 假数据 */
|
||||
default: {
|
||||
list.add(RequestDiskRow.builder().acctName(newCardName()).acctNo(pickCardNoRandomly()).amount(amounts[i]).refId(pickRefIdRandomly()).build());
|
||||
list.add(RequestDiskRow.builder().acctName(randomCardName()).acctNo(randomCardNo()).amount(amounts[i]).refId(randomRefId()).build());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -72,11 +72,11 @@ public class DataFactory {
|
||||
* 生成工行 & 招行测试用的卡号 + 姓名
|
||||
* @return
|
||||
*/
|
||||
public static final Pair<String,String> pickCmbCardRandomly(){
|
||||
public static final Pair<String,String> randomCmbCard(){
|
||||
return cmbCards.get(RandomUtil.randomInt(0,cmbCards.size()));
|
||||
}
|
||||
|
||||
public static final Pair<String,String> pickIcbcCardRandomly(){
|
||||
public static final Pair<String,String> randomIcbcCard(){
|
||||
return icbcCards.get(RandomUtil.randomInt(0,icbcCards.size()));
|
||||
}
|
||||
|
||||
@@ -97,16 +97,16 @@ public class DataFactory {
|
||||
add(new Pair<>("6214831150131511","吴极客"));
|
||||
}};
|
||||
|
||||
public static final String pickCardNoRandomly() {
|
||||
public static final String randomCardNo() {
|
||||
int index = random.nextInt(cards.length - 1);
|
||||
return cards[index];
|
||||
}
|
||||
|
||||
public static String pickRefIdRandomly() {
|
||||
public static String randomRefId() {
|
||||
return String.valueOf(IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
}
|
||||
|
||||
public static String newAmount()
|
||||
public static String randomAmount()
|
||||
{
|
||||
return String.valueOf(random.nextInt(500000000));
|
||||
}
|
||||
@@ -116,10 +116,10 @@ public class DataFactory {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static String pickPostscriptRandomly
|
||||
public static String randomPostscript
|
||||
() { return postscripts[random.nextInt(postscripts.length - 1)]; }
|
||||
|
||||
public static String pickCustomerIdRandomly() throws SQLException {
|
||||
public static String randomCustomerId() throws SQLException {
|
||||
String customerId = "";
|
||||
|
||||
List<Entity> rs = Db.use().query("SELECT CUSTOMER_ID FROM CAPCUSINF WHERE ENABLED = 'Y'",new HashMap());
|
||||
@@ -135,7 +135,7 @@ public class DataFactory {
|
||||
}
|
||||
|
||||
|
||||
public static String pickTitleIdRandomly() throws SQLException {
|
||||
public static String randomTitleId() throws SQLException {
|
||||
String titleId = "";
|
||||
|
||||
List<Entity> rs = null;
|
||||
@@ -267,7 +267,127 @@ public class DataFactory {
|
||||
"4367482505987361",
|
||||
"6222517213696554",
|
||||
"5588097736091856",
|
||||
"5274144695527717"};
|
||||
"5274144695527717",
|
||||
"4910324530476626",
|
||||
"5488446170650258",
|
||||
"5488442740532084",
|
||||
"4518102560628993",
|
||||
"5456199852397627",
|
||||
"6227506407600097",
|
||||
"5459473118226681",
|
||||
"4910325480725128",
|
||||
"5482595130517811",
|
||||
"4033611707045883",
|
||||
"4391885884392088",
|
||||
"6227509163790508",
|
||||
"4580717818338450",
|
||||
"4391886976436544",
|
||||
"4381255936183772",
|
||||
"5201521665038304",
|
||||
"4270104709788926",
|
||||
"5583604870359000",
|
||||
"4518042709565666",
|
||||
"4367688821593655",
|
||||
"4381266120937766",
|
||||
"5240478346281634",
|
||||
"4270206095387120",
|
||||
"5525994470729186",
|
||||
"4910325008575443",
|
||||
"6223497736660958",
|
||||
"5488442745158430",
|
||||
"6225004011817424",
|
||||
"5378303173084014",
|
||||
"5309807403661304",
|
||||
"5183643423875827",
|
||||
"4518105242408932",
|
||||
"4392257527193282",
|
||||
"4270298264677928",
|
||||
"6225007398018128",
|
||||
"6223478363752094",
|
||||
"4910404668267763",
|
||||
"5289318464854014",
|
||||
"4518100090689865",
|
||||
"5459475410983794",
|
||||
"9988002446337274",
|
||||
"6226305549870036",
|
||||
"9558824121303242",
|
||||
"6223057225815347",
|
||||
"4386005612410287",
|
||||
"6226222287684224",
|
||||
"1030000726548105507",
|
||||
"6223165274910453",
|
||||
"6223234755426774575",
|
||||
"6226921993916990",
|
||||
"1857203180318356",
|
||||
"8880008609586525",
|
||||
"6227006170404166009",
|
||||
"6222803729013494452",
|
||||
"6225980984265685",
|
||||
"6223486817999005",
|
||||
"622292384950941472",
|
||||
"6226154433191350",
|
||||
"6226308609744927",
|
||||
"6223252686599965",
|
||||
"6226989235246864",
|
||||
"6226315364035805",
|
||||
"6226924354312957",
|
||||
"622331121493374784",
|
||||
"4427293742040759",
|
||||
"6225803180076799",
|
||||
"6223242736822750591",
|
||||
"9558809266517375",
|
||||
"4336700211358470",
|
||||
"6222615188715415091",
|
||||
"6223123335184501",
|
||||
"6224919916945650",
|
||||
"6223285936394507787",
|
||||
"9558828996633930",
|
||||
"4340612371147193",
|
||||
"8701003818530478",
|
||||
"6223410074092270",
|
||||
"4427299996820101",
|
||||
"6227005520984333778",
|
||||
"8705007731518151",
|
||||
"6223392026205400",
|
||||
"6222607337440160627",
|
||||
"4026583347903103",
|
||||
"6225800938955811",
|
||||
"8701007476924006",
|
||||
"6224925409053324",
|
||||
"6226307585993920",
|
||||
"5264109147096266",
|
||||
"6223399787696123",
|
||||
"6226602718801911",
|
||||
"438589583329019216",
|
||||
"6226904359022603",
|
||||
"4340616703135248",
|
||||
"4026581250647808",
|
||||
"4427295109773880",
|
||||
"6225099304110017543",
|
||||
"6223333453435649",
|
||||
"94005652586006708",
|
||||
"6226601557827409",
|
||||
"6224985974044573702",
|
||||
"6223438112672689962",
|
||||
"6226818020801824298",
|
||||
"6226920625022441",
|
||||
"6223450061115365578",
|
||||
"6226925495683222",
|
||||
"6223127247481301",
|
||||
"6224987917149806624",
|
||||
"6223351946631319",
|
||||
"62231096270216434",
|
||||
"6227002362389092029",
|
||||
"62230850883263402",
|
||||
"6226170530609870",
|
||||
"9558811049452169",
|
||||
"6225096515560436494",
|
||||
"6223169645545410",
|
||||
"6223129466891145",
|
||||
"1030001094519248767",
|
||||
"62234072298103885",
|
||||
"6223129638985536"
|
||||
};
|
||||
|
||||
private final static String[] Surname = {"赵", "钱", "孙", "李", "周", "吴", "郑", "王", "冯", "陈", "褚", "卫", "蒋", "沈", "韩", "杨", "朱", "秦", "尤", "许",
|
||||
"何", "吕", "施", "张", "孔", "曹", "严", "华", "金", "魏", "陶", "姜", "戚", "谢", "邹", "喻", "柏", "水", "窦", "章", "云", "苏", "潘", "葛", "奚", "范", "彭", "郎",
|
||||
@@ -279,7 +399,7 @@ public class DataFactory {
|
||||
private final static String boy = "伟刚勇毅俊峰强军平保东文辉力明永健世广志义兴良海山仁波宁贵福生龙元全国胜学祥才发武新利清飞彬富顺信子杰涛昌成康星光天达安岩中茂进林有坚和彪博诚先敬震振壮会思群豪心邦承乐绍功松善厚庆磊民友裕河哲江超浩亮政谦亨奇固之轮翰朗伯宏言若鸣朋斌梁栋维启克伦翔旭鹏泽晨辰士以建家致树炎德行时泰盛雄琛钧冠策腾楠榕风航弘";
|
||||
|
||||
|
||||
private static final String newCardName()
|
||||
private static final String randomCardName()
|
||||
{
|
||||
int index = random.nextInt(Surname.length - 1);
|
||||
String name = Surname[index]; //获得一个随机的姓氏
|
||||
@@ -309,7 +429,7 @@ public class DataFactory {
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String[] newAmounts(int count, BigDecimal totalAmount)
|
||||
public static String[] randomAmounts(int count, BigDecimal totalAmount)
|
||||
{
|
||||
String[] amounts = new String[count];
|
||||
|
||||
@@ -325,7 +445,7 @@ public class DataFactory {
|
||||
* @param minMoney 最小金额
|
||||
* @return
|
||||
*/
|
||||
private static String[] newAmounts(int num,long totalMoney,long minMoney){
|
||||
private static String[] randomAmounts(int num, long totalMoney, long minMoney){
|
||||
String[] amounts = new String[num];
|
||||
long[] each = new long[num];
|
||||
for(int i=0;i<num-1;i++){
|
||||
|
||||
@@ -20,8 +20,10 @@ public class FastDFS {
|
||||
|
||||
private static WageFileHandle wageFileHandle = new WageFileHandle();
|
||||
|
||||
private static String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0IiwiaWF0IjoxNjExNjU5MTYzLCJleHAiOjE2MTQyNTExNjN9.57I2zXMW_rgYJpoJf984NyJ019rRdyuCkgH8fluLaIbspHWp7tUjz570pptiHXjhCiHjpA5bfRgVbSC7HL_FvQ";
|
||||
private static String url = "http://192.168.17.4:8094";
|
||||
// private static String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0IiwiaWF0IjoxNjExNjU5MTYzLCJleHAiOjE2MTQyNTExNjN9.57I2zXMW_rgYJpoJf984NyJ019rRdyuCkgH8fluLaIbspHWp7tUjz570pptiHXjhCiHjpA5bfRgVbSC7HL_FvQ";
|
||||
private static String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtdXJvbmciLCJpYXQiOjE2MjU3MjI0OTUsImV4cCI6MTYyODMxNDQ5NX0.Qm3BzjxHWUdx5GPczYf8eRDZWbMcTGXs3VM5EnEm2fXm7BVW7FO6hsP8eSs-WVifJfmV-jhsgXMsMnY0q6qdng";
|
||||
// private static String url = "http://192.168.17.4:8094";
|
||||
private static String url = "http://172.17.11.90";
|
||||
private static String user = "test";
|
||||
private static String password="9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
|
||||
|
||||
@@ -33,7 +35,7 @@ public class FastDFS {
|
||||
|
||||
WageFileHandle wageFileHandle = new WageFileHandle();
|
||||
|
||||
token = wageFileHandle.getToken(url,user,password);
|
||||
// token = wageFileHandle.getToken(url,user,password);
|
||||
|
||||
Map result = wageFileHandle.uploadFile(token,url,file);
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ public class DiskApplyRequestTest {
|
||||
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(DataFactory.pickCustomerIdRandomly())
|
||||
.titleId(DataFactory.pickTitleIdRandomly())
|
||||
.customerId(DataFactory.randomCustomerId())
|
||||
.titleId(DataFactory.randomTitleId())
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
File file = DiskTool.newSimpleDiskFile(request.getCustomerId(),request.getTitleId(),"代发工资",10,new BigDecimal(50000.00));
|
||||
|
||||
@@ -26,8 +26,8 @@ public class DiskApplyTest {
|
||||
DiskApplyRequest body = DiskApplyRequest.builder()
|
||||
.diskNo("lakjdfklasjdklfjaslkdf")
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(DataFactory.pickCustomerIdRandomly())
|
||||
.titleId(DataFactory.pickTitleIdRandomly())
|
||||
.customerId(DataFactory.randomCustomerId())
|
||||
.titleId(DataFactory.randomTitleId())
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
Api<DiskApplyRequest> request = new Api<>("diskApply",body);
|
||||
|
||||
@@ -95,8 +95,8 @@ public class MixedTest {
|
||||
public DiskInfo diskApplySimpleTest() throws Exception {
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(DataFactory.pickCustomerIdRandomly())
|
||||
.titleId(DataFactory.pickTitleIdRandomly())
|
||||
.customerId(DataFactory.randomCustomerId())
|
||||
.titleId(DataFactory.randomTitleId())
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
int totalCount = RandomUtil.randomInt(0,3000);
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.TimeInterval;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
import com.github.houbb.junitperf.core.annotation.JunitPerfConfig;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskApplyRequest;
|
||||
import ctg.entity.api.DiskResultRequest;
|
||||
import ctg.tool.DataFactory;
|
||||
import ctg.tool.DiskTool;
|
||||
import ctg.tool.FastDFS;
|
||||
import entity.DiskInfo;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.model.enums.AesKeyStrength;
|
||||
import net.lingala.zip4j.model.enums.EncryptionMethod;
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.RepeatedTest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 下午4:10 2021/2/24
|
||||
*/
|
||||
@Slf4j
|
||||
public class StressTest {
|
||||
private static String baseURL;
|
||||
private static String secretKey;
|
||||
private static String zipPassword;
|
||||
// private final static String propFile = "prop.setting.uat";
|
||||
// private final static String propFile = "prop.setting.sit";
|
||||
private final static String propFile = "prop.setting.stress";
|
||||
private final TimeInterval timer = DateUtil.timer();
|
||||
|
||||
@BeforeAll
|
||||
static void initProp() {
|
||||
Setting setting = new Setting(propFile);
|
||||
baseURL = setting.getStr("baseURL");
|
||||
secretKey = setting.getStr("secretKey");
|
||||
zipPassword = setting.getStr("zipPassword");
|
||||
}
|
||||
|
||||
/** 压测入口 */
|
||||
// @JunitPerfConfig(threads = 1, warmUp = 0 , duration = 3000 )
|
||||
@JunitPerfConfig(threads = 50, warmUp = 3000 , duration = 1000 * 60 * 30)
|
||||
public void stressTest() {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
log.info("{} started",threadName);
|
||||
timer.start(threadName);
|
||||
DiskInfo disk;
|
||||
try{
|
||||
/** 生成测试批次 */
|
||||
String customerId = DataFactory.randomCustomerId();
|
||||
String titleId = DataFactory.randomTitleId();
|
||||
int totalCount = RandomUtil.randomInt(2000,10000);
|
||||
BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(5000),new BigDecimal(1000000));
|
||||
/** 新建文件 */
|
||||
File file = DiskTool.newSimpleDiskFile(customerId,titleId,"代发工资",totalCount,totalAmount);
|
||||
disk = diskApply(customerId,titleId,file);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
DiskInfo result = null;
|
||||
|
||||
/* 批次为空(表示还在入库中),批次未终态(U:预计 0:成功 1:处理中) */
|
||||
while(result == null || StrUtil.equalsAny(result.getDiskSts(),"U","0","1")) {
|
||||
ThreadUtil.sleep(3000);
|
||||
result = diskResult(disk.getApplyDate(),disk.getDiskNo());
|
||||
}
|
||||
log.info("{} is completed, elapsed time:{}, disk:{}",threadName,timer.intervalSecond(threadName),result);
|
||||
}
|
||||
|
||||
/* 查询具体某一批次的结果 */
|
||||
@Test
|
||||
public void resultTest() throws Exception {
|
||||
DiskInfo disk = null;
|
||||
try {
|
||||
disk = diskResult("20210607","3b07422666b44315ac62b8bc55b207c2");
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error("error:{}",e.getMessage());
|
||||
return;
|
||||
}
|
||||
log.info("disk:{}",disk);
|
||||
}
|
||||
|
||||
/* 结果查询 */
|
||||
@SneakyThrows
|
||||
public DiskInfo diskResult(String applyDate,String diskNo) {
|
||||
log.info("applyDate:{} diskNo:{}",applyDate,diskNo);
|
||||
DiskResultRequest request = DiskResultRequest.builder().applyDate(applyDate).diskNo(diskNo).build();
|
||||
DiskInfo disk = new DiskInfo(applyDate,diskNo);
|
||||
Api<DiskResultRequest> api = new Api<>("diskResult",request);
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
log.info("[{}]:[{}]",respCode,respMessage);
|
||||
if(respCode.equals("00")) {
|
||||
disk.setDiskSts((String) XmlUtil.getByXPath("//root/body/diskSts",doc, XPathConstants.STRING));
|
||||
disk.setDiskMessage((String) XmlUtil.getByXPath("//root/body/diskMessage",doc, XPathConstants.STRING));
|
||||
disk.setLastDate((String) XmlUtil.getByXPath("//root/body/lastDate",doc, XPathConstants.STRING));
|
||||
disk.setLastTime((String) XmlUtil.getByXPath("//root/body/lastTime",doc, XPathConstants.STRING));
|
||||
disk.setTotalCount((String) XmlUtil.getByXPath("//root/body/totalCount",doc, XPathConstants.STRING));
|
||||
disk.setTotalAmount((String) XmlUtil.getByXPath("//root/body/totalAmount",doc, XPathConstants.STRING));
|
||||
disk.setFilePath((String) XmlUtil.getByXPath("//root/body/filePath",doc, XPathConstants.STRING));
|
||||
disk.setSuccAmount((String) XmlUtil.getByXPath("//root/body/succAmount",doc, XPathConstants.STRING));
|
||||
disk.setSuccCount((String) XmlUtil.getByXPath("//root/body/succCount",doc, XPathConstants.STRING));
|
||||
disk.setFailAmount((String) XmlUtil.getByXPath("//root/body/failAmount",doc, XPathConstants.STRING));
|
||||
disk.setFailCount((String) XmlUtil.getByXPath("//root/body/failCount",doc, XPathConstants.STRING));
|
||||
disk.setMd5((String) XmlUtil.getByXPath("//root/body/md5",doc, XPathConstants.STRING));
|
||||
return disk;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/* 送盘 */
|
||||
public DiskInfo diskApply(String customerId,String titleId,File file) throws Exception {
|
||||
DiskApplyRequest request = DiskApplyRequest.builder()
|
||||
.applyDate(DateUtil.format(new Date(),"YYYYMMdd"))
|
||||
.customerId(customerId)
|
||||
.titleId(titleId)
|
||||
.diskDesc("代发工资").build();
|
||||
|
||||
request.setDiskNo(file.getName());
|
||||
|
||||
log.info("disk:{}", file.getAbsolutePath());
|
||||
|
||||
/** 文件压缩 */
|
||||
if(!file.exists() || !file.isFile()) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
|
||||
File disk = new File(file.getParent() + "/" + file.getName() + ".zip");
|
||||
|
||||
if ("".equals(zipPassword)) {
|
||||
ZipParameters zipParameters = new ZipParameters();
|
||||
zipParameters.setEncryptFiles(true);
|
||||
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
|
||||
zipParameters.setAesKeyStrength(AesKeyStrength.KEY_STRENGTH_256);
|
||||
new ZipFile(disk, zipPassword.toCharArray()).addFile(file, zipParameters);
|
||||
}
|
||||
else {
|
||||
new ZipFile(disk).addFile(file);
|
||||
}
|
||||
|
||||
/** 上传文件 */
|
||||
String fid = FastDFS.upload(disk);
|
||||
log.info("fid:{}",fid);
|
||||
request.setFilePath(fid);
|
||||
request.setFileVersion("");
|
||||
request.setFilePath(fid);
|
||||
request.setMd5(SecureUtil.md5(disk));
|
||||
|
||||
/** 送盘请求 */
|
||||
Api<DiskApplyRequest> api = new Api<>("diskApply",request);
|
||||
|
||||
log.info("diskApply.request:[{}]",api.toData());
|
||||
String response = HttpUtil.createPost(baseURL).header("Signature",api.signature()).body(api.toData()).setConnectionTimeout(3000).timeout(3000).execute().body();
|
||||
log.info("diskApply.response:[{}]",response);
|
||||
|
||||
Document doc = XmlUtil.readXML(response);
|
||||
|
||||
String respCode = (String) XmlUtil.getByXPath("//root/head/respCode",doc, XPathConstants.STRING);
|
||||
String respMessage = (String) XmlUtil.getByXPath("//root/head/respMessage",doc, XPathConstants.STRING);
|
||||
|
||||
if(!"00".equals(respCode)) {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
return DiskInfo.builder().diskNo(request.getDiskNo()).applyDate(request.getApplyDate()).build();
|
||||
}
|
||||
|
||||
@JunitPerfConfig(threads = 100, duration = 6000)
|
||||
public void perfTest() {
|
||||
String threadName = Thread.currentThread().getName();
|
||||
timer.start(threadName);
|
||||
log.info("{} is started, start time:{}",threadName,DateUtil.now());
|
||||
ThreadUtil.safeSleep(3000);
|
||||
Assert.assertTrue(false);
|
||||
log.info("{} is end, elapsed time:{}",threadName,timer.intervalSecond(threadName));
|
||||
}
|
||||
}
|
||||
@@ -56,8 +56,8 @@ public class UatTest {
|
||||
DiskInfo disk;
|
||||
try{
|
||||
/** 生成测试批次 */
|
||||
String customerId = DataFactory.pickCustomerIdRandomly();
|
||||
String titleId = DataFactory.pickTitleIdRandomly();
|
||||
String customerId = DataFactory.randomCustomerId();
|
||||
String titleId = DataFactory.randomTitleId();
|
||||
int totalCount = RandomUtil.randomInt(0,3000);
|
||||
BigDecimal totalAmount = RandomUtil.randomBigDecimal(new BigDecimal(1),new BigDecimal(1000000));
|
||||
/** 新建文件 */
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## db.setting文件
|
||||
|
||||
url = jdbc:oracle:thin:@172.17.30.91:1521:mrdb
|
||||
user = mr_pay
|
||||
pass = mr_pay
|
||||
url = jdbc:oracle:thin:@192.168.3.191:1521:bidb
|
||||
user = MURONG_UAT2
|
||||
pass = MURONG_UAT2
|
||||
|
||||
## 可选配置
|
||||
# 是否在日志中显示执行的SQL
|
||||
|
||||
@@ -80,7 +80,8 @@
|
||||
|
||||
|
||||
|
||||
<root level="INFO">
|
||||
<!-- <root level="INFO">-->
|
||||
<root level="ERROR">
|
||||
<appender-ref ref="STDOUT" />
|
||||
<!-- <appender-ref ref="FILE" />-->
|
||||
<!-- <appender-ref ref="FILE-error" />-->
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
baseURL= http://172.17.20.91:9998/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
@@ -0,0 +1,4 @@
|
||||
baseURL= http://192.168.8.41/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
baseURL= http://192.168.8.41/api
|
||||
secretKey = HelloWorld
|
||||
zipPassword = 1234567
|
||||
Reference in New Issue
Block a user