This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new d127ed6a34 test: refactor HeartbeatListenerTest exception assertion to 
use JUnit 5 standards (#6947)
d127ed6a34 is described below

commit d127ed6a346dde4f30a2ce7935ab0c22812a8aab
Author: Limbo <[email protected]>
AuthorDate: Sun Sep 27 21:49:24 2026 +0800

    test: refactor HeartbeatListenerTest exception assertion to use JUnit 5 
standards (#6947)
    
    Co-authored-by: aias00 <[email protected]>
---
 .../shenyu/register/client/beat/HeartbeatListenerTest.java   | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git 
a/shenyu-register-center/shenyu-register-client-beat/src/test/java/org/apache/shenyu/register/client/beat/HeartbeatListenerTest.java
 
b/shenyu-register-center/shenyu-register-client-beat/src/test/java/org/apache/shenyu/register/client/beat/HeartbeatListenerTest.java
index ea0cd06e87..17929133f8 100644
--- 
a/shenyu-register-center/shenyu-register-client-beat/src/test/java/org/apache/shenyu/register/client/beat/HeartbeatListenerTest.java
+++ 
b/shenyu-register-center/shenyu-register-client-beat/src/test/java/org/apache/shenyu/register/client/beat/HeartbeatListenerTest.java
@@ -29,13 +29,16 @@ import org.mockito.junit.jupiter.MockitoExtension;
 import org.springframework.boot.autoconfigure.web.ServerProperties;
 
 import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
 import java.util.Optional;
 import java.util.Properties;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.anyString;
 
@@ -183,12 +186,9 @@ class HeartbeatListenerTest {
             org.apache.shenyu.register.common.dto.InstanceBeatInfoDTO beatInfo 
= 
                     new 
org.apache.shenyu.register.common.dto.InstanceBeatInfoDTO();
 
-            // Should throw RuntimeException due to login failure
-            try {
-                sendHeartbeatMethod.invoke(heartbeatListener, beatInfo);
-            } catch (Exception e) {
-                assertTrue(e.getCause() instanceof RuntimeException);
-            }
+            InvocationTargetException exception = 
assertThrows(InvocationTargetException.class,
+                    () -> sendHeartbeatMethod.invoke(heartbeatListener, 
beatInfo));
+            assertInstanceOf(RuntimeException.class, exception.getCause());
         }
     }
 

Reply via email to