diff --git a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java index 083b0faedf..f97ce922b2 100644 --- a/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/junit4/AbstractTransactionalJUnit4SpringContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -24,7 +24,6 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.EncodedResource; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; @@ -66,7 +65,6 @@ import org.springframework.transaction.annotation.Transactional; * @see org.springframework.test.context.transaction.TransactionalTestExecutionListener * @see org.springframework.test.context.transaction.TransactionConfiguration * @see org.springframework.transaction.annotation.Transactional - * @see org.springframework.test.annotation.NotTransactional * @see org.springframework.test.annotation.Rollback * @see org.springframework.test.context.transaction.BeforeTransaction * @see org.springframework.test.context.transaction.AfterTransaction @@ -78,13 +76,6 @@ import org.springframework.transaction.annotation.Transactional; @SuppressWarnings("deprecation") public abstract class AbstractTransactionalJUnit4SpringContextTests extends AbstractJUnit4SpringContextTests { - /** - * The {@code SimpleJdbcTemplate} that this base class manages, available to subclasses. - * @deprecated As of Spring 3.2, use {@link #jdbcTemplate} instead. - */ - @Deprecated - protected SimpleJdbcTemplate simpleJdbcTemplate; - /** * The {@code JdbcTemplate} that this base class manages, available to subclasses. * @since 3.2 @@ -96,12 +87,11 @@ public abstract class AbstractTransactionalJUnit4SpringContextTests extends Abst /** * Set the {@code DataSource}, typically provided via Dependency Injection. - *
This method also instantiates the {@link #simpleJdbcTemplate} and - * {@link #jdbcTemplate} instance variables. + *
This method also instantiates the {@link #jdbcTemplate} instance + * variable. */ @Autowired public void setDataSource(DataSource dataSource) { - this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource); } diff --git a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java index 41e70a704f..aefad7a220 100644 --- a/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java +++ b/spring-test/src/main/java/org/springframework/test/context/testng/AbstractTransactionalTestNGSpringContextTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2013 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. @@ -24,7 +24,6 @@ import org.springframework.core.io.Resource; import org.springframework.core.io.support.EncodedResource; import org.springframework.dao.DataAccessException; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; import org.springframework.test.context.TestExecutionListeners; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.test.jdbc.JdbcTestUtils; @@ -57,7 +56,6 @@ import org.springframework.transaction.annotation.Transactional; * @see org.springframework.test.context.transaction.TransactionalTestExecutionListener * @see org.springframework.test.context.transaction.TransactionConfiguration * @see org.springframework.transaction.annotation.Transactional - * @see org.springframework.test.annotation.NotTransactional * @see org.springframework.test.annotation.Rollback * @see org.springframework.test.context.transaction.BeforeTransaction * @see org.springframework.test.context.transaction.AfterTransaction @@ -69,13 +67,6 @@ import org.springframework.transaction.annotation.Transactional; @SuppressWarnings("deprecation") public abstract class AbstractTransactionalTestNGSpringContextTests extends AbstractTestNGSpringContextTests { - /** - * The {@code SimpleJdbcTemplate} that this base class manages, available to subclasses. - * @deprecated As of Spring 3.2, use {@link #jdbcTemplate} instead. - */ - @Deprecated - protected SimpleJdbcTemplate simpleJdbcTemplate; - /** * The {@code JdbcTemplate} that this base class manages, available to subclasses. * @since 3.2 @@ -87,12 +78,11 @@ public abstract class AbstractTransactionalTestNGSpringContextTests extends Abst /** * Set the {@code DataSource}, typically provided via Dependency Injection. - *
This method also instantiates the {@link #simpleJdbcTemplate} and - * {@link #jdbcTemplate} instance variables. + *
This method also instantiates the {@link #jdbcTemplate} instance + * variable. */ @Autowired public void setDataSource(DataSource dataSource) { - this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); this.jdbcTemplate = new JdbcTemplate(dataSource); } diff --git a/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java b/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java index 383b20dff9..27d14b82ac 100644 --- a/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java +++ b/spring-test/src/main/java/org/springframework/test/jdbc/JdbcTestUtils.java @@ -37,8 +37,6 @@ import org.springframework.util.StringUtils; * {@code JdbcTestUtils} is a collection of JDBC related utility functions * intended to simplify standard database testing scenarios. * - *
As of Spring 3.1.3, {@code JdbcTestUtils} supersedes {@link SimpleJdbcTestUtils}. - * * @author Thomas Risberg * @author Sam Brannen * @author Juergen Hoeller diff --git a/spring-test/src/main/java/org/springframework/test/jdbc/SimpleJdbcTestUtils.java b/spring-test/src/main/java/org/springframework/test/jdbc/SimpleJdbcTestUtils.java deleted file mode 100644 index 24cee9adb6..0000000000 --- a/spring-test/src/main/java/org/springframework/test/jdbc/SimpleJdbcTestUtils.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright 2002-2012 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.test.jdbc; - -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.LinkedList; -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.core.io.Resource; -import org.springframework.core.io.ResourceLoader; -import org.springframework.core.io.support.EncodedResource; -import org.springframework.dao.DataAccessException; -import org.springframework.dao.DataAccessResourceFailureException; -import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; - -/** - * A Java-5-based collection of JDBC related utility functions intended to - * simplify standard database testing scenarios. - * - * @author Sam Brannen - * @author Juergen Hoeller - * @author Thomas Risberg - * @since 2.5 - * @deprecated as of Spring 3.1.3; use {@link JdbcTestUtils} instead. - */ -@Deprecated -public abstract class SimpleJdbcTestUtils { - - private static final Log logger = LogFactory.getLog(SimpleJdbcTestUtils.class); - - - /** - * Count the rows in the given table. - * @param simpleJdbcTemplate the SimpleJdbcTemplate with which to perform JDBC operations - * @param tableName table name to count rows in - * @return the number of rows in the table - */ - public static int countRowsInTable(SimpleJdbcTemplate simpleJdbcTemplate, String tableName) { - return simpleJdbcTemplate.queryForInt("SELECT COUNT(0) FROM " + tableName); - } - - /** - * Delete all rows from the specified tables. - * @param simpleJdbcTemplate the SimpleJdbcTemplate with which to perform JDBC operations - * @param tableNames the names of the tables from which to delete - * @return the total number of rows deleted from all specified tables - */ - public static int deleteFromTables(SimpleJdbcTemplate simpleJdbcTemplate, String... tableNames) { - int totalRowCount = 0; - for (String tableName : tableNames) { - int rowCount = simpleJdbcTemplate.update("DELETE FROM " + tableName); - totalRowCount += rowCount; - if (logger.isInfoEnabled()) { - logger.info("Deleted " + rowCount + " rows from table " + tableName); - } - } - return totalRowCount; - } - - /** - * Execute the given SQL script. - *
The script will normally be loaded by classpath. There should be one statement - * per line. Any semicolons will be removed. Do not use this method to execute - * DDL if you expect rollback. - * @param simpleJdbcTemplate the SimpleJdbcTemplate with which to perform JDBC operations - * @param resourceLoader the resource loader (with which to load the SQL script - * @param sqlResourcePath the Spring resource path for the SQL script - * @param continueOnError whether or not to continue without throwing an - * exception in the event of an error - * @throws DataAccessException if there is an error executing a statement - * and continueOnError was {@code false} - */ - public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate, ResourceLoader resourceLoader, - String sqlResourcePath, boolean continueOnError) throws DataAccessException { - - Resource resource = resourceLoader.getResource(sqlResourcePath); - executeSqlScript(simpleJdbcTemplate, resource, continueOnError); - } - - /** - * Execute the given SQL script. The script will normally be loaded by classpath. - *
Statements should be delimited with a semicolon. If statements are not delimited with - * a semicolon then there should be one statement per line. Statements are allowed to span - * lines only if they are delimited with a semicolon. - *
Do not use this method to execute DDL if you expect rollback. - * @param simpleJdbcTemplate the SimpleJdbcTemplate with which to perform JDBC operations - * @param resource the resource to load the SQL script from. - * @param continueOnError whether or not to continue without throwing an - * exception in the event of an error. - * @throws DataAccessException if there is an error executing a statement - * and continueOnError was {@code false} - */ - public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate, Resource resource, - boolean continueOnError) throws DataAccessException { - - executeSqlScript(simpleJdbcTemplate, new EncodedResource(resource), continueOnError); - } - - /** - * Execute the given SQL script. - *
The script will normally be loaded by classpath. There should be one statement
- * per line. Any semicolons will be removed. Do not use this method to execute
- * DDL if you expect rollback.
- * @param simpleJdbcTemplate the SimpleJdbcTemplate with which to perform JDBC operations
- * @param resource the resource (potentially associated with a specific encoding)
- * to load the SQL script from.
- * @param continueOnError whether or not to continue without throwing an
- * exception in the event of an error.
- * @throws DataAccessException if there is an error executing a statement
- * and continueOnError was {@code false}
- */
- public static void executeSqlScript(SimpleJdbcTemplate simpleJdbcTemplate, EncodedResource resource,
- boolean continueOnError) throws DataAccessException {
-
- if (logger.isInfoEnabled()) {
- logger.info("Executing SQL script from " + resource);
- }
-
- long startTime = System.currentTimeMillis();
- List