From 9ac02b319d2fde39b5bb1cf11b5525b4f55cd198 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 30 Dec 2014 20:05:15 +0100 Subject: [PATCH] Remove pre-3.2 deprecated classes and methods Issue: SPR-12578 --- .../springframework/aop/support/AopUtils.java | 20 -- .../support/BeanDefinitionBuilder.java | 12 +- .../AbstractSimpleBeanDefinitionParser.java | 26 +- .../xml/BeanDefinitionDocumentReader.java | 9 - .../xml/BeanDefinitionParserDelegate.java | 15 -- .../DefaultBeanDefinitionDocumentReader.java | 5 - .../factory/xml/XmlBeanDefinitionReader.java | 2 - .../support/ResourceEditorRegistrar.java | 17 +- ...ormattingConversionServiceFactoryBean.java | 15 +- .../core/convert/TypeDescriptor.java | 33 --- .../support/ConversionServiceFactory.java | 20 +- .../core/io/ResourceEditor.java | 28 +- .../support/ResourceArrayPropertyEditor.java | 26 +- .../expression/common/ExpressionUtils.java | 19 +- .../jdbc/core/JdbcOperations.java | 118 --------- .../jdbc/core/JdbcTemplate.java | 42 --- .../NamedParameterJdbcOperations.java | 74 +----- .../NamedParameterJdbcTemplate.java | 26 -- .../oxm/castor/CastorMarshaller.java | 10 - .../springframework/test/AssertThrows.java | 246 ------------------ .../ContextConfigurationAttributes.java | 23 -- .../web/WebMergedContextConfiguration.java | 89 ++----- .../AnnotationDrivenBeanDefinitionParser.java | 21 +- .../interceptor/TransactionAspectSupport.java | 37 --- .../org/springframework/http/HttpHeaders.java | 11 - .../web/context/ContextLoader.java | 14 +- ...tContextPropertyPlaceholderConfigurer.java | 162 ------------ .../web/util/CookieGenerator.java | 9 +- .../springframework/web/util/UriUtils.java | 142 ---------- .../http/HttpHeadersTests.java | 13 +- .../web/util/UriUtilsTests.java | 61 +---- .../view/ContentNegotiatingViewResolver.java | 128 ++------- .../view/json/MappingJackson2JsonView.java | 19 -- .../support/ServletContextSupportTests.java | 234 +---------------- 34 files changed, 77 insertions(+), 1649 deletions(-) delete mode 100644 spring-test/src/main/java/org/springframework/test/AssertThrows.java delete mode 100644 spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertyPlaceholderConfigurer.java diff --git a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java index 2729d82af1b..ec236a1afdb 100644 --- a/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/support/AopUtils.java @@ -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. *

Returns the target class for an AOP proxy and the plain class else. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java index f70e163ce46..39d73b68f71 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java @@ -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 { 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. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java index 70adeede2b2..67fb7fde918 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/AbstractSimpleBeanDefinitionParser.java @@ -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 * @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. - *

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))); } /** diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java index 86e5fd9f5a1..a41bd8b343b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionDocumentReader.java @@ -37,15 +37,6 @@ import org.springframework.core.env.Environment; */ public interface BeanDefinitionDocumentReader { - /** - * Set the Environment to use when reading bean definitions. - *

Used for evaluating profile information to determine whether a - * {@code } 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. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java index d84c08aacd1..af8d44af55a 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java @@ -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 { 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. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java index bceec42ff91..9a11d38a4c1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultBeanDefinitionDocumentReader.java @@ -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). diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java index e6a1d59e194..0f7091ade4b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java @@ -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; diff --git a/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java b/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java index ffb460422e5..2214f14fea4 100644 --- a/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java +++ b/spring-beans/src/main/java/org/springframework/beans/support/ResourceEditorRegistrar.java @@ -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 { 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}. diff --git a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java index e7ee267b84f..2f5ae16930c 100644 --- a/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java +++ b/spring-context/src/main/java/org/springframework/format/support/FormattingConversionServiceFactoryBean.java @@ -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 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) { } diff --git a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java index e3fe172ff9b..7345b526f6a 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java +++ b/spring-core/src/main/java/org/springframework/core/convert/TypeDescriptor.java @@ -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); } diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java index 8a45f037e14..246bdeabdf7 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/ConversionServiceFactory.java @@ -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 { } } - /** - * 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); - } - } diff --git a/spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java b/spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java index a01d5f7f280..7f8036a384d 100644 --- a/spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java +++ b/spring-core/src/main/java/org/springframework/core/io/ResourceEditor.java @@ -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 { 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}. diff --git a/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java b/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java index e37a21f0485..101fe8150be 100644 --- a/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java +++ b/spring-core/src/main/java/org/springframework/core/io/support/ResourceArrayPropertyEditor.java @@ -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 { 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}). diff --git a/spring-expression/src/main/java/org/springframework/expression/common/ExpressionUtils.java b/spring-expression/src/main/java/org/springframework/expression/common/ExpressionUtils.java index 73cef6bc3fd..e9adf7382f0 100644 --- a/spring-expression/src/main/java/org/springframework/expression/common/ExpressionUtils.java +++ b/spring-expression/src/main/java/org/springframework/expression/common/ExpressionUtils.java @@ -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; */ 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 convert(EvaluationContext context, Object value, Class 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 diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java index 15af7524ab3..d60fc4d3dc0 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java @@ -183,44 +183,6 @@ public interface JdbcOperations { */ Map queryForMap(String sql) throws DataAccessException; - /** - * Execute a query that results in a long value, given static SQL. - *

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. - *

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. - *

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. - *

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. *

Uses a JDBC Statement, not a PreparedStatement. If you want to @@ -695,86 +657,6 @@ public interface JdbcOperations { */ Map 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. - *

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. - *

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. - *

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. - *

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. diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index 6190090e4b8..650f32dcc38 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -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 List queryForList(String sql, Class elementType) throws DataAccessException { return query(sql, getSingleColumnRowMapper(elementType)); @@ -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 List queryForList(String sql, Object[] args, int[] argTypes, Class elementType) throws DataAccessException { return query(sql, args, argTypes, getSingleColumnRowMapper(elementType)); diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java index 91e20f3fcd9..6bccebe5423 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcOperations.java @@ -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 { */ Map queryForMap(String sql, Map 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. - *

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. - *

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 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. - *

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. - *

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 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. diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java index 0baf5cab98f..94263807d9c 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/NamedParameterJdbcTemplate.java @@ -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 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 paramMap) throws DataAccessException { - return queryForInt(sql, new MapSqlParameterSource(paramMap)); - } - @Override public List queryForList(String sql, SqlParameterSource paramSource, Class elementType) throws DataAccessException { diff --git a/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java index ed13d839b8a..391e44f31ea 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/castor/CastorMarshaller.java @@ -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) diff --git a/spring-test/src/main/java/org/springframework/test/AssertThrows.java b/spring-test/src/main/java/org/springframework/test/AssertThrows.java deleted file mode 100644 index dd55e3fc58a..00000000000 --- a/spring-test/src/main/java/org/springframework/test/AssertThrows.java +++ /dev/null @@ -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 - * 'test-for-exception' scenario for unit testing. Intended for - * use with JUnit or TestNG. - * - *

Given the following business class... - * - *

- * // 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...
- *    }
- * }
- * - *

The test for the above bad argument path can be expressed using - * {@code AssertThrows} like so: - * - *

- * public class FooTest {
- *    public void testSomeBusinessLogicBadArgumentPath() {
- *        new AssertThrows(IllegalArgumentException.class) {
- *            public void test() {
- *                new Foo().someBusinessLogic(null);
- *            }
- *        }.runTest();
- *    }
- * }
- * - *

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: - * - *

"Must have thrown a [class java.lang.IllegalArgumentException]"
- * - *

If the wrong type of {@code Throwable} was thrown, - * the test will also fail, this time with a message similar to the following: - * - *

"java.lang.AssertionError: Was expecting a [class java.lang.UnsupportedOperationException] to be thrown, but instead a [class java.lang.IllegalArgumentException] was thrown"
- * - *

The test for the correct {@code Throwable} respects polymorphism, - * so you can test that any old {@code Exception} is thrown like so: - * - *

- * public class FooTest {
- *    public void testSomeBusinessLogicBadArgumentPath() {
- *        // any Exception will do...
- *        new AssertThrows(Exception.class) {
- *            public void test() {
- *                new Foo().someBusinessLogic(null);
- *            }
- *        }.runTest();
- *    }
- * }
- * - * @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 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 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 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 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 not thrown. - *

The default implementation simply fails the test by throwing an - * {@link AssertionError}. - *

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). - *

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; - } - -} diff --git a/spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java b/spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java index 16c724a8a65..db36807fe88 100644 --- a/spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java +++ b/spring-test/src/main/java/org/springframework/test/context/ContextConfigurationAttributes.java @@ -91,29 +91,6 @@ public class ContextConfigurationAttributes { (Class) 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 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 diff --git a/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java b/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java index fb577b6aa1c..f89ce244cff 100644 --- a/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java +++ b/spring-test/src/main/java/org/springframework/test/context/web/WebMergedContextConfiguration.java @@ -63,36 +63,6 @@ public class WebMergedContextConfiguration extends MergedContextConfiguration { * supplied parameters. *

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>> 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. - *

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 { /** * Create a new {@code WebMergedContextConfiguration} instance for the * supplied parameters. - * *

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 { * If an empty 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 { * @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>> contextInitializerClasses, String[] activeProfiles, String[] propertySourceLocations, String[] propertySourceProperties, String resourceBasePath, ContextLoader contextLoader, @@ -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 { 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 { */ @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 { */ @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(); } } diff --git a/spring-tx/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java b/spring-tx/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java index ad05526abf6..17def5845ff 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java +++ b/spring-tx/src/main/java/org/springframework/transaction/config/AnnotationDrivenBeanDefinitionParser.java @@ -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; */ 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 } tag. Will * {@link AopNamespaceUtils#registerAutoProxyCreatorIfNecessary register an AutoProxyCreator} diff --git a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java index 567ffd7f1be..23adcbf4973 100644 --- a/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java +++ b/spring-tx/src/main/java/org/springframework/transaction/interceptor/TransactionAspectSupport.java @@ -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. - *

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. *

Allows callers to perform custom TransactionAttribute lookups through diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index f13cdb182f7..192e080a302 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -624,17 +624,6 @@ public class HttpHeaders implements MultiValueMap, Serializable setDate(IF_MODIFIED_SINCE, ifModifiedSince); } - /** - * Return the value of the {@code IfModifiedSince} header. - *

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. *

The date is returned as the number of milliseconds since diff --git a/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java b/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java index 16da9161d32..208f03971dc 100644 --- a/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java +++ b/spring-web/src/main/java/org/springframework/web/context/ContextLoader.java @@ -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 { /** * 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 { 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 { * 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) */ diff --git a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertyPlaceholderConfigurer.java b/spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertyPlaceholderConfigurer.java deleted file mode 100644 index 720d26c0a98..00000000000 --- a/spring-web/src/main/java/org/springframework/web/context/support/ServletContextPropertyPlaceholderConfigurer.java +++ /dev/null @@ -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). - * - *

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). - * - *

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). - * - *

Optionally supports searching for ServletContext attributes: 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. - * - *

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. - *

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. - *

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. - *

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. - *

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; - } - -} diff --git a/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java b/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java index c79a59e6a21..2768278ad14 100644 --- a/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java +++ b/spring-web/src/main/java/org/springframework/web/util/CookieGenerator.java @@ -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 { */ 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()); diff --git a/spring-web/src/main/java/org/springframework/web/util/UriUtils.java b/spring-web/src/main/java/org/springframework/web/util/UriUtils.java index 538e6d3041f..e33531ba62e 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriUtils.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriUtils.java @@ -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. - *

Note 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: - *

-	 * UriComponents uriComponents = UriComponentsBuilder.fromUri("/path?name={value}").buildAndExpand("a=b");
-	 * String encodedUri = uriComponents.encode().toUriString();
-	 * 
- * @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. - *

Note that this method does not support fragments ({@code #}), - * as these are not supposed to be sent to the server, but retained by the client. - *

Note 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: - *

-	 * UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl("/path?name={value}").buildAndExpand("a=b");
-	 * String encodedUri = uriComponents.encode().toUriString();
-	 * 
- * @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 diff --git a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java index 2bac5b66fee..1d6993b2f7a 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpHeadersTests.java @@ -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 { 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 { 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 { headers.getFirst("Content-Disposition")); } - // SPR-11917 - - @Test + @Test // SPR-11917 public void getAllowEmptySet() { headers.setAllow(Collections. emptySet()); - assertThat(headers.getAllow(), Matchers.emptyCollectionOf(HttpMethod.class)); } diff --git a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java index f3ffc519c17..6480c5fa2e3 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriUtilsTests.java @@ -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 { 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 { 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); - } - } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java index 42302afbe78..7f7b9d8fa11 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/ContentNegotiatingViewResolver.java @@ -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; 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; 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. * - *

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. - * Note 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}.) + *

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. Note 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}). * - *

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. + *

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. * - *

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. + *

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). * - *

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. + *

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 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}. - *

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. - *

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}. - *

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}. - *

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. - *

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 mediaTypes) { - if (mediaTypes != null) { - Properties props = new Properties(); - props.putAll(mediaTypes); - this.cnManagerFactoryBean.setMediaTypes(props); - } - } - - /** - * Set the default content type. - *

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. diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java index b410a9b8690..5209d3b7049 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/json/MappingJackson2JsonView.java @@ -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 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 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. diff --git a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java index e36afe98b30..df0cce924f6 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/context/support/ServletContextSupportTests.java @@ -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; 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; 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 { 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 friends = new ManagedList(); - friends.add("na${age}me"); - friends.add(new RuntimeBeanReference("${ref}")); - pvs.add("friends", friends); - - Set someSet = new ManagedSet(); - someSet.add("na${age}me"); - someSet.add(new RuntimeBeanReference("${ref}")); - pvs.add("someSet", someSet); - - Map someMap = new ManagedMap(); - 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 { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/*.xml"); Set foundPaths = new HashSet(); - 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 { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/*/*.xml"); Set foundPaths = new HashSet(); - 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 { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/**/*.xml"); Set foundPaths = new HashSet(); - 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 { ServletContextResourcePatternResolver rpr = new ServletContextResourcePatternResolver(sc); Resource[] found = rpr.getResources("/WEB-INF/*.xml"); Set foundPaths = new HashSet(); - 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"));