Commit Graph

10737 Commits

Author SHA1 Message Date
Brian Clozel cf2aed9d00 Add a dateValue HeaderResultMatcher
HTTP headers such as "Expires", "Last-Modified" all use date
strings like "Tue, 21 Jul 2015 10:00:00 GMT". Prior to this commit,
there was no way to match those header values, besides formatting dates
manually.

This commit introduces a new HeaderResultMatcher to test those date
headers using a long timestamp:

```
this.mockMvc.perform(get("/persons/1").header("If-Modified-Since", now))
  .andExpect(status().isNotModified())
  .andExpect(header().dateValue("Last-Modified", timestamp));
```

Issue: SPR-13263
2015-07-22 11:22:44 +02:00
Sam Brannen ed20b3771c Clean up warnings on Hibernate support code 2015-07-21 23:39:07 +02:00
Juergen Hoeller edd6e76b9f Polishing 2015-07-21 22:58:34 +02:00
Juergen Hoeller 1a636b1023 Polishing 2015-07-21 20:33:13 +02:00
Juergen Hoeller 7c22d60fd8 Streamlined WebContentGenerator API variants: checkRequest, prepareResponse, applyCacheControl, applyCacheSeconds
Issue: SPR-11792
2015-07-21 20:33:03 +02:00
Juergen Hoeller b277c081e7 Upgrade to Hibernate Validator 5.2 GA and Jackson 2.6 GA 2015-07-21 20:20:45 +02:00
Sam Brannen dd0966e1f5 Cross reference Servlet API mocks in Testing chapter 2015-07-21 18:26:03 +02:00
Sam Brannen d67d8ddf2d Fix formatting 2015-07-21 18:24:52 +02:00
Sam Brannen 2dfa1804f4 Document AopTestUtils in the reference manual
Issue: SPR-13006
2015-07-21 17:32:30 +02:00
Sam Brannen 420e8ca833 Sync Javadoc and reference manual regarding ReflectionTestUtils 2015-07-21 17:10:00 +02:00
Sam Brannen 6b84c332fd Polishing 2015-07-21 15:13:21 +02:00
Brian Clozel 088a50c1fb Improve setDateHeader impl in MockServletResponse
Prior to this change, calling the `setDateHeader` method on a
MockHttpServletResponse instance (internal implementation for testing
the spring-web module) would just store the given long value in a Map,
not writing it as a formatted date String.

This can be problematic when testing features related to date headers
such as "Expires", "If-Modified-Since", "Last-Modified", etc.

This commit formats long dates into date Strings using the date format
recommended by the RFC and the GMT time zone.
2015-07-21 14:28:44 +02:00
Brian Clozel eef937e4f2 Rename <mvc:cachecontrol/> to <mvc:cache-control/> 2015-07-21 12:09:25 +02:00
Brian Clozel 9149bf7ad4 Polish 2015-07-21 11:57:02 +02:00
Brian Clozel 327785d19e Fix typo in resource handling reference doc 2015-07-21 10:36:14 +02:00
Felix 09e3fc40e5 Reset Pragma header in WebContentGenerator
As filter-based libraries and projects (such as Spring Security) may
use the "Pragma" header in HTTP responses, WebContentGenerator should
make sure that such headers are overwritten to avoid clashes with
the HTTP caching headers set by the HTTP caching configuration.

Issue: SPR-13252
2015-07-21 10:08:04 +02:00
Sam Brannen d8fb6c557d Delete unused imports in HeaderAssertionTests 2015-07-20 23:57:46 +02:00
Brian Clozel dba46c1358 Partial revert of SPR-13090
Use ServletHttpResponse.setDateHeader whenever possible and avoid using
SimpleDateFormat.
2015-07-20 22:48:20 +02:00
Sam Brannen 19fcb72d70 Polish Javadoc in the Spring MVC Test Framework 2015-07-20 22:41:30 +02:00
Sam Brannen bf06bf33ab Reuse mock request from the TCF in Spring MVC Test
Prior to this commit, the Spring MVC Test Framework always created a
new MockHttpServletRequest, disregarding any mock request already
present in Spring Web's RequestContextHolder -- for example, one
created by the ServletTestExecutionListener in the Spring TestContext
Framework (TCF).

This commit modifies MockHttpServletRequestBuilder so that it reuses a
mock request created by the TCF. However,
MockMultipartHttpServletRequestBuilder continues to always create a new
MockMultipartHttpServletRequest since a MockHttpServletRequest created
by the TCF is not directly compatible with a
MockMultipartHttpServletRequest. Furthermore, in order to avoid
unforeseen side effects, MockHttpServletRequestBuilder will always
create a new MockHttpServletRequest if a mock request is present in the
RequestContextHolder but not created by the TCF.

Issue: SPR-13211
2015-07-20 22:41:29 +02:00
Sam Brannen 24ff4f56e1 Introduce logging in TomcatWebSocketTestServer
This commit replaces calls to System.out.println() with explicit logging.
2015-07-20 17:03:44 +02:00
Sam Brannen 0153913ef4 Polish and simplify EnableSchedulingTests 2015-07-20 14:55:48 +02:00
Sam Brannen c3e36ad960 Polish further resources section in Testing chapter 2015-07-20 14:39:35 +02:00
Juergen Hoeller 34a81b605a PropertyOrFieldReference defensively catches Exception instead of just AccessException
Issue: SPR-13247
2015-07-20 13:04:34 +02:00
Juergen Hoeller cad0665187 Fixed exception message expectation plus formatting
Issue: SPR-13236
2015-07-20 13:01:14 +02:00
Sebastien Deleuze 57d55ddd56 Polish CorsFilter Javadoc 2015-07-20 11:14:37 +02:00
Sebastien Deleuze 70a03ee2a4 Rename CorsConfigurationMapping to UrlBasedCorsConfigurationSource
Issue: SPR-13192
2015-07-20 10:47:24 +02:00
Sam Brannen e9f64cf9ae Sync Servlet mocks between spring-test & spring-web 2015-07-19 20:23:51 +02:00
Sam Brannen 6950d977c2 Polish and simplify DispatcherServletInitializerTests 2015-07-19 19:52:38 +02:00
Sam Brannen 9124907b29 Polish and simplify Jackson2ObjectMapperFactoryBeanTests 2015-07-19 19:29:12 +02:00
Sam Brannen 5f3506ae8f Suppress build warnings in tests 2015-07-19 19:28:16 +02:00
Sam Brannen 0d0e879ed0 Upgrade to TestNG 6.9.6 2015-07-17 23:17:07 +03:00
Juergen Hoeller c3e57dd245 AsyncAnnotationBeanPostProcessor tries to find TaskExecutor by type/name
Issue: SPR-13248
2015-07-17 18:55:46 +02:00
Juergen Hoeller fca33f53e3 Ported test adaptations to JPA 2.1 variant
Issue: SPR-13243
2015-07-17 18:52:02 +02:00
Juergen Hoeller 8e55ad1c08 Polishing 2015-07-17 16:33:15 +02:00
Juergen Hoeller 66d8c2819f ScheduledAnnotationBeanPostProcessor falls back to "taskScheduler" bean by name
Issue: SPR-13236
2015-07-17 16:29:48 +02:00
Juergen Hoeller 0cce41eb94 Fixed exception message expectation plus formatting
Issue: SPR-13067
2015-07-17 16:19:11 +02:00
Juergen Hoeller cc0a4c1ea0 Upgrade to Jetty 9.3.1 and Undertow 1.2.9 2015-07-17 15:25:51 +02:00
Juergen Hoeller 203f1225c3 Polishing 2015-07-17 15:25:43 +02:00
Juergen Hoeller 7e2a662f63 Enforce TransactionRequiredException for pre-bound EntityManager without actual transaction active
Issue: SPR-13243
2015-07-17 15:25:29 +02:00
Juergen Hoeller 2f8ac91872 Only attempt to call joinTransaction in case of actual transaction active
Issue: SPR-13242
2015-07-17 15:24:52 +02:00
Juergen Hoeller a8fb551b1c Allow for overriding of computeTransactionAttribute
Issue: SPR-13246
2015-07-17 15:24:24 +02:00
Juergen Hoeller 9de824b73d AllEncompassingFormHttpMessageConverter registers MappingJackson2XmlHttpMessageConverter and GsonHttpMessageConverter (for consistency with RestTemplate and WebMvcConfigurationSupport)
Issue: SPR-13240
2015-07-17 15:24:12 +02:00
Juergen Hoeller aedef43a9a Exception fine-tuning and general polishing
Issue: SPR-13067
2015-07-17 15:24:04 +02:00
Juergen Hoeller 9f15f347bf Renamed 'name' attribute to 'scopeName' (in order to avoid common override conflicts)
Issue: SPR-13239
2015-07-17 15:23:47 +02:00
Brian Clozel 106cce58cc Fix tests
Issue: SPR-13241
2015-07-17 13:32:38 +02:00
Brian Clozel ec5019dbae Upgrade to groovy 2.4.4 2015-07-17 11:09:56 +02:00
Brian Clozel 064abad9d8 PathResourceResolver should not resolve root path
When resolving resources, the PathResourceResolver creates a Resource
instance and checks whether this resource `exists()` and `isReadable()`.
While that last call returns false for folders on the file system, both
calls return true for folders located inside JARs.

If a JAR location is configured as a resource location, then
PathResourceResolver can resolve folders in JARs as valid locations and
candidates for paths resolution.

Prior to this change, the PathResourceResolver would resolve "" as a
valid resource path (here, the "/META-INF/resources/webjars" if
configured, for example) and return a "" path for this resource,
effectively turning all "/" URLs into empty ones "".

This commit fixes the resolveUrlPathInternal implementation by not
allowing empty paths as valid resource paths.

Issue: SPR-13241
2015-07-17 10:31:37 +02:00
Stephane Nicoll 8e479e28ce Merge pull request #839 from michalkarolik/ResultActionsJavadocFix
* pr/839:
  Fix package references
2015-07-16 11:28:38 +02:00
Michal Karolik 95fe5f9033 Fix package references
Closes gh-839
2015-07-16 11:28:12 +02:00