Browse Source

Remove pre-3.2 deprecated classes and methods

Issue: SPR-12578
pull/715/head
Juergen Hoeller 11 years ago
parent
commit
9ac02b319d
  1. 20
      spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java
  2. 12
      spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java
  3. 26
      spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java
  4. 9
      spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java
  5. 15
      spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java
  6. 5
      spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java
  7. 2
      spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java
  8. 17
      spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java
  9. 15
      spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java
  10. 33
      spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java
  11. 20
      spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java
  12. 28
      spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java
  13. 26
      spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java
  14. 19
      spring-expression/src/main/java/org/springframework/expression/common/ExpressionUtils.java
  15. 118
      spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java
  16. 42
      spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java
  17. 74
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java
  18. 26
      spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java
  19. 10
      spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java
  20. 246
      spring-test/src/main/java/org/springframework/test/AssertThrows.java
  21. 23
      spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java
  22. 89
      spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java
  23. 21
      spring-tx/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java
  24. 37
      spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java
  25. 11
      spring-web/src/main/java/org/springframework/http/HttpHeaders.java
  26. 14
      spring-web/src/main/java/org/springframework/web/context/ContextLoader.java
  27. 162
      spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertyPlaceholderConfigurer.java
  28. 9
      spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java
  29. 142
      spring-web/src/main/java/org/springframework/web/util/UriUtils.java
  30. 13
      spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java
  31. 61
      spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java
  32. 128
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java
  33. 19
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java
  34. 234
      spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java

20
spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java

@ -84,26 +84,6 @@ public abstract class AopUtils { @@ -84,26 +84,6 @@ public abstract class AopUtils {
return (object instanceof SpringProxy && ClassUtils.isCglibProxy(object));
}
/**
* Check whether the specified class is a CGLIB-generated class.
* @param clazz the class to check
* @deprecated as of Spring 3.1 in favor of {@link ClassUtils#isCglibProxyClass(Class)}
*/
@Deprecated
public static boolean isCglibProxyClass(Class<?> clazz) {
return ClassUtils.isCglibProxyClass(clazz);
}
/**
* Check whether the specified class name is a CGLIB-generated class.
* @param className the class name to check
* @deprecated as of Spring 3.1 in favor of {@link ClassUtils#isCglibProxyClassName(String)}
*/
@Deprecated
public static boolean isCglibProxyClassName(String className) {
return ClassUtils.isCglibProxyClassName(className);
}
/**
* Determine the target class of the given bean instance which might be an AOP proxy.
* <p>Returns the target class for an AOP proxy and the plain class else.

12
spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -166,16 +166,6 @@ public class BeanDefinitionBuilder { @@ -166,16 +166,6 @@ public class BeanDefinitionBuilder {
return this;
}
/**
* Add an indexed constructor arg value. The current index is tracked internally
* and all additions are at the present point.
* @deprecated since Spring 2.5, in favor of {@link #addConstructorArgValue}
*/
@Deprecated
public BeanDefinitionBuilder addConstructorArg(Object value) {
return addConstructorArgValue(value);
}
/**
* Add an indexed constructor arg value. The current index is tracked internally
* and all additions are at the present point.

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -148,27 +148,9 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB @@ -148,27 +148,9 @@ public abstract class AbstractSimpleBeanDefinitionParser extends AbstractSingleB
* @see #isEligibleAttribute(String)
*/
protected boolean isEligibleAttribute(Attr attribute, ParserContext parserContext) {
boolean eligible = isEligibleAttribute(attribute);
if (!eligible) {
String fullName = attribute.getName();
eligible = (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") &&
isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute)));
}
return eligible;
}
/**
* Determine whether the given attribute is eligible for being
* turned into a corresponding bean property value.
* <p>The default implementation considers any attribute as eligible,
* except for the "id" attribute and namespace declaration attributes.
* @param attribute the XML attribute to check
* @see #isEligibleAttribute(String)
* @deprecated in favour of {@link #isEligibleAttribute(org.w3c.dom.Attr, ParserContext)}
*/
@Deprecated
protected boolean isEligibleAttribute(Attr attribute) {
return false;
String fullName = attribute.getName();
return (!fullName.equals("xmlns") && !fullName.startsWith("xmlns:") &&
isEligibleAttribute(parserContext.getDelegate().getLocalName(attribute)));
}
/**

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

@ -37,15 +37,6 @@ import org.springframework.core.env.Environment; @@ -37,15 +37,6 @@ import org.springframework.core.env.Environment;
*/
public interface BeanDefinitionDocumentReader {
/**
* Set the Environment to use when reading bean definitions.
* <p>Used for evaluating profile information to determine whether a
* {@code <beans/>} document/element should be included or ignored.
* @deprecated in favor of {@link XmlReaderContext#getEnvironment()}
*/
@Deprecated
void setEnvironment(Environment environment);
/**
* Read bean definitions from the given DOM document and
* register them with the registry in the given reader context.

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

@ -88,10 +88,6 @@ public class BeanDefinitionParserDelegate { @@ -88,10 +88,6 @@ public class BeanDefinitionParserDelegate {
public static final String MULTI_VALUE_ATTRIBUTE_DELIMITERS = ",; ";
/** @deprecated as of Spring 3.1 in favor of {@link #MULTI_VALUE_ATTRIBUTE_DELIMITERS} */
@Deprecated
public static final String BEAN_NAME_DELIMITERS = MULTI_VALUE_ATTRIBUTE_DELIMITERS;
/**
* Value of a T/F attribute that represents true.
* Anything else represents false. Case seNsItive.
@ -266,17 +262,6 @@ public class BeanDefinitionParserDelegate { @@ -266,17 +262,6 @@ public class BeanDefinitionParserDelegate {
this.readerContext = readerContext;
}
/**
* Create a new BeanDefinitionParserDelegate associated with the supplied
* {@link XmlReaderContext}.
* @deprecated since the given {@link Environment} parameter is effectively
* ignored in favor of {@link XmlReaderContext#getEnvironment()}
*/
@Deprecated
public BeanDefinitionParserDelegate(XmlReaderContext readerContext, Environment environment) {
this(readerContext);
}
/**
* Get the {@link XmlReaderContext} associated with this helper instance.

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

@ -81,11 +81,6 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume @@ -81,11 +81,6 @@ public class DefaultBeanDefinitionDocumentReader implements BeanDefinitionDocume
private BeanDefinitionParserDelegate delegate;
@Deprecated
@Override
public void setEnvironment(Environment environment) {
}
/**
* This implementation parses bean definitions according to the "spring-beans" XSD
* (or DTD, historically).

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

@ -502,10 +502,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { @@ -502,10 +502,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
* @see #setDocumentReaderClass
* @see BeanDefinitionDocumentReader#registerBeanDefinitions
*/
@SuppressWarnings("deprecation")
public int registerBeanDefinitions(Document doc, Resource resource) throws BeanDefinitionStoreException {
BeanDefinitionDocumentReader documentReader = createBeanDefinitionDocumentReader();
documentReader.setEnvironment(getEnvironment());
int countBefore = getRegistry().getBeanDefinitionCount();
documentReader.registerBeanDefinitions(doc, createReaderContext(resource));
return getRegistry().getBeanDefinitionCount() - countBefore;

17
spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -62,21 +62,6 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar { @@ -62,21 +62,6 @@ public class ResourceEditorRegistrar implements PropertyEditorRegistrar {
private final ResourceLoader resourceLoader;
/**
* Create a new ResourceEditorRegistrar for the given {@link ResourceLoader}
* using a {@link StandardEnvironment}.
* @param resourceLoader the ResourceLoader (or ResourcePatternResolver)
* to create editors for (usually an ApplicationContext)
* @see org.springframework.core.io.support.ResourcePatternResolver
* @see org.springframework.context.ApplicationContext
* @deprecated as of Spring 3.1 in favor of
* {@link #ResourceEditorRegistrar(ResourceLoader, PropertyResolver)}
*/
@Deprecated
public ResourceEditorRegistrar(ResourceLoader resourceLoader) {
this(resourceLoader, new StandardEnvironment());
}
/**
* Create a new ResourceEditorRegistrar for the given {@link ResourceLoader}
* and {@link PropertyResolver}.

15
spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -157,19 +157,6 @@ public class FormattingConversionServiceFactoryBean @@ -157,19 +157,6 @@ public class FormattingConversionServiceFactoryBean
registrar.registerFormatters(this.conversionService);
}
}
installFormatters(this.conversionService);
}
/**
* Subclasses may override this method to register formatters and/or converters.
* Starting with Spring 3.1 however the recommended way of doing that is to
* through FormatterRegistrars.
* @see #setFormatters(Set)
* @see #setFormatterRegistrars(Set)
* @deprecated since Spring 3.1 in favor of {@link #setFormatterRegistrars(Set)}
*/
@Deprecated
protected void installFormatters(FormatterRegistry registry) {
}

33
spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java

@ -427,39 +427,6 @@ public class TypeDescriptor implements Serializable { @@ -427,39 +427,6 @@ public class TypeDescriptor implements Serializable {
return narrow(mapValue, getMapValueTypeDescriptor());
}
/**
* Returns the value of {@link TypeDescriptor#getType() getType()} for the
* {@link #getElementTypeDescriptor() elementTypeDescriptor}.
* @deprecated in Spring 3.1 in favor of {@link #getElementTypeDescriptor()}
* @throws IllegalStateException if this type is not a {@code java.util.Collection} or array type
*/
@Deprecated
public Class<?> getElementType() {
return getType(getElementTypeDescriptor());
}
/**
* Returns the value of {@link TypeDescriptor#getType() getType()} for the
* {@link #getMapKeyTypeDescriptor() getMapKeyTypeDescriptor}.
* @deprecated in Spring 3.1 in favor of {@link #getMapKeyTypeDescriptor()}
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Deprecated
public Class<?> getMapKeyType() {
return getType(getMapKeyTypeDescriptor());
}
/**
* Returns the value of {@link TypeDescriptor#getType() getType()} for the
* {@link #getMapValueTypeDescriptor() getMapValueTypeDescriptor}.
* @deprecated in Spring 3.1 in favor of {@link #getMapValueTypeDescriptor()}
* @throws IllegalStateException if this type is not a {@code java.util.Map}
*/
@Deprecated
public Class<?> getMapValueType() {
return getType(getMapValueTypeDescriptor());
}
private Class<?> getType(TypeDescriptor typeDescriptor) {
return (typeDescriptor != null ? typeDescriptor.getType() : null);
}

20
spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -60,22 +60,4 @@ public abstract class ConversionServiceFactory { @@ -60,22 +60,4 @@ public abstract class ConversionServiceFactory {
}
}
/**
* Create a new default GenericConversionService instance that can be safely modified.
* @deprecated in Spring 3.1 in favor of {@link DefaultConversionService#DefaultConversionService()}
*/
@Deprecated
public static GenericConversionService createDefaultConversionService() {
return new DefaultConversionService();
}
/**
* Populate the given GenericConversionService instance with the set of default converters.
* @deprecated in Spring 3.1 in favor of {@link DefaultConversionService#addDefaultConverters(ConverterRegistry)}
*/
@Deprecated
public static void addDefaultConverters(GenericConversionService conversionService) {
DefaultConversionService.addDefaultConverters(conversionService);
}
}

28
spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -63,32 +63,6 @@ public class ResourceEditor extends PropertyEditorSupport { @@ -63,32 +63,6 @@ public class ResourceEditor extends PropertyEditorSupport {
this(new DefaultResourceLoader(), null);
}
/**
* Create a new instance of the {@link ResourceEditor} class
* using the given {@link ResourceLoader} and a {@link StandardEnvironment}.
* @param resourceLoader the {@code ResourceLoader} to use
* @deprecated as of Spring 3.1 in favor of
* {@link #ResourceEditor(ResourceLoader, PropertyResolver)}
*/
@Deprecated
public ResourceEditor(ResourceLoader resourceLoader) {
this(resourceLoader, null, true);
}
/**
* Create a new instance of the {@link ResourceEditor} class
* using the given {@link ResourceLoader}.
* @param resourceLoader the {@code ResourceLoader} to use
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
* if no corresponding property could be found
* @deprecated as of Spring 3.1 in favor of
* {@link #ResourceEditor(ResourceLoader, PropertyResolver, boolean)}
*/
@Deprecated
public ResourceEditor(ResourceLoader resourceLoader, boolean ignoreUnresolvablePlaceholders) {
this(resourceLoader, null, ignoreUnresolvablePlaceholders);
}
/**
* Create a new instance of the {@link ResourceEditor} class
* using the given {@link ResourceLoader} and {@link PropertyResolver}.

26
spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -74,30 +74,6 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport { @@ -74,30 +74,6 @@ public class ResourceArrayPropertyEditor extends PropertyEditorSupport {
this(new PathMatchingResourcePatternResolver(), null, true);
}
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and a {@link StandardEnvironment}.
* @param resourcePatternResolver the ResourcePatternResolver to use
* @deprecated as of 3.1 in favor of {@link #ResourceArrayPropertyEditor(ResourcePatternResolver, PropertyResolver)}
*/
@Deprecated
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver) {
this(resourcePatternResolver, null, true);
}
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and a {@link StandardEnvironment}.
* @param resourcePatternResolver the ResourcePatternResolver to use
* @param ignoreUnresolvablePlaceholders whether to ignore unresolvable placeholders
* if no corresponding system property could be found
* @deprecated as of 3.1 in favor of {@link #ResourceArrayPropertyEditor(ResourcePatternResolver, PropertyResolver, boolean)}
*/
@Deprecated
public ResourceArrayPropertyEditor(ResourcePatternResolver resourcePatternResolver, boolean ignoreUnresolvablePlaceholders) {
this(resourcePatternResolver, null, ignoreUnresolvablePlaceholders);
}
/**
* Create a new ResourceArrayPropertyEditor with the given {@link ResourcePatternResolver}
* and {@link PropertyResolver} (typically an {@link Environment}).

19
spring-expression/src/main/java/org/springframework/expression/common/ExpressionUtils.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -32,23 +32,6 @@ import org.springframework.util.ClassUtils; @@ -32,23 +32,6 @@ import org.springframework.util.ClassUtils;
*/
public abstract class ExpressionUtils {
/**
* Determines if there is a type converter available in the specified context and
* attempts to use it to convert the supplied value to the specified type. Throws an
* exception if conversion is not possible.
* @param context the evaluation context that may define a type converter
* @param value the value to convert (may be null)
* @param targetType the type to attempt conversion to
* @return the converted value
* @throws EvaluationException if there is a problem during conversion or conversion
* of the value to the specified type is not supported
* @deprecated use {@link #convertTypedValue(EvaluationContext, TypedValue, Class)}
*/
@Deprecated
public static <T> T convert(EvaluationContext context, Object value, Class<T> targetType) throws EvaluationException {
return convertTypedValue(context, new TypedValue(value), targetType);
}
/**
* Determines if there is a type converter available in the specified context and
* attempts to use it to convert the supplied value to the specified type. Throws an

118
spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java

@ -183,44 +183,6 @@ public interface JdbcOperations { @@ -183,44 +183,6 @@ public interface JdbcOperations {
*/
Map<String, Object> queryForMap(String sql) throws DataAccessException;
/**
* Execute a query that results in a long value, given static SQL.
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
* execute a static query with a PreparedStatement, use the overloaded
* {@code queryForLong} method with {@code null} as argument array.
* <p>This method is useful for running static SQL with a known outcome.
* The query is expected to be a single row/single column query that results
* in a long value.
* @param sql SQL query to execute
* @return the long value, or 0 in case of SQL NULL
* @throws IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws DataAccessException if there is any problem executing the query
* @see #queryForLong(String, Object[])
* @deprecated in favor of {@link #queryForObject(String, Class)}
*/
@Deprecated
long queryForLong(String sql) throws DataAccessException;
/**
* Execute a query that results in an int value, given static SQL.
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
* execute a static query with a PreparedStatement, use the overloaded
* {@code queryForInt} method with {@code null} as argument array.
* <p>This method is useful for running static SQL with a known outcome.
* The query is expected to be a single row/single column query that results
* in an int value.
* @param sql SQL query to execute
* @return the int value, or 0 in case of SQL NULL
* @throws IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws DataAccessException if there is any problem executing the query
* @see #queryForInt(String, Object[])
* @deprecated in favor of {@link #queryForObject(String, Class)}
*/
@Deprecated
int queryForInt(String sql) throws DataAccessException;
/**
* Execute a query for a result list, given static SQL.
* <p>Uses a JDBC Statement, not a PreparedStatement. If you want to
@ -695,86 +657,6 @@ public interface JdbcOperations { @@ -695,86 +657,6 @@ public interface JdbcOperations {
*/
Map<String, Object> queryForMap(String sql, Object... args) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in a long value.
* <p>The query is expected to be a single row/single column query that
* results in a long value.
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @param argTypes SQL types of the arguments
* (constants from {@code java.sql.Types})
* @return the long value, or 0 in case of SQL NULL
* @throws IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws DataAccessException if the query fails
* @see #queryForLong(String)
* @see java.sql.Types
* @deprecated in favor of {@link #queryForObject(String, Object[], int[], Class)} )}
*/
@Deprecated
long queryForLong(String sql, Object[] args, int[] argTypes) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in a long value.
* <p>The query is expected to be a single row/single column query that
* results in a long value.
* @param sql SQL query to execute
* @param args arguments to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
* may also contain {@link SqlParameterValue} objects which indicate not
* only the argument value but also the SQL type and optionally the scale
* @return the long value, or 0 in case of SQL NULL
* @throws IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws DataAccessException if the query fails
* @see #queryForLong(String)
* @deprecated in favor of {@link #queryForObject(String, Class, Object[])} )}
*/
@Deprecated
long queryForLong(String sql, Object... args) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in an int value.
* <p>The query is expected to be a single row/single column query that
* results in an int value.
* @param sql SQL query to execute
* @param args arguments to bind to the query
* @param argTypes SQL types of the arguments
* (constants from {@code java.sql.Types})
* @return the int value, or 0 in case of SQL NULL
* @throws IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws DataAccessException if the query fails
* @see #queryForInt(String)
* @see java.sql.Types
* @deprecated in favor of {@link #queryForObject(String, Object[], int[], Class)} )}
*/
@Deprecated
int queryForInt(String sql, Object[] args, int[] argTypes) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in an int value.
* <p>The query is expected to be a single row/single column query that
* results in an int value.
* @param sql SQL query to execute
* @param args arguments to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type);
* may also contain {@link SqlParameterValue} objects which indicate not
* only the argument value but also the SQL type and optionally the scale
* @return the int value, or 0 in case of SQL NULL
* @throws IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws DataAccessException if the query fails
* @see #queryForInt(String)
* @deprecated in favor of {@link #queryForObject(String, Class, Object[])} )}
*/
@Deprecated
int queryForInt(String sql, Object... args) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, expecting a result list.

42
spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

@ -497,20 +497,6 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { @@ -497,20 +497,6 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
return queryForObject(sql, getSingleColumnRowMapper(requiredType));
}
@Override
@Deprecated
public long queryForLong(String sql) throws DataAccessException {
Number number = queryForObject(sql, Long.class);
return (number != null ? number.longValue() : 0);
}
@Override
@Deprecated
public int queryForInt(String sql) throws DataAccessException {
Number number = queryForObject(sql, Integer.class);
return (number != null ? number.intValue() : 0);
}
@Override
public <T> List<T> queryForList(String sql, Class<T> elementType) throws DataAccessException {
return query(sql, getSingleColumnRowMapper(elementType));
@ -839,34 +825,6 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { @@ -839,34 +825,6 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
return queryForObject(sql, args, getColumnMapRowMapper());
}
@Override
@Deprecated
public long queryForLong(String sql, Object[] args, int[] argTypes) throws DataAccessException {
Number number = queryForObject(sql, args, argTypes, Long.class);
return (number != null ? number.longValue() : 0);
}
@Override
@Deprecated
public long queryForLong(String sql, Object... args) throws DataAccessException {
Number number = queryForObject(sql, args, Long.class);
return (number != null ? number.longValue() : 0);
}
@Override
@Deprecated
public int queryForInt(String sql, Object[] args, int[] argTypes) throws DataAccessException {
Number number = queryForObject(sql, args, argTypes, Integer.class);
return (number != null ? number.intValue() : 0);
}
@Override
@Deprecated
public int queryForInt(String sql, Object... args) throws DataAccessException {
Number number = queryForObject(sql, args, Integer.class);
return (number != null ? number.intValue() : 0);
}
@Override
public <T> List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elementType) throws DataAccessException {
return query(sql, args, argTypes, getSingleColumnRowMapper(elementType));

74
spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -325,78 +325,6 @@ public interface NamedParameterJdbcOperations { @@ -325,78 +325,6 @@ public interface NamedParameterJdbcOperations {
*/
Map<String, Object> queryForMap(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in a long value.
* <p>The query is expected to be a single row/single column query that
* results in a long value.
* @param sql SQL query to execute
* @param paramSource container of arguments to bind to the query
* @return the long value, or 0 in case of SQL NULL
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException
* if the query does not return exactly one row, or does not return exactly
* one column in that row
* @throws org.springframework.dao.DataAccessException if the query fails
* @see org.springframework.jdbc.core.JdbcTemplate#queryForLong(String)
* @deprecated in favor of {@link #queryForObject(String, SqlParameterSource, Class)}
*/
@Deprecated
long queryForLong(String sql, SqlParameterSource paramSource) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in a long value.
* <p>The query is expected to be a single row/single column query that
* results in a long value.
* @param sql SQL query to execute
* @param paramMap map of parameters to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type)
* @return the long value, or 0 in case of SQL NULL
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException
* if the query does not return exactly one row, or does not return exactly
* one column in that row
* @throws org.springframework.dao.DataAccessException if the query fails
* @see org.springframework.jdbc.core.JdbcTemplate#queryForLong(String)
* @deprecated in favor of {@link #queryForObject(String, Map, Class)}
*/
@Deprecated
long queryForLong(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in an int value.
* <p>The query is expected to be a single row/single column query that
* results in an int value.
* @param sql SQL query to execute
* @param paramSource container of arguments to bind to the query
* @return the int value, or 0 in case of SQL NULL
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws org.springframework.dao.DataAccessException if the query fails
* @see org.springframework.jdbc.core.JdbcTemplate#queryForInt(String)
* @deprecated in favor of {@link #queryForObject(String, SqlParameterSource, Class)}
*/
@Deprecated
int queryForInt(String sql, SqlParameterSource paramSource) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, resulting in an int value.
* <p>The query is expected to be a single row/single column query that
* results in an int value.
* @param sql SQL query to execute
* @param paramMap map of parameters to bind to the query
* (leaving it to the PreparedStatement to guess the corresponding SQL type)
* @return the int value, or 0 in case of SQL NULL
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the query does not return
* exactly one row, or does not return exactly one column in that row
* @throws org.springframework.dao.DataAccessException if the query fails
* @see org.springframework.jdbc.core.JdbcTemplate#queryForInt(String)
* @deprecated in favor of {@link #queryForObject(String, Map, Class)}
*/
@Deprecated
int queryForInt(String sql, Map<String, ?> paramMap) throws DataAccessException;
/**
* Query given SQL to create a prepared statement from SQL and a
* list of arguments to bind to the query, expecting a result list.

26
spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java

@ -243,32 +243,6 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations @@ -243,32 +243,6 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
return queryForObject(sql, paramMap, new ColumnMapRowMapper());
}
@Override
@Deprecated
public long queryForLong(String sql, SqlParameterSource paramSource) throws DataAccessException {
Number number = queryForObject(sql, paramSource, Long.class);
return (number != null ? number.longValue() : 0);
}
@Override
@Deprecated
public long queryForLong(String sql, Map<String, ?> paramMap) throws DataAccessException {
return queryForLong(sql, new MapSqlParameterSource(paramMap));
}
@Override
@Deprecated
public int queryForInt(String sql, SqlParameterSource paramSource) throws DataAccessException {
Number number = queryForObject(sql, paramSource, Integer.class);
return (number != null ? number.intValue() : 0);
}
@Override
@Deprecated
public int queryForInt(String sql, Map<String, ?> paramMap) throws DataAccessException {
return queryForInt(sql, new MapSqlParameterSource(paramMap));
}
@Override
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
throws DataAccessException {

10
spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java

@ -321,16 +321,6 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing @@ -321,16 +321,6 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
this.ignoreExtraElements = ignoreExtraElements;
}
/**
* Set the expected root object for the unmarshaller, into which the source will be unmarshalled.
* @see org.exolab.castor.xml.Unmarshaller#setObject(Object)
* @deprecated in favor of {@link #setRootObject}
*/
@Deprecated
public void setObject(Object root) {
this.rootObject = root;
}
/**
* Set the expected root object for the unmarshaller, into which the source will be unmarshalled.
* @see org.exolab.castor.xml.Unmarshaller#setObject(Object)

246
spring-test/src/main/java/org/springframework/test/AssertThrows.java

@ -1,246 +0,0 @@ @@ -1,246 +0,0 @@
/*
* Copyright 2002-2014 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;
import org.springframework.util.Assert;
/**
* {@code AssertThrows} is a simple method object that encapsulates the
* <em>'test-for-exception'</em> scenario for unit testing. Intended for
* use with JUnit or TestNG.
*
* <p>Given the following business class...
*
* <pre class="code">
* // the class under test
* public class Foo {
* public void someBusinessLogic(String name) {
* if (name == null) {
* throw new IllegalArgumentException("The 'name' argument is required");
* }
* // rest of business logic here...
* }
* }</pre>
*
* <p>The test for the above bad argument path can be expressed using
* {@code AssertThrows} like so:
*
* <pre class="code">
* public class FooTest {
* public void testSomeBusinessLogicBadArgumentPath() {
* new AssertThrows(IllegalArgumentException.class) {
* public void test() {
* new Foo().someBusinessLogic(null);
* }
* }.runTest();
* }
* }</pre>
*
* <p>This will result in the test passing if the {@code Foo.someBusinessLogic(..)}
* method threw an {@code IllegalArgumentException}; if it did not, the
* test would fail with the following message:
*
* <pre class="code">"Must have thrown a [class java.lang.IllegalArgumentException]"</pre>
*
* <p>If the <strong>wrong</strong> type of {@code Throwable} was thrown,
* the test will also fail, this time with a message similar to the following:
*
* <pre class="code">"java.lang.AssertionError: Was expecting a [class java.lang.UnsupportedOperationException] to be thrown, but instead a [class java.lang.IllegalArgumentException] was thrown"</pre>
*
* <p>The test for the correct {@code Throwable} respects polymorphism,
* so you can test that any old {@code Exception} is thrown like so:
*
* <pre class="code">
* public class FooTest {
* public void testSomeBusinessLogicBadArgumentPath() {
* // any Exception will do...
* new AssertThrows(Exception.class) {
* public void test() {
* new Foo().someBusinessLogic(null);
* }
* }.runTest();
* }
* }</pre>
*
* @author Rick Evans
* @author Juergen Hoeller
* @author Sam Brannen
* @since 2.0
* @deprecated Favor use of JUnit's {@code @Test(expected=...)} or
* {@code @Rule ExpectedException} support or TestNG's
* {@code @Test(expectedExceptions=...)} support
*/
@Deprecated
public abstract class AssertThrows {
private final Class<? extends Throwable> expectedException;
private String failureMessage;
private Throwable actualException;
/**
* Create a new instance of the {@code AssertThrows} class.
* @param expectedException the {@link Throwable} expected to be
* thrown during the execution of the surrounding test
* @throws IllegalArgumentException if the supplied {@code expectedException} is
* {@code null}; or if said argument is not a {@code Throwable}-derived class
*/
public AssertThrows(Class<? extends Throwable> expectedException) {
this(expectedException, null);
}
/**
* Create a new instance of the {@code AssertThrows} class.
* @param expectedException the {@link Throwable} expected to be
* thrown during the execution of the surrounding test
* @param failureMessage the extra, contextual failure message that will be
* included in the failure text if the text fails (can be {@code null})
* @throws IllegalArgumentException if the supplied {@code expectedException} is
* {@code null}; or if said argument is not a {@code Throwable}-derived class
*/
public AssertThrows(Class<? extends Throwable> expectedException, String failureMessage) {
Assert.notNull(expectedException, "expectedException is required");
Assert.isAssignable(Throwable.class, expectedException, "expectedException: ");
this.expectedException = expectedException;
this.failureMessage = failureMessage;
}
/**
* Return the {@link java.lang.Throwable} expected to be thrown during
* the execution of the surrounding test.
*/
protected Class<? extends Throwable> getExpectedException() {
return this.expectedException;
}
/**
* Set the extra, contextual failure message that will be included
* in the failure text if the text fails.
*/
public void setFailureMessage(String failureMessage) {
this.failureMessage = failureMessage;
}
/**
* Return the extra, contextual failure message that will be included
* in the failure text if the text fails.
*/
protected String getFailureMessage() {
return this.failureMessage;
}
/**
* Subclass must override this {@code abstract} method and
* provide the test logic.
* @throws Throwable if an error occurs during the execution of the
* aforementioned test logic
*/
public abstract void test() throws Throwable;
/**
* The main template method that drives the running of the
* {@linkplain #test() test logic} and the
* {@linkplain #checkExceptionExpectations(Throwable) checking} of the
* resulting (expected) {@link java.lang.Throwable}.
* @see #test()
* @see #doFail()
* @see #checkExceptionExpectations(Throwable)
*/
public void runTest() {
try {
test();
doFail();
}
catch (Throwable actualException) {
this.actualException = actualException;
checkExceptionExpectations(actualException);
}
}
/**
* Template method called when the test fails; i.e. the expected
* {@link java.lang.Throwable} is <b>not</b> thrown.
* <p>The default implementation simply fails the test by throwing an
* {@link AssertionError}.
* <p>If you want to customize the failure message, consider overriding
* {@link #createMessageForNoExceptionThrown()}, and / or supplying an
* extra, contextual failure message via the appropriate constructor.
* @see #getFailureMessage()
* @see #createMessageForNoExceptionThrown()
*/
protected void doFail() {
throw new AssertionError(createMessageForNoExceptionThrown());
}
/**
* Creates the failure message used if the test fails
* (i.e. the expected exception is not thrown in the body of the test).
* @return the failure message used if the test fails
* @see #getFailureMessage()
*/
protected String createMessageForNoExceptionThrown() {
StringBuilder sb = new StringBuilder();
sb.append("Should have thrown a [").append(this.getExpectedException()).append("]");
if (getFailureMessage() != null) {
sb.append(": ").append(getFailureMessage());
}
return sb.toString();
}
/**
* Does the donkey work of checking (verifying) that the
* {@link Throwable} that was thrown in the body of the test is
* an instance of the {@link #getExpectedException()} class (or an
* instance of a subclass).
* <p>If you want to customize the failure message, consider overriding
* {@link #createMessageForWrongThrownExceptionType(Throwable)}.
* @param actualException the {@link Throwable} that has been thrown
* in the body of a test method (will never be {@code null})
*/
protected void checkExceptionExpectations(Throwable actualException) {
if (!getExpectedException().isAssignableFrom(actualException.getClass())) {
AssertionError error = new AssertionError(createMessageForWrongThrownExceptionType(actualException));
error.initCause(actualException);
throw error;
}
}
/**
* Creates the failure message used if the wrong type
* of {@link java.lang.Throwable} is thrown in the body of the test.
* @param actualException the actual exception thrown
* @return the message for the given exception
*/
protected String createMessageForWrongThrownExceptionType(Throwable actualException) {
StringBuilder sb = new StringBuilder();
sb.append("Was expecting a [").append(getExpectedException().getName());
sb.append("] to be thrown, but instead a [").append(actualException.getClass().getName());
sb.append("] was thrown.");
return sb.toString();
}
/**
* Expose the actual exception thrown from {@link #test}, if any.
* @return the actual exception, or {@code null} if none
*/
public final Throwable getActualException() {
return this.actualException;
}
}

23
spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java

@ -91,29 +91,6 @@ public class ContextConfigurationAttributes { @@ -91,29 +91,6 @@ public class ContextConfigurationAttributes {
(Class<? extends ContextLoader>) annAttrs.getClass("loader"));
}
/**
* Construct a new {@link ContextConfigurationAttributes} instance for the
* {@linkplain Class test class} that declared the
* {@link ContextConfiguration @ContextConfiguration} annotation and its
* corresponding attributes.
* @param declaringClass the test class that declared {@code @ContextConfiguration}
* @param locations the resource locations declared via {@code @ContextConfiguration}
* @param classes the annotated classes declared via {@code @ContextConfiguration}
* @param inheritLocations the {@code inheritLocations} flag declared via {@code @ContextConfiguration}
* @param contextLoaderClass the {@code ContextLoader} class declared via {@code @ContextConfiguration}
* @throws IllegalArgumentException if the {@code declaringClass} or {@code contextLoaderClass} is
* {@code null}
* @deprecated as of Spring 3.2, use
* {@link #ContextConfigurationAttributes(Class, String[], Class[], boolean, Class[], boolean, String, Class)}
* instead
*/
@Deprecated
public ContextConfigurationAttributes(Class<?> declaringClass, String[] locations, Class<?>[] classes,
boolean inheritLocations, Class<? extends ContextLoader> contextLoaderClass) {
this(declaringClass, locations, classes, inheritLocations, null, true, null, contextLoaderClass);
}
/**
* Construct a new {@link ContextConfigurationAttributes} instance for the
* {@linkplain Class test class} that declared the

89
spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java

@ -63,36 +63,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -63,36 +63,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
* 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}
* @see #WebMergedContextConfiguration(Class, String[], Class[], Set, String[], String, ContextLoader, CacheAwareContextLoaderDelegate, MergedContextConfiguration)
* @deprecated as of Spring 3.2.2, use
* {@link #WebMergedContextConfiguration(Class, String[], Class[], Set, 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) {
this(testClass, locations, classes, contextInitializerClasses, activeProfiles, null, null, resourceBasePath,
contextLoader, null, null);
}
/**
* 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
@ -137,7 +107,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -137,7 +107,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
/**
* Create a new {@code WebMergedContextConfiguration} instance for the
* supplied parameters.
*
* <p>If a {@code null} value is supplied for {@code locations},
* {@code classes}, {@code activeProfiles}, {@code propertySourceLocations},
* or {@code propertySourceProperties} an empty array will be stored instead.
@ -146,7 +115,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -146,7 +115,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
* If an <em>empty</em> value is supplied for the {@code resourceBasePath}
* an empty string will be used. Furthermore, active profiles will be sorted,
* and duplicate profiles will be removed.
*
* @param testClass the test class for which the configuration was merged
* @param locations the merged resource locations
* @param classes the merged annotated classes
@ -161,10 +129,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -161,10 +129,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
* @param parent the parent configuration or {@code null} if there is no parent
* @since 4.1
*/
public WebMergedContextConfiguration(
Class<?> testClass,
String[] locations,
Class<?>[] classes,
public WebMergedContextConfiguration(Class<?> testClass, String[] locations, Class<?>[] classes,
Set<Class<? extends ApplicationContextInitializer<? extends ConfigurableApplicationContext>>> contextInitializerClasses,
String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties,
String resourceBasePath, ContextLoader contextLoader,
@ -176,6 +141,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -176,6 +141,7 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
this.resourceBasePath = !StringUtils.hasText(resourceBasePath) ? "" : resourceBasePath;
}
/**
* Get the resource path to the root directory of the web application for the
* {@linkplain #getTestClass() test class}, configured via {@code @WebAppConfiguration}.
@ -185,18 +151,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -185,18 +151,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
return this.resourceBasePath;
}
/**
* Generate a unique hash code for all properties of this
* {@code WebMergedContextConfiguration} excluding the
* {@linkplain #getTestClass() test class}.
*/
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + resourceBasePath.hashCode();
return result;
}
/**
* Determine if the supplied object is equal to this {@code WebMergedContextConfiguration}
@ -210,19 +164,26 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -210,19 +164,26 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof WebMergedContextConfiguration)) {
return false;
}
final WebMergedContextConfiguration that = (WebMergedContextConfiguration) obj;
WebMergedContextConfiguration that = (WebMergedContextConfiguration) obj;
return super.equals(that) && this.getResourceBasePath().equals(that.getResourceBasePath());
}
/**
* Generate a unique hash code for all properties of this
* {@code WebMergedContextConfiguration} excluding the
* {@linkplain #getTestClass() test class}.
*/
@Override
public int hashCode() {
return super.hashCode() * 31 + this.resourceBasePath.hashCode();
}
/**
* Provide a String representation of the {@linkplain #getTestClass() test class},
* {@linkplain #getLocations() locations}, {@linkplain #getClasses() annotated classes},
@ -236,18 +197,18 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { @@ -236,18 +197,18 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration {
*/
@Override
public String toString() {
return new ToStringCreator(this)//
.append("testClass", getTestClass())//
.append("locations", ObjectUtils.nullSafeToString(getLocations()))//
.append("classes", ObjectUtils.nullSafeToString(getClasses()))//
.append("contextInitializerClasses", ObjectUtils.nullSafeToString(getContextInitializerClasses()))//
.append("activeProfiles", ObjectUtils.nullSafeToString(getActiveProfiles()))//
.append("propertySourceLocations", ObjectUtils.nullSafeToString(getPropertySourceLocations()))//
.append("propertySourceProperties", ObjectUtils.nullSafeToString(getPropertySourceProperties()))//
.append("resourceBasePath", getResourceBasePath())//
.append("contextLoader", nullSafeToString(getContextLoader()))//
.append("parent", getParent())//
.toString();
return new ToStringCreator(this)
.append("testClass", getTestClass())
.append("locations", ObjectUtils.nullSafeToString(getLocations()))
.append("classes", ObjectUtils.nullSafeToString(getClasses()))
.append("contextInitializerClasses", ObjectUtils.nullSafeToString(getContextInitializerClasses()))
.append("activeProfiles", ObjectUtils.nullSafeToString(getActiveProfiles()))
.append("propertySourceLocations", ObjectUtils.nullSafeToString(getPropertySourceLocations()))
.append("propertySourceProperties", ObjectUtils.nullSafeToString(getPropertySourceProperties()))
.append("resourceBasePath", getResourceBasePath())
.append("contextLoader", nullSafeToString(getContextLoader()))
.append("parent", getParent())
.toString();
}
}

21
spring-tx/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -48,25 +48,6 @@ import org.springframework.transaction.interceptor.TransactionInterceptor; @@ -48,25 +48,6 @@ import org.springframework.transaction.interceptor.TransactionInterceptor;
*/
class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser {
/**
* The bean name of the internally managed transaction advisor (mode="proxy").
* @deprecated as of Spring 3.1 in favor of
* {@link TransactionManagementConfigUtils#TRANSACTION_ADVISOR_BEAN_NAME}
*/
@Deprecated
public static final String TRANSACTION_ADVISOR_BEAN_NAME =
TransactionManagementConfigUtils.TRANSACTION_ADVISOR_BEAN_NAME;
/**
* The bean name of the internally managed transaction aspect (mode="aspectj").
* @deprecated as of Spring 3.1 in favor of
* {@link TransactionManagementConfigUtils#TRANSACTION_ASPECT_BEAN_NAME}
*/
@Deprecated
public static final String TRANSACTION_ASPECT_BEAN_NAME =
TransactionManagementConfigUtils.TRANSACTION_ASPECT_BEAN_NAME;
/**
* Parses the {@code <tx:annotation-driven/>} tag. Will
* {@link AopNamespaceUtils#registerAutoProxyCreatorIfNecessary register an AutoProxyCreator}

37
spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java

@ -385,46 +385,9 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init @@ -385,46 +385,9 @@ public abstract class TransactionAspectSupport implements BeanFactoryAware, Init
* @see org.springframework.util.ClassUtils#getQualifiedMethodName
*/
protected String methodIdentification(Method method, Class<?> targetClass) {
String simpleMethodId = methodIdentification(method);
if (simpleMethodId != null) {
return simpleMethodId;
}
return (targetClass != null ? targetClass : method.getDeclaringClass()).getName() + "." + method.getName();
}
/**
* Convenience method to return a String representation of this Method
* for use in logging. Can be overridden in subclasses to provide a
* different identifier for the given method.
* @param method the method we're interested in
* @return a String representation identifying this method
* @deprecated in favor of {@link #methodIdentification(Method, Class)}
*/
@Deprecated
protected String methodIdentification(Method method) {
return null;
}
/**
* Create a transaction if necessary, based on the given method and class.
* <p>Performs a default TransactionAttribute lookup for the given method.
* @param method the method about to execute
* @param targetClass the class that the method is being invoked on
* @return a TransactionInfo object, whether or not a transaction was created.
* The {@code hasTransaction()} method on TransactionInfo can be used to
* tell if there was a transaction created.
* @see #getTransactionAttributeSource()
* @deprecated in favor of
* {@link #createTransactionIfNecessary(PlatformTransactionManager, TransactionAttribute, String)}
*/
@Deprecated
protected TransactionInfo createTransactionIfNecessary(Method method, Class<?> targetClass) {
// If the transaction attribute is null, the method is non-transactional.
TransactionAttribute txAttr = getTransactionAttributeSource().getTransactionAttribute(method, targetClass);
PlatformTransactionManager tm = determineTransactionManager(txAttr);
return createTransactionIfNecessary(tm, txAttr, methodIdentification(method, targetClass));
}
/**
* Create a transaction if necessary based on the given TransactionAttribute.
* <p>Allows callers to perform custom TransactionAttribute lookups through

11
spring-web/src/main/java/org/springframework/http/HttpHeaders.java

@ -624,17 +624,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable @@ -624,17 +624,6 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
setDate(IF_MODIFIED_SINCE, ifModifiedSince);
}
/**
* Return the value of the {@code IfModifiedSince} header.
* <p>The date is returned as the number of milliseconds since
* January 1, 1970 GMT. Returns -1 when the date is unknown.
* @deprecated use {@link #getIfModifiedSince()}
*/
@Deprecated
public long getIfNotModifiedSince() {
return getIfModifiedSince();
}
/**
* Return the value of the {@code If-Modified-Since} header.
* <p>The date is returned as the number of milliseconds since

14
spring-web/src/main/java/org/springframework/web/context/ContextLoader.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -107,7 +107,6 @@ public class ContextLoader { @@ -107,7 +107,6 @@ public class ContextLoader {
/**
* Config param for the root WebApplicationContext implementation class to use: {@value}
* @see #determineContextClass(ServletContext)
* @see #createWebApplicationContext(ServletContext, ApplicationContext)
*/
public static final String CONTEXT_CLASS_PARAM = "contextClass";
@ -360,16 +359,6 @@ public class ContextLoader { @@ -360,16 +359,6 @@ public class ContextLoader {
return (ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass);
}
/**
* @deprecated as of Spring 3.1 in favor of
* {@link #createWebApplicationContext(ServletContext)} and
* {@link #configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext, ServletContext)}
*/
@Deprecated
protected WebApplicationContext createWebApplicationContext(ServletContext sc, ApplicationContext parent) {
return createWebApplicationContext(sc);
}
protected void configureAndRefreshWebApplicationContext(ConfigurableWebApplicationContext wac, ServletContext sc) {
if (ObjectUtils.identityToString(wac).equals(wac.getId())) {
// The application context id is still set to its original default value
@ -417,7 +406,6 @@ public class ContextLoader { @@ -417,7 +406,6 @@ public class ContextLoader {
* org.springframework.core.annotation.Order Order} will be sorted appropriately.
* @param sc the current servlet context
* @param wac the newly created application context
* @see #createWebApplicationContext(ServletContext, ApplicationContext)
* @see #CONTEXT_INITIALIZER_CLASSES_PARAM
* @see ApplicationContextInitializer#initialize(ConfigurableApplicationContext)
*/

162
spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertyPlaceholderConfigurer.java

@ -1,162 +0,0 @@ @@ -1,162 +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.web.context.support;
import java.util.Properties;
import javax.servlet.ServletContext;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.web.context.ServletContextAware;
/**
* Subclass of {@link PropertyPlaceholderConfigurer} that resolves placeholders as
* ServletContext init parameters (that is, {@code web.xml} context-param
* entries).
*
* <p>Can be combined with "locations" and/or "properties" values in addition
* to web.xml context-params. Alternatively, can be defined without local
* properties, to resolve all placeholders as {@code web.xml} context-params
* (or JVM system properties).
*
* <p>If a placeholder could not be resolved against the provided local
* properties within the application, this configurer will fall back to
* ServletContext parameters. Can also be configured to let ServletContext
* init parameters override local properties (contextOverride=true).
*
* <p>Optionally supports searching for ServletContext <i>attributes</i>: If turned
* on, an otherwise unresolvable placeholder will matched against the corresponding
* ServletContext attribute, using its stringified value if found. This can be
* used to feed dynamic values into Spring's placeholder resolution.
*
* <p>If not running within a WebApplicationContext (or any other context that
* is able to satisfy the ServletContextAware callback), this class will behave
* like the default PropertyPlaceholderConfigurer. This allows for keeping
* ServletContextPropertyPlaceholderConfigurer definitions in test suites.
*
* @author Juergen Hoeller
* @since 1.1.4
* @see #setLocations
* @see #setProperties
* @see #setSystemPropertiesModeName
* @see #setContextOverride
* @see #setSearchContextAttributes
* @see javax.servlet.ServletContext#getInitParameter(String)
* @see javax.servlet.ServletContext#getAttribute(String)
* @deprecated in Spring 3.1 in favor of {@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer}
* in conjunction with {@link StandardServletEnvironment}.
*/
@Deprecated
public class ServletContextPropertyPlaceholderConfigurer extends PropertyPlaceholderConfigurer
implements ServletContextAware {
private boolean contextOverride = false;
private boolean searchContextAttributes = false;
private ServletContext servletContext;
/**
* Set whether ServletContext init parameters (and optionally also ServletContext
* attributes) should override local properties within the application.
* Default is "false": ServletContext settings serve as fallback.
* <p>Note that system properties will still override ServletContext settings,
* if the system properties mode is set to "SYSTEM_PROPERTIES_MODE_OVERRIDE".
* @see #setSearchContextAttributes
* @see #setSystemPropertiesModeName
* @see #SYSTEM_PROPERTIES_MODE_OVERRIDE
*/
public void setContextOverride(boolean contextOverride) {
this.contextOverride = contextOverride;
}
/**
* Set whether to search for matching a ServletContext attribute before
* checking a ServletContext init parameter. Default is "false": only
* checking init parameters.
* <p>If turned on, the configurer will look for a ServletContext attribute with
* the same name as the placeholder, and use its stringified value if found.
* Exposure of such ServletContext attributes can be used to dynamically override
* init parameters defined in {@code web.xml}, for example in a custom
* context listener.
* @see javax.servlet.ServletContext#getInitParameter(String)
* @see javax.servlet.ServletContext#getAttribute(String)
*/
public void setSearchContextAttributes(boolean searchContextAttributes) {
this.searchContextAttributes = searchContextAttributes;
}
/**
* Set the ServletContext to resolve placeholders against.
* Will be auto-populated when running in a WebApplicationContext.
* <p>If not set, this configurer will simply not resolve placeholders
* against the ServletContext: It will effectively behave like a plain
* PropertyPlaceholderConfigurer in such a scenario.
*/
@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
@Override
protected String resolvePlaceholder(String placeholder, Properties props) {
String value = null;
if (this.contextOverride && this.servletContext != null) {
value = resolvePlaceholder(placeholder, this.servletContext, this.searchContextAttributes);
}
if (value == null) {
value = super.resolvePlaceholder(placeholder, props);
}
if (value == null && this.servletContext != null) {
value = resolvePlaceholder(placeholder, this.servletContext, this.searchContextAttributes);
}
return value;
}
/**
* Resolves the given placeholder using the init parameters
* and optionally also the attributes of the given ServletContext.
* <p>Default implementation checks ServletContext attributes before
* init parameters. Can be overridden to customize this behavior,
* potentially also applying specific naming patterns for parameters
* and/or attributes (instead of using the exact placeholder name).
* @param placeholder the placeholder to resolve
* @param servletContext the ServletContext to check
* @param searchContextAttributes whether to search for a matching
* ServletContext attribute
* @return the resolved value, of null if none
* @see javax.servlet.ServletContext#getInitParameter(String)
* @see javax.servlet.ServletContext#getAttribute(String)
*/
protected String resolvePlaceholder(
String placeholder, ServletContext servletContext, boolean searchContextAttributes) {
String value = null;
if (searchContextAttributes) {
Object attrValue = servletContext.getAttribute(placeholder);
if (attrValue != null) {
value = attrValue.toString();
}
}
if (value == null) {
value = servletContext.getInitParameter(placeholder);
}
return value;
}
}

9
spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -46,13 +46,6 @@ public class CookieGenerator { @@ -46,13 +46,6 @@ public class CookieGenerator {
*/
public static final String DEFAULT_COOKIE_PATH = "/";
/**
* Default maximum age of cookies: maximum integer value, i.e. forever.
* @deprecated in favor of setting no max age value at all in such a case
*/
@Deprecated
public static final int DEFAULT_COOKIE_MAX_AGE = Integer.MAX_VALUE;
protected final Log logger = LogFactory.getLog(getClass());

142
spring-web/src/main/java/org/springframework/web/util/UriUtils.java

@ -67,148 +67,6 @@ public abstract class UriUtils { @@ -67,148 +67,6 @@ public abstract class UriUtils {
PATH_PATTERN + "(\\?" + LAST_PATTERN + ")?");
// encoding
/**
* Encodes the given source URI into an encoded String. All various URI components are
* encoded according to their respective valid character sets.
* <p><strong>Note</strong> that this method does not attempt to encode "=" and "&"
* characters in query parameter names and query parameter values because they cannot
* be parsed in a reliable way. Instead use:
* <pre class="code">
* UriComponents uriComponents = UriComponentsBuilder.fromUri("/path?name={value}").buildAndExpand("a=b");
* String encodedUri = uriComponents.encode().toUriString();
* </pre>
* @param uri the URI to be encoded
* @param encoding the character encoding to encode to
* @return the encoded URI
* @throws IllegalArgumentException when the given uri parameter is not a valid URI
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
* @deprecated in favor of {@link UriComponentsBuilder}; see note about query param encoding
*/
@Deprecated
public static String encodeUri(String uri, String encoding) throws UnsupportedEncodingException {
Assert.notNull(uri, "URI must not be null");
Assert.hasLength(encoding, "Encoding must not be empty");
Matcher matcher = URI_PATTERN.matcher(uri);
if (matcher.matches()) {
String scheme = matcher.group(2);
String authority = matcher.group(3);
String userinfo = matcher.group(5);
String host = matcher.group(6);
String port = matcher.group(8);
String path = matcher.group(9);
String query = matcher.group(11);
String fragment = matcher.group(13);
return encodeUriComponents(scheme, authority, userinfo, host, port, path, query, fragment, encoding);
}
else {
throw new IllegalArgumentException("[" + uri + "] is not a valid URI");
}
}
/**
* Encodes the given HTTP URI into an encoded String. All various URI components are
* encoded according to their respective valid character sets.
* <p><strong>Note</strong> that this method does not support fragments ({@code #}),
* as these are not supposed to be sent to the server, but retained by the client.
* <p><strong>Note</strong> that this method does not attempt to encode "=" and "&"
* characters in query parameter names and query parameter values because they cannot
* be parsed in a reliable way. Instead use:
* <pre class="code">
* UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl("/path?name={value}").buildAndExpand("a=b");
* String encodedUri = uriComponents.encode().toUriString();
* </pre>
* @param httpUrl the HTTP URL to be encoded
* @param encoding the character encoding to encode to
* @return the encoded URL
* @throws IllegalArgumentException when the given uri parameter is not a valid URI
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
* @deprecated in favor of {@link UriComponentsBuilder}; see note about query param encoding
*/
@Deprecated
public static String encodeHttpUrl(String httpUrl, String encoding) throws UnsupportedEncodingException {
Assert.notNull(httpUrl, "HTTP URL must not be null");
Assert.hasLength(encoding, "Encoding must not be empty");
Matcher matcher = HTTP_URL_PATTERN.matcher(httpUrl);
if (matcher.matches()) {
String scheme = matcher.group(1);
String authority = matcher.group(2);
String userinfo = matcher.group(4);
String host = matcher.group(5);
String portString = matcher.group(7);
String path = matcher.group(8);
String query = matcher.group(10);
return encodeUriComponents(scheme, authority, userinfo, host, portString, path, query, null, encoding);
}
else {
throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL");
}
}
/**
* Encodes the given source URI components into an encoded String. All various URI components
* are optional, but encoded according to their respective valid character sets.
* @param scheme the scheme
* @param authority the authority
* @param userInfo the user info
* @param host the host
* @param port the port
* @param path the path
* @param query the query
* @param fragment the fragment
* @param encoding the character encoding to encode to
* @return the encoded URI
* @throws IllegalArgumentException when the given uri parameter is not a valid URI
* @throws UnsupportedEncodingException when the given encoding parameter is not supported
* @deprecated in favor of {@link UriComponentsBuilder}
*/
@Deprecated
public static String encodeUriComponents(String scheme, String authority, String userInfo,
String host, String port, String path, String query, String fragment, String encoding)
throws UnsupportedEncodingException {
Assert.hasLength(encoding, "Encoding must not be empty");
StringBuilder sb = new StringBuilder();
if (scheme != null) {
sb.append(encodeScheme(scheme, encoding));
sb.append(':');
}
if (authority != null) {
sb.append("//");
if (userInfo != null) {
sb.append(encodeUserInfo(userInfo, encoding));
sb.append('@');
}
if (host != null) {
sb.append(encodeHost(host, encoding));
}
if (port != null) {
sb.append(':');
sb.append(encodePort(port, encoding));
}
}
sb.append(encodePath(path, encoding));
if (query != null) {
sb.append('?');
sb.append(encodeQuery(query, encoding));
}
if (fragment != null) {
sb.append('#');
sb.append(encodeFragment(fragment, encoding));
}
return sb.toString();
}
// encoding convenience methods
/**
* Encodes the given URI scheme with the given encoding.
* @param scheme the scheme to be encoded

13
spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java

@ -42,11 +42,13 @@ public class HttpHeadersTests { @@ -42,11 +42,13 @@ public class HttpHeadersTests {
private HttpHeaders headers;
@Before
public void setUp() {
headers = new HttpHeaders();
}
@Test
public void accept() {
MediaType mediaType1 = new MediaType("text", "html");
@ -59,9 +61,7 @@ public class HttpHeadersTests { @@ -59,9 +61,7 @@ public class HttpHeadersTests {
assertEquals("Invalid Accept header", "text/html, text/plain", headers.getFirst("Accept"));
}
// SPR-9655
@Test
@Test // SPR-9655
public void acceptiPlanet() {
headers.add("Accept", "text/html");
headers.add("Accept", "text/plain");
@ -228,7 +228,7 @@ public class HttpHeadersTests { @@ -228,7 +228,7 @@ public class HttpHeadersTests {
calendar.setTimeZone(TimeZone.getTimeZone("CET"));
long date = calendar.getTimeInMillis();
headers.setIfModifiedSince(date);
assertEquals("Invalid If-Modified-Since header", date, headers.getIfNotModifiedSince());
assertEquals("Invalid If-Modified-Since header", date, headers.getIfModifiedSince());
assertEquals("Invalid If-Modified-Since header", "Thu, 18 Dec 2008 10:20:00 GMT",
headers.getFirst("if-modified-since"));
}
@ -260,12 +260,9 @@ public class HttpHeadersTests { @@ -260,12 +260,9 @@ public class HttpHeadersTests {
headers.getFirst("Content-Disposition"));
}
// SPR-11917
@Test
@Test // SPR-11917
public void getAllowEmptySet() {
headers.setAllow(Collections.<HttpMethod> emptySet());
assertThat(headers.getAllow(), Matchers.emptyCollectionOf(HttpMethod.class));
}

61
spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@ -30,7 +30,6 @@ public class UriUtilsTests { @@ -30,7 +30,6 @@ public class UriUtilsTests {
private static final String ENC = "UTF-8";
@Test
public void encodeScheme() throws UnsupportedEncodingException {
assertEquals("Invalid encoded result", "foobar+-.", UriUtils.encodeScheme("foobar+-.", ENC));
@ -105,62 +104,4 @@ public class UriUtilsTests { @@ -105,62 +104,4 @@ public class UriUtilsTests {
UriUtils.decode("foo%2", ENC);
}
@Test
@Deprecated
public void encodeUri() throws UnsupportedEncodingException {
assertEquals("Invalid encoded URI", "http://www.ietf.org/rfc/rfc3986.txt",
UriUtils.encodeUri("http://www.ietf.org/rfc/rfc3986.txt", ENC));
assertEquals("Invalid encoded URI", "https://www.ietf.org/rfc/rfc3986.txt",
UriUtils.encodeUri("https://www.ietf.org/rfc/rfc3986.txt", ENC));
assertEquals("Invalid encoded URI", "http://www.google.com/?q=Z%C3%BCrich",
UriUtils.encodeUri("http://www.google.com/?q=Z\u00fcrich", ENC));
assertEquals("Invalid encoded URI",
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)",
UriUtils.encodeUri(
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar#and(java.util.BitSet)",
ENC));
assertEquals("Invalid encoded URI", "http://java.sun.com/j2se/1.3/",
UriUtils.encodeUri("http://java.sun.com/j2se/1.3/", ENC));
assertEquals("Invalid encoded URI", "docs/guide/collections/designfaq.html#28",
UriUtils.encodeUri("docs/guide/collections/designfaq.html#28", ENC));
assertEquals("Invalid encoded URI", "../../../demo/jfc/SwingSet2/src/SwingSet2.java",
UriUtils.encodeUri("../../../demo/jfc/SwingSet2/src/SwingSet2.java", ENC));
assertEquals("Invalid encoded URI", "file:///~/calendar", UriUtils.encodeUri("file:///~/calendar", ENC));
assertEquals("Invalid encoded URI", "http://example.com/query=foo@bar",
UriUtils.encodeUri("http://example.com/query=foo@bar", ENC));
// SPR-8974
assertEquals("http://example.org?format=json&url=http://another.com?foo=bar",
UriUtils.encodeUri("http://example.org?format=json&url=http://another.com?foo=bar", ENC));
}
@Test
@Deprecated
public void encodeHttpUrl() throws UnsupportedEncodingException {
assertEquals("Invalid encoded HTTP URL", "http://www.ietf.org/rfc/rfc3986.txt",
UriUtils.encodeHttpUrl("http://www.ietf.org/rfc/rfc3986.txt", ENC));
assertEquals("Invalid encoded URI", "https://www.ietf.org/rfc/rfc3986.txt",
UriUtils.encodeHttpUrl("https://www.ietf.org/rfc/rfc3986.txt", ENC));
assertEquals("Invalid encoded HTTP URL", "http://www.google.com/?q=Z%C3%BCrich",
UriUtils.encodeHttpUrl("http://www.google.com/?q=Z\u00fcrich", ENC));
assertEquals("Invalid encoded HTTP URL", "http://ws.geonames.org/searchJSON?q=T%C5%8Dky%C5%8D&style=FULL&maxRows=300",
UriUtils.encodeHttpUrl("http://ws.geonames.org/searchJSON?q=T\u014dky\u014d&style=FULL&maxRows=300", ENC));
assertEquals("Invalid encoded HTTP URL",
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar",
UriUtils.encodeHttpUrl(
"http://arjen:foobar@java.sun.com:80/javase/6/docs/api/java/util/BitSet.html?foo=bar", ENC));
assertEquals("Invalid encoded HTTP URL", "http://search.twitter.com/search.atom?q=%23avatar",
UriUtils.encodeHttpUrl("http://search.twitter.com/search.atom?q=#avatar", ENC));
assertEquals("Invalid encoded HTTP URL", "http://java.sun.com/j2se/1.3/",
UriUtils.encodeHttpUrl("http://java.sun.com/j2se/1.3/", ENC));
assertEquals("Invalid encoded HTTP URL", "http://example.com/query=foo@bar",
UriUtils.encodeHttpUrl("http://example.com/query=foo@bar", ENC));
}
@Test(expected = IllegalArgumentException.class)
@Deprecated
public void encodeHttpUrlMail() throws UnsupportedEncodingException {
UriUtils.encodeHttpUrl("mailto:java-net@java.sun.com", ENC);
}
}

128
spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -23,9 +23,7 @@ import java.util.LinkedHashSet; @@ -23,9 +23,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.activation.FileTypeMap;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -55,29 +53,31 @@ import org.springframework.web.servlet.View; @@ -55,29 +53,31 @@ import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
/**
* Implementation of {@link ViewResolver} that resolves a view based on the request file name or {@code Accept} header.
* Implementation of {@link ViewResolver} that resolves a view based on the request file name
* or {@code Accept} header.
*
* <p>The {@code ContentNegotiatingViewResolver} does not resolve views itself, but delegates to other {@link
* ViewResolver}s. By default, these other view resolvers are picked up automatically from the application context,
* though they can also be set explicitly by using the {@link #setViewResolvers(List) viewResolvers} property.
* <strong>Note</strong> that in order for this view resolver to work properly, the {@link #setOrder(int) order}
* property needs to be set to a higher precedence than the others (the default is {@link Ordered#HIGHEST_PRECEDENCE}.)
* <p>The {@code ContentNegotiatingViewResolver} does not resolve views itself, but delegates to
* other {@link ViewResolver}s. By default, these other view resolvers are picked up automatically
* from the application context, though they can also be set explicitly by using the
* {@link #setViewResolvers viewResolvers} property. <strong>Note</strong> that in order for this
* view resolver to work properly, the {@link #setOrder order} property needs to be set to a higher
* precedence than the others (the default is {@link Ordered#HIGHEST_PRECEDENCE}).
*
* <p>This view resolver uses the requested {@linkplain MediaType media type} to select a suitable {@link View} for a
* request. The requested media type is determined through the configured {@link ContentNegotiationManager}.
* Once the requested media type has been determined, this resolver queries each delegate view resolver for a
* {@link View} and determines if the requested media type is {@linkplain MediaType#includes(MediaType) compatible}
* with the view's {@linkplain View#getContentType() content type}). The most compatible view is returned.
* <p>This view resolver uses the requested {@linkplain MediaType media type} to select a suitable
* {@link View} for a request. The requested media type is determined through the configured
* {@link ContentNegotiationManager}. Once the requested media type has been determined, this resolver
* queries each delegate view resolver for a {@link View} and determines if the requested media type
* is {@linkplain MediaType#includes(MediaType) compatible} with the view's
* {@linkplain View#getContentType() content type}). The most compatible view is returned.
*
* <p>Additionally, this view resolver exposes the {@link #setDefaultViews(List) defaultViews} property, allowing you to
* override the views provided by the view resolvers. Note that these default views are offered as candidates, and
* still need have the content type requested (via file extension, parameter, or {@code Accept} header, described above).
* You can also set the {@linkplain #setDefaultContentType(MediaType) default content type} directly, which will be
* returned when the other mechanisms ({@code Accept} header, file extension or parameter) do not result in a match.
* <p>Additionally, this view resolver exposes the {@link #setDefaultViews(List) defaultViews} property,
* allowing you to override the views provided by the view resolvers. Note that these default views are
* offered as candidates, and still need have the content type requested (via file extension, parameter,
* or {@code Accept} header, described above).
*
* <p>For example, if the request path is {@code /view.html}, this view resolver will look for a view that has the
* {@code text/html} content type (based on the {@code html} file extension). A request for {@code /view} with a {@code
* text/html} request {@code Accept} header has the same result.
* <p>For example, if the request path is {@code /view.html}, this view resolver will look for a view
* that has the {@code text/html} content type (based on the {@code html} file extension). A request
* for {@code /view} with a {@code text/html} request {@code Accept} header has the same result.
*
* @author Arjen Poutsma
* @author Juergen Hoeller
@ -123,90 +123,6 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport @@ -123,90 +123,6 @@ public class ContentNegotiatingViewResolver extends WebApplicationObjectSupport
this.contentNegotiationManager = contentNegotiationManager;
}
/**
* Indicate whether the extension of the request path should be used to determine the requested media type,
* in favor of looking at the {@code Accept} header. The default value is {@code true}.
* <p>For instance, when this flag is {@code true} (the default), a request for {@code /hotels.pdf}
* will result in an {@code AbstractPdfView} being resolved, while the {@code Accept} header can be the
* browser-defined {@code text/html,application/xhtml+xml}.
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setFavorPathExtension(boolean favorPathExtension) {
this.cnManagerFactoryBean.setFavorPathExtension(favorPathExtension);
}
/**
* Indicate whether to use the Java Activation Framework to map from file extensions to media types.
* <p>Default is {@code true}, i.e. the Java Activation Framework is used (if available).
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setUseJaf(boolean useJaf) {
this.cnManagerFactoryBean.setUseJaf(useJaf);
}
/**
* Indicate whether a request parameter should be used to determine the requested media type,
* in favor of looking at the {@code Accept} header. The default value is {@code false}.
* <p>For instance, when this flag is {@code true}, a request for {@code /hotels?format=pdf} will result
* in an {@code AbstractPdfView} being resolved, while the {@code Accept} header can be the browser-defined
* {@code text/html,application/xhtml+xml}.
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setFavorParameter(boolean favorParameter) {
this.cnManagerFactoryBean.setFavorParameter(favorParameter);
}
/**
* Set the parameter name that can be used to determine the requested media type if the {@link
* #setFavorParameter} property is {@code true}. The default parameter name is {@code format}.
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setParameterName(String parameterName) {
this.cnManagerFactoryBean.setParameterName(parameterName);
}
/**
* Indicate whether the HTTP {@code Accept} header should be ignored. Default is {@code false}.
* <p>If set to {@code true}, this view resolver will only refer to the file extension and/or
* parameter, as indicated by the {@link #setFavorPathExtension favorPathExtension} and
* {@link #setFavorParameter favorParameter} properties.
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setIgnoreAcceptHeader(boolean ignoreAcceptHeader) {
this.cnManagerFactoryBean.setIgnoreAcceptHeader(ignoreAcceptHeader);
}
/**
* Set the mapping from file extensions to media types.
* <p>When this mapping is not set or when an extension is not present, this view resolver
* will fall back to using a {@link FileTypeMap} when the Java Action Framework is available.
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setMediaTypes(Map<String, String> mediaTypes) {
if (mediaTypes != null) {
Properties props = new Properties();
props.putAll(mediaTypes);
this.cnManagerFactoryBean.setMediaTypes(props);
}
}
/**
* Set the default content type.
* <p>This content type will be used when file extension, parameter, nor {@code Accept}
* header define a content-type, either through being disabled or empty.
* @deprecated use {@link #setContentNegotiationManager(ContentNegotiationManager)}
*/
@Deprecated
public void setDefaultContentType(MediaType defaultContentType) {
this.cnManagerFactoryBean.setDefaultContentType(defaultContentType);
}
/**
* Indicate whether a {@link HttpServletResponse#SC_NOT_ACCEPTABLE 406 Not Acceptable}
* status code should be returned if no suitable view can be found.

19
spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java

@ -133,25 +133,6 @@ public class MappingJackson2JsonView extends AbstractJackson2View { @@ -133,25 +133,6 @@ public class MappingJackson2JsonView extends AbstractJackson2View {
return this.modelKeys;
}
/**
* Set the attributes in the model that should be rendered by this view.
* When set, all other model attributes will be ignored.
* @deprecated use {@link #setModelKeys(Set)} instead
*/
@Deprecated
public void setRenderedAttributes(Set<String> renderedAttributes) {
this.modelKeys = renderedAttributes;
}
/**
* Return the attributes in the model that should be rendered by this view.
* @deprecated use {@link #getModelKeys()} instead
*/
@Deprecated
public final Set<String> getRenderedAttributes() {
return this.modelKeys;
}
/**
* Set whether to serialize models containing a single attribute as a map or whether to
* extract the single value from the model and serialize it directly.

234
spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@ -20,7 +20,6 @@ import java.io.IOException; @@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -28,14 +27,6 @@ import org.junit.Test; @@ -28,14 +27,6 @@ import org.junit.Test;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.config.BeanDefinitionHolder;
import org.springframework.beans.factory.config.ConstructorArgumentValues;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.ChildBeanDefinition;
import org.springframework.beans.factory.support.ManagedList;
import org.springframework.beans.factory.support.ManagedMap;
import org.springframework.beans.factory.support.ManagedSet;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.core.io.Resource;
import org.springframework.mock.web.test.MockServletContext;
import org.springframework.tests.sample.beans.TestBean;
@ -141,213 +132,6 @@ public class ServletContextSupportTests { @@ -141,213 +132,6 @@ public class ServletContextSupportTests {
assertSame(tb, sc.getAttribute("attr2"));
}
@Test
@Deprecated
public void testServletContextPropertyPlaceholderConfigurer() {
MockServletContext sc = new MockServletContext();
sc.addInitParameter("key4", "mykey4");
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "${age}");
pvs.add("name", "${key4}name${var}${var}${");
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
wac.registerSingleton("tb1", TestBean.class, pvs);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.add("properties", "age=98\nvar=${m}var\nref=tb2\nm=my");
wac.registerSingleton("configurer", ServletContextPropertyPlaceholderConfigurer.class, pvs);
wac.refresh();
TestBean tb1 = (TestBean) wac.getBean("tb1");
TestBean tb2 = (TestBean) wac.getBean("tb2");
assertEquals(98, tb1.getAge());
assertEquals("mykey4namemyvarmyvar${", tb1.getName());
assertEquals(tb2, tb1.getSpouse());
}
@Test
@Deprecated
public void testServletContextPropertyPlaceholderConfigurerWithLocalOverriding() {
MockServletContext sc = new MockServletContext();
sc.addInitParameter("key4", "mykey4");
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "${age}");
pvs.add("name", "${key4}name${var}${var}${");
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
wac.registerSingleton("tb1", TestBean.class, pvs);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.add("properties", "age=98\nvar=${m}var\nref=tb2\nm=my\nkey4=yourkey4");
wac.registerSingleton("configurer", ServletContextPropertyPlaceholderConfigurer.class, pvs);
wac.refresh();
TestBean tb1 = (TestBean) wac.getBean("tb1");
TestBean tb2 = (TestBean) wac.getBean("tb2");
assertEquals(98, tb1.getAge());
assertEquals("yourkey4namemyvarmyvar${", tb1.getName());
assertEquals(tb2, tb1.getSpouse());
}
@Test
@Deprecated
public void testServletContextPropertyPlaceholderConfigurerWithContextOverride() {
MockServletContext sc = new MockServletContext();
sc.addInitParameter("key4", "mykey4");
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "${age}");
pvs.add("name", "${key4}name${var}${var}${");
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
wac.registerSingleton("tb1", TestBean.class, pvs);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.add("properties", "age=98\nvar=${m}var\nref=tb2\nm=my\nkey4=yourkey4");
pvs.add("contextOverride", Boolean.TRUE);
wac.registerSingleton("configurer", ServletContextPropertyPlaceholderConfigurer.class, pvs);
wac.refresh();
TestBean tb1 = (TestBean) wac.getBean("tb1");
TestBean tb2 = (TestBean) wac.getBean("tb2");
assertEquals(98, tb1.getAge());
assertEquals("mykey4namemyvarmyvar${", tb1.getName());
assertEquals(tb2, tb1.getSpouse());
}
@Test
@Deprecated
public void testServletContextPropertyPlaceholderConfigurerWithContextOverrideAndAttributes() {
MockServletContext sc = new MockServletContext();
sc.addInitParameter("key4", "mykey4");
sc.setAttribute("key4", "attrkey4");
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "${age}");
pvs.add("name", "${key4}name${var}${var}${");
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
wac.registerSingleton("tb1", TestBean.class, pvs);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class);
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.add("properties", "age=98\nvar=${m}var\nref=tb2\nm=my\nkey4=yourkey4");
pvs.add("contextOverride", Boolean.TRUE);
pvs.add("searchContextAttributes", Boolean.TRUE);
wac.registerSingleton("configurer", ServletContextPropertyPlaceholderConfigurer.class, pvs);
wac.refresh();
TestBean tb1 = (TestBean) wac.getBean("tb1");
TestBean tb2 = (TestBean) wac.getBean("tb2");
assertEquals(98, tb1.getAge());
assertEquals("attrkey4namemyvarmyvar${", tb1.getName());
assertEquals(tb2, tb1.getSpouse());
}
@Test
@Deprecated
public void testServletContextPropertyPlaceholderConfigurerWithAttributes() {
MockServletContext sc = new MockServletContext();
sc.addInitParameter("key4", "mykey4");
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.setServletContext(sc);
MutablePropertyValues pvs = new MutablePropertyValues();
pvs.add("age", "${age}");
pvs.add("name", "name${var}${var}${");
pvs.add("spouse", new RuntimeBeanReference("${ref}"));
wac.registerSingleton("tb1", TestBean.class, pvs);
ConstructorArgumentValues cas = new ConstructorArgumentValues();
cas.addIndexedArgumentValue(1, "${age}");
cas.addGenericArgumentValue("${var}name${age}");
pvs = new MutablePropertyValues();
List<Object> friends = new ManagedList<Object>();
friends.add("na${age}me");
friends.add(new RuntimeBeanReference("${ref}"));
pvs.add("friends", friends);
Set<Object> someSet = new ManagedSet<Object>();
someSet.add("na${age}me");
someSet.add(new RuntimeBeanReference("${ref}"));
pvs.add("someSet", someSet);
Map<String, Object> someMap = new ManagedMap<String, Object>();
someMap.put("key1", new RuntimeBeanReference("${ref}"));
someMap.put("key2", "${age}name");
MutablePropertyValues innerPvs = new MutablePropertyValues();
innerPvs.add("touchy", "${os.name}");
RootBeanDefinition innerBd = new RootBeanDefinition(TestBean.class);
innerBd.setPropertyValues(innerPvs);
someMap.put("key3", innerBd);
MutablePropertyValues innerPvs2 = new MutablePropertyValues(innerPvs);
someMap.put("${key4}", new BeanDefinitionHolder(new ChildBeanDefinition("tb1", innerPvs2), "child"));
pvs.add("someMap", someMap);
RootBeanDefinition bd = new RootBeanDefinition(TestBean.class, cas, pvs);
wac.getDefaultListableBeanFactory().registerBeanDefinition("tb2", bd);
pvs = new MutablePropertyValues();
pvs.add("properties", "var=${m}var\nref=tb2\nm=my");
pvs.add("searchContextAttributes", Boolean.TRUE);
wac.registerSingleton("configurer", ServletContextPropertyPlaceholderConfigurer.class, pvs);
sc.setAttribute("age", new Integer(98));
wac.refresh();
TestBean tb1 = (TestBean) wac.getBean("tb1");
TestBean tb2 = (TestBean) wac.getBean("tb2");
assertEquals(98, tb1.getAge());
assertEquals(98, tb2.getAge());
assertEquals("namemyvarmyvar${", tb1.getName());
assertEquals("myvarname98", tb2.getName());
assertEquals(tb2, tb1.getSpouse());
assertEquals(2, tb2.getFriends().size());
assertEquals("na98me", tb2.getFriends().iterator().next());
assertEquals(tb2, tb2.getFriends().toArray()[1]);
assertEquals(2, tb2.getSomeSet().size());
assertTrue(tb2.getSomeSet().contains("na98me"));
assertTrue(tb2.getSomeSet().contains(tb2));
assertEquals(4, tb2.getSomeMap().size());
assertEquals(tb2, tb2.getSomeMap().get("key1"));
assertEquals("98name", tb2.getSomeMap().get("key2"));
TestBean inner1 = (TestBean) tb2.getSomeMap().get("key3");
TestBean inner2 = (TestBean) tb2.getSomeMap().get("mykey4");
assertEquals(0, inner1.getAge());
assertEquals(null, inner1.getName());
assertEquals(System.getProperty("os.name"), inner1.getTouchy());
assertEquals(98, inner2.getAge());
assertEquals("namemyvarmyvar${", inner2.getName());
assertEquals(System.getProperty("os.name"), inner2.getTouchy());
}
@Test
public void testServletContextResourceLoader() {
MockServletContext sc = new MockServletContext("classpath:org/springframework/web/context");
@ -377,8 +161,8 @@ public class ServletContextSupportTests { @@ -377,8 +161,8 @@ public class ServletContextSupportTests {
ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc);
Resource[] found = rpr.getResources("/WEB-INF/*.xml");
Set<String> foundPaths = new HashSet<String>();
for (int i = 0; i < found.length; i++) {
foundPaths.add(((ServletContextResource) found[i]).getPath());
for (Resource resource : found) {
foundPaths.add(((ServletContextResource) resource).getPath());
}
assertEquals(2, foundPaths.size());
assertTrue(foundPaths.contains("/WEB-INF/context1.xml"));
@ -410,8 +194,8 @@ public class ServletContextSupportTests { @@ -410,8 +194,8 @@ public class ServletContextSupportTests {
ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc);
Resource[] found = rpr.getResources("/WEB-INF/*/*.xml");
Set<String> foundPaths = new HashSet<String>();
for (int i = 0; i < found.length; i++) {
foundPaths.add(((ServletContextResource) found[i]).getPath());
for (Resource resource : found) {
foundPaths.add(((ServletContextResource) resource).getPath());
}
assertEquals(2, foundPaths.size());
assertTrue(foundPaths.contains("/WEB-INF/mydir1/context1.xml"));
@ -450,8 +234,8 @@ public class ServletContextSupportTests { @@ -450,8 +234,8 @@ public class ServletContextSupportTests {
ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc);
Resource[] found = rpr.getResources("/WEB-INF/**/*.xml");
Set<String> foundPaths = new HashSet<String>();
for (int i = 0; i < found.length; i++) {
foundPaths.add(((ServletContextResource) found[i]).getPath());
for (Resource resource : found) {
foundPaths.add(((ServletContextResource) resource).getPath());
}
assertEquals(3, foundPaths.size());
assertTrue(foundPaths.contains("/WEB-INF/mydir1/context1.xml"));
@ -479,8 +263,8 @@ public class ServletContextSupportTests { @@ -479,8 +263,8 @@ public class ServletContextSupportTests {
ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc);
Resource[] found = rpr.getResources("/WEB-INF/*.xml");
Set<String> foundPaths = new HashSet<String>();
for (int i = 0; i < found.length; i++) {
foundPaths.add(((ServletContextResource) found[i]).getPath());
for (Resource resource : found) {
foundPaths.add(((ServletContextResource) resource).getPath());
}
assertEquals(2, foundPaths.size());
assertTrue(foundPaths.contains("/WEB-INF/context1.xml"));

Loading…
Cancel
Save