Polishing

This commit is contained in:
Juergen Hoeller
2015-11-12 00:48:14 +01:00
parent cc06183668
commit e8a0ef0206
5 changed files with 54 additions and 22 deletions

View File

@@ -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;
import java.sql.Connection;
@@ -29,11 +45,14 @@ import static org.mockito.BDDMockito.*;
public class CallMetaDataContextTests {
private DataSource dataSource;
private Connection connection;
private DatabaseMetaData databaseMetaData;
private CallMetaDataContext context = new CallMetaDataContext();
@Before
public void setUp() throws Exception {
connection = mock(Connection.class);
@@ -48,6 +67,7 @@ public class CallMetaDataContextTests {
verify(connection).close();
}
@Test
public void testMatchParameterValuesAndSqlInOutParameters() throws Exception {
final String TABLE = "customers";

View File

@@ -49,13 +49,17 @@ import static org.springframework.tests.Matchers.*;
*/
public class SimpleJdbcCallTests {
private Connection connection;
private DatabaseMetaData databaseMetaData;
private DataSource dataSource;
private CallableStatement callableStatement;
@Rule
public ExpectedException thrown = ExpectedException.none();
private Connection connection;
private DatabaseMetaData databaseMetaData;
private DataSource dataSource;
private CallableStatement callableStatement;
@Before
public void setUp() throws Exception {
@@ -67,6 +71,7 @@ public class SimpleJdbcCallTests {
given(dataSource.getConnection()).willReturn(connection);
}
@Test
public void testNoSuchStoredProcedure() throws Exception {
final String NO_SUCH_PROC = "x";

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -39,12 +39,15 @@ import static org.mockito.BDDMockito.*;
*/
public class SimpleJdbcInsertTests {
private Connection connection;
private DatabaseMetaData databaseMetaData;
private DataSource dataSource;
@Rule
public ExpectedException thrown = ExpectedException.none();
private Connection connection;
private DatabaseMetaData databaseMetaData;
private DataSource dataSource;
@Before
public void setUp() throws Exception {
@@ -60,6 +63,7 @@ public class SimpleJdbcInsertTests {
verify(connection).close();
}
@Test
public void testNoSuchTable() throws Exception {
ResultSet resultSet = mock(ResultSet.class);
@@ -81,4 +85,5 @@ public class SimpleJdbcInsertTests {
verify(resultSet).close();
}
}
}

View File

@@ -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");
* you may not use this file except in compliance with the License.
@@ -43,11 +43,14 @@ import static org.mockito.BDDMockito.*;
public class TableMetaDataContextTests {
private Connection connection;
private DataSource dataSource;
private DatabaseMetaData databaseMetaData;
private TableMetaDataContext context = new TableMetaDataContext();
@Before
public void setUp() throws Exception {
connection = mock(Connection.class);
@@ -57,9 +60,6 @@ public class TableMetaDataContextTests {
given(dataSource.getConnection()).willReturn(connection);
}
public void verifyClosed() throws Exception {
verify(connection).close();
}
@Test
public void testMatchInParametersAndSqlTypeInfoWrapping() throws Exception {
@@ -153,4 +153,5 @@ public class TableMetaDataContextTests {
verify(metaDataResultSet).close();
verify(columnsResultSet).close();
}
}