fix(接口测试): 修复包含excel文件的请求执行失败问题
--bug=1015442 --user=赵勇 【接口测试】执行带excel文件的接口会报错 https://www.tapd.cn/55049933/s/1213910
This commit is contained in:
parent
4fdaf95a8c
commit
6cf6579601
|
@ -210,7 +210,7 @@
|
|||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>2.2.10</version>
|
||||
<version>3.1.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package io.metersphere.api.controller;
|
||||
|
||||
import io.metersphere.api.jmeter.JMeterThreadUtils;
|
||||
import io.metersphere.api.service.ApiJmeterFileService;
|
||||
import io.metersphere.api.service.ApiJMeterFileService;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -12,10 +12,10 @@ import java.util.UUID;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("/api/jmeter")
|
||||
public class ApiJmeterFileController {
|
||||
public class ApiJMeterFileController {
|
||||
|
||||
@Resource
|
||||
private ApiJmeterFileService apiJmeterFileService;
|
||||
private ApiJMeterFileService apiJmeterFileService;
|
||||
|
||||
@GetMapping("stop/{name}")
|
||||
public String stop(@PathVariable String name) {
|
|
@ -501,34 +501,27 @@ public class ESBParser extends EsbAbstractParser {
|
|||
|
||||
private String getCellValue(Cell cell) {
|
||||
String returnCellValue = "";
|
||||
int cellType = cell.getCellType();
|
||||
switch (cellType) {
|
||||
case Cell.CELL_TYPE_BLANK:
|
||||
returnCellValue = "";
|
||||
break;
|
||||
case Cell.CELL_TYPE_BOOLEAN:
|
||||
returnCellValue = String.valueOf(cell.getBooleanCellValue());
|
||||
break;
|
||||
case Cell.CELL_TYPE_ERROR:
|
||||
returnCellValue = "";
|
||||
break;
|
||||
case Cell.CELL_TYPE_NUMERIC:
|
||||
if (cell.getCellType() == CellType.BLANK) {
|
||||
returnCellValue = "";
|
||||
} else if (cell.getCellType() == CellType.BOOLEAN) {
|
||||
returnCellValue = String.valueOf(cell.getBooleanCellValue());
|
||||
} else if (cell.getCellType() == CellType.ERROR) {
|
||||
returnCellValue = "";
|
||||
} else if (cell.getCellType() == CellType.NUMERIC) {
|
||||
returnCellValue = getValueOfNumericCell(cell);
|
||||
} else if (cell.getCellType() == CellType.FORMULA) {
|
||||
try {
|
||||
returnCellValue = getValueOfNumericCell(cell);
|
||||
break;
|
||||
case Cell.CELL_TYPE_FORMULA:
|
||||
} catch (IllegalStateException e) {
|
||||
try {
|
||||
returnCellValue = getValueOfNumericCell(cell);
|
||||
} catch (IllegalStateException e) {
|
||||
try {
|
||||
returnCellValue = cell.getRichStringCellValue().toString();
|
||||
} catch (IllegalStateException e2) {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
returnCellValue = cell.getRichStringCellValue().toString();
|
||||
} catch (IllegalStateException e2) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
returnCellValue = cell.getRichStringCellValue().getString();
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
}
|
||||
} else {
|
||||
returnCellValue = cell.getRichStringCellValue().getString();
|
||||
}
|
||||
if (returnCellValue == null) {
|
||||
returnCellValue = "";
|
||||
|
|
|
@ -35,7 +35,7 @@ import java.util.zip.ZipEntry;
|
|||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
@Service
|
||||
public class ApiJmeterFileService {
|
||||
public class ApiJMeterFileService {
|
||||
@Resource
|
||||
private ApiCaseSerialService apiCaseSerialService;
|
||||
@Resource
|
||||
|
@ -123,7 +123,7 @@ public class ApiJmeterFileService {
|
|||
Map<String, byte[]> files = new HashMap<>();
|
||||
// 获取JAR
|
||||
Map<String, byte[]> jarFiles = this.getJar();
|
||||
if (!com.alibaba.excel.util.CollectionUtils.isEmpty(jarFiles)) {
|
||||
if (!MapUtils.isEmpty(jarFiles)) {
|
||||
for (String k : jarFiles.keySet()) {
|
||||
byte[] v = jarFiles.get(k);
|
||||
files.put(k, v);
|
||||
|
@ -136,7 +136,7 @@ public class ApiJmeterFileService {
|
|||
Map<String, byte[]> files = new HashMap<>();
|
||||
// 获取JAR
|
||||
Map<String, byte[]> jarFiles = this.getPlugJar();
|
||||
if (!com.alibaba.excel.util.CollectionUtils.isEmpty(jarFiles)) {
|
||||
if (!MapUtils.isEmpty(jarFiles)) {
|
||||
for (String k : jarFiles.keySet()) {
|
||||
byte[] v = jarFiles.get(k);
|
||||
files.put(k, v);
|
|
@ -4,7 +4,7 @@ package io.metersphere.performance.controller;
|
|||
import io.metersphere.commons.utils.WeakConcurrentHashMap;
|
||||
import io.metersphere.controller.handler.annotation.NoResultHolder;
|
||||
import io.metersphere.performance.dto.ZipDTO;
|
||||
import io.metersphere.performance.service.JmeterFileService;
|
||||
import io.metersphere.performance.service.JMeterFileService;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -20,9 +20,9 @@ import java.util.stream.Collectors;
|
|||
|
||||
@RestController
|
||||
@RequestMapping("jmeter")
|
||||
public class JmeterFileController {
|
||||
public class JMeterFileController {
|
||||
@Resource
|
||||
private JmeterFileService jmeterFileService;
|
||||
private JMeterFileService jmeterFileService;
|
||||
private final WeakConcurrentHashMap<String, List<Double>> readyMap = new WeakConcurrentHashMap<>(30 * 60 * 1000);// 默认保留30分钟
|
||||
|
||||
@GetMapping("ping")
|
|
@ -1,6 +1,5 @@
|
|||
package io.metersphere.performance.service;
|
||||
|
||||
import com.alibaba.excel.util.CollectionUtils;
|
||||
import io.metersphere.base.domain.LoadTestReportWithBLOBs;
|
||||
import io.metersphere.base.mapper.LoadTestReportMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper;
|
||||
|
@ -10,6 +9,7 @@ import io.metersphere.performance.dto.ZipDTO;
|
|||
import io.metersphere.performance.engine.EngineContext;
|
||||
import io.metersphere.performance.engine.EngineFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -23,7 +23,7 @@ import java.util.zip.ZipOutputStream;
|
|||
|
||||
// 非事务运行
|
||||
@Service
|
||||
public class JmeterFileService {
|
||||
public class JMeterFileService {
|
||||
@Resource
|
||||
private ExtLoadTestReportMapper extLoadTestReportMapper;
|
||||
@Resource
|
Loading…
Reference in New Issue