mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-10 15:37:28 +00:00
fix(test): BaiduPhotoParserTest Vertx 资源泄漏修复
将各 @Test 方法中局部创建的 Vertx.vertx() 统一为成员变量, 通过 @Before 创建并初始化,@After 关闭,避免资源泄漏。
This commit is contained in:
@@ -8,6 +8,8 @@ import cn.qaiu.parser.customjs.JsParserExecutor;
|
|||||||
import cn.qaiu.WebClientVertxInit;
|
import cn.qaiu.WebClientVertxInit;
|
||||||
import io.vertx.core.Vertx;
|
import io.vertx.core.Vertx;
|
||||||
import io.vertx.core.json.JsonObject;
|
import io.vertx.core.json.JsonObject;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -22,15 +24,26 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class BaiduPhotoParserTest {
|
public class BaiduPhotoParserTest {
|
||||||
|
|
||||||
|
private Vertx vertx;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() {
|
||||||
|
vertx = Vertx.vertx();
|
||||||
|
WebClientVertxInit.init(vertx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void tearDown() {
|
||||||
|
if (vertx != null) {
|
||||||
|
vertx.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBaiduPhotoParserRegistration() {
|
public void testBaiduPhotoParserRegistration() {
|
||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
// 检查是否加载了百度相册解析器
|
// 检查是否加载了百度相册解析器
|
||||||
CustomParserConfig config = CustomParserRegistry.get("baidu_photo");
|
CustomParserConfig config = CustomParserRegistry.get("baidu_photo");
|
||||||
assert config != null : "百度相册解析器未加载";
|
assert config != null : "百度相册解析器未加载";
|
||||||
@@ -45,10 +58,6 @@ public class BaiduPhotoParserTest {
|
|||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建解析器 - 测试文件分享链接
|
// 创建解析器 - 测试文件分享链接
|
||||||
IPanTool tool = ParserCreate.fromType("baidu_photo")
|
IPanTool tool = ParserCreate.fromType("baidu_photo")
|
||||||
@@ -77,10 +86,6 @@ public class BaiduPhotoParserTest {
|
|||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建解析器 - 测试文件夹分享链接
|
// 创建解析器 - 测试文件夹分享链接
|
||||||
IPanTool tool = ParserCreate.fromType("baidu_photo")
|
IPanTool tool = ParserCreate.fromType("baidu_photo")
|
||||||
@@ -109,10 +114,6 @@ public class BaiduPhotoParserTest {
|
|||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IPanTool tool = ParserCreate.fromType("baidu_photo")
|
IPanTool tool = ParserCreate.fromType("baidu_photo")
|
||||||
// 分享key PPgOEodBVE
|
// 分享key PPgOEodBVE
|
||||||
@@ -167,10 +168,6 @@ public class BaiduPhotoParserTest {
|
|||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 创建ShareLinkInfo
|
// 创建ShareLinkInfo
|
||||||
Map<String, Object> otherParam = new HashMap<>();
|
Map<String, Object> otherParam = new HashMap<>();
|
||||||
|
|||||||
Reference in New Issue
Block a user