You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2024/09/08 14:26:10 UTC

(shardingsphere) branch master updated: Add more test cases on StandaloneProcessPersistService (#32808)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new d68017fba64 Add more test cases on StandaloneProcessPersistService (#32808)
d68017fba64 is described below

commit d68017fba642a8a69f3987677d58ca7c31c63037
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Sep 8 22:26:04 2024 +0800

    Add more test cases on StandaloneProcessPersistService (#32808)
---
 .../StandaloneProcessPersistServiceTest.java        | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneProcessPersistServiceTest.java b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneProcessPersistServiceTest.java
index 0f626d760b8..d4611c69cd8 100644
--- a/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneProcessPersistServiceTest.java
+++ b/mode/type/standalone/core/src/test/java/org/apache/shardingsphere/mode/manager/standalone/persist/StandaloneProcessPersistServiceTest.java
@@ -21,7 +21,6 @@ import org.apache.shardingsphere.infra.executor.sql.process.Process;
 import org.apache.shardingsphere.infra.executor.sql.process.ProcessRegistry;
 import org.apache.shardingsphere.test.mock.AutoMockExtension;
 import org.apache.shardingsphere.test.mock.StaticMockSettings;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
 
@@ -29,7 +28,6 @@ import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.Collections;
 
-import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -38,12 +36,7 @@ import static org.mockito.Mockito.when;
 @StaticMockSettings(ProcessRegistry.class)
 class StandaloneProcessPersistServiceTest {
     
-    private StandaloneProcessPersistService processPersistService;
-    
-    @BeforeEach
-    void setUp() {
-        processPersistService = new StandaloneProcessPersistService();
-    }
+    private final StandaloneProcessPersistService processPersistService = new StandaloneProcessPersistService();
     
     @Test
     void assertGetProcessList() {
@@ -60,8 +53,16 @@ class StandaloneProcessPersistServiceTest {
         Process process = mock(Process.class);
         Statement statement = mock(Statement.class);
         when(process.getProcessStatements()).thenReturn(Collections.singletonMap(1, statement));
-        when(processRegistry.get(any())).thenReturn(process);
-        processPersistService.killProcess("foo_process_id");
+        when(processRegistry.get("foo_id")).thenReturn(process);
+        processPersistService.killProcess("foo_id");
         verify(statement).cancel();
     }
+    
+    @Test
+    void assertKillProcessWithNotExistedProcessId() throws SQLException {
+        ProcessRegistry processRegistry = mock(ProcessRegistry.class);
+        when(ProcessRegistry.getInstance()).thenReturn(processRegistry);
+        when(processRegistry.get("foo_id")).thenReturn(null);
+        processPersistService.killProcess("foo_id");
+    }
 }