Commit Graph

5844 Commits

Author SHA1 Message Date
Juergen Hoeller a6ce821ad8 Made AutoProxyCreatorTests less dependent on container's own interrogation of FactoryBeans
Issue: SPR-9857
2012-10-12 23:34:22 +02:00
Juergen Hoeller 3cf5572ee8 LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably
Reverted change for @Bean methods that declare FactoryBean as their return type: The effects of trying to create the FactoryBean to find out about its implementation type are too far-reaching. It's better to recommend declaring a specific return type in the method signature if you want the container to specifically react to your implementation type.

Issue: SPR-9857
2012-10-12 23:34:22 +02:00
Juergen Hoeller 0af9244571 LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably
Includes a change for factory methods that declare their return type as FactoryBean: When asked for a specific type match (e.g. LoadTimeWeaverAware), we do check early singleton instances as well (reusing the instances that we create for getObjectType checks). This is necessary in order to make @Bean method introspection as capable as XML bean definition introspection, even in case of the @Bean method using a generic FactoryBean declaration for its return type (instead of the FactoryBean impl class).

Issue: SPR-9857
2012-10-12 23:34:21 +02:00
Juergen Hoeller 0f11920007 Only cache by-type lookups if configuration has been marked as frozen
Issue: SPR-9448
2012-10-12 23:34:20 +02:00
Juergen Hoeller d7e2de019f Mention matching bean names in exception message in case of non-unique EntityManagerFactory lookup 2012-10-12 23:34:19 +02:00
Juergen Hoeller 538ce4747d Only cache by-type lookups if configuration has been marked as frozen
Issue: SPR-9448
2012-10-12 23:34:18 +02:00
Juergen Hoeller 3c59725b94 LoadTimeWeaverAware beans are consistently being created early for JPA weaving to work reliably
Includes a change for factory methods that declare their return type as FactoryBean: When asked for a specific type match (e.g. LoadTimeWeaverAware), we do check early singleton instances as well (reusing the instances that we create for getObjectType checks). This is necessary in order to make @Bean method introspection as capable as XML bean definition introspection, even in case of the @Bean method using a generic FactoryBean declaration for its return type (instead of the FactoryBean impl class).

Issue: SPR-9857
2012-10-12 23:34:18 +02:00
Juergen Hoeller cfdcb54711 Jaxb2Marshaller has non-synchronized access to the JAXBContext once initialized
Issue: SPR-9867
2012-10-12 23:34:17 +02:00
Juergen Hoeller 138fa8af0e OpDivide does not return a TypedValue for its operate result (consistent with OpMultiply)
Issue: SPR-9869
2012-10-12 23:34:16 +02:00
Juergen Hoeller ff7dcec5f7 BeanWrapper does not fall back to String constructor if ConversionService attempt failed before
Issue: SPR-9865
2012-10-12 23:34:15 +02:00
Juergen Hoeller 65743936ff Provider injection into prototype beans works for method parameters as well
Issue: SPR-9630
2012-10-12 23:34:14 +02:00
Phillip Webb 3f1fb4eeea Merge pull request #155 from philwebb/SPR-9284
* SPR-9284:
  Allow MapToMap conversion to work when the target map does not have a default constructor (as long as a new map copy is not required).
  Polish trailing whitespace
2012-10-12 13:11:02 -07:00
Phillip Webb 38c4393592 Allow MapToMap conversion to work when the target map does not have a
default constructor (as long as a new map copy is not required).

Issue: SPR-9284
2012-10-12 13:10:07 -07:00
Phillip Webb 60afa5ead4 Polish trailing whitespace 2012-10-12 13:09:53 -07:00
Phillip Webb ea8b1327b4 Merge pull request #136 from philwebb/SPR-9017
* SPR-9017:
  SpEL support for methods and properties on class …
  Remove trailing whitespace
2012-10-12 13:00:56 -07:00
Phillip Webb d28592a6c6 SpEL support for methods and properties on class …
Update the ReflectiveMethodResolver and ReflectivePropertyAccessor
to allow methods and properties of java.lang.Class to be resolved
when the target object is a class.

Issue: SPR-9017
2012-10-12 13:00:56 -07:00
Phillip Webb 98808347ca Remove trailing whitespace 2012-10-12 13:00:55 -07:00
Chris Beams 27c83710b0 Merge pull request #166 from philwebb/SPR-9851
# By Phillip Webb
* SPR-9851:
  Prevent memory leaks with @Configuration beans
2012-10-12 12:56:25 -07:00
Phillip Webb c8061393fb Prevent memory leaks with @Configuration beans
Refactor ConfigurationClassEnhancer to allow cglib caching of
generated classes.  Prior to this commit each enhanced @Configuration
class would consume permgen space when created.

The CallbackFilter and Callback Types are now defined as static final
members so that they can be shared by all enhancers.  Only the
callbackInstances remain specific to a @Configuration class and
these are not used by cglib as part of the cache key.

Issue: SPR-9851
2012-10-12 12:33:42 -07:00
Rossen Stoyanchev 365a42da64 Add file upload test to Spring MVC Test 2012-10-12 09:17:27 -04:00
Rossen Stoyanchev dc01f088f7 Fix issue in message conversion
This change ensures that when the Accept and the Producible media types
are equally specific, we use the one from the Accept header, which may
for example carry a different charset.
2012-10-12 08:49:30 -04:00
Rossen Stoyanchev f7943786de Polish Spring MVC Test code
Remove use of UriTemplate in MockMvcRequestBuilders.
Rely on UriComponentsBuilder instead.

Decode query params before setting them on MockHttpServletRequest.

Add more options to model result matching for the count of errors.

Ignore white spaces and comments when comparing XML.
2012-10-11 22:18:22 -04:00
Phillip Webb 1858ef10ff Tests for DelegatingDataSource Wrappers 2012-10-10 15:49:03 -07:00
Juergen Hoeller 1a6940dd05 Fixed test failure on CI server (classpath search failing for some reason)
Issue: SPR-9797
2012-10-11 00:35:04 +02:00
Juergen Hoeller 15bf31a09e ResourceDatabasePopulator etc 2012-10-11 00:35:03 +02:00
Juergen Hoeller 84b3f7106d Polishing along with 3.1.3 backport
Issue: SPR-9761
Issue: SPR-9762
2012-10-11 00:35:02 +02:00
Phillip Webb 69b380583a Merge pull request #134 from philwebb/SPR-9744
* SPR-9744:
  Improve annotation methods in TypeDescriptor
  Polish code and JavaDoc formatting
2012-10-10 15:17:02 -07:00
Phillip Webb e543ffdfd7 Improve annotation methods in TypeDescriptor
- Use generic typing for getAnnotation()
- Add hasAnnoation() method
- Update existing code and tests to make use of changes

Issue: SPR-9744
2012-10-10 15:16:46 -07:00
Phillip Webb 23f089ff1e Polish code and JavaDoc formatting
- Remove trailing whitespace
- Apply consistent JavaDoc formatting
2012-10-10 15:16:46 -07:00
Juergen Hoeller efd872e35a JPA persistence.xml files may use jar-file entries relative to the unit root (as per the JPA spec)
Issue: SPR-9797
2012-10-10 23:34:24 +02:00
Juergen Hoeller 92a92b7937 Minor changes along with 3.1.3 backport
Issue: SPR-9781
Issue: SPR-9784
2012-10-10 23:34:23 +02:00
Juergen Hoeller 014f7f0242 Changes along with 3.1.3 backport
Aside from minor polishing, this change sets the "systemProperties" and "systemEnvironment" beans at each factory level as well.

Issue: SPR-9756
Issue: SPR-9764
2012-10-10 23:34:22 +02:00
Juergen Hoeller 9eeb6f15e5 Minor changes along with 3.1.3 backport
Issue: SPR-9798
Issue: SPR-9804
2012-10-10 23:34:21 +02:00
Phillip Webb e5cfe8a2c5 Merge pull request #154 from philwebb/SPR-9285
* SPR-9285:
  Chain exception cause on create failure
2012-10-10 14:05:56 -07:00
Phillip Webb 2e48656906 Chain exception cause on create failure
Propogate root cause of exceptions thrown from createCollection
and createMap.

Issue: SPR-9285
2012-10-10 14:03:02 -07:00
Rossen Stoyanchev 2748f2b8eb Remove deprecated methods in spring-test-mvc 2012-10-10 16:10:49 -04:00
Rossen Stoyanchev e7a7f751b6 Prefix REST client test support classes w/ "MockRest"
Add "MockRest-" prefix to RequestMatchers and ResponseCreators to
make it easy to find classes with static imports with
Ctrl+Shift+T "MockRest" - similar to the "MockMvc"
prefix on the server-side.
2012-10-10 15:44:51 -04:00
Rossen Stoyanchev d4fa5c0331 Fix NPE in AbstractMessageConverterMethodProcessor
Issue: SPR-9868
2012-10-10 09:00:43 -04:00
Juergen Hoeller c020096bbd Further changes for 3.2 RC1 2012-10-10 14:28:56 +02:00
Juergen Hoeller d15ca6277a Polishing 2012-10-10 14:28:55 +02:00
Juergen Hoeller fe16334dd4 Hibernate 4 LocalSessionFactoryBuilder sets thread context ClassLoader (for JBoss 7 compatibility)
Issue: SPR-9846
2012-10-10 14:28:54 +02:00
Juergen Hoeller 6445f09c36 Consistently upgraded Apache HttpComponents usage to 4.2
Issue: SPR-9475
2012-10-10 14:28:53 +02:00
Juergen Hoeller 8bdc6be074 Consistent "this." reference to local variable 2012-10-10 14:28:52 +02:00
Juergen Hoeller 9ff640a95d AbstractRoutingDataSource consistently implements JDBC 4.0's Wrapper interface as well
Issue: SPR-9856
2012-10-10 14:28:52 +02:00
Juergen Hoeller 93aa411886 HttpComponentsHttpInvokerRequestExecutor uses HttpComponents 4.2 to explicitly release connections
Issue: SPR-9833
2012-10-10 14:28:51 +02:00
Chris Beams 0c0a563a24 Avoid further 'type mismatch' errors in ExtendedBeanInfo
This change fixes further cases under JDK 6 in which setting a bridged
(e.g. String-returning) read method can conflict with an existing
corresponding bridge write method that accepts an Object parameter.

This appears to be a implementation difference between JDKs 6 and 7,
where the JDK 6 Introspector adds bridge methods and JDK 7 does not.

The solution here is to consistently null-out any existing write method
before setting the read method. We were doing this elsewhere in
ExtendedBeanInfo already, but these two changes make the approach
consistent throuhout.

Issue: SPR-8806
2012-10-09 20:10:50 -07:00
Rossen Stoyanchev 7b4bc08b14 Update context-based tests in spring-test-mvc
Added WebAppResourceTests
Removed unused config file TestContextTests-context.xml
Moved servlet-context.xml in package that matches the test classes
2012-10-08 12:41:09 -04:00
Sam Brannen 9937f840d5 Merge pull request #160 from sbrannen/SPR-5243
Support loading WebApplicationContexts in the TCF
2012-10-07 15:29:18 -07:00
Sam Brannen a73280ccc8 Support loading WebApplicationContexts in the TCF
Prior to this commit, the Spring TestContext Framework only supported
loading an ApplicationContext in integration tests from either XML or
Java Properties files (since Spring 2.5), and Spring 3.1 introduced
support for loading an ApplicationContext in integration tests from
annotated classes (e.g., @Configuration classes). All of the
ContextLoader implementations used to provide this support load a
GenericApplicationContext. However, a GenericApplicationContext is not
suitable for testing a web application since a web application relies on
an implementation of WebApplicationContext (WAC).

This commit makes it possible to integration test Spring-powered web
applications by adding the following functionality to the Spring
TestContext Framework.

 - Introduced AbstractGenericWebContextLoader and two concrete
   subclasses:
   - XmlWebContextLoader
   - AnnotationConfigWebContextLoader

 - Pulled up prepareContext(context, mergedConfig) from
   AbstractGenericContextLoader into AbstractContextLoader to allow it
   to be shared across web and non-web context loaders.

 - Introduced AnnotationConfigContextLoaderUtils and refactored
   AnnotationConfigContextLoader accordingly. These utils are also used
   by AnnotationConfigWebContextLoader.

 - Introduced a new @WebAppConfiguration annotation to denote that the
   ApplicationContext loaded for a test should be a WAC and to configure
   the base resource path for the root directory of a web application.

 - Introduced WebMergedContextConfiguration which extends
   MergedContextConfiguration with support for a baseResourcePath for
   the root directory of a web application.

 - ContextLoaderUtils.buildMergedContextConfiguration() now builds a
   WebMergedContextConfiguration instead of a standard
   MergedContextConfiguration if @WebAppConfiguration is present on the
   test class.

 - Introduced a configureWebResources() method in
   AbstractGenericWebContextLoader that is responsible for creating a
   MockServletContext with a proper ResourceLoader for the
   resourceBasePath configured in the WebMergedContextConfiguration. The
   resulting mock ServletContext is set in the WAC, and the WAC is
   stored as the Root WAC in the ServletContext.

 - Introduced a WebTestExecutionListener that sets up default thread
   local state via RequestContextHolder before each test method by using
   the MockServletContext already present in the WAC and by creating a
   MockHttpServletRequest, MockHttpServletResponse, and
   ServletWebRequest that is set in the RequestContextHolder. WTEL also
   ensures that the MockHttpServletResponse and ServletWebRequest can be
   injected into the test instance (e.g., via @Autowired) and cleans up
   thread locals after each test method.

 - WebTestExecutionListener is configured as a default
   TestExecutionListener before DependencyInjectionTestExecutionListener

 - Extracted AbstractDelegatingSmartContextLoader from
   DelegatingSmartContextLoader and introduced a new
   WebDelegatingSmartContextLoader.

 - ContextLoaderUtils now selects the default delegating ContextLoader
   class name based on the presence of @WebAppConfiguration on the test
   class.

 - Tests in the spring-test-mvc module no longer use a custom
   ContextLoader to load a WebApplicationContext. Instead, they now
   rely on new core functionality provided in this commit.

Issue: SPR-5243
2012-10-08 00:23:19 +02:00
Rossen Stoyanchev 3552173b81 Fix issue in AnnotationMethodHandlerExceptionResolver
Caching of resovled exceptions introduced in SPR-7703 also introduced a
side effect whereby if exactly one exception was previously cached, any
other exception would appear as a match to the previously matched
@ExceptionHandler method.

This change ensures use of a fresh map when determining matching
@ExceptionHandler methods while also updating the cache.

Issue: SPR-9209
2012-10-06 21:58:34 -04:00