Commit Graph

582 Commits

Author SHA1 Message Date
Sam Brannen
2454b31b30 Polish MockRestRequestMatchers[Tests] 2018-03-07 14:20:57 +01:00
Juergen Hoeller
a0cc80063d Concurrency and exception message refinements for test transactions 2018-03-05 13:00:35 +01:00
Rossen Stoyanchev
e12fcca1e3 Fix failing test 2018-02-26 20:35:17 -05:00
Juergen Hoeller
01d9475bcc Turn registered controller classes into controller instances on the fly
Issue: SPR-16520
2018-02-25 14:29:44 +01:00
Rossen Stoyanchev
bb8cddda23 Assert instances (vs classes) in MockMvc/WebTestClient
Issue: SPR-16520
2018-02-21 14:01:53 -05:00
Juergen Hoeller
3b810f3544 Consistent Class array vs vararg declarations (and related polishing) 2018-02-14 14:44:00 +01:00
igor-suhorukov
0ee505b73e Polish: assertion arguments should be passed in the correct order,
use assertNull instead of assertEquals(null, value),
declare delta as double value in assertEquals
2018-02-10 17:17:28 +01:00
Rossen Stoyanchev
1653a32a04 Stabilize Flux.interval emissions in integration tests
After this commit the use of interval in tests is combined with
take(n).onBackpressureBuffer(n) to ensure emissions don't fail if the
fixed rate is exceeded (e.g. on slow CI server).

Tests that verify N number of items followed by verifyOnComplete()
should set the number of emissions to N.

Tests that verify N number of items followed by thenCancel() should
set the number of buffered to an arbitrary number greater than N.
2018-02-06 11:01:19 -05:00
Rossen Stoyanchev
f20eacdb9b Polish 2018-02-02 15:06:59 -05:00
Rob Winch
0cd427bdd3 MockHttpServletRequestBuilder decodes pathInfo
Previously MockHttpServletRequestBuilder calculated the pathInfo from the
provided URL without decoding the value. This meant that the pathInfo
incorrectly included URL encoded values.

Now MockHttpServletRequestBuilder properly decodes the pathInfo.

Fixes: SPR-16453
2018-02-02 15:00:47 -05:00
Juergen Hoeller
b3e21ec737 MockHttpServletRequest leniently handles invalid Accept-Language header
Issue: SPR-16454
2018-02-02 11:34:22 +01:00
Sam Brannen
b612f53e27 Rename doesExist() to exists() for header assertions 2018-01-26 17:24:54 +01:00
Sam Brannen
165ca12e6d Add doesExist() to HeaderAssertions for WebTestClient 2018-01-25 15:50:19 +01:00
Sam Brannen
431494096a Polishing 2018-01-25 15:49:06 +01:00
Rossen Stoyanchev
49f1aa78eb Polish 2018-01-24 17:37:49 -05:00
Neonailol
81ca1f7c2b Add doesExist assertion method to HeaderResultMatchers 2018-01-24 17:28:46 -05:00
Rossen Stoyanchev
0c289283ff Separate from expectations from response creation
This commit separates the creation of a response so that it is executed
after the synchronized block inside which requests need to be matched
and validated (for order and count).

This allows a ResponseCreator to be slow or block if it has to.

Issue: SPR-16319
2018-01-17 13:01:40 -05:00
Sam Brannen
c88f11f958 Avoid deprecation warnings on JDK 9 in spring-test 2018-01-13 16:45:04 +01:00
Juergen Hoeller
8f6d3feaa0 Tests for non-required MultipartFile parameters
Issue: SPR-16329
2018-01-11 10:22:59 +01:00
Rossen Stoyanchev
0f1f95e090 Add hasJsonPath/doesNotHaveJsonPath assertion options
Issue: SPR-16339
2018-01-03 20:27:09 -05:00
Brian Clozel
6e587d5c57 Add new WebTestClient header assertions
This commit adds new header assertions for `WebTestClient`.

`doesNotExist` tests that a given header is not present:

    .expectHeader().doesNotExist("Cache-Control");

`contentTypeCompatibleWith` tests for MediaType compatibility:

    .expectHeader().contentTypeCompatibleWith("text/*");

Issue: SPR-16285
2017-12-21 20:34:24 +01:00
Rossen Stoyanchev
a8cf275aed MockServerHttpRequest builder supports query params
Issue: SPR-16280
2017-12-19 15:38:12 -05:00
Juergen Hoeller
7697b398d5 Polishing 2017-11-14 17:11:16 +01:00
Rossen Stoyanchev
cb34b0b963 Polish 2017-11-09 17:16:31 -05:00
anton_bondarenko
b487db294b Fix NullPointer when setting cookies in RequestUriSpec 2017-11-09 16:59:44 -05:00
Juergen Hoeller
4ec60f08ad PrintingResultHandler defensively accesses session.getAttributeNames()
Issue: SPR-16164
2017-11-06 21:19:44 +01:00
Juergen Hoeller
80a0cf71f4 MockHttpServletResponse.getDateHeader returns -1 for non-existent header
Includes consistent getDateHeader results in both MockHttpServletResponse variants (spring-test and spring-web)

Issue: SPR-16160
2017-11-05 16:12:21 +01:00
Juergen Hoeller
0edf4d6509 MockHttpServletRequest.getRequestURL aligns with getServerName/Port
Issue: SPR-16138
2017-11-05 16:11:21 +01:00
Rossen Stoyanchev
579328bd7a MockClientHttpRequest|Response support cookie headers
Issue: SPR-16124
2017-10-31 12:08:18 -04:00
Juergen Hoeller
295e3b6a99 MockRestServiceServer test for follow-up request after failure
Issue: SPR-16132
2017-10-30 16:40:20 +01:00
Eric Pabst
43d88e4a25 Move requests.add(request) into finally block.
This avoids "IllegalStateException: Expectations already declared" when
a MockRestServiceServer is used after one request throws an exception.

Issues: SPR-16132
2017-10-30 08:53:13 -06:00
Juergen Hoeller
70ed45020b Add StatusAssertions.isForbidden
Includes aligned quoting for header assertion messages.
Also aligns HeaderAssertionTests class name.

Issue: SPR-16129
2017-10-29 09:51:25 +01:00
Rossen Stoyanchev
a982123ed5 Decouple ExchangeResult from WiretapRequest/Response
This commit decouples ExchangeResult from knowledge about
WiretapClientHttpRequest/Response both of which are now private to
WiretapConnector.

ExchangeResult takes ClientHttpRequest/Response instead along with
promises for the serialized request and response content in the form
of MonoProcessor<byte[]>.

This sets up the possibility for an ExchangeResult to be created
outside and independent of WebTestClient, should we decide to make its
constructor public.

Issue: SPR-16101
2017-10-25 17:41:46 -04:00
Rossen Stoyanchev
cd634633d8 MockMvc re-uses response instance on async dispatch
MockMvc now properly detects the presence of an AsyncContext and
re-uses the response instance used to start it.

This commit also includes a minor fix in
ResponseBodyEmitterReturnValueHandler to ensure it does not disable
ETag related content buffering for reactive return values that do not
result in streaming (e.g. single value or collections).

Issue: SPR-16067
2017-10-17 16:57:35 -04:00
Arjen Poutsma
24ca8ccf5a WebTestClient.mutate() should not impact future .mutate() invocations
Issue: SPR-16059
2017-10-13 16:54:30 +02:00
Rossen Stoyanchev
d04d4bfb4d Better "no content" support and polish in WebTestClient
The WebTestClient now takes advantage of the support for decoding
response to Void.class in WebClient so that applications can use
expectBody(Void.class) to the same effect as using
response.bodyToMono(Void.class) as documneted on WebClient#exchange.

The top-level, no-arg returnResult method (added very recently) has been
retracted, since the use of returnResult at that level, i.e. without
consuming the response content, should be used mainly for streaming.
It shouldn't be used for "no content" scenarios.

Documentation and Javadoc have been udpated accordingly.
2017-10-04 15:05:25 -04:00
Juergen Hoeller
15c82afc1c Consistent conversion of Optional array/list arrangements
Issue: SPR-15918
Issue: SPR-15919
Issue: SPR-15676
2017-09-20 18:28:49 +02:00
Juergen Hoeller
ea01c4113a Revisit MockPart constructors
Issue: SPR-15854
2017-09-20 10:55:06 +02:00
Sam Brannen
dcdb0b416f Rename SPRING_CLASS_RULE fields to springClassRule 2017-09-06 17:38:22 +02:00
Sam Brannen
ba6b617bd5 Demo: @Autowired rules not supported with Spring's JUnit rules
This commit introduces a test that demonstrates that custom JUnit 4
rules can be @Autowired into a test instance but that they will not be
applied by JUnit since JUnit only ever sees such fields as null and
therefore ignores them.

Issue: SPR-15927
2017-09-06 17:29:04 +02:00
Sam Brannen
0702898836 Clean up warnings in Gradle build output 2017-09-04 16:26:51 +02:00
Sam Brannen
9da3927235 Polishing 2017-08-22 22:23:44 +01:00
Juergen Hoeller
fac1f236c3 Upgrade to Servlet API 4.0 for MVC and merge EhCache 3 tests into spring-context-support
Includes general streamlining of dependency declarations with reduced version variables, direct use of EclipseLink 2.7 and its implicit JPA 2.2 dependency in spring-orm, mixed use of Hibernate 5.2.10 and 5.1.10 for integration tests, as well as an upgrade to Jetty 9.4.7 RC0 and a downgrade to Groovy 2.4.12 (since Groovy 2.5 won't be final in time for Spring Framework 5.0).

Issue: SPR-15879
Issue: SPR-15880
2017-08-21 01:34:11 +02:00
Rossen Stoyanchev
9c3bd8ce85 Separate forwarded~ and redirectedUrlTemplate methods
This commit restores and existing redirectedUrl and forwardedUrl
methods (simple String comparison) and creates separate
redirectedUrlTemplate and forwardedUrlTemplate methods that expand
and also encode before comparing.

Issue: SPR-15834
2017-08-15 15:25:39 +02:00
Drummond Dawson
809189be1a URI variables with MockRestRequestMatchers requestToUriTemplate
Issue: SPR-15819
2017-08-15 14:55:56 +02:00
Sam Brannen
4630e62c20 Fix formatting 2017-07-28 12:25:05 +02:00
Sam Brannen
859da2f074 Clean up warnings in spring-test 2017-07-28 12:24:53 +02:00
Rossen Stoyanchev
45e714ec13 Add test case for SPR-15719 2017-07-25 12:29:44 +02:00
Rossen Stoyanchev
d20e5fcc59 Polish 2017-07-25 12:29:44 +02:00
Juergen Hoeller
46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00