Commit Graph

662 Commits

Author SHA1 Message Date
Sebastien Deleuze
5a0ac42b85 Merge branch '5.1.x' 2019-03-21 19:17:22 +01:00
Sebastien Deleuze
d4714847a0 Restore 2 digit days format in HttpHeaders
As recommended by RFC 7231, this commit restore using 2 digit days
when formatting dates while still using
DateTimeFormatter.RFC_1123_DATE_TIME for parsing.

Closes gh-22478
2019-03-21 18:31:45 +01:00
Sam Brannen
fef43048b2 Polish annotation-driven event listener support 2019-03-14 23:13:41 +01:00
Sam Brannen
7abe9c6a08 Polishing 2019-03-06 14:22:16 +01:00
Sam Brannen
4112ca7da8 Separate async/sync TestContext event listeners in tests
See gh-18490
2019-03-03 21:30:49 +01:00
Sam Brannen
b5fb7437c9 Test exception handling for TestContext event annotations
This commit introduces tests for both synchronous and asynchronous
exception handling for TestContext event annotations.

See gh-18490
2019-03-03 16:36:00 +01:00
Sam Brannen
e272e2e151 Support conditional processing in TestContext event annotations
This commit introduces support for SpEL expressions for conditional
event processing in annotations such as @BeforeTestClass,
@BeforeTestMethod, etc.

This commit also introduces a new getTestContext() method in
TestContextEvent in order to improve the readability of such SpEL
expressions.

See gh-18490
2019-03-02 17:26:57 +01:00
Sam Brannen
7d926a847d Polish tests for TestContext lifecycle events
See gh-18490
2019-03-01 21:26:37 +01:00
Sam Brannen
2d6624de71 Polish support for publishing TestContext lifecycle events
See gh-18490
2019-03-01 15:25:35 +01:00
Frank Scheffler
34fee867d2 Provide support for publishing TestContext lifecycle events
This commit introduces a new EventPublishingTestExecutionListener for
publishing events to the test ApplicationContext. These may be consumed
by @EventListener annotated methods to react to the TestContext
lifecycle. The listener is not registered by default.

Closes gh-18490
2019-03-01 15:22:54 +01:00
Juergen Hoeller
9efea7eb73 MockHttpServletRequest preserves original Accept-Language header value
Issue: SPR-17566
2018-12-04 22:07:43 +01:00
Juergen Hoeller
d5dab12909 NettyDataBufferFactory.join returns single-element buffer as-is
Issue: SPR-17560
2018-12-03 23:52:35 +01:00
Sam Brannen
58cde3c2e6 Avoid test compile-time dependency on junit-jupiter-engine
Issue: SPR-17533
2018-11-23 18:05:34 +01:00
Sam Brannen
aa7f69a5d1 Ensure that parameter resolution in SpringExtension is thread-safe
Prior to this commit, parallel execution of @BeforeEach and @AfterEach
methods that accepted @Autowired arguments would fail intermittently
due to a race condition in the internal implementation of the JDK's
java.lang.reflect.Executable.getParameters() method.

This commit addresses this issue by creating instances of
SynthesizingMethodParameter via
SynthesizingMethodParameter.forExecutable(Executable, int) instead of
SynthesizingMethodParameter.forParameter(Parameter), since the latter
looks up the parameter index by iterating over the array returned by
Executable.getParameters() (which is not thread-safe).

Issue: SPR-17533
2018-11-23 16:35:19 +01:00
Stephane Nicoll
7b6f2f8fb3 Polish contribution
Closes gh-2019
2018-11-19 08:45:33 +01:00
Hanope
bfb49c7249 Fix typos
See gh-2019
2018-11-19 08:41:21 +01:00
Sam Brannen
b3aad549c9 Fix @since tag 2018-11-10 16:56:39 +01:00
Sam Brannen
865f1f692a Introduce tests for @Sql and @Transactional support in @Nested test classes
This commit was inspired by the following question on Stack Overflow.

https://stackoverflow.com/questions/53236807/spring-boot-testing-run-script-in-a-nested-test-sql-script-sql
2018-11-10 15:47:30 +01:00
Sam Brannen
93df24af16 Polishing 2018-11-10 15:47:29 +01:00
Rossen Stoyanchev
c2b55e60cd Fix failing test
After the fix #658c7f for lenient parsing of dates, the error message
raised uses an HttpHeaders-formatted date. As a result the test
verifying the error message fails in the beginning of the month between
1-9 because it's formatted slightly differently.
2018-11-01 15:27:39 -04:00
Juergen Hoeller
93bb78ec23 Avoid private bean classes in integration tests (for CGLIB on JDK 11)
Issue: SPR-16391
2018-10-15 12:26:38 +02:00
Rossen Stoyanchev
ecd0d7f0f6 Complete initialization with bindToRouterFunction
Issue: SPR-17239
2018-10-12 17:11:35 -04:00
Rossen Stoyanchev
658c7f99d7 Lenient date parsing in HeadersResultMatchers
Rather than formatting the expected value, and be susceptible to
minor formatting differences (e.g. 01 vs 1 for day of month), parse the
actual header value leniently with HttpHeaders and compare time values.

Issue: SPR-17330
2018-10-12 15:41:42 -04:00
Juergen Hoeller
bfc5ad890e MockHttpServletRequest resets InputStream/Reader on setContent
Issue: SPR-17373
2018-10-12 16:00:31 +02:00
Rossen Stoyanchev
8df0bc88d2 Improve access to raw content in WebTestClient
If the content has not been consumed, cause it to be produced, and
wait for a certain amount of time before giving up, so the raw content
can be made available. This can occur when:

1) In a mock server scenario the Flux representing the client request
content is passed directly to the mock server request, but is never
consumed because of an error before the body is read.

2) Test obtains FluxExchangeResult (e.g. for streaming) but instead of
consuming the Flux, it calls getResponseBodyContent() instead.

Issue: SPR-17363
2018-10-11 20:25:56 -04:00
Rossen Stoyanchev
050f44d75b Rename WebTestClientConnectorTests to match class name 2018-10-11 19:47:37 -04:00
Sam Brannen
e63bffcfa0 Introduce not-null precondition for MockCookie parsing 2018-10-02 13:07:20 +02:00
Sam Brannen
77205ca165 Polish MockCookie contribution
Issue: SPR-17321, #1974
2018-10-02 13:06:16 +02:00
Sam Brannen
31095f1d4e Move MockCookie parsing tests to correct class
Issue: SPR-17321, #1974
2018-10-02 12:43:17 +02:00
Sam Brannen
49bc746640 Polish MockCookie[Tests] 2018-10-02 12:41:07 +02:00
Michael Bell
1b8421c7fe Fix MockCookie parsing when attribute is omitted
Issue: SPR-17321, #1974
2018-10-02 06:18:45 -04:00
Sam Brannen
c450f8dd82 Revert "PoC: migrate from JUnit 4 to JUnit Jupiter Assertions"
This reverts commit fd352b84b3, and the
PoC will be moved to a feature branch.
2018-09-06 15:58:58 +02:00
Sam Brannen
fd352b84b3 PoC: migrate from JUnit 4 to JUnit Jupiter Assertions 2018-09-06 14:36:19 +02:00
Toshiaki Maki
d570f82456 Use long for expires and lastModified in HeaderAssertions
This commit changes the type of parameters so that HeaderAssertions
can assert expires and lastModified properly.

Issue: SPR-17194
2018-09-05 17:16:14 -04:00
Juergen Hoeller
9614817e88 Do not proxy test instances based on "original instance" convention
Issue: SPR-17137
2018-08-24 00:49:01 +02:00
Sam Brannen
d20d95b7ac Allow directly present @BootstrapWith to override meta annotations
Prior to this commit, if a test class was meta-annotated with multiple
@BootstrapWith declarations that registered different
TestContextBootstrapper implementations, such a configuration would
result in an IllegalStateException, and there was no way to override
this behavior.

This commit addresses this shortcoming by relaxing the explicit
TestContextBootstrapper resolution in BootstrapUtils so that a directly
present @BootstrapWith annotation will now override declarations of
@BootstrapWith that are meta-present. In other words, if @BootstrapWith
is used as a meta-annotation, it can be overridden directly on the test
class via an explicit, local declaration of @BootstrapWith.

Issue: SPR-17006
2018-08-15 16:17:05 +02:00
Sam Brannen
1b54d2119d Polishing 2018-08-15 12:27:45 +02:00
Vedran Pavic
bb2db87c2f Add support for adding cookies as headers in MockHttpServletResponse
Issue: SPR-17110
2018-08-03 16:44:14 +03:00
Vedran Pavic
70dbaf9751 Publish binding event for replaced attributes in MockHttpSession
Issue: SPR-17109
2018-08-01 13:07:41 +02:00
Rossen Stoyanchev
bcb485b5ed bindToApplicatonContext uses WebSessionManager bean
Issue: SPR-17094
2018-07-26 15:53:41 -04:00
Rossen Stoyanchev
91122ec0f5 Add Consumer methods to WebTestClient assertion classes
Issue: SPR-16574
2018-07-20 22:28:40 -04:00
Rossen Stoyanchev
20de5003ff Hamcrest methods in WebTestClient
Issue: SPR-16729
2018-07-20 17:40:38 -04:00
Rossen Stoyanchev
0c62d6b5da Polish
Leaving out hamcrest for now, to address more broadly.

Issue: SPR-16741
2018-07-20 17:40:38 -04:00
Eric Deandrea
2734f01067 Provide XML assertions in WebTestClient
Adds XML-based assertions in
org.springframework.test.web.reactive.server.WebTestClient.BodyContentSpec
for asserting against the XML body as well as xPath,
similar to those assertions offered when using
MockMvcResultMatchers.xpath().

Issue: SPR-16741
2018-07-20 17:38:04 -04:00
Juergen Hoeller
b3d6283d7d CookieAssertionTests expects language tag compliance by default
Issue: SPR-16700
2018-07-17 18:18:54 +02:00
Rossen Stoyanchev
75e45103b5 Polish DefaultUriBuilderFactory 2018-07-16 21:21:34 -04:00
Rossen Stoyanchev
fd90b73748 Correlated WebFlux server log messages
Issue: SPR-16966
2018-07-05 08:27:13 -04:00
Sam Brannen
160002cf8b Polishing 2018-07-04 14:33:39 +02:00
Sam Brannen
755add3087 Verify that TestContextBootstrapper resolution ignores duplicates
This commit introduces a test to verify that multiple declarations of
@BootstrapWith that register the same TestContextBootstrapper type
(i.e., duplicates) do not result in an error.

Issue: SPR-17006
2018-07-04 13:58:49 +02:00
Juergen Hoeller
d22d408261 Propagate read-only status through Session.setDefaultReadOnly(true)
Issue: SPR-16956
2018-07-03 22:22:19 +02:00