Skip to content

Commit 8d707eb

Browse files
committed
Polishing
1 parent 9543384 commit 8d707eb

File tree

4 files changed

+48
-34
lines changed

4 files changed

+48
-34
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-context/src/main/java/org/springframework/instrument/classloading/jboss/JBossLoadTimeWeaver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public JBossLoadTimeWeaver(ClassLoader classLoader) {
8585
if (this.addTransformer == null) {
8686
throw new IllegalArgumentException(
8787
"Could not find 'addTransformer' method on JBoss DelegatingClassFileTransformer: " +
88-
this.delegatingTransformer.getClass().getName());
88+
this.delegatingTransformer.getClass().getName());
8989
}
9090
this.addTransformer.setAccessible(true);
9191
}

spring-jdbc/src/main/java/org/springframework/jdbc/core/simple/SimpleJdbcInsertOperations.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ public interface SimpleJdbcInsertOperations {
7474

7575
/**
7676
* Include synonyms for the column meta data lookups via JDBC.
77-
* Note: this is only necessary to include for Oracle since other
78-
* databases supporting synonyms seems to include the synonyms
79-
* automatically.
77+
* <p>Note: This is only necessary to include for Oracle since other databases
78+
* supporting synonyms seems to include the synonyms automatically.
8079
* @return the instance of this SimpleJdbcInsert
8180
*/
8281
SimpleJdbcInsertOperations includeSynonymsForTableColumnMetaData();

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

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.springframework.jdbc.SQLWarningException;
4646
import org.springframework.jdbc.UncategorizedSQLException;
4747
import org.springframework.jdbc.core.support.AbstractInterruptibleBatchPreparedStatementSetter;
48+
import org.springframework.jdbc.datasource.ConnectionProxy;
4849
import org.springframework.jdbc.datasource.SingleConnectionDataSource;
4950
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
5051
import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
@@ -65,17 +66,24 @@
6566
*/
6667
public class JdbcTemplateTests {
6768

68-
@Rule
69-
public ExpectedException thrown = ExpectedException.none();
70-
7169
private Connection connection;
70+
7271
private DataSource dataSource;
72+
7373
private PreparedStatement preparedStatement;
74+
7475
private Statement statement;
76+
7577
private ResultSet resultSet;
78+
7679
private JdbcTemplate template;
80+
7781
private CallableStatement callableStatement;
7882

83+
@Rule
84+
public ExpectedException thrown = ExpectedException.none();
85+
86+
7987
@Before
8088
public void setup() throws Exception {
8189
this.connection = mock(Connection.class);
@@ -96,6 +104,7 @@ public void setup() throws Exception {
96104
given(this.callableStatement.getResultSet()).willReturn(this.resultSet);
97105
}
98106

107+
99108
@Test
100109
public void testBeanProperties() throws Exception {
101110
assertTrue("datasource ok", this.template.getDataSource() == this.dataSource);
@@ -141,32 +150,29 @@ public void testBogusUpdate() throws Exception {
141150

142151
@Test
143152
public void testStringsWithStaticSql() throws Exception {
144-
doTestStrings(false, null, null, null, null, new JdbcTemplateCallback() {
153+
doTestStrings(null, null, null, null, new JdbcTemplateCallback() {
145154
@Override
146-
public void doInJdbcTemplate(JdbcTemplate template, String sql,
147-
RowCallbackHandler rch) {
155+
public void doInJdbcTemplate(JdbcTemplate template, String sql, RowCallbackHandler rch) {
148156
template.query(sql, rch);
149157
}
150158
});
151159
}
152160

153161
@Test
154162
public void testStringsWithStaticSqlAndFetchSizeAndMaxRows() throws Exception {
155-
doTestStrings(false, 10, 20, 30, null, new JdbcTemplateCallback() {
163+
doTestStrings(10, 20, 30, null, new JdbcTemplateCallback() {
156164
@Override
157-
public void doInJdbcTemplate(JdbcTemplate template, String sql,
158-
RowCallbackHandler rch) {
165+
public void doInJdbcTemplate(JdbcTemplate template, String sql, RowCallbackHandler rch) {
159166
template.query(sql, rch);
160167
}
161168
});
162169
}
163170

164171
@Test
165172
public void testStringsWithEmptyPreparedStatementSetter() throws Exception {
166-
doTestStrings(true, null, null, null, null, new JdbcTemplateCallback() {
173+
doTestStrings(null, null, null, null, new JdbcTemplateCallback() {
167174
@Override
168-
public void doInJdbcTemplate(JdbcTemplate template, String sql,
169-
RowCallbackHandler rch) {
175+
public void doInJdbcTemplate(JdbcTemplate template, String sql, RowCallbackHandler rch) {
170176
template.query(sql, (PreparedStatementSetter) null, rch);
171177
}
172178
});
@@ -175,10 +181,9 @@ public void doInJdbcTemplate(JdbcTemplate template, String sql,
175181
@Test
176182
public void testStringsWithPreparedStatementSetter() throws Exception {
177183
final Integer argument = 99;
178-
doTestStrings(true, null, null, null, argument, new JdbcTemplateCallback() {
184+
doTestStrings(null, null, null, argument, new JdbcTemplateCallback() {
179185
@Override
180-
public void doInJdbcTemplate(JdbcTemplate template, String sql,
181-
RowCallbackHandler rch) {
186+
public void doInJdbcTemplate(JdbcTemplate template, String sql, RowCallbackHandler rch) {
182187
template.query(sql, new PreparedStatementSetter() {
183188
@Override
184189
public void setValues(PreparedStatement ps) throws SQLException {
@@ -191,10 +196,9 @@ public void setValues(PreparedStatement ps) throws SQLException {
191196

192197
@Test
193198
public void testStringsWithEmptyPreparedStatementArgs() throws Exception {
194-
doTestStrings(true, null, null, null, null, new JdbcTemplateCallback() {
199+
doTestStrings(null, null, null, null, new JdbcTemplateCallback() {
195200
@Override
196-
public void doInJdbcTemplate(JdbcTemplate template, String sql,
197-
RowCallbackHandler rch) {
201+
public void doInJdbcTemplate(JdbcTemplate template, String sql, RowCallbackHandler rch) {
198202
template.query(sql, (Object[]) null, rch);
199203
}
200204
});
@@ -203,20 +207,16 @@ public void doInJdbcTemplate(JdbcTemplate template, String sql,
203207
@Test
204208
public void testStringsWithPreparedStatementArgs() throws Exception {
205209
final Integer argument = 99;
206-
doTestStrings(true, null, null, null, argument, new JdbcTemplateCallback() {
210+
doTestStrings(null, null, null, argument, new JdbcTemplateCallback() {
207211
@Override
208-
public void doInJdbcTemplate(JdbcTemplate template, String sql,
209-
RowCallbackHandler rch) {
212+
public void doInJdbcTemplate(JdbcTemplate template, String sql, RowCallbackHandler rch) {
210213
template.query(sql, new Object[] { argument }, rch);
211214
}
212215
});
213216
}
214217

215-
private void doTestStrings(
216-
boolean usePreparedStatement,
217-
Integer fetchSize, Integer maxRows, Integer queryTimeout, Object argument,
218-
JdbcTemplateCallback jdbcTemplateCallback)
219-
throws Exception {
218+
private void doTestStrings(Integer fetchSize, Integer maxRows, Integer queryTimeout,
219+
Object argument, JdbcTemplateCallback jdbcTemplateCallback) throws Exception {
220220

221221
String sql = "SELECT FORENAME FROM CUSTMR";
222222
String[] results = { "rod", "gary", " portia" };
@@ -293,6 +293,19 @@ public void testLeaveConnectionOpenOnRequest() throws Exception {
293293
verify(this.preparedStatement).close();
294294
}
295295

296+
@Test
297+
public void testConnectionCallback() throws Exception {
298+
String result = this.template.execute(new ConnectionCallback<String>() {
299+
@Override
300+
public String doInConnection(Connection con) {
301+
assertTrue(con instanceof ConnectionProxy);
302+
assertSame(JdbcTemplateTests.this.connection, ((ConnectionProxy) con).getTargetConnection());
303+
return "test";
304+
}
305+
});
306+
assertEquals("test", result);
307+
}
308+
296309
@Test
297310
public void testConnectionCallbackWithStatementSettings() throws Exception {
298311
String result = this.template.execute(new ConnectionCallback<String>() {
@@ -724,7 +737,6 @@ public int getBatchSize() {
724737

725738
@Test
726739
public void testBatchUpdateWithListOfObjectArrays() throws Exception {
727-
728740
final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?";
729741
final List<Object[]> ids = new ArrayList<>();
730742
ids.add(new Object[] {100});
@@ -835,13 +847,15 @@ public void testCouldntGetConnectionForOperationWithLazyExceptionTranslator() th
835847

836848
@Test
837849
public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitializedViaBeanProperty()
838-
throws Exception {
850+
throws SQLException {
851+
839852
doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized(true);
840853
}
841854

842855
@Test
843856
public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitializedInAfterPropertiesSet()
844-
throws Exception {
857+
throws SQLException {
858+
845859
doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized(false);
846860
}
847861

@@ -851,6 +865,7 @@ public void testCouldntGetConnectionInOperationWithExceptionTranslatorInitialize
851865
*/
852866
private void doTestCouldntGetConnectionInOperationWithExceptionTranslatorInitialized(boolean beanProperty)
853867
throws SQLException {
868+
854869
SQLException sqlException = new SQLException("foo", "07xxx");
855870
this.dataSource = mock(DataSource.class);
856871
given(this.dataSource.getConnection()).willThrow(sqlException);

0 commit comments

Comments
 (0)