Polishing
This commit is contained in:
@@ -39,18 +39,19 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
|||||||
* the JDBC driver. Since we rely on the JDBC driver, this "auto-detection"
|
* the JDBC driver. Since we rely on the JDBC driver, this "auto-detection"
|
||||||
* can only be used for databases that are known to provide accurate meta data.
|
* can only be used for databases that are known to provide accurate meta data.
|
||||||
* These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2,
|
* These currently include Derby, MySQL, Microsoft SQL Server, Oracle, DB2,
|
||||||
* Sybase and PostgreSQL. For any other databases you are required to declare all
|
* Sybase and PostgreSQL. For any other databases you are required to declare
|
||||||
* parameters explicitly. You can of course declare all parameters explicitly even
|
* all parameters explicitly. You can of course declare all parameters
|
||||||
* if the database provides the necessary meta data. In that case your declared
|
* explicitly even if the database provides the necessary meta data. In that
|
||||||
* parameters will take precedence. You can also turn off any meta data processing
|
* case your declared parameters will take precedence. You can also turn off
|
||||||
* if you want to use parameter names that do not match what is declared during
|
* any metadata processing if you want to use parameter names that do not
|
||||||
* the stored procedure compilation.
|
* match what is declared during the stored procedure compilation.
|
||||||
*
|
*
|
||||||
* <p>The actual insert is being handled using Spring's
|
* <p>The actual insert is being handled using Spring's
|
||||||
* {@link org.springframework.jdbc.core.JdbcTemplate}.
|
* {@link org.springframework.jdbc.core.JdbcTemplate}.
|
||||||
*
|
*
|
||||||
* <p>Many of the configuration methods return the current instance of the SimpleJdbcCall
|
* <p>Many of the configuration methods return the current instance of the
|
||||||
* to provide the ability to chain multiple ones together in a "fluent" interface style.
|
* SimpleJdbcCall in order to provide the ability to chain multiple ones
|
||||||
|
* together in a "fluent" interface style.
|
||||||
*
|
*
|
||||||
* @author Thomas Risberg
|
* @author Thomas Risberg
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
@@ -61,8 +62,8 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
|||||||
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations {
|
public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOperations {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that takes one parameter with the JDBC DataSource to use when creating the
|
* Constructor that takes one parameter with the JDBC DataSource to use when
|
||||||
* JdbcTemplate.
|
* creating the underlying JdbcTemplate.
|
||||||
* @param dataSource the {@code DataSource} to use
|
* @param dataSource the {@code DataSource} to use
|
||||||
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
|
* @see org.springframework.jdbc.core.JdbcTemplate#setDataSource
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2002-2015 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed 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.springframework.jdbc.core.simple;
|
package org.springframework.jdbc.core.simple;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -29,11 +45,14 @@ import static org.mockito.BDDMockito.*;
|
|||||||
public class CallMetaDataContextTests {
|
public class CallMetaDataContextTests {
|
||||||
|
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
private DatabaseMetaData databaseMetaData;
|
private DatabaseMetaData databaseMetaData;
|
||||||
|
|
||||||
private CallMetaDataContext context = new CallMetaDataContext();
|
private CallMetaDataContext context = new CallMetaDataContext();
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
connection = mock(Connection.class);
|
connection = mock(Connection.class);
|
||||||
@@ -48,6 +67,7 @@ public class CallMetaDataContextTests {
|
|||||||
verify(connection).close();
|
verify(connection).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchParameterValuesAndSqlInOutParameters() throws Exception {
|
public void testMatchParameterValuesAndSqlInOutParameters() throws Exception {
|
||||||
final String TABLE = "customers";
|
final String TABLE = "customers";
|
||||||
|
|||||||
@@ -49,13 +49,17 @@ import static org.springframework.tests.Matchers.*;
|
|||||||
*/
|
*/
|
||||||
public class SimpleJdbcCallTests {
|
public class SimpleJdbcCallTests {
|
||||||
|
|
||||||
|
private Connection connection;
|
||||||
|
|
||||||
|
private DatabaseMetaData databaseMetaData;
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
private CallableStatement callableStatement;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private Connection connection;
|
|
||||||
private DatabaseMetaData databaseMetaData;
|
|
||||||
private DataSource dataSource;
|
|
||||||
private CallableStatement callableStatement;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -67,6 +71,7 @@ public class SimpleJdbcCallTests {
|
|||||||
given(dataSource.getConnection()).willReturn(connection);
|
given(dataSource.getConnection()).willReturn(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoSuchStoredProcedure() throws Exception {
|
public void testNoSuchStoredProcedure() throws Exception {
|
||||||
final String NO_SUCH_PROC = "x";
|
final String NO_SUCH_PROC = "x";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -39,12 +39,15 @@ import static org.mockito.BDDMockito.*;
|
|||||||
*/
|
*/
|
||||||
public class SimpleJdbcInsertTests {
|
public class SimpleJdbcInsertTests {
|
||||||
|
|
||||||
|
private Connection connection;
|
||||||
|
|
||||||
|
private DatabaseMetaData databaseMetaData;
|
||||||
|
|
||||||
|
private DataSource dataSource;
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public ExpectedException thrown = ExpectedException.none();
|
public ExpectedException thrown = ExpectedException.none();
|
||||||
|
|
||||||
private Connection connection;
|
|
||||||
private DatabaseMetaData databaseMetaData;
|
|
||||||
private DataSource dataSource;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
@@ -60,6 +63,7 @@ public class SimpleJdbcInsertTests {
|
|||||||
verify(connection).close();
|
verify(connection).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNoSuchTable() throws Exception {
|
public void testNoSuchTable() throws Exception {
|
||||||
ResultSet resultSet = mock(ResultSet.class);
|
ResultSet resultSet = mock(ResultSet.class);
|
||||||
@@ -81,4 +85,5 @@ public class SimpleJdbcInsertTests {
|
|||||||
verify(resultSet).close();
|
verify(resultSet).close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2013 the original author or authors.
|
* Copyright 2002-2015 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -43,11 +43,14 @@ import static org.mockito.BDDMockito.*;
|
|||||||
public class TableMetaDataContextTests {
|
public class TableMetaDataContextTests {
|
||||||
|
|
||||||
private Connection connection;
|
private Connection connection;
|
||||||
|
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
private DatabaseMetaData databaseMetaData;
|
private DatabaseMetaData databaseMetaData;
|
||||||
|
|
||||||
private TableMetaDataContext context = new TableMetaDataContext();
|
private TableMetaDataContext context = new TableMetaDataContext();
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
connection = mock(Connection.class);
|
connection = mock(Connection.class);
|
||||||
@@ -57,9 +60,6 @@ public class TableMetaDataContextTests {
|
|||||||
given(dataSource.getConnection()).willReturn(connection);
|
given(dataSource.getConnection()).willReturn(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verifyClosed() throws Exception {
|
|
||||||
verify(connection).close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchInParametersAndSqlTypeInfoWrapping() throws Exception {
|
public void testMatchInParametersAndSqlTypeInfoWrapping() throws Exception {
|
||||||
@@ -153,4 +153,5 @@ public class TableMetaDataContextTests {
|
|||||||
verify(metaDataResultSet).close();
|
verify(metaDataResultSet).close();
|
||||||
verify(columnsResultSet).close();
|
verify(columnsResultSet).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user