Skip to content

Commit db76542

Browse files
committed
Polishing
1 parent 78fce80 commit db76542

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateQueryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
*/
5151
public class JdbcTemplateQueryTests {
5252

53-
private Connection connection = mock();
54-
5553
private DataSource dataSource = mock();
5654

55+
private Connection connection = mock();
56+
5757
private Statement statement = mock();
5858

5959
private PreparedStatement preparedStatement = mock();

spring-jdbc/src/test/java/org/springframework/jdbc/core/JdbcTemplateTests.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@
7575
*/
7676
public class JdbcTemplateTests {
7777

78-
private Connection connection = mock();
79-
8078
private DataSource dataSource = mock();
8179

80+
private Connection connection = mock();
81+
8282
private Statement statement = mock();
8383

8484
private PreparedStatement preparedStatement = mock();
8585

86-
private ResultSet resultSet = mock();
87-
8886
private CallableStatement callableStatement = mock();
8987

88+
private ResultSet resultSet = mock();
89+
9090
private JdbcTemplate template = new JdbcTemplate(this.dataSource);
9191

9292

@@ -136,9 +136,9 @@ public void testBogusUpdate() throws Exception {
136136
given(this.preparedStatement.executeUpdate()).willThrow(sqlException);
137137

138138
Dispatcher d = new Dispatcher(idParam, sql);
139-
assertThatExceptionOfType(UncategorizedSQLException.class).isThrownBy(() ->
140-
this.template.update(d))
141-
.withCause(sqlException);
139+
assertThatExceptionOfType(UncategorizedSQLException.class)
140+
.isThrownBy(() -> this.template.update(d))
141+
.withCause(sqlException);
142142
verify(this.preparedStatement).setInt(1, idParam);
143143
verify(this.preparedStatement).close();
144144
verify(this.connection, atLeastOnce()).close();
@@ -371,9 +371,9 @@ public void testSqlUpdateEncountersSqlException() throws Exception {
371371
given(this.statement.executeUpdate(sql)).willThrow(sqlException);
372372
given(this.connection.createStatement()).willReturn(this.statement);
373373

374-
assertThatExceptionOfType(DataAccessException.class).isThrownBy(() ->
375-
this.template.update(sql))
376-
.withCause(sqlException);
374+
assertThatExceptionOfType(DataAccessException.class)
375+
.isThrownBy(() -> this.template.update(sql))
376+
.withCause(sqlException);
377377
verify(this.statement).close();
378378
verify(this.connection, atLeastOnce()).close();
379379
}
@@ -672,9 +672,9 @@ public int getBatchSize() {
672672
};
673673

674674
try {
675-
assertThatExceptionOfType(DataAccessException.class).isThrownBy(() ->
676-
this.template.batchUpdate(sql, setter))
677-
.withCause(sqlException);
675+
assertThatExceptionOfType(DataAccessException.class)
676+
.isThrownBy(() -> this.template.batchUpdate(sql, setter))
677+
.withCause(sqlException);
678678
}
679679
finally {
680680
verify(this.preparedStatement, times(2)).addBatch();
@@ -776,9 +776,9 @@ public void testCouldNotGetConnectionForOperationOrExceptionTranslator() throws
776776
JdbcTemplate template = new JdbcTemplate(this.dataSource, false);
777777
RowCountCallbackHandler rcch = new RowCountCallbackHandler();
778778

779-
assertThatExceptionOfType(CannotGetJdbcConnectionException.class).isThrownBy(() ->
780-
template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
781-
.withCause(sqlException);
779+
assertThatExceptionOfType(CannotGetJdbcConnectionException.class)
780+
.isThrownBy(() -> template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
781+
.withCause(sqlException);
782782
}
783783

784784
@Test
@@ -790,9 +790,9 @@ public void testCouldNotGetConnectionForOperationWithLazyExceptionTranslator() t
790790
this.template.afterPropertiesSet();
791791
RowCountCallbackHandler rcch = new RowCountCallbackHandler();
792792

793-
assertThatExceptionOfType(CannotGetJdbcConnectionException.class).isThrownBy(() ->
794-
this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
795-
.withCause(sqlException);
793+
assertThatExceptionOfType(CannotGetJdbcConnectionException.class)
794+
.isThrownBy(() -> this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
795+
.withCause(sqlException);
796796
}
797797

798798
@Test
@@ -830,9 +830,9 @@ private void doTestCouldNotGetConnectionInOperationWithExceptionTranslatorInitia
830830
this.template.afterPropertiesSet();
831831
}
832832
RowCountCallbackHandler rcch = new RowCountCallbackHandler();
833-
assertThatExceptionOfType(CannotGetJdbcConnectionException.class).isThrownBy(() ->
834-
this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
835-
.withCause(sqlException);
833+
assertThatExceptionOfType(CannotGetJdbcConnectionException.class)
834+
.isThrownBy(() -> this.template.query("SELECT ID, FORENAME FROM CUSTMR WHERE ID < 3", rcch))
835+
.withCause(sqlException);
836836
}
837837

838838
@Test
@@ -859,9 +859,9 @@ public void testPreparedStatementSetterFails() throws Exception {
859859
given(this.preparedStatement.executeUpdate()).willThrow(sqlException);
860860

861861
PreparedStatementSetter pss = ps -> ps.setString(1, name);
862-
assertThatExceptionOfType(DataAccessException.class).isThrownBy(() ->
863-
new JdbcTemplate(this.dataSource).update(sql, pss))
864-
.withCause(sqlException);
862+
assertThatExceptionOfType(DataAccessException.class)
863+
.isThrownBy(() -> new JdbcTemplate(this.dataSource).update(sql, pss))
864+
.withCause(sqlException);
865865
verify(this.preparedStatement).setString(1, name);
866866
verify(this.preparedStatement).close();
867867
verify(this.connection, atLeastOnce()).close();
@@ -897,9 +897,9 @@ public void testFatalWarning() throws Exception {
897897
t.setIgnoreWarnings(false);
898898

899899
ResultSetExtractor<Byte> extractor = rs -> rs.getByte(1);
900-
assertThatExceptionOfType(SQLWarningException.class).isThrownBy(() ->
901-
t.query(sql, extractor))
902-
.withCause(warnings);
900+
assertThatExceptionOfType(SQLWarningException.class)
901+
.isThrownBy(() -> t.query(sql, extractor))
902+
.withCause(warnings);
903903
verify(this.resultSet).close();
904904
verify(this.preparedStatement).close();
905905
verify(this.connection).close();
@@ -940,7 +940,7 @@ public void testSQLErrorCodeTranslation() throws Exception {
940940
this.template.query(sql, (RowCallbackHandler) rs -> {
941941
throw sqlException;
942942
}))
943-
.withCause(sqlException);
943+
.withCause(sqlException);
944944
verify(this.resultSet).close();
945945
verify(this.preparedStatement).close();
946946
verify(this.connection, atLeastOnce()).close();
@@ -960,7 +960,7 @@ public void testSQLErrorCodeTranslationWithSpecifiedDatabaseName() throws Except
960960
this.template.query(sql, (RowCallbackHandler) rs -> {
961961
throw sqlException;
962962
}))
963-
.withCause(sqlException);
963+
.withCause(sqlException);
964964
verify(this.resultSet).close();
965965
verify(this.preparedStatement).close();
966966
verify(this.connection).close();
@@ -990,7 +990,7 @@ public void testUseCustomExceptionTranslator() throws Exception {
990990
template.query(sql, (RowCallbackHandler) rs -> {
991991
throw sqlException;
992992
}))
993-
.withCause(sqlException);
993+
.withCause(sqlException);
994994
verify(this.resultSet).close();
995995
verify(this.preparedStatement).close();
996996
verify(this.connection).close();

0 commit comments

Comments
 (0)