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

jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git


The following commit(s) were added to refs/heads/2.x by this push:
     new 9432f72ca6 test: improve unit test coverage of seata-rm moudle (#7457)
9432f72ca6 is described below

commit 9432f72ca6f3a40d705beb76703c294e29b897a3
Author: xiaoyu <93440108+yvce...@users.noreply.github.com>
AuthorDate: Sat Jun 21 14:37:43 2025 +0800

    test: improve unit test coverage of seata-rm moudle (#7457)
---
 changes/en-us/2.x.md                               |   1 +
 changes/zh-cn/2.x.md                               |   1 +
 .../org/apache/seata/rm/AbstractRMHandlerTest.java | 153 +++++++++++++++
 .../seata/rm/AbstractResourceManagerTest.java      | 208 +++++++++++++++++++++
 .../org/apache/seata/rm/DefaultRMHandlerTest.java  | 114 +++++++++++
 rm/src/test/resources/file.conf                    |  29 +++
 rm/src/test/resources/registry.conf                |  34 ++++
 .../store/db/AbstractDataSourceProviderTest.java   |   4 -
 8 files changed, 540 insertions(+), 4 deletions(-)

diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index ac61d9b79e..3e12da481a 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -96,6 +96,7 @@ Add changes here for all PR submitted to the 2.x branch.
 - [[#7436](https://github.com/apache/incubator-seata/pull/7436)] fix 
namingserver ut error
 - [[#7435](https://github.com/apache/incubator-seata/pull/7435)] Add common 
test config for dynamic server port assignment in tests
 - [[#7442](https://github.com/apache/incubator-seata/pull/7442)] add some UT 
for saga compatible
+- [[#7457](https://github.com/apache/incubator-seata/pull/7457)] improve unit 
test coverage of seata-rm moudle
 
 ### refactor:
 
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index c8ffa9a494..2d37d217a8 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -97,6 +97,7 @@
 - [[#7435](https://github.com/apache/incubator-seata/pull/7435)] 
为测试中的动态服务器端口分配添加通用测试配置
 - [[#7432](https://github.com/apache/incubator-seata/pull/7432)] 使用Maven 
Profile按条件引入Test模块
 - [[#7442](https://github.com/apache/incubator-seata/pull/7442)] 增加 saga 
compatible 模块单测
+- [[#7457](https://github.com/apache/incubator-seata/pull/7457)] 增加 rm 模块的单测
 
 
 ### refactor:
diff --git a/rm/src/test/java/org/apache/seata/rm/AbstractRMHandlerTest.java 
b/rm/src/test/java/org/apache/seata/rm/AbstractRMHandlerTest.java
new file mode 100644
index 0000000000..8bedeb1a66
--- /dev/null
+++ b/rm/src/test/java/org/apache/seata/rm/AbstractRMHandlerTest.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm;
+
+import org.apache.seata.core.exception.TransactionException;
+import org.apache.seata.core.model.BranchStatus;
+import org.apache.seata.core.model.BranchType;
+import org.apache.seata.core.model.ResourceManager;
+import org.apache.seata.core.protocol.AbstractMessage;
+import org.apache.seata.core.protocol.AbstractResultMessage;
+import 
org.apache.seata.core.protocol.transaction.AbstractTransactionRequestToRM;
+import org.apache.seata.core.protocol.transaction.AbstractTransactionResponse;
+import org.apache.seata.core.protocol.transaction.BranchCommitRequest;
+import org.apache.seata.core.protocol.transaction.BranchCommitResponse;
+import org.apache.seata.core.protocol.transaction.BranchRollbackRequest;
+import org.apache.seata.core.protocol.transaction.BranchRollbackResponse;
+import org.apache.seata.core.protocol.transaction.UndoLogDeleteRequest;
+import org.apache.seata.core.rpc.RpcContext;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class AbstractRMHandlerTest {
+
+    @Mock
+    private ResourceManager resourceManager;
+
+    private AbstractRMHandler rmHandler;
+
+    @BeforeEach
+    void setUp() {
+        rmHandler = new AbstractRMHandler() {
+            @Override
+            protected ResourceManager getResourceManager() {
+                return resourceManager;
+            }
+
+            @Override
+            public BranchType getBranchType() {
+                return BranchType.AT;
+            }
+        };
+    }
+
+    @Test
+    void testHandleBranchCommitSuccess() throws TransactionException {
+        BranchCommitRequest request = new BranchCommitRequest();
+        request.setXid("xid-123");
+        request.setBranchId(1L);
+        request.setResourceId("res-1");
+        request.setApplicationData("appData");
+        request.setBranchType(BranchType.AT);
+
+        when(resourceManager.branchCommit(any(), anyString(), anyLong(), 
anyString(), anyString()))
+                .thenReturn(BranchStatus.PhaseTwo_Committed);
+
+        BranchCommitResponse response = rmHandler.handle(request);
+
+        assertEquals("xid-123", response.getXid());
+        assertEquals(1L, response.getBranchId());
+        assertEquals(BranchStatus.PhaseTwo_Committed, 
response.getBranchStatus());
+    }
+
+    @Test
+    void testHandleBranchRollbackSuccess() throws TransactionException {
+        BranchRollbackRequest request = new BranchRollbackRequest();
+        request.setXid("xid-456");
+        request.setBranchId(2L);
+        request.setResourceId("res-2");
+        request.setApplicationData("data");
+        request.setBranchType(BranchType.AT);
+
+        when(resourceManager.branchRollback(any(), anyString(), anyLong(), 
anyString(), anyString()))
+                .thenReturn(BranchStatus.PhaseTwo_Rollbacked);
+
+        BranchRollbackResponse response = rmHandler.handle(request);
+
+        assertEquals("xid-456", response.getXid());
+        assertEquals(2L, response.getBranchId());
+        assertEquals(BranchStatus.PhaseTwo_Rollbacked, 
response.getBranchStatus());
+    }
+
+    @Test
+    void testOnResponseShouldLogInfo() {
+        AbstractResultMessage response = mock(AbstractResultMessage.class);
+        when(response.toString()).thenReturn("MockResponse");
+
+        rmHandler.onResponse(response, new RpcContext());
+        // The absence of exceptions indicates success. Log does not make 
assertions
+    }
+
+    @Test
+    void testHandleUndoLogDelete() {
+        rmHandler.handle(new UndoLogDeleteRequest());
+        // This method is an empty implementation. It only needs to be 
verified without throwing exceptions
+    }
+
+    @Test
+    void testOnRequestWithInvalidTypeThrowsException() {
+        assertThrows(IllegalArgumentException.class, () -> {
+            rmHandler.onRequest(mock(AbstractMessage.class), new RpcContext());
+        });
+    }
+
+    @Test
+    void testOnRequestWithValidRequest() {
+        AbstractTransactionRequestToRM txRequest = 
mock(AbstractTransactionRequestToRM.class);
+        DummyTransactionResponse dummyResponse = new 
DummyTransactionResponse();
+        when(txRequest.handle(any())).thenReturn(dummyResponse);
+
+        AbstractResultMessage result = rmHandler.onRequest(txRequest, new 
RpcContext());
+
+        verify(txRequest).setRMInboundMessageHandler(eq(rmHandler));
+        verify(txRequest).handle(any());
+        assertNotNull(result);
+    }
+
+    public static class DummyTransactionResponse extends 
AbstractTransactionResponse {
+        @Override
+        public short getTypeCode() {
+            return 0;
+        }
+    }
+}
+
diff --git 
a/rm/src/test/java/org/apache/seata/rm/AbstractResourceManagerTest.java 
b/rm/src/test/java/org/apache/seata/rm/AbstractResourceManagerTest.java
new file mode 100644
index 0000000000..2756109e8e
--- /dev/null
+++ b/rm/src/test/java/org/apache/seata/rm/AbstractResourceManagerTest.java
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm;
+
+import org.apache.seata.core.exception.RmTransactionException;
+import org.apache.seata.core.exception.TransactionException;
+import org.apache.seata.core.exception.TransactionExceptionCode;
+import org.apache.seata.core.model.BranchStatus;
+import org.apache.seata.core.model.BranchType;
+import org.apache.seata.core.model.GlobalStatus;
+import org.apache.seata.core.model.Resource;
+import org.apache.seata.core.protocol.ResultCode;
+import org.apache.seata.core.protocol.transaction.BranchRegisterResponse;
+import org.apache.seata.core.protocol.transaction.BranchReportResponse;
+import org.apache.seata.core.protocol.transaction.GlobalStatusResponse;
+import org.apache.seata.core.rpc.netty.RmNettyRemotingClient;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+import org.mockito.Mockito;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeoutException;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+
+/**
+ * Unit tests for AbstractResourceManager
+ */
+public class AbstractResourceManagerTest {
+    // Create anonymous implementation classes for testing
+    private final AbstractResourceManager rm = new AbstractResourceManager() {
+        @Override
+        public BranchType getBranchType() {
+            return BranchType.AT;
+        }
+
+        @Override
+        public BranchStatus branchCommit(BranchType branchType, String xid, 
long branchId,
+                                         String resourceId, String 
applicationData) throws TransactionException {
+            throw new UnsupportedOperationException("Not implemented for 
test.");
+        }
+
+        @Override
+        public BranchStatus branchRollback(BranchType branchType, String xid, 
long branchId,
+                                           String resourceId, String 
applicationData) throws TransactionException {
+            throw new UnsupportedOperationException("Not implemented for 
test.");
+        }
+
+        @Override
+        public Map<String, Resource> getManagedResources() {
+            return new HashMap<>();
+        }
+    };
+
+
+    @Test
+    void testBranchRegisterSuccess() throws Exception {
+        BranchRegisterResponse mockResponse = new BranchRegisterResponse();
+        mockResponse.setResultCode(ResultCode.Success);
+        mockResponse.setBranchId(123L);
+
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            
Mockito.when(mockClient.sendSyncRequest(any())).thenReturn(mockResponse);
+
+            Long branchId = rm.branchRegister(BranchType.AT, "res1", 
"client1", "xid123", "appData", "lockKeys");
+            assertEquals(123L, branchId);
+        }
+    }
+
+    @Test
+    void testBranchRegisterFailed() throws Exception {
+        BranchRegisterResponse mockResponse = new BranchRegisterResponse();
+        mockResponse.setResultCode(ResultCode.Failed);
+        
mockResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchRegisterFailed);
+        mockResponse.setMsg("register failed");
+
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            
Mockito.when(mockClient.sendSyncRequest(any())).thenReturn(mockResponse);
+
+            assertThrows(RmTransactionException.class, () ->
+                    rm.branchRegister(BranchType.AT, "res1", "client1", 
"xid123", "appData", "lockKeys"));
+        }
+    }
+
+    @Test
+    void testBranchRegisterTimeout() throws Exception {
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            Mockito.when(mockClient.sendSyncRequest(any())).thenThrow(new 
TimeoutException("timeout"));
+
+            RmTransactionException exception = 
assertThrows(RmTransactionException.class, () ->
+                    rm.branchRegister(BranchType.AT, "res1", "client1", 
"xid123", "appData", "lockKeys"));
+            assertTrue(exception.getMessage().contains("timeout"));
+        }
+    }
+
+    @Test
+    void testBranchReportSuccess() throws Exception {
+        BranchReportResponse mockResponse = new BranchReportResponse();
+        mockResponse.setResultCode(ResultCode.Success);
+
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            
Mockito.when(mockClient.sendSyncRequest(any())).thenReturn(mockResponse);
+
+            assertDoesNotThrow(() ->
+                    rm.branchReport(BranchType.AT, "xid123", 100L, 
BranchStatus.PhaseOne_Done, "appData"));
+        }
+    }
+
+    @Test
+    void testBranchReportFailed() throws Exception {
+        BranchReportResponse mockResponse = new BranchReportResponse();
+        mockResponse.setResultCode(ResultCode.Failed);
+        
mockResponse.setTransactionExceptionCode(TransactionExceptionCode.BranchReportFailed);
+        mockResponse.setMsg("report failed");
+
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            
Mockito.when(mockClient.sendSyncRequest(any())).thenReturn(mockResponse);
+
+            assertThrows(RmTransactionException.class, () ->
+                    rm.branchReport(BranchType.AT, "xid123", 100L, 
BranchStatus.PhaseOne_Failed, "appData"));
+        }
+    }
+
+    @Test
+    void testGetGlobalStatusSuccess() throws Exception {
+        GlobalStatusResponse mockResponse = new GlobalStatusResponse();
+        mockResponse.setGlobalStatus(GlobalStatus.Committed);
+
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            
Mockito.when(mockClient.sendSyncRequest(any())).thenReturn(mockResponse);
+
+            GlobalStatus status = rm.getGlobalStatus(BranchType.AT, "xid123");
+            assertEquals(GlobalStatus.Committed, status);
+        }
+    }
+
+    @Test
+    void testGetGlobalStatusTimeout() throws Exception {
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+            Mockito.when(mockClient.sendSyncRequest(any())).thenThrow(new 
TimeoutException("timeout"));
+
+            RuntimeException ex = assertThrows(RuntimeException.class, () ->
+                    rm.getGlobalStatus(BranchType.AT, "xid123"));
+            assertTrue(ex.getMessage().contains("timeout"));
+        }
+    }
+
+    @Test
+    void testUnregisterResourceShouldThrow() {
+        Resource mockResource = Mockito.mock(Resource.class);
+        assertThrows(RuntimeException.class, () -> 
rm.unregisterResource(mockResource));
+    }
+
+    @Test
+    void testRegisterResource() {
+        Resource mockResource = Mockito.mock(Resource.class);
+        Mockito.when(mockResource.getResourceGroupId()).thenReturn("group1");
+        Mockito.when(mockResource.getResourceId()).thenReturn("res1");
+
+        try (MockedStatic<RmNettyRemotingClient> mockedStatic = 
Mockito.mockStatic(RmNettyRemotingClient.class)) {
+            RmNettyRemotingClient mockClient = 
Mockito.mock(RmNettyRemotingClient.class);
+            
mockedStatic.when(RmNettyRemotingClient::getInstance).thenReturn(mockClient);
+
+            assertDoesNotThrow(() -> rm.registerResource(mockResource));
+            Mockito.verify(mockClient).registerResource("group1", "res1");
+        }
+    }
+
+    @Test
+    void testLockQueryDefaultFalse() throws TransactionException {
+        assertFalse(rm.lockQuery(BranchType.AT, "resId", "xid123", 
"lockKeys"));
+    }
+
+}
diff --git a/rm/src/test/java/org/apache/seata/rm/DefaultRMHandlerTest.java 
b/rm/src/test/java/org/apache/seata/rm/DefaultRMHandlerTest.java
new file mode 100644
index 0000000000..b1e3c6059c
--- /dev/null
+++ b/rm/src/test/java/org/apache/seata/rm/DefaultRMHandlerTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.rm;
+
+import org.apache.seata.common.exception.FrameworkException;
+import org.apache.seata.core.model.BranchType;
+import org.apache.seata.core.protocol.transaction.BranchCommitRequest;
+import org.apache.seata.core.protocol.transaction.BranchCommitResponse;
+import org.apache.seata.core.protocol.transaction.BranchRollbackRequest;
+import org.apache.seata.core.protocol.transaction.BranchRollbackResponse;
+import org.apache.seata.core.protocol.transaction.UndoLogDeleteRequest;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class DefaultRMHandlerTest {
+    @Mock
+    private AbstractRMHandler mockHandlerAT;
+
+    @Mock
+    private BranchCommitRequest commitRequest;
+
+    @Mock
+    private BranchRollbackRequest rollbackRequest;
+
+    @Mock
+    private UndoLogDeleteRequest undoRequest;
+
+    @Mock
+    private BranchCommitResponse mockCommitResp;
+
+    @Mock
+    private BranchRollbackResponse mockRollbackResp;
+
+    @BeforeEach
+    void setUp() {
+        DefaultRMHandler.allRMHandlersMap.clear();
+        DefaultRMHandler.allRMHandlersMap.put(BranchType.AT, mockHandlerAT);
+    }
+
+    @Test
+    void testHandleBranchCommitRequest() {
+        when(commitRequest.getBranchType()).thenReturn(BranchType.AT);
+        when(commitRequest.getXid()).thenReturn("x123");
+        when(commitRequest.getBranchId()).thenReturn(456L);
+        when(mockHandlerAT.handle(commitRequest)).thenReturn(mockCommitResp);
+
+        BranchCommitResponse response = 
DefaultRMHandler.get().handle(commitRequest);
+        assertEquals(mockCommitResp, response);
+
+        verify(mockHandlerAT).handle(commitRequest);
+    }
+
+    @Test
+    void testHandleBranchRollbackRequest() {
+        when(rollbackRequest.getBranchType()).thenReturn(BranchType.AT);
+        when(rollbackRequest.getXid()).thenReturn("x123");
+        when(rollbackRequest.getBranchId()).thenReturn(456L);
+        
when(mockHandlerAT.handle(rollbackRequest)).thenReturn(mockRollbackResp);
+
+        BranchRollbackResponse response = 
DefaultRMHandler.get().handle(rollbackRequest);
+        assertEquals(mockRollbackResp, response);
+
+        verify(mockHandlerAT).handle(rollbackRequest);
+    }
+
+    @Test
+    void testHandleUndoLogDeleteRequest() {
+        when(undoRequest.getBranchType()).thenReturn(BranchType.AT);
+
+        DefaultRMHandler.get().handle(undoRequest);
+        verify(mockHandlerAT).handle(undoRequest);
+    }
+
+    @Test
+    void testGetResourceManager_shouldThrowFrameworkException() {
+        DefaultRMHandler handler = (DefaultRMHandler) DefaultRMHandler.get();
+
+        FrameworkException exception = assertThrows(FrameworkException.class, 
handler::getResourceManager);
+
+        assertEquals("DefaultRMHandler isn't a real AbstractRMHandler", 
exception.getMessage());
+    }
+
+    @Test
+    void testGetBranchType_shouldThrowFrameworkException() {
+        DefaultRMHandler handler = (DefaultRMHandler) DefaultRMHandler.get();
+
+        FrameworkException exception = assertThrows(FrameworkException.class, 
handler::getBranchType);
+
+        assertEquals("DefaultRMHandler isn't a real AbstractRMHandler", 
exception.getMessage());
+    }
+}
diff --git a/rm/src/test/resources/file.conf b/rm/src/test/resources/file.conf
new file mode 100644
index 0000000000..789450fc1e
--- /dev/null
+++ b/rm/src/test/resources/file.conf
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+service {
+  #transaction service group mapping
+  vgroupMapping.default_tx_group = "default"
+  #only support when registry.type=file, please don't set multiple addresses
+  default.grouplist = "127.0.0.1:8091"
+  #disable seata
+  disableGlobalTransaction = false
+}
+transport {
+  enableRmClientChannelCheckFailFast = false
+  enableTmClientChannelCheckFailFast = false
+}
\ No newline at end of file
diff --git a/rm/src/test/resources/registry.conf 
b/rm/src/test/resources/registry.conf
new file mode 100644
index 0000000000..5ad014bf55
--- /dev/null
+++ b/rm/src/test/resources/registry.conf
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+registry {
+  # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
+  type = "file"
+
+  file {
+    name = "file.conf"
+  }
+}
+
+config {
+  # file、nacos 、apollo、zk、consul、etcd3
+  type = "file"
+
+  file {
+    name = "file.conf"
+  }
+}
\ No newline at end of file
diff --git 
a/server/src/test/java/org/apache/seata/server/store/db/AbstractDataSourceProviderTest.java
 
b/server/src/test/java/org/apache/seata/server/store/db/AbstractDataSourceProviderTest.java
index d99e184c30..1aff8cc975 100644
--- 
a/server/src/test/java/org/apache/seata/server/store/db/AbstractDataSourceProviderTest.java
+++ 
b/server/src/test/java/org/apache/seata/server/store/db/AbstractDataSourceProviderTest.java
@@ -23,10 +23,6 @@ import 
org.apache.seata.common.loader.EnhancedServiceNotFoundException;
 import org.apache.seata.config.ConfigurationFactory;
 import org.apache.seata.core.store.db.DataSourceProvider;
 import org.apache.seata.server.DynamicPortTestConfig;
-import org.apache.seata.server.lock.LockerManagerFactory;
-import org.apache.seata.server.session.SessionHolder;
-import org.junit.After;
-import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org
For additional commands, e-mail: notifications-h...@seata.apache.org

Reply via email to