refactor(接口测试): 优化接口字段
This commit is contained in:
parent
65e9c45897
commit
d20f596363
|
@ -15,11 +15,25 @@ import java.util.LinkedList;
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
public abstract class AbstractMsTestElement implements MsTestElement {
|
public abstract class AbstractMsTestElement implements MsTestElement {
|
||||||
|
|
||||||
// 组件标签名称
|
/**
|
||||||
|
* 步骤ID(唯一)
|
||||||
|
*/
|
||||||
|
private String stepId;
|
||||||
|
/**
|
||||||
|
* 关联的资源ID(用例ID/接口ID/场景ID)等
|
||||||
|
*/
|
||||||
|
private String resourceId;
|
||||||
|
/**
|
||||||
|
* 组件标签名称
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
// 是否启用
|
|
||||||
private Boolean enable = true;
|
|
||||||
|
|
||||||
// 子组件
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
|
private Boolean enable = true;
|
||||||
|
/**
|
||||||
|
* 子组件
|
||||||
|
*/
|
||||||
private LinkedList<AbstractMsTestElement> children;
|
private LinkedList<AbstractMsTestElement> children;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class KeyValueParam {
|
public class KeyValueParam {
|
||||||
/**
|
|
||||||
* 参数ID
|
|
||||||
*/
|
|
||||||
private String id;
|
|
||||||
/**
|
/**
|
||||||
* 键
|
* 键
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,6 +9,8 @@ import io.metersphere.api.parser.jmeter.body.MsFormDataBodyConverter;
|
||||||
import io.metersphere.api.parser.jmeter.body.MsWWWFormBodyConverter;
|
import io.metersphere.api.parser.jmeter.body.MsWWWFormBodyConverter;
|
||||||
import io.metersphere.plugin.api.dto.ParameterConfig;
|
import io.metersphere.plugin.api.dto.ParameterConfig;
|
||||||
import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter;
|
import io.metersphere.plugin.api.spi.AbstractJmeterElementConverter;
|
||||||
|
import io.metersphere.sdk.util.LogUtils;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
|
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy;
|
||||||
import org.apache.jmeter.save.SaveService;
|
import org.apache.jmeter.save.SaveService;
|
||||||
|
@ -28,6 +30,10 @@ public class MsHTTPElementConverter extends AbstractJmeterElementConverter<MsHTT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void toHashTree(HashTree tree, MsHTTPElement msHTTPElement, ParameterConfig config) {
|
public void toHashTree(HashTree tree, MsHTTPElement msHTTPElement, ParameterConfig config) {
|
||||||
|
if (BooleanUtils.isFalse(msHTTPElement.getEnable())) {
|
||||||
|
LogUtils.info("MsHTTPElement is disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.config = config;
|
this.config = config;
|
||||||
HTTPSamplerProxy sampler = new HTTPSamplerProxy();
|
HTTPSamplerProxy sampler = new HTTPSamplerProxy();
|
||||||
sampler.setName(msHTTPElement.getName());
|
sampler.setName(msHTTPElement.getName());
|
||||||
|
|
|
@ -416,6 +416,7 @@ public class ApiDebugControllerTests extends BaseTest {
|
||||||
Body generalBody = MsHTTPElementTest.getGeneralBody();
|
Body generalBody = MsHTTPElementTest.getGeneralBody();
|
||||||
generalBody.setBodyType(Body.BodyType.FORM_DATA.name());
|
generalBody.setBodyType(Body.BodyType.FORM_DATA.name());
|
||||||
msHTTPElement.setBody(generalBody);
|
msHTTPElement.setBody(generalBody);
|
||||||
|
msHTTPElement.setEnable(true);
|
||||||
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
||||||
this.requestPostWithOk(DEBUG, request);
|
this.requestPostWithOk(DEBUG, request);
|
||||||
|
|
||||||
|
@ -439,11 +440,19 @@ public class ApiDebugControllerTests extends BaseTest {
|
||||||
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
||||||
this.requestPostWithOk(DEBUG, request);
|
this.requestPostWithOk(DEBUG, request);
|
||||||
|
|
||||||
// 测试 XML
|
// 测试 RAW
|
||||||
generalBody.setBodyType(Body.BodyType.RAW.name());
|
generalBody.setBodyType(Body.BodyType.RAW.name());
|
||||||
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
||||||
this.requestPostWithOk(DEBUG, request);
|
this.requestPostWithOk(DEBUG, request);
|
||||||
|
|
||||||
|
// 增加覆盖率
|
||||||
|
msHTTPElement.setMethod("GET");
|
||||||
|
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
||||||
|
this.requestPostWithOk(DEBUG, request);
|
||||||
|
msHTTPElement.setEnable(false);
|
||||||
|
request.setRequest(ApiDataUtils.toJSONString(msHTTPElement));
|
||||||
|
this.requestPostWithOk(DEBUG, request);
|
||||||
|
|
||||||
// 增加覆盖率
|
// 增加覆盖率
|
||||||
new TestElementParserFactory();
|
new TestElementParserFactory();
|
||||||
new ImportParserFactory();
|
new ImportParserFactory();
|
||||||
|
|
|
@ -202,7 +202,7 @@ public class PluginLoadService {
|
||||||
/**
|
/**
|
||||||
* 卸载插件
|
* 卸载插件
|
||||||
*/
|
*/
|
||||||
public void unloadPlugin(String pluginId) {
|
public synchronized void unloadPlugin(String pluginId) {
|
||||||
if (hasPlugin(pluginId)) {
|
if (hasPlugin(pluginId)) {
|
||||||
msPluginManager.deletePlugin(pluginId);
|
msPluginManager.deletePlugin(pluginId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue