Commit Graph

1109 Commits

Author SHA1 Message Date
Juergen Hoeller dd4f915234 Upgrade to JCache 1.1 (and Caffeine 2.6.1)
Issue: SPR-13574
2017-12-28 14:08:21 +01: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
Juergen Hoeller 9d27e86951 Upgrade to Hibernate Validator 6.0.7 2017-12-21 17:00:06 +01:00
Rossen Stoyanchev a8cf275aed MockServerHttpRequest builder supports query params
Issue: SPR-16280
2017-12-19 15:38:12 -05:00
Rossen Stoyanchev 6df1a7874a MockHttpServletResponse uses correct language header
Issue: SPR-16311
2017-12-19 13:56:16 -05:00
Juergen Hoeller 3a51b5a9d2 Upgrade to Hibernate Validator 6.0.6 2017-12-15 15:58:12 +01:00
Juergen Hoeller f2e8171bfb Latest dependency updates (RxJava 2.1.7, TestNG 6.13.1, Selenium HtmlUnit Driver 2.28.2) 2017-11-28 12:10:26 +01:00
Juergen Hoeller a8323f6a27 Latest dependency updates (OkHttp 3.9.1, JRuby 9.1.14, Rome 1.9) 2017-11-26 16:03:48 +01:00
Juergen Hoeller 604017894e Upgrade to Tiles 3.0.8 (and Selenium HtmlUnit Driver 2.28.1) 2017-11-21 17:56:42 +01:00
sdeleuze 9f1d8517ba Polish Kotlin source code style 2017-11-21 15:59:23 +01:00
Juergen Hoeller 14a7da8183 Upgrade to Hibernate Validator 6.0.5 2017-11-19 21:16:10 +01:00
Juergen Hoeller 7697b398d5 Polishing 2017-11-14 17:11:16 +01:00
Juergen Hoeller 3e5209bea5 Test dependency updates (Mockito 2.12, HtmlUnit 2.28, Selenium 3.7.1, XMLUnit 2.5.1) 2017-11-13 21:51:23 +01:00
Rossen Stoyanchev 87375fe6f8 ServerHttpRequest exposes SSL certificates
Issue: SPR-15964
2017-11-10 16:43:12 -05: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
Rossen Stoyanchev 263da1535b WebTestClient can be configured with connector
Issue: SPR-16168
2017-11-07 13:01:12 -05:00
Rossen Stoyanchev 14f02d7192 Update reference with examples of multipart requests
Issue: SPR-16118
2017-11-06 16:33:58 -05:00
Juergen Hoeller 4ec60f08ad PrintingResultHandler defensively accesses session.getAttributeNames()
Issue: SPR-16164
2017-11-06 21:19:44 +01:00
Juergen Hoeller e5c1deea63 Polishing 2017-11-05 16:23:30 +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
Sebastien Deleuze b9a0e6bbf2 Update documentation about WebTestClient Kotlin issue
Issue: SPR-16057
2017-10-27 13:52:51 +02: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
Juergen Hoeller 9bab7a2708 Upgrade to Java Activation Framework 1.2 for test runtime
Includes upgrade to Hibernate Validator 6.0.4 (where applicable)

Issue: SPR-16115
2017-10-25 19:18:10 +02:00
Juergen Hoeller f31069ac05 Upgrade to Selenium 3.6 and XMLUnit 2.5 2017-10-23 17:13:55 +02:00
Juergen Hoeller e17ad551f3 Latest dependency updates (RxJava 1.3.3, Hibernate ORM 5.2.12, Hibernate Validator 5.4.2 & 6.0.3) 2017-10-20 16:16:06 +02: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
Rossen Stoyanchev 94c4a7f941 Shortcut factory method in MockServerWebExchange
MockServerWebExchange now has a second factory method that accepts a
MockServerHttpRequest.BaseBuilder.

Issue: SPR-16079
2017-10-17 12:23:12 -04:00
Arjen Poutsma 24ca8ccf5a WebTestClient.mutate() should not impact future .mutate() invocations
Issue: SPR-16059
2017-10-13 16:54:30 +02:00
Sam Brannen ef0e4dc56a Delete unused import 2017-10-12 17:31:10 +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
Rossen Stoyanchev decb6329db DefaultWebTestClient internal refactoring
Use the ClientResponse methods bodyToMono and bodyToFlux rather than
passing in a BodyExtractor so that WebTestclient now also benefits from
the recently improved handling of Void.class.
2017-10-04 15:05:25 -04:00
Juergen Hoeller 3eebdb389b Upgrade to JUnit 5.0.1 and Tomcat 8.5.23 2017-10-03 20:20:35 +02:00
Rossen Stoyanchev 48c41049b1 Correct package for MockServerWebExchange
Discovered late, but not too late. MockServerWebExchange is now in the
proper package matching to the location of ServerWebExchange.
2017-09-29 17:03:23 -04:00
Rossen Stoyanchev 223e27d53d Package private request and response implementations
Concrete server and client, reactive request and response
implementations should not have to be accessed outside their package.
They could be seen as private to their HttpHandler adapters and
ClientHttpConnector's respectively.

The one exception, WebSocket upgrades in spring-webflux, is an internal
framework use case, accommodated via downcast + accessors in the
abstract base classes.
2017-09-29 13:04:03 -04:00
Brian Clozel 126ac849e5 Fix behavior of ClientResponse#bodyTo** with Void
Prior to this commit, asking for a `Void` type using any of the
`ClientResponse#bodyTo*` methods would immediately return an empty
`Publisher` without consuming the response body.

Not doing so can lead to HTTP connection pool inconsistencies and/or
memory leaks, since:

* a connection that still has a response body being written to it cannot
be properly recycled in the connection pool
* incoming `DataBuffer` might not be released

This commit detects when `Void` types are asked as body types and in
those cases does the following:

1. Subscribe to the response body `Publisher` to allow the connection to
be returned to the connection pool
2. `cancel()` the body `Publisher` if the response body is not empty; in
that case, we choose to close the connection vs. consume the whole
response body

Those changes imply that `ClientHttpResponse` and other related
contracts don't need a `close()` method anymore.

Issue: SPR-16018
2017-09-28 00:58:38 +02:00
Rossen Stoyanchev 6ee1af27c6 WebFlux supports HTTP HEAD
Issue: SPR-15994
2017-09-27 15:25:29 -04:00
Sam Brannen 2b91d668df Polish Javadoc for @DisabledIf 2017-09-27 16:25:30 +02:00
Juergen Hoeller efce7902c4 Polishing 2017-09-27 01:34:11 +02:00
Sam Brannen 96bbd18e98 Delete unused import 2017-09-26 16:19:49 +02:00
Arjen Poutsma 1a3cc3df94 Moved fromServerRequest to ServerRequest itself
This commit moves WebFluxUriComponentsBuilder.fromServerRequest to the
ServerRequest interface itself.

Consequently, the WebFluxUriComponentsBuilder is removes itself, as it
contained no other methods.

Issue: SPR-15953
2017-09-25 11:29:07 +02:00
Sebastien Deleuze 0d8031d9b4 Remove remaining Kotlin compilation warning 2017-09-24 23:11:36 +02:00
Juergen Hoeller e2882fe1db Build against EE 8 API level wherever possible
Upgrade to JAXB 2.3, JAX-WS 2.3, Annotations 1.3.1, Interceptor 1.2.1.
Also includes Log4J 2.9.1 and Asciidoctor 1.5.6.
2017-09-24 17:18:21 +02:00
Juergen Hoeller 9190b76ab9 Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
Rossen Stoyanchev d742fc198a Add consumeWith to FluxExchangeResult
Issue: SPR-15959
2017-09-22 21:04:02 -04:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02: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
Arjen Poutsma 2fb3eeba6f Introduce ServerRequest.methodName()
This commit introduces a methodName() method to the ServerRequest,
returning the String name of the method. This method is useful for
non-standard HTTP methods.
2017-09-15 14:14:39 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

1) It adds a new Spring @NonNull annotation which allows to apply
@NonNullApi semantic on a specific element, like @Nullable does.
Combined with @Nullable, it allows partial null-safety support when
package granularity is too broad.

2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order
to be used on generic type arguments (SPR-15942).

3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore
since it is not supported yet (applicability for such use case is
controversial and need to be discussed).

4) @NonNullApi does not apply to ElementType.FIELD anymore since in a
lot of use cases (private, protected) it is not part for the public API
+ its usage should remain opt-in. A dedicated @NonNullFields annotation
has been added in order to set fields default to non-nullable.

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Juergen Hoeller 69af698ceb Latest dependency updates (EclipseLink 2.7 final, Hibernate ORM 5.2.11, Selenium 3.5.3) 2017-09-14 15:16:53 +02:00
Juergen Hoeller fd0132c7e6 Polishing 2017-09-08 16:56:22 +02:00
Sam Brannen 8acb8aef1f Exclude commons-logging from spring-test dependencies
Prior to this commit, various dependencies in the spring-test module
pulled in commons-logging as a transitive dependency. Consequently,
the presence of commons-logging in the generated Eclipse classpath
overrode the intended use of the spring-jcl module causing JUL to be
used instead of log4j for tests executed within Eclipse, thereby
ignoring the configuration in src/test/resources/log4j2-test.xml.

This commit addresses this issue by excluding commons-logging in
spring-test.gradle for all Selenium dependencies.

Issue: SPR-15930
2017-09-07 12:16:53 +02:00
Sam Brannen dcdb0b416f Rename SPRING_CLASS_RULE fields to springClassRule 2017-09-06 17:38:22 +02:00
Brian Clozel 16f3f8d28f Add close() method on HTTP client response
Before this commit, there was no way to signal the HTTP client that we
were done consuming the response. Without that, the underlying client
library cannot know when it is safe to release the associated resources
(e.g. the HTTP connection).

This commit adds new `close()` methods on both `ClientHttpResponse`
and `ClientResponse`. This methods is non-blocking and its behavior
depends on the library, its configuration, HTTP version, etc.

At the `WebClient` level, `close()` is called automatically if we
consume the response body through the `ResponseSpec` or the
`ClientResponse` itself.

Note that it is *required* to call `close()` manually otherwise; not
doing so might create resource leaks or connection issues.

Issue: SPR-15920
2017-09-06 17:29:18 +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
Juergen Hoeller b122bc6dcc Upgrade to Hibernate Validator 6.0.2
Includes latest dependency updates (Netty 4.1.15, Undertow 1.4.19)

Issue: SPR-15808
2017-08-29 15:04:17 +02:00
Sam Brannen d20b3cf86d Upgrade to TestNG 6.12 2017-08-24 15:27:46 +01:00
Sam Brannen 9da3927235 Polishing 2017-08-22 22:23:44 +01:00
Brian Clozel 397fd24849 Revert "Leverage Kotlin plugin dependency management"
This reverts commit 3e2f6c848a.
2017-08-22 21:29:39 +02:00
Sebastien Deleuze 3e2f6c848a Leverage Kotlin plugin dependency management 2017-08-22 17:35:57 +02:00
Brian Clozel cc3d7d2d48 Apply dependency management to selected modules
This commit applies the Dependency Management Plugin to modules that
require it; right now Spring Framework is importing BOMs for Netty and
Reactor dependencies only.

Instead of applying those BOMs to all modules, they're applied only
where they're needed.

Issue: SPR-15885
2017-08-21 14:42:03 +02:00
Brian Clozel 2eeb428e95 Move modules to independent build files
The main `build.gradle` file contains now only the common build
infrastructure; all module-specific build configurations have
been moved to their own build file.

Issue: SPR-15885
2017-08-21 14:41:55 +02: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
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +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
Rossen Stoyanchev ea2864c73e Polish 2017-08-15 15:08:23 +02:00
Drummond Dawson 809189be1a URI variables with MockRestRequestMatchers requestToUriTemplate
Issue: SPR-15819
2017-08-15 14:55:56 +02:00
Sam Brannen c4f7ff04dc Polish JavaDoc for the SpringExtension 2017-08-03 23:26:38 +03:00
Sam Brannen da8d50f91f Revise SpringExtension based on recent changes in JUnit Jupiter
This commit revises the implementation of the SpringExtension to use
the getRequired*() methods in the ExtensionContext which are now built
into JUnit Jupiter thanks to inspiration from the initial "convenience"
methods implemented here.
2017-08-03 23:19:57 +03:00
Rossen Stoyanchev 6855a85c41 Move RequestPath to parent server package 2017-07-28 12:26:34 +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
Arjen Poutsma eb435f5947 Add ParameterizedTypeReference method variants to ServerRequest/ServerResponse
This commit changes adds overloaded `ParameterizedTypeReference `
variants to body-related methods in `ServerRequest` and
`ServerResponse`.
It also adds a single PTR variant to ClientRequest, which was missing
before.

Issue: SPR-15817
2017-07-27 13:38:35 +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
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Sebastien Deleuze ff85726fa9 Fix warnings in Kotlin tests 2017-07-19 08:12:48 +02:00
Rossen Stoyanchev f5c54f90b3 Add shortcut to mutate + apply to WebTestClient
Issue: SPR-15770
2017-07-14 16:24:15 +02:00
Juergen Hoeller 50493a0f5f Missing abstract declaration on ReflectionTestUtils
Issue: SPR-15757
2017-07-13 13:19:52 +02:00
Arjen Poutsma e11bb17aa6 Change ServerRequest.attribute(String) to return Object
This commit changes `ServerRequest.attribute(String)`` to return
`Optional<Object>` instead of `Optional<T>`, where `T` was infered
from a type parameter.
2017-07-11 15:41:33 +02:00
Rossen Stoyanchev 1d5bd8ef35 Polish 2017-07-11 12:01:44 +02:00
Rossen Stoyanchev eb84547894 Fix MockMvc + HttpPutFormContentFilter issue
Issue: SPR-15753
2017-07-11 11:43:48 +02:00
Rossen Stoyanchev 9f7d57f933 Encapsulate choice of URI encoding within RequestPath
Currently the URI path is always treated as UTF-8 so we can eliminate
the encoding parameter from RequestPath#parse.
2017-07-11 06:05:36 +02:00
Juergen Hoeller dd43b6aabe ReflectionTestUtils does not require spring-aop on the classpath
Issue: SPR-15757
2017-07-10 20:43:34 +02:00
Rossen Stoyanchev 7d747f9645 Deprecate AsyncRestTemplate methods in MockRestServiceServer 2017-07-07 19:20:36 +02:00
Juergen Hoeller 00f4c36d7a Nullability fine-tuning (RequestContext, LocaleResolver)
Includes page-level JSTL time zone support for JSP tags.

Issue: SPR-15720
Issue: SPR-15746
2017-07-07 18:46:19 +02:00
Sam Brannen 4a3ca17d3f Fix imports 2017-07-07 17:23:43 +02:00
Arjen Poutsma 5f2d2b21d9 Avoid required uri when using WebTestClient w/ base url
This commit makes the `uri` step of the WebTestClient optional, so that
users who have specified a base URL during WebClient config do not need
to provide an empty one (i.e. `url("")`).

Issue: SPR-15695
2017-07-07 17:07:15 +02:00
Sam Brannen 1c07369406 Verify interoperability w/ JUnit Jupiter's @ParameterizedTest in TCF
This commit introduces integration tests which verify that the
SpringExtension can be used in conjunction with JUnit Jupiter's
@ParameterizedTest support.
2017-07-07 16:52:37 +02:00
Sam Brannen 2b03507894 Polishing wording regarding JUnit Platform and JUnit Jupiter 2017-07-07 16:52:37 +02:00
Sam Brannen ad5f85f8d3 Clean up deprecation warnings in spring-test 2017-07-07 15:41:02 +02:00
Rossen Stoyanchev aad4916cac WiretapConnector removes exchanges
Issue: SPR-15744
2017-07-06 23:01:01 +02:00