fix(接口自动化): 修复jmx文件导入解析错误 #1004805

This commit is contained in:
fit2-zhao 2021-07-05 17:01:49 +08:00 committed by fit2-zhao
parent c2a9911138
commit a3cf691518
1 changed files with 5 additions and 1 deletions

View File

@ -240,7 +240,9 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
Body body = new Body();
body.init();
body.initKvs();
body.getKvs().clear();
body.initBinary();
body.getBinary().clear();
samplerProxy.setBody(body);
if (source != null && source.getHTTPFiles().length > 0) {
samplerProxy.getBody().initBinary();
@ -278,7 +280,7 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
samplerProxy.getBody().setRaw(v);
});
samplerProxy.getBody().initKvs();
} else if (StringUtils.isNotEmpty(bodyType)) {
} else if (StringUtils.isNotEmpty(bodyType) || (source.getMethod().equalsIgnoreCase("POST") && source.getArguments().getArgumentsAsMap().size() > 0)) {
samplerProxy.getBody().setType(Body.WWW_FROM);
source.getArguments().getArgumentsAsMap().forEach((k, v) -> {
KeyValue keyValue = new KeyValue(k, v);
@ -309,6 +311,8 @@ public class MsJmeterParser extends ApiImportAbstractParser<ScenarioImport> {
}
samplerProxy.setId(UUID.randomUUID().toString());
samplerProxy.setType("HTTPSamplerProxy");
body.getKvs().add(new KeyValue());
body.getBinary().add(new KeyValue());
} catch (Exception e) {
e.printStackTrace();