mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2026-06-11 16:07:27 +00:00
fix(test): JsFetchBridgeTest Vertx 资源泄漏修复
将各 @Test 方法中局部创建的 Vertx.vertx() 统一为成员变量, 通过 @Before 创建并初始化,@After 关闭,避免资源泄漏。
This commit is contained in:
@@ -7,6 +7,8 @@ import cn.qaiu.parser.ParserCreate;
|
|||||||
import cn.qaiu.parser.custom.CustomParserConfig;
|
import cn.qaiu.parser.custom.CustomParserConfig;
|
||||||
import cn.qaiu.parser.custom.CustomParserRegistry;
|
import cn.qaiu.parser.custom.CustomParserRegistry;
|
||||||
import io.vertx.core.Vertx;
|
import io.vertx.core.Vertx;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -19,12 +21,23 @@ public class JsFetchBridgeTest {
|
|||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(JsFetchBridgeTest.class);
|
private static final Logger log = LoggerFactory.getLogger(JsFetchBridgeTest.class);
|
||||||
|
|
||||||
|
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 testFetchPolyfillLoaded() {
|
public void testFetchPolyfillLoaded() {
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
@@ -83,10 +96,6 @@ public class JsFetchBridgeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPromiseBasicUsage() {
|
public void testPromiseBasicUsage() {
|
||||||
// 初始化Vertx
|
|
||||||
Vertx vertx = Vertx.vertx();
|
|
||||||
WebClientVertxInit.init(vertx);
|
|
||||||
|
|
||||||
// 清理注册表
|
// 清理注册表
|
||||||
CustomParserRegistry.clear();
|
CustomParserRegistry.clear();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user