refactor(接口测试): 批量执行的API过滤掉回收站中的数据
This commit is contained in:
parent
f68fb91a5b
commit
405e573123
|
@ -222,7 +222,7 @@ public class ApiCaseExecuteService {
|
||||||
List<MsExecResponseDTO> responseDTOS = new LinkedList<>();
|
List<MsExecResponseDTO> responseDTOS = new LinkedList<>();
|
||||||
|
|
||||||
ApiTestCaseExample example = new ApiTestCaseExample();
|
ApiTestCaseExample example = new ApiTestCaseExample();
|
||||||
example.createCriteria().andIdIn(request.getIds());
|
example.createCriteria().andIdIn(request.getIds()).andStatusNotEqualTo("Trash");
|
||||||
List<ApiTestCaseWithBLOBs> caseList = apiTestCaseMapper.selectByExampleWithBLOBs(example);
|
List<ApiTestCaseWithBLOBs> caseList = apiTestCaseMapper.selectByExampleWithBLOBs(example);
|
||||||
LoggerUtil.debug("查询到执行数据:" + caseList.size());
|
LoggerUtil.debug("查询到执行数据:" + caseList.size());
|
||||||
// 环境检查
|
// 环境检查
|
||||||
|
|
|
@ -108,22 +108,28 @@ public class PluginService {
|
||||||
return resources;
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadJar(String jarPath) {
|
private boolean loadJar(String jarPath) {
|
||||||
try {
|
try {
|
||||||
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
ClassLoader classLoader = ClassLoader.getSystemClassLoader();
|
||||||
try {
|
try {
|
||||||
|
File file = new File(jarPath);
|
||||||
|
if (!file.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Method method = classLoader.getClass().getDeclaredMethod("addURL", URL.class);
|
Method method = classLoader.getClass().getDeclaredMethod("addURL", URL.class);
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(classLoader, new File(jarPath).toURI().toURL());
|
method.invoke(classLoader, file.toURI().toURL());
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
Method method = classLoader.getClass()
|
Method method = classLoader.getClass()
|
||||||
.getDeclaredMethod("appendToClassPathForInstrumentation", String.class);
|
.getDeclaredMethod("appendToClassPathForInstrumentation", String.class);
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
method.invoke(classLoader, jarPath);
|
method.invoke(classLoader, jarPath);
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadPlugins() {
|
public void loadPlugins() {
|
||||||
|
@ -135,7 +141,12 @@ public class PluginService {
|
||||||
-> new TreeSet<>(Comparator.comparing(Plugin::getPluginId))), ArrayList::new));
|
-> new TreeSet<>(Comparator.comparing(Plugin::getPluginId))), ArrayList::new));
|
||||||
if (CollectionUtils.isNotEmpty(plugins)) {
|
if (CollectionUtils.isNotEmpty(plugins)) {
|
||||||
plugins.forEach(item -> {
|
plugins.forEach(item -> {
|
||||||
this.loadJar(item.getSourcePath());
|
boolean isLoad = this.loadJar(item.getSourcePath());
|
||||||
|
if (!isLoad) {
|
||||||
|
PluginExample pluginExample = new PluginExample();
|
||||||
|
pluginExample.createCriteria().andPluginIdEqualTo(item.getPluginId());
|
||||||
|
pluginMapper.deleteByExample(pluginExample);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue