Broadly remove deprecated core classes and methods
Issue: SPR-14430
This commit is contained in:
@@ -59,36 +59,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
|
||||
private final String resourceBasePath;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new {@code WebMergedContextConfiguration} instance for the
|
||||
* supplied parameters.
|
||||
* <p>Delegates to
|
||||
* {@link #WebMergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}.
|
||||
* @param testClass the test class for which the configuration was merged
|
||||
* @param locations the merged resource locations
|
||||
* @param classes the merged annotated classes
|
||||
* @param contextInitializerClasses the merged context initializer classes
|
||||
* @param activeProfiles the merged active bean definition profiles
|
||||
* @param resourceBasePath the resource path to the root directory of the web application
|
||||
* @param contextLoader the resolved {@code ContextLoader}
|
||||
* @param cacheAwareContextLoaderDelegate a cache-aware context loader
|
||||
* delegate with which to retrieve the parent context
|
||||
* @param parent the parent configuration or {@code null} if there is no parent
|
||||
* @since 3.2.2
|
||||
* @deprecated as of Spring 4.1, use
|
||||
* {@link #WebMergedContextConfiguration(Class, String[], Class[], Set, String[], String[], String[], String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes,
|
||||
Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses,
|
||||
String[] activeProfiles, String resourceBasePath, ContextLoader contextLoader,
|
||||
CacheAwareContextLoaderDelegate cacheAwareContextLoaderDelegate, MergedContextConfiguration parent) {
|
||||
|
||||
this(testClass, locations, classes, contextInitializerClasses, activeProfiles, null, null, resourceBasePath,
|
||||
contextLoader, cacheAwareContextLoaderDelegate, parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@code WebMergedContextConfiguration} instance by copying
|
||||
* all properties from the supplied {@code MergedContextConfiguration}.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -16,21 +16,11 @@
|
||||
|
||||
package org.springframework.test.jdbc;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
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.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.SqlParameterValue;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.jdbc.datasource.init.ScriptUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -124,6 +114,7 @@ public class JdbcTestUtils {
|
||||
*/
|
||||
public static int deleteFromTableWhere(JdbcTemplate jdbcTemplate, String tableName, String whereClause,
|
||||
Object... args) {
|
||||
|
||||
String sql = "DELETE FROM " + tableName;
|
||||
if (StringUtils.hasText(whereClause)) {
|
||||
sql += " WHERE " + whereClause;
|
||||
@@ -149,143 +140,4 @@ public class JdbcTestUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given SQL script.
|
||||
* <p>The script will typically be loaded from the classpath. There should
|
||||
* be one statement per line. Any semicolons and line comments will be removed.
|
||||
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
||||
* @param jdbcTemplate the JdbcTemplate 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 {@code continueOnError} is {@code false}
|
||||
* @see ResourceDatabasePopulator
|
||||
* @see #executeSqlScript(JdbcTemplate, Resource, boolean)
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#executeSqlScript}
|
||||
* or {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void executeSqlScript(JdbcTemplate jdbcTemplate, ResourceLoader resourceLoader,
|
||||
String sqlResourcePath, boolean continueOnError) throws DataAccessException {
|
||||
Resource resource = resourceLoader.getResource(sqlResourcePath);
|
||||
executeSqlScript(jdbcTemplate, resource, continueOnError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given SQL script.
|
||||
* <p>The script will typically be loaded from the 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. Any
|
||||
* line comments will be removed.
|
||||
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
||||
* @param jdbcTemplate the JdbcTemplate 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 {@code continueOnError} is {@code false}
|
||||
* @see ResourceDatabasePopulator
|
||||
* @see #executeSqlScript(JdbcTemplate, EncodedResource, boolean)
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#executeSqlScript}
|
||||
* or {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void executeSqlScript(JdbcTemplate jdbcTemplate, Resource resource, boolean continueOnError)
|
||||
throws DataAccessException {
|
||||
executeSqlScript(jdbcTemplate, new EncodedResource(resource), continueOnError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the given SQL script.
|
||||
* <p>The script will typically be loaded from the classpath. There should
|
||||
* be one statement per line. Any semicolons and line comments will be removed.
|
||||
* <p><b>Do not use this method to execute DDL if you expect rollback.</b>
|
||||
* @param jdbcTemplate the JdbcTemplate 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 {@code continueOnError} is {@code false}
|
||||
* @see ResourceDatabasePopulator
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#executeSqlScript}
|
||||
* or {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator}.
|
||||
*/
|
||||
@Deprecated
|
||||
public static void executeSqlScript(JdbcTemplate jdbcTemplate, EncodedResource resource, boolean continueOnError)
|
||||
throws DataAccessException {
|
||||
new ResourceDatabasePopulator(continueOnError, false, resource.getEncoding(), resource.getResource()).execute(jdbcTemplate.getDataSource());
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a script from the provided {@code LineNumberReader}, using
|
||||
* "{@code --}" as the comment prefix, and build a {@code String} containing
|
||||
* the lines.
|
||||
* @param lineNumberReader the {@code LineNumberReader} containing the script
|
||||
* to be processed
|
||||
* @return a {@code String} containing the script lines
|
||||
* @see #readScript(LineNumberReader, String)
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#readScript(LineNumberReader, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String readScript(LineNumberReader lineNumberReader) throws IOException {
|
||||
return readScript(lineNumberReader, ScriptUtils.DEFAULT_COMMENT_PREFIX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a script from the provided {@code LineNumberReader}, using the supplied
|
||||
* comment prefix, and build a {@code String} containing the lines.
|
||||
* <p>Lines <em>beginning</em> with the comment prefix are excluded from the
|
||||
* results; however, line comments anywhere else — for example, within
|
||||
* a statement — will be included in the results.
|
||||
* @param lineNumberReader the {@code LineNumberReader} containing the script
|
||||
* to be processed
|
||||
* @param commentPrefix the prefix that identifies comments in the SQL script — typically "--"
|
||||
* @return a {@code String} containing the script lines
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#readScript(LineNumberReader, String, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static String readScript(LineNumberReader lineNumberReader, String commentPrefix) throws IOException {
|
||||
return ScriptUtils.readScript(lineNumberReader, commentPrefix, ScriptUtils.DEFAULT_STATEMENT_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the provided SQL script contains the specified delimiter.
|
||||
* @param script the SQL script
|
||||
* @param delim character delimiting each statement — typically a ';' character
|
||||
* @return {@code true} if the script contains the delimiter; {@code false} otherwise
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#containsSqlScriptDelimiters}
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean containsSqlScriptDelimiters(String script, char delim) {
|
||||
return ScriptUtils.containsSqlScriptDelimiters(script, String.valueOf(delim));
|
||||
}
|
||||
|
||||
/**
|
||||
* Split an SQL script into separate statements delimited by the provided
|
||||
* delimiter character. Each individual statement will be added to the
|
||||
* provided {@code List}.
|
||||
* <p>Within a statement, "{@code --}" will be used as the comment prefix;
|
||||
* any text beginning with the comment prefix and extending to the end of
|
||||
* the line will be omitted from the statement. In addition, multiple adjacent
|
||||
* whitespace characters will be collapsed into a single space.
|
||||
* @param script the SQL script
|
||||
* @param delim character delimiting each statement — typically a ';' character
|
||||
* @param statements the list that will contain the individual statements
|
||||
* @deprecated as of Spring 4.0.3, in favor of using
|
||||
* {@link org.springframework.jdbc.datasource.init.ScriptUtils#splitSqlScript(String, char, List)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void splitSqlScript(String script, char delim, List<String> statements) {
|
||||
ScriptUtils.splitSqlScript(script, delim, statements);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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.test.util;
|
||||
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.StringDescription;
|
||||
|
||||
/**
|
||||
* A replacement of {@link org.hamcrest.MatcherAssert} that removes the need to
|
||||
* depend on "hamcrest-all" when using Hamcrest 1.1 and also maintains backward
|
||||
* compatibility with Hamcrest 1.1 (also embedded in JUnit 4.4 through 4.8).
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Sam Brannen
|
||||
* @since 3.2
|
||||
* @deprecated as of Spring 4.2, in favor of the original
|
||||
* {@link org.hamcrest.MatcherAssert} class with JUnit 4.9 / Hamcrest 1.3
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract class MatcherAssertionErrors {
|
||||
|
||||
/**
|
||||
* Assert that the given matcher matches the actual value.
|
||||
* @param <T> the static type accepted by the matcher
|
||||
* @param actual the value to match against
|
||||
* @param matcher the matcher
|
||||
*/
|
||||
public static <T> void assertThat(T actual, Matcher<T> matcher) {
|
||||
assertThat("", actual, matcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the given matcher matches the actual value.
|
||||
* @param <T> the static type accepted by the matcher
|
||||
* @param reason additional information about the error
|
||||
* @param actual the value to match against
|
||||
* @param matcher the matcher
|
||||
*/
|
||||
public static <T> void assertThat(String reason, T actual, Matcher<T> matcher) {
|
||||
if (!matcher.matches(actual)) {
|
||||
Description description = new StringDescription();
|
||||
description.appendText(reason);
|
||||
description.appendText("\nExpected: ");
|
||||
description.appendDescriptionOf(matcher);
|
||||
description.appendText("\n but: ");
|
||||
matcher.describeMismatch(actual, description);
|
||||
throw new AssertionError(description.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -99,35 +99,6 @@ public final class MockMvcWebConnection implements WebConnection {
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance that assumes the context path of the application
|
||||
* is {@code ""} (i.e., the root context).
|
||||
* <p>For example, the URL {@code http://localhost/test/this} would use
|
||||
* {@code ""} as the context path.
|
||||
* @param mockMvc the {@code MockMvc} instance to use; never {@code null}
|
||||
* @deprecated Use {@link #MockMvcWebConnection(MockMvc, WebClient)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MockMvcWebConnection(MockMvc mockMvc) {
|
||||
this(mockMvc, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance with the specified context path.
|
||||
* <p>The path may be {@code null} in which case the first path segment
|
||||
* of the URL is turned into the contextPath. Otherwise it must conform
|
||||
* to {@link javax.servlet.http.HttpServletRequest#getContextPath()}
|
||||
* which states that it can be an empty string and otherwise must start
|
||||
* with a "/" character and not end with a "/" character.
|
||||
* @param mockMvc the {@code MockMvc} instance to use; never {@code null}
|
||||
* @param contextPath the contextPath to use
|
||||
* @deprecated use {@link #MockMvcWebConnection(MockMvc, WebClient, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public MockMvcWebConnection(MockMvc mockMvc, String contextPath) {
|
||||
this(mockMvc, new WebClient(), contextPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the supplied {@code contextPath}.
|
||||
* <p>If the value is not {@code null}, it must conform to
|
||||
|
||||
@@ -136,25 +136,6 @@ public abstract class MockMvcWebConnectionBuilderSupport<T extends MockMvcWebCon
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link WebConnection} that will use a {@link MockMvc}
|
||||
* instance if one of the specified {@link WebRequestMatcher} instances
|
||||
* matches.
|
||||
* @param defaultConnection the default WebConnection to use if none of
|
||||
* the specified {@code WebRequestMatcher} instances matches; never {@code null}
|
||||
* @return a new {@code WebConnection} that will use a {@code MockMvc}
|
||||
* instance if one of the specified {@code WebRequestMatcher} matches
|
||||
* @see #alwaysUseMockMvc()
|
||||
* @see #useMockMvc(WebRequestMatcher...)
|
||||
* @see #useMockMvcForHosts(String...)
|
||||
* @deprecated Use {@link #createConnection(WebClient)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
protected final WebConnection createConnection(WebConnection defaultConnection) {
|
||||
Assert.notNull(defaultConnection, "Default WebConnection must not be null");
|
||||
return createConnection(new WebClient(), defaultConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link WebConnection} that will use a {@link MockMvc}
|
||||
* instance if one of the specified {@link WebRequestMatcher} instances
|
||||
|
||||
Reference in New Issue
Block a user