fix(性能测试): 修复性能测试输出jmx格式化的问题

--bug=1010141 --user=刘瑞斌 [性能测试]github#10263性能测试引用自动化场景或者 场景转性能,会
格式化前后置脚本,如果脚本中有注释的话,格式化后 换行 导致脚本报错
https://www.tapd.cn/55049933/s/1101654

Closes #10263
This commit is contained in:
CaptainB 2022-02-08 12:26:01 +08:00 committed by 刘瑞斌
parent 1e3d08663b
commit 82da159c12
1 changed files with 3 additions and 19 deletions

View File

@ -1,20 +1,16 @@
package io.metersphere.performance.parse;
import io.metersphere.commons.constants.FileType;
import io.metersphere.commons.utils.LogUtil;
import io.metersphere.performance.parse.xml.reader.JmeterDocumentParser;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.XMLFilterImpl;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
public class EngineSourceParserFactory {
public static final boolean IS_TRANS = true;
@ -39,20 +35,8 @@ public class EngineSourceParserFactory {
}
public static byte[] getBytes(Document document) throws Exception {
OutputFormat format = OutputFormat.createCompactFormat();
try (
ByteArrayOutputStream out = new ByteArrayOutputStream();
) {
XMLWriter xw = new XMLWriter(out, format);
xw.setEscapeText(IS_TRANS);
xw.write(document);
xw.flush();
xw.close();
return out.toByteArray();
} catch (IOException e) {
LogUtil.error(e);
}
return new byte[0];
// todo 格式化代码会导致前后置脚本缩进有问题先使用基本方式
return document.asXML().getBytes(StandardCharsets.UTF_8);
}
public static XMLFilterImpl getFilter() {