Commit Graph

639 Commits

Author SHA1 Message Date
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
Phillip Webb
a89e716cc7 Use tabs rather than spaces in tests
Update tests to ensure that tabs are used instead of spaces. Also
consistently apply a new line at the end of each file.

Issue: SPR-16968
2018-06-28 10:28:44 +02:00
Juergen Hoeller
3fc8ec498c MockHttpServletRequest returns a single InputStream or Reader
Issue: SPR-16505
Issue: SPR-16499
2018-06-13 22:03:16 +02:00
Rossen Stoyanchev
124d4c833c Support for Servlet request params with HTTP DELETE
This commit adds FormContentFilter, which is the same as the
HttpPutFormContentFilter but also supports DELETE.

The HttpPutFormContentFilter is now deprecated.

Issue: SPR-16874
2018-06-04 15:48:47 -04:00
Rossen Stoyanchev
2a993bf9ff Respect async request timeout of -1 in MockMvc
When falling back on the timeout associated with the async request,
a value of -1 must be treated as: never time out.

Issue: SPR-16869
2018-05-24 12:33:19 -04:00
Rossen Stoyanchev
d3f3b41f52 MockHttpServletResponse writer sets committed flag
Issue: SPR-16683
2018-05-10 16:22:54 -04:00
Sam Brannen
7444a62f98 Test Spring-managed JUnit Jupiter extension 2018-05-09 13:34:30 +02:00
Sam Brannen
ae3fd49ebb Introduce non-transactional test for TestNG support 2018-04-23 16:18:02 +02:00
Sam Brannen
c6ed41ec47 Suppress warning in SpringFailOnTimeoutTests 2018-04-14 15:02:57 +02:00
Sam Brannen
8317f12a9b Move SpringFailOnTimeoutTests to 'statements' package 2018-04-12 11:14:08 +02:00
Sam Brannen
4f3a7dd9b4 Expand scope of SpringFailOnTimeoutTests
Issue: SPR-16716
2018-04-12 10:56:40 +02:00
Igor Suhorukov
3c34a1cb8c Throw exception from user code in SpringFailOnTimeout even if a timeout occurs
Issue: SPR-16717
2018-04-12 10:37:13 +02:00
Rossen Stoyanchev
313308208e TestDispatcherServlet unwraps to find mock request
Issue: SPR-16695
2018-04-06 11:02:46 -04:00
Sam Brannen
56774baa2a Use Gradle 4.6's built-in support for the JUnit Platform
Gradle 4.6 provides built-in support for the JUnit Platform within the
standard `test` task.

This commit configures a custom `testJUnitJupiter` test task for
executing JUnit Jupiter tests directly on the JUnit Platform instead of
indirectly on JUnit 4 via @RunWith(JUnitPlatform.class).

This switch provides for better integration with Gradle's test reporting
and paves the way for a possible transition to the JUnit Platform in the
future.

Issue: SPR-16672
2018-04-04 15:43:44 +02:00
Sam Brannen
71cacff8c2 Upgrade to JUnit Jupiter 5.1
Issue: SPR-16408
2018-04-04 12:29:26 +02:00
Sam Brannen
e5096be660 Polishing 2018-03-30 12:23:28 +02:00
Sam Brannen
f79562f8d1 Introduce tests for generics & @Nested test classes 2018-03-30 12:12:21 +02:00
Sam Brannen
9244090ba0 Support DI of individual constructor args in @Nested tests
Prior to this commit it was impossible to have an individual
constructor argument in a @Nested (i.e., inner) test class injected via
@Autowired, @Qualifier, or @Value.

This is due to a bug in javac on JDK versions prior to 9, whereby
annotation lookups performed directly via the
java.lang.reflect.Parameter API fail for inner class constructors.

Specifically, the parameter annotations array in the compiled byte code
for the user's test class excludes an entry for the implicit enclosing
instance parameter for an inner class constructor.

This commit introduces a workaround in ParameterAutowireUtils for this
off-by-one error by transparently looking up annotations on the
preceding Parameter object (i.e., index - 1). In addition, this commit
relies on the change recently introduced in MethodParameter in order to
compensate for the same JDK bug (see SPR-16652).

Issue: SPR-16653
2018-03-29 17:47:45 +02:00
Rossen Stoyanchev
f9e6ea5482 MvcResult returns asyncResult after asyncDispatch
Issue: SPR-16648
2018-03-28 22:15:16 -04:00
Sam Brannen
75f70b269e Introduce @Nested tests with constructor injection
This commit introduces @Nested tests to verify support for constructor
injection when using the SpringExtension.

One of the tests is disabled on Java 8 due to a bug in javac that was
first fixed in JDK 9.

See https://github.com/junit-team/junit5/issues/1345 for details.
2018-03-27 16:45:26 +02:00
Arjen Poutsma
b31d55dfce Deprecated ClientRequest.method in favor of ClientRequest.create
The former method clashed with the ClientRequest.method() getter.
2018-03-16 17:27:29 +01:00
Rossen Stoyanchev
541ee13934 Add bufferContent option to MockRestServiceServer
Issue: SPR-14694
2018-03-15 22:13:44 -04:00
Rossen Stoyanchev
f7e75a5b82 Polish MockRestServiceServer client tests 2018-03-15 22:13:43 -04:00
Sam Brannen
5f4d5f17f7 Polishing 2018-03-13 16:48:52 +01:00