Commit Graph

717 Commits

Author SHA1 Message Date
Juergen Hoeller
d4010573af MockHttpServletRequest returns empty BufferedReader in case of no content
Issue: SPR-15215
(cherry picked from commit 0da964f)
2017-02-02 21:16:44 +01:00
Juergen Hoeller
28849e0987 Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
(cherry picked from commit 1b2dc36)
2017-01-31 10:28:46 +01:00
Rossen Stoyanchev
c8b0ff2fca Add ExpectedCount#never()
Issue: SPR-15168
2017-01-20 17:11:09 -05:00
Rossen Stoyanchev
fcead670f0 Add locking to AbstractRequestExpectationManager
This commit ensures that verifying a request, which includes finding
and updating expectations, is done synchronously to avoid concurrent
modification exceptions.

Technically SimpleRequestExpectationManager is not even expected to see
concurrent requests by definition but with
UnorderedRequestExpectationManager it can happen.

Issue: SPR-15029
2017-01-17 16:48:26 -05:00
Vedran Pavić
d1c0ea7d74 Set MockSessionCookieConfig#maxAge default to -1
Issue: SPR-15142
(cherry picked from 83beb9d57d)
2017-01-16 23:07:26 +01:00
Juergen Hoeller
cce84711c6 MockHttpServletRequestBuilder reliably detects form body content type again
Issue: SPR-15116
(cherry picked from commit e88e8f1)
2017-01-16 22:43:01 +01:00
Juergen Hoeller
c5500b2332 MockHttpServletRequestBuilder supports multiple locales
Includes revised content type handling.

Issue: SPR-15116
(cherry picked from commit 02d727f)
2017-01-12 22:50:50 +01:00
Rossen Stoyanchev
b14d189db9 MockRestRequestMatchers can match query params
Issue: SPR-14995
2016-12-13 16:07:19 -05:00
Juergen Hoeller
0028b29760 Polishing 2016-12-01 19:09:26 +01:00
Juergen Hoeller
2b0293578f Consistent use of "URI variables" terminology
Issue: SPR-14969
(cherry picked from commit 7a8ec4f)
2016-12-01 14:12:07 +01:00
Rossen Stoyanchev
872d6ef55a HtmlUnitRequestBuilder detects form encoding type
Issue: SPR-14916
2016-11-28 18:08:44 -05:00
Juergen Hoeller
7e7504f5ea Polishing 2016-11-03 23:20:33 +01:00
Stephane Nicoll
1e3012cb49 Allow to customize TestDispatcherServlet
This commit introduces the `DispatcherServletCustomizer` callback
interface that can be used to customize the `DispatcherServlet` that a
`MockMvc` is using.

Previously, only the `dispatchOptions` flag can be customized. This
commit allows to customize any property of `DispatcherServlet` before it
is initialized.

Issue: SPR-14277
2016-10-29 11:09:48 +02:00
Juergen Hoeller
9de28d640e Polishing
(cherry picked from commit 3726c6f)
2016-10-21 12:59:59 +02:00
Juergen Hoeller
37670924f6 Polishing 2016-08-31 01:53:03 +02:00
Juergen Hoeller
d8f7347000 Consistent comma splitting without regex overhead
Issue: SPR-14635
(cherry picked from commit 03609c1)
2016-08-31 00:44:52 +02:00
Juergen Hoeller
430180aa96 Polishing 2016-08-26 18:33:13 +02:00
Rossen Stoyanchev
d09b0fe83a Support target type in JsonPath assertions
This change adds support for a target type in JsonPath assertions in
Spring MVC Test.

The existing assertValue(String expression, Object expectedValue)
transparently falls back on using an alternative JsonPath API that
allows specifying the target type to coerce to.

There is also a new overloaded method
assertValue(String expression, Matcher<T> matcher, Class<T> targetType)
for use with Hamcrest matchers where the target type can be specified.

Issue: SPR-14498
(cherry picked from commit 7fdb892)
2016-08-26 17:28:37 +02:00
Juergen Hoeller
2a82b8fed9 Consistent use of Charset.forName over JDK 7 StandardCharsets in 4.x line 2016-08-26 13:11:39 +02:00
Rob Winch
43faabd4cc Fix HtmlUnitRequestBuilder merge
Previously invoking HtmlUnitRequestBuilder merge caused the pathInfo of
the parent to be corrupted. This could additional invocations with the
same parent.

This fix ensures that the parent is no longer directly used. Instead,
we create a copy of the parent by merging the parent that was passed in
with the copy.

Fixes SPR-14584
2016-08-12 20:49:48 -05:00
Juergen Hoeller
79a56967a1 PersistenceAnnotationBeanPostProcessor obtains default EntityManagerFactory via getBean(Class) algorithm
Issue: SPR-7549
(cherry picked from commit 6157fad)
2016-08-11 23:25:35 +02:00
Juergen Hoeller
0bc0453700 Polishing 2016-08-10 16:59:22 +02:00
Juergen Hoeller
35e247aa26 Polishing 2016-08-10 16:21:35 +02:00
Juergen Hoeller
67ba187b6f Polishing
(cherry picked from commit 59a24b4)
2016-08-10 14:57:50 +02:00
Juergen Hoeller
67f0b1986c Consistent spelling for StandaloneMockMvcBuilder's addPlaceholderValue
(cherry picked from commit a4b6682)
2016-08-10 14:57:43 +02:00
Juergen Hoeller
aade2d1ec9 Polishing
(cherry picked from commit 9475c06)
2016-08-09 12:37:07 +02:00
Juergen Hoeller
4627545a3b Polishing
(cherry picked from commit eae079a)
2016-08-09 11:03:51 +02:00
Juergen Hoeller
e2ba7c9b8c MockClientHttpResponse closes body stream on close()
Issue: SPR-14563
(cherry picked from commit 47e9360)
2016-08-09 11:03:46 +02:00
Juergen Hoeller
36e1c82ef5 Backported refinements and polishing 2016-07-20 21:46:25 +02:00
Vladimir L
df556333a8 Add StreamingResponseBody MockMvc sample tests
Issue: SPR-14456
(cherry picked from 7da63c)
2016-07-19 10:48:29 -04:00
Sam Brannen
813108a928 Ensure TestContextManager always tracks after-class exception
This commit fixes a minor bug introduced in 0adc4921ed.

Issue: SPR-14447
2016-07-10 16:00:30 +02:00
Juergen Hoeller
3c14911401 Polishing 2016-07-06 17:59:49 +02:00
Juergen Hoeller
92d78c10a2 Polishing (backported from master) 2016-07-06 17:13:18 +02:00
Juergen Hoeller
080dcad218 Add missing package-info file for new test.context.web.socket package
Issue: SPR-14420
2016-07-02 15:46:21 +02:00
Juergen Hoeller
b204437cef Polishing 2016-07-02 14:48:15 +02:00
Juergen Hoeller
e5122d084a Avoid wrapping in plain RuntimeException in favor of IllegalStateException 2016-07-02 13:03:33 +02:00
Juergen Hoeller
dda0942c78 Polishing 2016-06-30 21:39:51 +02:00
Juergen Hoeller
66ec1c1618 Add missing package-info files for common packages
Issue: SPR-14420
2016-06-30 21:39:06 +02:00
Sam Brannen
3dbf25e018 Implement equals() & hashCode() in MockServerContainerContextCustomizer
Issue: SPR-14367
2016-06-23 13:22:10 +02:00
Sam Brannen
f7dd757593 Support WebSocket ServletServerContainerFB in the TCF
Prior to this commit, any attempt to include a bean of type
ServletServerContainerFactoryBean in the WebApplicationContext for an
integration test class annotated with @WebAppConfiguration in
conjunction the Spring TestContext Framework (TCF) would have resulted
in an IllegalStateException stating that "A ServletContext is required
to access the javax.websocket.server.ServerContainer instance."

In such scenarios, the MockServletContext was in fact present in the
WebApplicationContext; however there was no WebSocket ServerContainer
stored in the ServletContext.

This commit addresses this issue by introducing the following.

- MockServerContainer: a private mock implementation of the
  javax.websocket.server.ServerContainer interface.

- MockServerContainerContextCustomizer: a ContextCustomizer that
  instantiates a new MockServerContainer and stores it in the
  ServletContext under the attribute named
  "javax.websocket.server.ServerContainer".

- MockServerContainerContextCustomizerFactory: a
  ContextCustomizerFactory which creates a
  MockServerContainerContextCustomizer if WebSocket support is present
  in the classpath and the test class is annotated with
  @WebAppConfiguration. This factory is registered by default via the
  spring.factories mechanism.

Issue: SPR-14367
2016-06-22 22:10:16 +02:00
nkjackzhang
981a748dcc Fix ambiguous static import in TestPropertySourceUtilsTests 2016-06-17 17:18:36 +02:00
Sam Brannen
045ee52232 Invoke target.toString() safely in ReflectionTestUtils
ReflectionTestUtils invokes toString() on target objects in order to
build exception and logging messages, and prior to this commit problems
could occur if the invocation of toString() threw an exception.

This commit addresses this issue by ensuring that all invocations of
toString() on target objects within ReflectionTestUtils are performed
safely within try-catch blocks.

Issue: SPR-14363
2016-06-14 20:08:26 +02:00
Sam Brannen
de78f05707 Polishing 2016-06-07 16:24:50 +02:00
Sam Brannen
eaa9511921 Avoid ClassCastException in HandlerResultMatchers.methodCall() 2016-06-07 16:13:42 +02:00
Sam Brannen
5a0100111e Polish HandlerAssertionTests 2016-06-07 16:13:42 +02:00
Juergen Hoeller
8c4bc3656b Polishing 2016-06-07 15:42:16 +02:00
Sam Brannen
c19740a020 Clean up warnings in spring-test 2016-06-06 18:54:16 +02:00
Rossen Stoyanchev
998b83ce8c Fix hardcoded value MockRestServiceServerBuilder 2016-06-06 08:46:50 -04:00
Rossen Stoyanchev
d10134b5a5 Polish 2016-05-31 12:56:17 -04:00
Rob Winch
54f84cbd97 MockMvcWebConnection stores cookies from response
Previously MockMvcWebConnection did not update the cookie manager with the
cookies from MockHttpServletResponse. This meant that newly added cookies
are not saved to the cookie manager and thus are not presented in the next
request.

This commit ensures that MockMvcWebConnection stores the response cookies
in the cookie manager.

Issue: SPR-14265
2016-05-31 12:43:58 -04:00