Polish contribution

See gh-37261
This commit is contained in:
Sam Brannen
2026-09-14 17:38:39 +02:00
parent d571c4097d
commit 8c1b366bda
2 changed files with 13 additions and 11 deletions
@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
* Proxy for a target DataSource, fetching actual JDBC Connections lazily, * Proxy for a target DataSource, fetching actual JDBC Connections lazily,
* i.e. not until first creation of a Statement. Connection initialization * i.e. not until first creation of a Statement. Connection initialization
* properties like auto-commit mode, transaction isolation, read-only mode, * properties like auto-commit mode, transaction isolation, read-only mode,
* catalog, schema, holdability, client info and network timeout will be kept * catalog, schema, holdability, client info, and network timeout will be kept
* and applied to the actual JDBC Connection as soon as an actual Connection * and applied to the actual JDBC Connection as soon as an actual Connection
* is fetched (if ever). Consequently, commit and rollback calls will be ignored * is fetched (if ever). Consequently, commit and rollback calls will be ignored
* if no Statements have been created. * if no Statements have been created.
@@ -40,8 +40,8 @@ import static java.sql.Connection.TRANSACTION_REPEATABLE_READ;
import static java.sql.Connection.TRANSACTION_SERIALIZABLE; import static java.sql.Connection.TRANSACTION_SERIALIZABLE;
import static java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT; import static java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.doThrow;
@@ -119,7 +119,7 @@ class LazyConnectionDataSourceProxyTests {
} }
@Test @Test
void lazyHandlingCatalog() throws SQLException { void lazyHandlingOfCatalog() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection1 = mock(); Connection physicalConnection1 = mock();
Connection physicalConnection2 = mock(); Connection physicalConnection2 = mock();
@@ -140,7 +140,7 @@ class LazyConnectionDataSourceProxyTests {
} }
@Test @Test
void lazyHandlingSchema() throws SQLException { void lazyHandlingOfSchema() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection1 = mock(); Connection physicalConnection1 = mock();
Connection physicalConnection2 = mock(); Connection physicalConnection2 = mock();
@@ -161,7 +161,7 @@ class LazyConnectionDataSourceProxyTests {
} }
@Test @Test
void lazyHandlingHoldability() throws SQLException { void lazyHandlingOfHoldability() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection1 = mock(); Connection physicalConnection1 = mock();
Connection physicalConnection2 = mock(); Connection physicalConnection2 = mock();
@@ -182,7 +182,7 @@ class LazyConnectionDataSourceProxyTests {
} }
@Test @Test
void lazyHandlingTransactionIsolation() throws SQLException { void lazyHandlingOfTransactionIsolation() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection = mock(); Connection physicalConnection = mock();
when(mockDataSource.getConnection()).thenReturn(physicalConnection); when(mockDataSource.getConnection()).thenReturn(physicalConnection);
@@ -198,7 +198,7 @@ class LazyConnectionDataSourceProxyTests {
} }
@Test @Test
void lazyHandlingAutoCommit() throws SQLException { void lazyHandlingOfAutoCommit() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection = mock(); Connection physicalConnection = mock();
when(mockDataSource.getConnection()).thenReturn(physicalConnection); when(mockDataSource.getConnection()).thenReturn(physicalConnection);
@@ -214,7 +214,7 @@ class LazyConnectionDataSourceProxyTests {
} }
@Test @Test
void lazyHandlingNetworkTimeoutExecutor() throws SQLException { void lazyHandlingOfNetworkTimeoutExecutor() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection1 = mock(); Connection physicalConnection1 = mock();
Connection physicalConnection2 = mock(); Connection physicalConnection2 = mock();
@@ -234,11 +234,12 @@ class LazyConnectionDataSourceProxyTests {
// null executor // null executor
Connection lazyConnection2 = lazyProxy.getConnection(); Connection lazyConnection2 = lazyProxy.getConnection();
lazyConnection2.setNetworkTimeout(null, 1000); lazyConnection2.setNetworkTimeout(null, 1000);
assertThatThrownBy(() -> establishPhysicalConnection(lazyConnection2)).isInstanceOf(SQLException.class); assertThatExceptionOfType(SQLException.class)
.isThrownBy(() -> establishPhysicalConnection(lazyConnection2));
} }
@Test @Test
void lazyHandlingClientInfoForKV() throws SQLException { void lazyHandlingOfClientInfoForKeyValuePairs() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection = mock(); Connection physicalConnection = mock();
when(mockDataSource.getConnection()).thenReturn(physicalConnection); when(mockDataSource.getConnection()).thenReturn(physicalConnection);
@@ -251,11 +252,12 @@ class LazyConnectionDataSourceProxyTests {
verify(physicalConnection, never()).setClientInfo("k2", "v2"); verify(physicalConnection, never()).setClientInfo("k2", "v2");
lazyConnection.getClientInfo("k1"); // establish physical connection immediately lazyConnection.getClientInfo("k1"); // establish physical connection immediately
verify(physicalConnection).setClientInfo("k1", "v1"); verify(physicalConnection).setClientInfo("k1", "v1");
verify(physicalConnection).setClientInfo("k2", "v2");
verify(physicalConnection).getClientInfo("k1"); verify(physicalConnection).getClientInfo("k1");
} }
@Test @Test
void nonLazyHandlingClientInfoForProperties() throws SQLException { void nonLazyHandlingOfClientInfoForProperties() throws SQLException {
DataSource mockDataSource = mock(); DataSource mockDataSource = mock();
Connection physicalConnection = mock(); Connection physicalConnection = mock();
when(mockDataSource.getConnection()).thenReturn(physicalConnection); when(mockDataSource.getConnection()).thenReturn(physicalConnection);