Browse Source

对于不同的API接口协议(如REST、SOAP、XML-RPC等),测试工具可提供对应的协议测试工具,

master
zhouyl 1 year ago
parent
commit
d751dca200
  1. 2
      tp-admin/src/main/resources/application.yml
  2. 35
      tp-functional/src/main/java/com/inscloudtech/functional/controller/FuncCarApiController.java

2
tp-admin/src/main/resources/application.yml

@ -6,7 +6,7 @@ testplatform:
version: ${test-platform-service.version}
# 版权年份
# 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
profile: /app/testP/uploadPath
profile: /app/testp/uploadPath
copyrightYear: 2024
# 缓存懒加载
cacheLazy: false

35
tp-functional/src/main/java/com/inscloudtech/functional/controller/FuncCarApiController.java

@ -1,7 +1,6 @@
package com.inscloudtech.functional.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.inscloudtech.common.annotation.Log;
import com.inscloudtech.common.annotation.RepeatSubmit;
import com.inscloudtech.common.config.ProjectConfig;
import com.inscloudtech.common.core.controller.BaseController;
@ -9,7 +8,6 @@ import com.inscloudtech.common.core.domain.PageQuery;
import com.inscloudtech.common.core.domain.R;
import com.inscloudtech.common.core.page.TableDataInfo;
import com.inscloudtech.common.core.validate.AddGroup;
import com.inscloudtech.common.enums.BusinessType;
import com.inscloudtech.common.utils.StringUtils;
import com.inscloudtech.common.utils.file.FileUtils;
import com.inscloudtech.functional.domain.FuncCarApi;
@ -39,6 +37,8 @@ public class FuncCarApiController extends BaseController {
private final ProjectConfig projectConfig;
private final static String JMETER_FILE_NAME = "apache-jmeter.zip";
/**
* 查询API接口在不同操作系统不同浏览器不同设备以及不同网络环境下的兼容性测试结果列表
*/
@ -64,23 +64,7 @@ public class FuncCarApiController extends BaseController {
*/
@GetMapping("/jmDownload")
public void jmDownload(HttpServletResponse response, HttpServletRequest request) {
String fileName = "apache-jmeter-5.6.3.zip";
try {
if (!FileUtils.checkAllowDownload(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = projectConfig.getDownloadPath() + fileName;
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
// if (delete) {
// FileUtils.deleteFile(filePath);
// }
} catch (Exception e) {
e.printStackTrace();
}
doDownLoad(JMETER_FILE_NAME,response);
}
/**
@ -98,13 +82,16 @@ public class FuncCarApiController extends BaseController {
*/
@GetMapping("/protocolToolDownload")
public void protocolToolDownload(HttpServletResponse response, HttpServletRequest request) {
String fileName = "apache-jmeter-5.6.3.zip";
doDownLoad(JMETER_FILE_NAME,response);
}
void doDownLoad(String filename,HttpServletResponse response){
try {
if (!FileUtils.checkAllowDownload(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
if (!FileUtils.checkAllowDownload(filename)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", filename));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = projectConfig.getDownloadPath() + fileName;
String realFileName = System.currentTimeMillis() + filename.substring(filename.indexOf("_") + 1);
String filePath = projectConfig.getDownloadPath() + filename;
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);

Loading…
Cancel
Save