fix: 禁用连接本地达梦数据库的单元测试

This commit is contained in:
王绍宏
2026-09-11 16:35:33 +08:00
parent ce473b2c7d
commit 77580ea0bf
3 changed files with 22 additions and 9 deletions
@@ -1,9 +1,18 @@
2026-09-05 00:15:43.802 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.haobang.syslog.SysjavacollectApplicationTests], using SpringBootContextLoader 2026-09-11 16:29:58.327 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.haobang.syslog.SysjavacollectApplicationTests], using SpringBootContextLoader
2026-09-05 00:15:43.811 [main] INFO o.s.t.c.s.AbstractContextLoader - Could not detect default resource locations for test class [com.haobang.syslog.SysjavacollectApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}. 2026-09-11 16:29:58.338 [main] INFO o.s.t.c.s.AbstractContextLoader - Could not detect default resource locations for test class [com.haobang.syslog.SysjavacollectApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
2026-09-05 00:15:43.812 [main] INFO o.s.t.c.s.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.haobang.syslog.SysjavacollectApplicationTests]: SysjavacollectApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration. 2026-09-11 16:29:58.340 [main] INFO o.s.t.c.s.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.haobang.syslog.SysjavacollectApplicationTests]: SysjavacollectApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2026-09-05 00:15:44.008 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.haobang.syslog.syslogClientApplication for test class com.haobang.syslog.SysjavacollectApplicationTests 2026-09-11 16:29:58.524 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.haobang.syslog.syslogClientApplication for test class com.haobang.syslog.SysjavacollectApplicationTests
2026-09-05 00:15:44.220 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener] 2026-09-11 16:29:58.774 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
2026-09-05 00:15:44.234 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@2bdd8394, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@5f9edf14, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@68746f22, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@2f01783a, org.springframework.test.context.support.DirtiesContextTestExecutionListener@68878f6d, org.springframework.test.context.event.EventPublishingTestExecutionListener@41488b16, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@a8ef162, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@2eea88a1, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@7ac296f6, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@7fd7a283, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@22f59fa, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@78fa769e] 2026-09-11 16:29:58.789 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@3214ee6, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@383dc82c, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@4a07d605, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@74287ea3, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7d7758be, org.springframework.test.context.event.EventPublishingTestExecutionListener@2bdd8394, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@5f9edf14, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@68746f22, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@2f01783a, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@68878f6d, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@41488b16, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@a8ef162]
2026-09-05 00:15:44.726 [main] INFO c.h.s.SysjavacollectApplicationTests - Starting SysjavacollectApplicationTests using Java 1.8.0_351 on wangshaohongdeMacBook-Pro.local with PID 26248 (started by wangshaohong in /Users/wangshaohong/WorkSpace/fufeng/ai-security-xdr/haobang-security-dm/syslog-client) 2026-09-11 16:29:59.280 [main] INFO c.h.s.SysjavacollectApplicationTests - Starting SysjavacollectApplicationTests using Java 1.8.0_351 on wangshaohongdeMacBook-Pro.local with PID 63617 (started by wangshaohong in /Users/wangshaohong/WorkSpace/fufeng/ai-security-xdr/haobang-security-dm/syslog-client)
2026-09-05 00:15:44.729 [main] INFO c.h.s.SysjavacollectApplicationTests - No active profile set, falling back to 1 default profile: "default" 2026-09-11 16:29:59.286 [main] INFO c.h.s.SysjavacollectApplicationTests - No active profile set, falling back to 1 default profile: "default"
2026-09-05 00:15:45.889 [main] INFO c.h.s.SysjavacollectApplicationTests - Started SysjavacollectApplicationTests in 1.581 seconds (JVM running for 3.423) 2026-09-11 16:30:00.361 [main] INFO c.h.s.SysjavacollectApplicationTests - Started SysjavacollectApplicationTests in 1.499 seconds (JVM running for 3.309)
2026-09-11 16:34:00.334 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.haobang.syslog.SysjavacollectApplicationTests], using SpringBootContextLoader
2026-09-11 16:34:00.338 [main] INFO o.s.t.c.s.AbstractContextLoader - Could not detect default resource locations for test class [com.haobang.syslog.SysjavacollectApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
2026-09-11 16:34:00.339 [main] INFO o.s.t.c.s.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.haobang.syslog.SysjavacollectApplicationTests]: SysjavacollectApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
2026-09-11 16:34:00.401 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.haobang.syslog.syslogClientApplication for test class com.haobang.syslog.SysjavacollectApplicationTests
2026-09-11 16:34:00.490 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.event.ApplicationEventsTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener, org.springframework.test.context.event.EventPublishingTestExecutionListener]
2026-09-11 16:34:00.496 [main] INFO o.s.b.t.c.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@68746f22, org.springframework.test.context.event.ApplicationEventsTestExecutionListener@2f01783a, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@68878f6d, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@41488b16, org.springframework.test.context.support.DirtiesContextTestExecutionListener@a8ef162, org.springframework.test.context.event.EventPublishingTestExecutionListener@2eea88a1, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@7ac296f6, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@7fd7a283, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@22f59fa, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@78fa769e, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@16612a51, org.springframework.boot.test.autoconfigure.webservices.client.MockWebServiceServerTestExecutionListener@54e041a4]
2026-09-11 16:34:00.647 [main] INFO c.h.s.SysjavacollectApplicationTests - Starting SysjavacollectApplicationTests using Java 1.8.0_392 on wangshaohongdeMacBook-Pro.local with PID 65327 (started by wangshaohong in /Users/wangshaohong/WorkSpace/fufeng/ai-security-xdr-orig-apipull/haobang-security-dm/syslog-client)
2026-09-11 16:34:00.647 [main] INFO c.h.s.SysjavacollectApplicationTests - No active profile set, falling back to 1 default profile: "default"
2026-09-11 16:34:00.957 [main] INFO c.h.s.SysjavacollectApplicationTests - Started SysjavacollectApplicationTests in 0.436 seconds (JVM running for 1.012)
@@ -2,6 +2,7 @@ package com.haobang.syslog;
import com.common.entity.DeviceDevice; import com.common.entity.DeviceDevice;
import com.common.mapper.DeviceDeviceMapper; import com.common.mapper.DeviceDeviceMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.MethodOrderer; import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
@@ -16,6 +17,7 @@ import java.util.List;
/** /**
* 达梦数据库连接测试 — 查询 device_device 表 * 达梦数据库连接测试 — 查询 device_device 表
*/ */
@Disabled("依赖外部达梦数据库,不在本地单元测试阶段执行")
@SpringBootTest(properties = { @SpringBootTest(properties = {
"syslog.server.enabled=false", "syslog.server.enabled=false",
"syslog.wal.directory=${java.io.tmpdir}/syslog-serve-device-test-${random.uuid}", "syslog.wal.directory=${java.io.tmpdir}/syslog-serve-device-test-${random.uuid}",
@@ -1,8 +1,10 @@
package com.haobang.syslog; package com.haobang.syslog;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@Disabled("启动完整应用会初始化外部达梦连接,不在本地单元测试阶段执行")
@SpringBootTest(properties = { @SpringBootTest(properties = {
"syslog.server.enabled=false", "syslog.server.enabled=false",
"syslog.wal.directory=${java.io.tmpdir}/syslog-serve-context-${random.uuid}", "syslog.wal.directory=${java.io.tmpdir}/syslog-serve-context-${random.uuid}",