提交 1a9d1e19 编写于 作者: C Captain.B

refactor: 单接口调试处理mock数据

上级 32ba381a
......@@ -30,11 +30,12 @@ public class JmeterDocumentParser {
private final static String ELEMENT_PROP = "elementProp";
public static byte[] parse(byte[] source) {
final InputSource inputSource = new InputSource(new ByteArrayInputStream(source));
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
try (
ByteArrayInputStream byteStream = new ByteArrayInputStream(source)
) {
InputSource inputSource = new InputSource(byteStream);
DocumentBuilder docBuilder = factory.newDocumentBuilder();
final Document document = docBuilder.parse(inputSource);
final Element jmeterTestPlan = document.getDocumentElement();
......@@ -157,7 +158,6 @@ public class JmeterDocumentParser {
break;
case "Argument.value":
String textContent = ele.getTextContent();
System.out.println(textContent);
ele.setTextContent(ScriptEngineUtils.calculate(textContent));
break;
default:
......
......@@ -344,7 +344,10 @@ public class APITestService {
InputStream is = null;
try {
is = new ByteArrayInputStream(file.getBytes());
byte[] bytes = file.getBytes();
// 解析 xml 处理 mock 数据
bytes = JmeterDocumentParser.parse(bytes);
is = new ByteArrayInputStream(bytes);
} catch (IOException e) {
LogUtil.error(e);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册