first commit
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package hro;
|
||||
|
||||
import cn.hutool.core.util.XmlUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import ctg.constant.PropConstants;
|
||||
import ctg.entity.api.Api;
|
||||
import ctg.entity.api.DiskResultRequest;
|
||||
import entity.DiskInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
/**
|
||||
* @Author: Alawn
|
||||
* @Description:
|
||||
* @Date: Create in 11:03 上午 2021/2/7
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class DiskResultTest {
|
||||
|
||||
@Test
|
||||
public void diskResultSimpleTest() throws Exception {
|
||||
String applyDate = "20200101";
|
||||
String diskNo = "jkljclkvjalksjdfkljalksdjf";
|
||||
|
||||
DiskResultRequest request = DiskResultRequest.builder().applyDate(applyDate).diskNo(diskNo).build();
|
||||
Api<DiskResultRequest> api = new Api<>("diskResult",request);
|
||||
String response = HttpUtil.createPost(PropConstants.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"))
|
||||
{
|
||||
DiskInfo disk = new DiskInfo();
|
||||
disk.setDiskNo(diskNo);
|
||||
disk.setApplyDate(applyDate);
|
||||
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));
|
||||
log.info("disk:{}",disk);
|
||||
}
|
||||
else {
|
||||
throw new Exception(respMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String keyFile = "~/Desktop/测试数据";
|
||||
FileInputStream fs = null;
|
||||
try {
|
||||
fs = new FileInputStream(keyFile);
|
||||
byte[] certBytes = new byte[fs.available()];
|
||||
fs.read(certBytes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally { // 通过finally释放io
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user