This is an automated email from the ASF dual-hosted git repository.
terrymanu 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 2fdd007a462 Refactor ProxyBackendTransactionManagerTest (#39009)
2fdd007a462 is described below
commit 2fdd007a462184ad2824895f2d32a16e0f2ba288
Author: Liang Zhang <[email protected]>
AuthorDate: Sun Jul 5 21:13:42 2026 +0800
Refactor ProxyBackendTransactionManagerTest (#39009)
---
.../transaction/ProxyBackendTransactionManagerTest.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
index 16dc5926a73..44793979a3b 100644
---
a/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
+++
b/proxy/backend/core/src/test/java/org/apache/shardingsphere/proxy/backend/connector/jdbc/transaction/ProxyBackendTransactionManagerTest.java
@@ -118,7 +118,7 @@ class ProxyBackendTransactionManagerTest {
when(connectionSession.getConnectionContext()).thenReturn(connectionContext);
when(connectionContext.getTransactionContext()).thenReturn(transactionContext);
when(databaseConnectionManager.getConnectionPostProcessors()).thenReturn(connectionPostProcessors);
-
when(databaseConnectionManager.getCachedConnections()).thenReturn(mockCachedConnections(connection));
+ mockCachedConnections(connection);
}
@SneakyThrows(ReflectiveOperationException.class)
@@ -319,11 +319,11 @@ class ProxyBackendTransactionManagerTest {
transactionContext.setExceptionOccur(initialExceptionFlag);
if (exceptionCount == 2) {
Connection anotherConnection = mock(Connection.class);
-
when(databaseConnectionManager.getCachedConnections()).thenReturn(mockCachedConnections(connection,
anotherConnection));
+ mockCachedConnections(connection, anotherConnection);
doThrow(new
SQLException("first")).when(savepointManager).rollbackToSavepoint(connection,
"sp");
doThrow(new
SQLException("second")).when(savepointManager).rollbackToSavepoint(anotherConnection,
"sp");
} else {
-
when(databaseConnectionManager.getCachedConnections()).thenReturn(mockCachedConnections(connection));
+ mockCachedConnections(connection);
}
mockProxyContext(TransactionType.LOCAL, null, Collections.emptyMap());
ProxyBackendTransactionManager transactionManager = new
ProxyBackendTransactionManager(databaseConnectionManager);
@@ -346,7 +346,7 @@ class ProxyBackendTransactionManagerTest {
@Test
void assertReleaseSavepointThrowsCombinedSQLException() throws
SQLException {
Connection anotherConnection = mock(Connection.class);
-
when(databaseConnectionManager.getCachedConnections()).thenReturn(mockCachedConnections(connection,
anotherConnection));
+ mockCachedConnections(connection, anotherConnection);
ConnectionSavepointManager savepointManager =
mock(ConnectionSavepointManager.class);
when(ConnectionSavepointManager.getInstance()).thenReturn(savepointManager);
doThrow(new
SQLException("first")).when(savepointManager).releaseSavepoint(connection,
"sp");
@@ -366,12 +366,12 @@ class ProxyBackendTransactionManagerTest {
verify(savepointManager).releaseSavepoint(connection, "sp");
}
- private Multimap<String, Connection> mockCachedConnections(final
Connection... connections) {
- Multimap<String, Connection> result = LinkedHashMultimap.create();
+ private void mockCachedConnections(final Connection... connections) {
+ Multimap<String, Connection> cachedConnections =
LinkedHashMultimap.create();
for (Connection each : connections) {
- result.put("ds1", each);
+ cachedConnections.put("ds1", each);
}
- return result;
+
when(databaseConnectionManager.getCachedConnections()).thenReturn(cachedConnections);
}
private void mockProxyContext(final TransactionType defaultType, final
ShardingSphereTransactionManagerEngine engine, final Map<ShardingSphereRule,
TransactionHook> transactionHooks) {