Commit Graph

1607 Commits

Author SHA1 Message Date
Juergen Hoeller 9e55422334 Polishing 2018-02-25 15:38:32 +01: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
igor-suhorukov c782075a13 Polish: Array designators "[]" should be on the type, not the variable 2018-02-25 13:14:20 +01:00
Juergen Hoeller 3531c104b0 Prefer Collections.addAll call with array over Set.addAll(Arrays.asList) 2018-02-25 00:21:39 +01:00
Juergen Hoeller a5cbf5fe24 Consistent use of Collection.toArray with zero-sized array argument
Includes consistent use of ClassUtils.toClassArray (as non-null variant)

Issue: SPR-16523
2018-02-22 11:29:46 +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 0de36d2883 Consistent HttpMethod identity comparisons 2018-02-18 22:01:22 +01:00
Juergen Hoeller d7cab23e6d Consistent use of StringUtils.toStringArray
(cherry picked from commit 6d11b40)
2018-02-16 20:49:17 +01:00
Juergen Hoeller 8d3264f680 Prefer List.sort(Comparator) over Collections.sort(List, Comparator) 2018-02-16 10:23:18 +01:00
igor-suhorukov 2be4985b8f Polish: anonymous inner classes containing only one method should become lambdas,
use getOrDefault instead of ternary operator
2018-02-16 09:38:19 +01:00
Juergen Hoeller 3b810f3544 Consistent Class array vs vararg declarations (and related polishing) 2018-02-14 14:44:00 +01:00
igor-suhorukov 45e520ed86 Polish: remove unused private fields, remove empty operator 2018-02-13 23:00:18 +01:00
Sam Brannen c11a963b1e Remove dependency on apiguardian-api in spring-test
The apiguardian-api dependency is once again a mandatory transitive
dependency of JUnit 5 since JUnit Jupiter 5.0.3.
2018-02-13 13:04:48 +01:00
Juergen Hoeller c9aede3727 Upgrade to Tomcat 8.5.28 (and Selenium HtmlUnit Driver 2.29.2) 2018-02-13 12:44:34 +01:00
Juergen Hoeller a5a069c5b1 Upgrade to JavaMail 1.6.1 2018-02-13 00:02:43 +01:00
Juergen Hoeller 91965500cb Upgrade to TestNG 6.14.2 and Selenium 3.9.1 2018-02-10 17:48:58 +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
Juergen Hoeller 39201adca4 Consistent handling of InterruptedException
Issue: SPR-16479
2018-02-10 13:03:33 +01:00
igor-suhorukov 9a6fbf59c5 Polish: follow name convention - make immutable fields final 2018-02-10 12:09:19 +01:00
Stephane Nicoll 991eb4858e Update copyright header 2018-02-09 10:16:58 +01:00
igor-suhorukov e381514b07 Collection.isEmpty() should be used to test for emptiness
Closes gh-1670
2018-02-09 10:11:44 +01:00
Juergen Hoeller 4318710b9b Upgrade to Hibernate 5.2.13 2018-02-07 14:14:22 +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
Rossen Stoyanchev 6d909b013e Do not commit response on access to content
MockHttpServletResponse no longer calls flushBuffer on calls to
getContentAsByteArray and getContentAsString. The flushing doesn't
actually do anything useful but does commit the response leading to
unexpected side effects.

Issue: SPR-16430
2018-01-30 16:19:08 -05:00
Sam Brannen b612f53e27 Rename doesExist() to exists() for header assertions 2018-01-26 17:24:54 +01:00
Juergen Hoeller c6b0d85a7c Consistent available() support in DelegatingServletInputStream
Issue: SPR-16416
2018-01-25 19:06:20 +01:00
Ketan Padegaonkar a0c9fdba12 Fix `DelegatingServletInputStream#available`
Ensure that the method returns the correct number of bytes that can be
read without blocking

Issue: #SPR-16416
2018-01-25 18:02:59 +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 97894a1c22 Improve logging dependencies for tests 2018-01-23 10:42:41 -05:00
Juergen Hoeller 91e6274b7d Upgrade to Apache HttpClient 4.5.5 and Tomcat 8.5.27 2018-01-22 22:11:00 +01:00
Juergen Hoeller 61579ffe7b Polishing 2018-01-22 21:34:44 +01:00
Juergen Hoeller 9d0e62ef68 Javadoc format and related polishing 2018-01-22 11:43:21 +01:00
Juergen Hoeller 40127bd9ad Polishing 2018-01-19 12:30:10 +01: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
Rossen Stoyanchev 7ab4d0ca08 Polish MockRestServiceServer code 2018-01-17 13:01:40 -05:00
Juergen Hoeller 214576673a Proper NoClassDefFoundError check against BeanUtils.instantiateClass
Issue: SPR-16369
2018-01-17 18:29:05 +01:00
Sam Brannen c88f11f958 Avoid deprecation warnings on JDK 9 in spring-test 2018-01-13 16:45:04 +01:00
Juergen Hoeller a15975d94d Log non-loadable TestExecutionListener classes at debug level only
Issue: SPR-16369
2018-01-12 16:47:46 +01:00
Juergen Hoeller 8f6d3feaa0 Tests for non-required MultipartFile parameters
Issue: SPR-16329
2018-01-11 10:22:59 +01:00
Juergen Hoeller 73cad470e5 Upgrade to HtmlUnit 2.29 and Selenium 3.8.1 2018-01-08 13:41:36 +01:00
Juergen Hoeller 4a57e26d76 Polishing 2018-01-07 23:33:35 +01:00
Rossen Stoyanchev 0f1f95e090 Add hasJsonPath/doesNotHaveJsonPath assertion options
Issue: SPR-16339
2018-01-03 20:27:09 -05:00
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
Arjen Poutsma 74b4c02881 Add ClientRequest attributes
This commit introduces client-side request attributes, similar to those
found on the server-side. The attributes can be used, for instance, for
passing on request-specific information to a globally registered
ExchangeFilterFunction.

The client request builder, as well as WebClient.RequestHeadersSpec and
WebTestClient.RequestHeaderSpec, add methods for adding a single
attribute, as well as manipulating the entire attributes map.

The client request itself adds a accessor for the (immutable) attributes
map.

This commit also introduces a new variant of the basic authentication
filter in ExchangeFilterFunctions. This variant takes the username and
password from well-known attributes.

Issue: SPR-15691
2017-07-05 14:52:38 +02:00
Sam Brannen 75a71accea Upgrade to JUnit Jupiter 5.0 M5
Issue: SPR-15728
2017-07-04 22:21:13 +02:00
Arjen Poutsma f8589d9eca Return MultiValueMap from ServerRequest.queryParams instead of List
This commit changes ServerRequest.queryParams from returning a
List<String> given a String name, to returning a
MultiValueMap<String, String>, which gives more flexibility.
2017-07-03 16:23:33 +02:00
Arjen Poutsma 2ccbc55ffd Use PathContainer in web.reactive.function.server
This commit uses the newly introduced `PathContainer` and `RequestPath`
support in the functional web framework. It exposes the path container
as property in `ServerRequest`, and uses that in the path-based
`RequestPredicates`.
2017-07-03 13:36:30 +02:00
Sam Brannen f790337880 Clean up warnings in spring-test 2017-07-02 21:28:39 +02:00
Arjen Poutsma 930f0f1760 Add ServerRequest.cookies()
This commit introduces a cookies() method on ServerRequest, returning a
MultiValueMap<String, HttpCookie>.

Issue: SPR-15715
2017-06-30 16:31:37 +02:00
Juergen Hoeller cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Rossen Stoyanchev 7de6cfa1df Refactor WebSession#getAttribute options
Issue: SPR-15718
2017-06-29 15:23:36 -04:00
Rossen Stoyanchev 9253facf02 Refactor ServerWebExchange#getAttribute options
Issue: SPR-15718
2017-06-29 14:55:30 -04:00
Rossen Stoyanchev 667437e300 Polish 2017-06-27 18:48:45 -04:00
Sebastien Deleuze d728d597f2 Add missing license headers in Kotlin files 2017-06-27 14:39:26 +02:00
Rossen Stoyanchev 5b8f7f503f Deprecate adapter classes for async interceptors 2017-06-26 15:34:51 -04:00
Rossen Stoyanchev 043c0eff4f Same session after mutate for WebTestClient mock server
Issue: SPR-15674
2017-06-23 19:19:14 -04:00
Rossen Stoyanchev 12850c5fc4 Fix test failure by using the new cloneBuilder method
The cloneBuilder helps to avoid the issue in the comment of the ticket.
Rather than creating the WebClient to then obtain a fresh builder which
causes connector instantiation, we now use the cloneBuilder

Issue: SPR-15674
2017-06-23 16:22:10 -04:00
Rossen Stoyanchev 8fc3b3bc37 Add WebTestClientConfigurer
Issue: SPR-15674
2017-06-23 14:45:46 -04:00
Rossen Stoyanchev 4db0ce12e1 Add MockServerConfigurer to WebTestClient
Issue: SPR-15674
2017-06-23 10:46:59 -04:00
Rossen Stoyanchev c37c59f578 Consumer methods for WebHttpHandlerBuilder
Replace the more limited List-based methods to add filtes and exception
handlers with Consumer<List<?>> variants.
2017-06-23 07:12:10 -04:00
Sebastien Deleuze 5c1d8c7c59 Leverage ZonedDateTime in HttpHeaders
This commit introduces 2 new public methods in HttpHeaders in order
to leverage Java 8 ZonedDateTime in addition to the existing long
(with GMT time zone implied) variants:
 - ZonedDateTime getFirstZonedDateTime(String headerName)
 - void setZonedDateTime(String headerName, ZonedDateTime date)

This commit also leverages Java 8 thread-safe DateTimeFormatter for
HttpHeader implementation instead of SimpleDateFormat. As a consequence
of the usage of DateTimeFormatter.RFC_1123_DATE_TIME, HTTP date header
serialization could change slightly for single digit days from for
example "Thu, 01 Jan 1970 00:00:00 GMT" to
"Thu, 1 Jan 1970 00:00:00 GMT".

Issue: SPR-15661
2017-06-23 00:15:51 +02:00
Arjen Poutsma a95cf07317 Add WebTestClient.mutate()
This commit introduces a WebTestClient.mutate() method,
returning a WebTestClient.Builder.

Issue: SPR-15657
2017-06-20 17:11:52 +02:00
Arjen Poutsma 4a0597d612 Replace WebClient.filter with Builder.filter
This commit replaces the WebClient.filter method with
WebClient.Builder.filter. The reason for this change is that filters
added via WebClient.filter would be applied in the opposite order of
their declaration, due to the compositional nature of the method,
combined with the immutable nature of the WebClient.
WebClient.Builder.filter does keep the order of the filters, as
registered.

Furthermore, this commit introduces a WebClient.mutate() method,
returning a WebClient.Builder. This method allow to add/remove filters
and other defaults from a given WebClient.

Issue: SPR-15657

Add WebClient.Builder.addFilter

Add Consumer-based headers and cookies methods to builders.

Add WebClient.mutate
2017-06-20 14:25:52 +02:00
Juergen Hoeller efb735aa99 SimpleRequestExpectationManager properly handles sequential requests with different count
Issue: SPR-15672
2017-06-16 13:32:43 +02:00
Sebastien Deleuze 04d5a2951c Remove KClass based Kotlin extensions
Issue: SPR-15660
2017-06-13 18:43:59 +02:00
diguage 1ef5f61ab2 Refactor iterator of Map with Java8's Map.forEach
See gh-1459
2017-06-13 16:06:20 +02:00
Sebastien Deleuze e0e6736bc5 Introduce LocaleContextResolver in WebFlux
This commit introduces LocaleContextResolver interface, which is used
at ServerWebExchange level to resolve Locale, TimeZone and other i18n
related informations.

It follows Spring MVC locale resolution patterns with a few differences:
 - Only LocaleContextResolver is supported since LocaleResolver is less
   flexible
 - Support is implemented in the org.springframework.web.server.i18n
   package of spring-web module rather than in spring-webflux in order
   to be able to leverage it at ServerWebExchange level

2 implementations are provided:
 - FixedLocaleContextResolver
 - AcceptHeaderLocaleContextResolver

It can be configured with both functional or annotation-based APIs.

Issue: SPR-15036
2017-06-13 15:10:18 +02:00
Stephane Nicoll 58242f2249 Polish 2017-06-13 10:13:14 +02:00
Stephane Nicoll fc64b8040f Polish "Replace relevant code with lambda"
Closes gh-1454
2017-06-13 09:42:20 +02:00
diguage 4b1478d830 Replace relevant code with lambda
See gh-1454
2017-06-13 08:55:38 +02:00
Juergen Hoeller 47ec966757 TargetSource.getTarget() is nullable again (for compatibility with MethodInvocation.getThis)
Issue: SPR-15651
2017-06-12 22:54:18 +02:00
Juergen Hoeller 3ae84d6dd8 Consistent support for Charset/StandardCharsets in UriUtils etc
Issue: SPR-15613
2017-06-12 15:51:45 +02:00
Sebastien Deleuze 3373a3f7ef Add Kotlin extensions for WebTestClient API
Issue: SPR-15622
2017-06-12 10:42:56 +02:00
diguage c1d44d9a34 Use the diamond syntax
Closes gh-1450
2017-06-12 09:19:06 +02:00
Rossen Stoyanchev 38a12ed4ba Expose RequestPath in ServerHttpRequest
The new structured getPath() method replaces the existing
getContextPath() + getPathWithinApplication().

Issue: SPR-15648
2017-06-11 21:59:24 -04:00
Arjen Poutsma 5e954dcba0 Use ParameterizedTypeReference in public-facing WebFlux APIs
This commit changes the use of `ResolvableType` to
`ParameterizedTypeReference` in all public-facing WebFlux APIs. This
change removes the necessity for providing the parameterized type
information twice: once for creating the `ResolvableType`, and once for
specifying a `BodyExtractor`.

Issue: SPR-15636
2017-06-09 13:29:15 +02:00
Juergen Hoeller fd53d2a51a Consistent use of @Nullable in spring-test
This commit also removes nullability from two common spots: ResolvableType.getType() and TargetSource.getTarget(), both of which are never effectively null with any regular implementation. For such scenarios, a non-null empty type/target is the cleaner contract.

Issue: SPR-15540
2017-06-08 22:52:59 +02:00
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Arjen Poutsma 8504084553 Add package-info.java to mock.web.reactive.function.server 2017-06-01 12:37:42 +02:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Rossen Stoyanchev abcc4ac979 Fix composability issue in ExchangeMutatorWebFilter
This commit replaces the UnaryOperatory<ServerWebExchange> inputs with
Function<ServerWebExchange, ServerWebExchange> instead. Unfortunately
the composability methods inherited from Function don't work in terms
of generics for composing multiple UnaryOperator's.

Issue: SPR-15599
2017-05-31 09:30:04 -04:00
Rossen Stoyanchev 5dcfd84d3b MockServerHttpRequest and Response set cookie headers
Issue: SPR-15522
2017-05-30 11:00:15 -04:00
Rossen Stoyanchev 67bcef22e4 Polish MockServerHttpRequest|Response 2017-05-30 11:00:15 -04:00
Arjen Poutsma 42d1ba080d Copy MockServerRequest to spring-test
This commit copies the MockServerRequest to the spring-test module, in
the mock.web.reactive.function.server package.

Issue: SPR-15530
2017-05-29 10:16:55 +02:00
Stéphane Nicoll 7efa0db1d1 Merge pull request #1436 from wilkinsona/patch-2
Correct the javadoc for ExchangeResult.getUrl()
2017-05-27 09:01:54 +02:00
Sebastien Deleuze 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
Andy Wilkinson bc2e1b375e Correct the javadoc for ExchangeResult.getUrl() 2017-05-26 20:58:53 +01:00
Rossen Stoyanchev 0287a74d69 ExchangeResult exposes URI template used if any
Issue: SPR-15589
2017-05-25 17:07:50 -04:00
Rossen Stoyanchev fd51893a44 Refactor exchange mutator
As a follow-up to the recent commit 246e72 some slight modifications
to MockServerExchangeMutator (renamed to ExchnageMutatorWebFilter).

Aside from the name change, the main difference is that "per request"
exchange processors are now simply applied via WebTestClient#filter(..).

Issue: SPR-15570
2017-05-25 11:41:28 -04:00
Rossen Stoyanchev 346d5d2fab Refactor WebTestClient consumeWith methods
Issue: SPR-15587
2017-05-24 20:24:54 -04:00
Rossen Stoyanchev 204a9cf056 Public constant for webtestclient-request-id header
Issue: SPR-15575
2017-05-24 14:26:52 -04:00
Rossen Stoyanchev 4d4c3d5c0b Replace bindToHttpHandler with bindToWebHandler
This commit replaces the option to bind the WebTestClient to an
HttpHandler to bind to a WebHandler instead.

This allows testing below the WebFlux level such as WebFilter,
WebHandler, or WebSession scenarios, but still a level above
HttpHandler so that WebTestClient is in charge of creating the
ServerWebExchange and expose consistently the
WebTestClient#MockServerSpec setup across all "mock" server bindToXxx
options.

Issue: SPR-15570
2017-05-24 14:03:57 -04:00
Rossen Stoyanchev 246e72ff2f Refactor WebTestClient exchange mutator support
This commit factors ServerWebExchange mutator support out of
WebTestClient in favor of an independent public class called
MockServerExchangeMutator which implements WebFilter and can be
applied to the WebTestClient as any other WebFilter.

The MockServerExchangeMutator also exposes a method to apply
a client-side filter for "per request" mutators. See the Javadoc
of the MockServerExchangeMutator.

Issue: SPR-15570
2017-05-24 14:03:57 -04:00
Arjen Poutsma 630fc194f0 Add HttpRequest.getMethodValue
This commit introduces a new method in HttpRequest:
`String getMethodValue`, which returns the HTTP method as a String.
Furthermore, HttpRequest.getMethod() has been given a default
implementation using this String value in combination with
`HttpMethod.resolve`.

Issue: SPR-15545
2017-05-24 16:36:58 +02:00
Arjen Poutsma 01e3561db9 Support RouterFunction in @EnableWebFlux
This commit removes the RouterFunctions.toHandlerMapping method, in
favor of native support for RouterFunctions in @EnableWebFlux
configuration classes.

In order to accomplish this, the HandlerStrategies components has been
repurposed to only be used for the "bare-bones" HttpHandler, while the
(newly introduced) RouterFunctionMapping uses the strategies as exposed
through WebFluxConfigurationSupport.

Furthermore, this commit also introduces support for testing
RouterFunctions without resorting to an application context.

Issue: SPR-15536
2017-05-24 11:42:15 +02:00
Juergen Hoeller db69a082d9 Avoid java.util.Optional signatures for simple field access
Issue: SPR-15576
2017-05-23 22:05:15 +02:00
Rossen Stoyanchev 5ac7955de9 More qualified "request-id" header in WebTestClient
Issue: SPR-15501
2017-05-15 15:52:50 -04:00
Arjen Poutsma b649041976 Add ServerHttpResponse.addCookie method
This commit adds a `addCookie(ResponseCookie)` method to the reactive
`ServerHttpResponse` interface.

Issue: SPR-15523
2017-05-09 10:18:39 +02:00
Rossen Stoyanchev 1c4babd410 Fix minor issue in ExchangeResult 2017-05-05 16:14:03 -04:00
Juergen Hoeller 652266bcc2 Polishing 2017-05-04 22:27:36 +02:00
Rossen Stoyanchev 16901b1497 Add bindToHttpHandler to WebTestClient
Issue: SPR-15499
2017-05-02 18:13:27 -04:00
Rossen Stoyanchev 4db1eb1e4e Polish 2017-05-02 17:59:22 -04:00
Rossen Stoyanchev 1292bb20f9 WebTestClient supports customer argument resolvers
Issue: SPR-15495
2017-04-28 15:04:43 -04:00
Sebastien Deleuze 8e272bc5b0 Expose ServerCodecConfigurer as a bean
With this commit, ServerCodecConfigurer is now exposed as a bean in
order to be provided to DefaultServerWebExchange via
WebHttpHandlerBuilder and HttpWebHandlerAdapter. This allows
DefaultServerWebExchange to get configured codecs for reading form or
multipart requests.

Issue: SPR-14546
2017-04-28 16:42:23 +02:00
Juergen Hoeller 04f0f137e6 Aligned exception message for httpOnly
Issue: SPR-15488
2017-04-27 21:32:11 +02:00
nyo e80de55929 Added httpOnly cookie ResultMatcher 2017-04-27 14:22:00 +02:00
Juergen Hoeller 0479dc96c4 Correct attributeHasNoErrors message in ModelResultMatchers
Includes consistent name quoting and use of Java 8 lambdas.

Issue: SPR-15487
2017-04-26 21:32:50 +02:00
Sam Brannen 4b1e3df283 Clean up warnings in spring-test 2017-04-26 19:15:51 +02:00
Rossen Stoyanchev 191bbc20dc StandaloneMockMvcBuilder allows custom HandlerMapping
Issue: SPR-15472
2017-04-25 17:23:20 -04:00
Rossen Stoyanchev 6e71828a35 Add space before cookie attributes
According to RFC-6265 that there should be a space between the ; and
the attribute name, i.e. the header should be something like
name=value; Domain=localhost; HttpOnly rather than
name=value;Domain=localhost;HttpOnly

Issue: SPR-15225
2017-04-25 16:07:25 -04:00
Sebastien Deleuze 20718e682e Polishing 2017-04-25 12:16:11 +02:00
Arjen Poutsma b9dbac7b2c Rename ServerResponse.BodyBuilder.body to syncBody
This commit renames the `body(Object)` on ServerResponse to
`syncBody(Object)`. The reason for this is that the original method
name clashed with the `body(Publisher)` method in the Kotlin extension.

The new name nicely reflects the synchronous nature of the method,
 making it less appealing than the `Publisher`-based `body` method.

Issue: SPR-15467
2017-04-25 11:33:47 +02:00
Rossen Stoyanchev 7df3d68b2a Replace WebMvcConfigurerAdapter with default methods
Issue: SPR-15465
2017-04-20 16:14:13 -04:00
Brian Clozel 88f8df4dce Update Mono.then(Supplier) deprecated calls
Reactor Core has now deprecated the `Mono.then(Supplier)`.
This is now replaced with `Mono.then(Mono.defer(Supplier))`.
2017-04-18 21:11:19 +02:00
Rossen Stoyanchev 3efb76c852 Jackson encoder skips String.class
Jackson2Encoder explicitly disables String from the supported types
consistent with the same change on the decoder side:

0662dbf044

Issue: SPR-15443
2017-04-14 17:21:26 -04:00
Rossen Stoyanchev 7ea2caa82c JSON content and JsonPath support for WebTestClient
Issue: SPR-15420
2017-04-14 16:39:30 -04:00
Rossen Stoyanchev 1e8c7e55de WebTestClient assert response body with Consumer<B>
Issue: SPR-15421
2017-04-14 16:39:30 -04:00
Rossen Stoyanchev 0e84f246cb Refactor WebTestClient response body expectations
Reduce the number of required steps and re-introduce generics support
for simple Class<T> cases.
2017-04-14 16:39:30 -04:00
Sam Brannen 95e78b16f7 Clean up warnings in spring-test 2017-04-11 17:53:44 +02:00
Rossen Stoyanchev e33f603f68 Revert (recently added) cookie set header flags
Issue: SPR-15225
2017-04-11 07:19:07 -04:00
Rossen Stoyanchev 5d92a85fcb Mock Servlet request/response support Accept-Language
Issue: SPR-15209
2017-04-11 07:19:07 -04:00
Rossen Stoyanchev e5fc40a9de MockHttpSevlet[Request|Response] set cookie headers
Issue: SPR-15225
2017-04-10 17:37:11 -04:00
Rossen Stoyanchev 4da4f2be31 Async support in MockMvcClientHttpRequestFactory
Issue: SPR-15181
2017-04-10 15:28:44 -04:00
Juergen Hoeller 3037277d0e Minimize reflective interaction with annotation instances during retrieval
Issue: SPR-15387
2017-04-06 14:07:17 +02:00
Juergen Hoeller 699064870f Applicable commons-logging excludes for libraries (HtmlUnit, Castor XML, Apache HttpClient)
Includes upgrade to HtmlUnit 2.26 and Selenium 3.3.1.

Issue: SPR-14512
2017-04-06 09:52:56 +02:00
Sam Brannen 8e84fd0aed Clean up warnings in spring-test 2017-04-04 15:53:49 +02:00
Amey Jadiye 472954bbb7 Polish javadoc
Closes gh-1370
2017-04-02 08:06:57 +02:00
Sam Brannen ce21fa4152 Upgrade to JUnit 5.0 M4
Issue: SPR-15361
2017-04-01 22:55:24 +02:00
Sebastien Deleuze 9f321e8d56 Suppress warnings in tests 2017-03-30 14:28:10 +02:00
Arjen Poutsma 118f33aeda Request body improvements in WebClient, WebTestClient
This commit makes changes to WebClient and WebTestClient in oder to
limit setting the body according to HTTP method and also to facilitate
providing the request body as Object.

Specifically, this commit:

 - Moves methods that operate on the request body to a RequestBodySpec
 in both WebClient and WebTestClient, and rename them to `body`.
 These methods now just *set* the body, without performing
 an exchange (which now requires an explicit exchange call).
 - Parameterizes UriSpec in both WebClient and WebTestClient, so that
 it returns either a RequestHeadersSpec or a RequestBodySpec.

Issue: SPR-15394
2017-03-29 12:22:15 -04:00
Arjen Poutsma 81430caa43 Deprecated AsyncRestTemplate and related types
This commit deprecates `AsyncRestTemplate` and related types
(`AsyncClientHttpRequestFactory` etc.) in favor of the Spring 5.0
`WebClient`.

Issue: SPR-15294
2017-03-29 15:54:06 +02:00
Sam Brannen b053311306 Clean up warnings in spring-test 2017-03-28 20:06:42 +02:00
Sam Brannen 0f0aa46e49 Delete unnecessary PropertySourcesPlaceholderConfigurer beans
Issue: SPR-14140
2017-03-28 20:02:27 +02:00
Connor Lin c8fd4cb584 Remove a redundant word
Closes gh-1361
2017-03-27 10:06:42 +02:00
Rossen Stoyanchev 5414cd0cf8 Collape ServerHttpMessage[Reader|Writer]
This commit folds ServerHttpMessage[Reader|Writer] into its parent
HttpMessage[Reader|Writer] with the server methods pre-implemented
by default to be simple pass-through delegates.
2017-03-24 17:48:40 -04:00
Rossen Stoyanchev 4a7218f54f Introduce ServerCodecConfigurer
Issue: SPR-15247
2017-03-24 17:47:44 -04:00
Juergen Hoeller 15bff8f911 HeaderValueHolder.toString() exposes underlying list of header values
Issue: SPR-15375
2017-03-24 11:07:01 +01:00
Arjen Poutsma e2aa880301 Return null from MockServletContext.getMimeType for unknown type
ServletContext.getMimeType() returns `null` for unknown mime types; not
`application/octet-stream`.

Issue: SPR-14908
2017-03-23 12:45:48 +01:00
Arjen Poutsma fd1db57e05 Change MediaTypeFactory to return Optional
This commit changes the `MediaTypeFactory` to return
`Optional<MediaType>` (instead of a plain `MediaType`) for the
`getMediaType` methods.

Issue: SPR-14908
2017-03-23 10:14:43 +01:00
Juergen Hoeller e892e02f41 Polishing 2017-03-21 17:44:47 +01:00
Rossen Stoyanchev 5345bd4a85 Fix failing tests 2017-03-21 11:37:42 -04:00
Arjen Poutsma d414718467 Update MockServletContext to MediaTypeFactory
This commit changes the `MockServletContext.getMimeType` method to use
`MediaTypeFactory` instead of JAF. It also adds a `addMimeType(String,
MediaType)` method to customize the mime types returned from said
method.

Issue: SPR-14908
2017-03-21 09:39:22 -04:00
Rossen Stoyanchev 1329ccf1bc Update tests to new mime types
This commit updates the test code base to conform to changes in media
types returned by the MediaTypeFactory.

Issue: SPR-14908
2017-03-21 09:39:16 -04:00
Sam Brannen 7c84266259 Remove trailing whitespace in spring-test 2017-03-20 20:09:22 +01:00
Rossen Stoyanchev 54192cf513 WebTestClient (server-less) setup accepts WebFilter's
Issue: SPR-15349
2017-03-16 15:38:49 -04:00
Rossen Stoyanchev 41c413a748 Add MockServerWebExchange and toExchange shortcuts
Issue: SPR-15350
2017-03-16 11:55:09 -04:00
Rossen Stoyanchev 8be0b9ce90 Fix issue in WebTestClient support for exchange mutators
ExchangeMutatorWebFilter now supports multiple mutator registrations
for the same request header id by creating a single composed function.

Issue: SPR-15250
2017-03-15 18:26:54 -04:00
Juergen Hoeller e4741b8e42 SpringExtension.getApplicationContext declared as public
Issue: SPR-15340
2017-03-14 15:18:44 +01:00
Juergen Hoeller e999da0eb0 Upgrade to TestNG 6.11 (and Netty 4.1.9) 2017-03-14 14:38:41 +01:00
Sam Brannen dda8beeb78 Clean up warnings in spring-test 2017-03-13 17:37:41 +01:00
Rossen Stoyanchev f84580c32d Per-request exchange mutating for WebTestClient
Issue: SPR-15250
2017-03-10 17:24:27 -05:00
Rossen Stoyanchev f36e3d4a0d Support for mutating ServerWebExchange in WebTestClient
This commit adds a common base class for server-less setup with the
option to configure a transformation function on the
ServerWebExchange for every request.

The transformation is applied through a WebFilter. As a result the
RouterFunction setup is now invoked behind a DispatcherHandler with
a HandlerMapping + HandlerAdapter.

Issue: SPR-15250
2017-03-10 17:04:11 -05:00
Brian Clozel b799013567 Update to Reactor Aluminium SNAPSHOT
Currently the BOM versions are:

* reactor-core 3.0.6.BUILD-SNAPSHOT
* reactor-netty 0.6.2.BUILD-SNAPSHOT

This commit fixes as well a few deprecations in reactor-core.
2017-03-10 15:20:40 +01:00
Rossen Stoyanchev 813d3efe61 ExchangeResult refactoring in WebTestClient
The WebTestClient API no longer provides access to a base
ExchangeResult without a decoded response body.

Instead the response has to be decoded first and tests can then
access the EntityExchangeResult and FluxExchangeResult sub-types.
2017-03-09 17:40:56 -05:00
Juergen Hoeller 9aaed2bcef Polishing 2017-03-07 11:02:26 +01:00
Juergen Hoeller eeb01db888 Support for new ServletContext methods in Servlet 4.0 b03
Issue: SPR-12674
2017-03-06 21:42:41 +01:00
Juergen Hoeller e61e8d5062 Upgrade to HtmlUnit 2.25 and Jackson 2.9 PR1
Includes Log4J 2.8.1 and Selenium 3.2 as well.

Issue: SPR-15319
2017-03-06 17:54:28 +01:00
Rossen Stoyanchev ccb2c6530e Support for @ControllerAdvice in WebFlux
Issue: SPR-15132
2017-03-02 03:30:34 -05:00
Rossen Stoyanchev aecdf738d3 Print session attributes in PrintingResultHandler
Issue: SPR-15189
2017-02-23 16:39:21 -05:00
Rossen Stoyanchev 24dbfc8ace Fix wrong access modifier in MockMvc standalone setup
Issue: SPR-15248
2017-02-23 16:10:47 -05:00
Arjen Poutsma 8450c69497 Add ListBodySpec.size implementation
Added implementation for WebTestClient.ListBodySpec.size().
2017-02-21 11:25:49 +01:00
Rossen Stoyanchev 262e5f783d Polish 2017-02-20 21:59:47 -05:00
Rossen Stoyanchev 2515134f8e Fix direction of arrows in request/response output 2017-02-20 18:38:15 -05:00
Rossen Stoyanchev e6401b29e6 Access to request and response byte[] in WebTestClient
The WiretapConnector now decorated the ClientHttpRequest & Response
in order to intercept and save the actual content written and read.

The saved content is now incorporated in the diagnostic output but may
be used for other purposes as well (e.g. REST Docs).

Diagnostic information about an exchange has also been refactored
similar to command line output from curl.
2017-02-20 18:29:30 -05:00
Rossen Stoyanchev d59dc970a0 Expose response cookies from ExchangeResult 2017-02-20 18:29:30 -05:00
Arjen Poutsma 63f261155a Fixed build by suppressing unchecked warnings 2017-02-20 09:22:59 +01:00
Rossen Stoyanchev 24358200c3 Assertion errors with request and response details
Issue: SPR-15249
2017-02-19 21:14:48 -05:00
Rossen Stoyanchev d1a64e1122 Refactor ExchangeResult
Clearly separate how the result of an exchange is represented before
the response body has been read (e.g. assertions on status and headers
only) vs later after the body is extracted to a representation
(assertions on the extracted body) or is decoded to Flux<T> (e.g. for
use with a StepVerifier).
2017-02-19 21:14:48 -05:00
Rossen Stoyanchev 20be40bf64 WebTestClient polish and minor refactoring 2017-02-19 21:14:48 -05:00
Rossen Stoyanchev 9829a62044 Refactor WebTestClient assertions take 3
WebTestClient now defines all the steps from setup to performing
an exchange and applying expectations.

The order of expectations now ensures the response status and headers
are verified first since that's available before the body is consumed
and also because it determines how the body is to be decoded, i.e.
error vs success scenarios.

There is now a built-in option for verifying the response as a Map
along with Map-specific assertions.

There are similar options for verifying the response as a List as well
as whether to "collect" the list or "take" the first N elements from
the response stream.
2017-02-17 23:10:34 -05:00
Rossen Stoyanchev 285ba7d391 Update WebTestClient builder 2017-02-15 20:10:47 -05:00
Rossen Stoyanchev 51f2042e97 Refactor WebTestClient assertions
Rather than returning ExchangeActions that contains ExchangeInfo and
applies a chain of assertions, the exchange operation in WebTestClient
now has an extra step to decode the response.

The outcome of that is ExchangeResult<T>, parameterized with the
decoded body type, and containing the request and response details,
also providing access to built-inassertions via an assertThat()
instance method.

This approach lends itself better to decoding and asserting response
body types with generecis. It is also more friendly to using any
assertion library such as AssertJ since you get the result first
and then deal with assertions.
2017-02-15 18:11:51 -05:00
Juergen Hoeller 599c1ba73e Polishing 2017-02-15 18:05:38 +01:00
Jan-Espen Oversand 5158207fe0 Passing the uri as a string to the MockMvc request builder will cause an encoded uri to become double encoded. 2017-02-14 09:37:49 +01:00
Rossen Stoyanchev 130598ffb2 Updates to ExchangeActions
Add assertEntity(Foo.class).map() -> Map<String, Foo>

Add assertBody().map() -> Map<String, String>

Rename andAssert(Consumer<?>) to "consume" in assertion classes

Remove andAssert + andDo from top-level ExchangeActions
2017-02-13 22:03:04 -05:00
Phillip Webb 656e7f801e Remove XmlExpectationsHelper hard XML Unit requirement
Update XmlExpectationsHelper to use an inner class for XML Unit calls
so that the XML Unit dependency remains optional.

Issue: SPR-15156
2017-02-13 16:17:21 -08:00
Brian Clozel 28e77fa68a Assert XML without considering order in XmlExpectationsHelper
This commit changes the `assertXmlEqual` implementation to compare
expected and actual XML documents without considering the order of XML
nodes.

Issue: SPR-15156
2017-02-13 21:07:35 +01:00
Rossen Stoyanchev 896e4db411 ExchangeActions update
Put assertBodyXyz options behind a common assertBody() entry point
currently including "isEmpty" and "asMap" but in the future others
related to JSON content or XPath for example.

Now that ExchangeActions provides method to access the ExchangeInfo
it has been removed from constructors of assertion classes that
already have ExchangeActions.
2017-02-13 09:29:17 -05:00
Juergen Hoeller 199aa776c9 Support for Servlet 4.0 (PushBuilder argument, MockServletContext)
Issue: SPR-12674
2017-02-13 15:06:59 +01:00
Arjen Poutsma 45770d73ed Remove parameterisation from ClientRequest
This commit removes the parameterisation from ClientRequest, similarly
to ServerResponse. Dropping the parameterisation facilitates a
ClientRequest.from method that also copies the body of the target
request.

SPR-15234 Work in Progress
2017-02-13 13:54:23 +01:00
Rossen Stoyanchev d513fe87f2 Refactor ExchangeActions 2017-02-11 16:25:22 -05:00
Rossen Stoyanchev 92f09c650f Unit test for reactive test support 2017-02-11 16:25:15 -05:00
Rossen Stoyanchev 4b4201efa1 WebFlux test support for server endpoints
Issue: SPR-14590
2017-02-10 17:53:12 -05:00
Juergen Hoeller ed85337901 MockHttpServletRequest exposes "HTTP/1.1" as default protocol
Issue: SPR-15232
2017-02-10 10:47:36 +01:00
Stephane Nicoll 75b18d7b7b Update copyright header 2017-02-09 16:05:57 +01:00
Masayasu Yamamoto 6aa300d733 Fix Javadoc in ContentResultMatchers
Closes gh-1322
2017-02-09 16:04:46 +01:00
Rossen Stoyanchev f2967467e0 Improve writing in mock reactive request and response
Before this change the write Publisher was saved and Mono.empty()
returned from the write metohd which did not properly implement
the write contract since no writing ("consuming") was done.

This can be a problem in some cases. For example the request may appear
to succeed even if the publisher produces an error later when
subscribed to later after request handling completes.

This commit introduces a writeHandler function in the mock request and
response. By default it "writes" by consuming the content immediately,
which allows it to return a Mono<Void> that properly reflects when
writing is done, and it also caches the data so it may be replayed
later for test assertions.

For streaming scenario a custom writeHandler may be registered which
allows the custom handling to determine how long to stream before
cancelling so request handling may complete.

Issue: SPR-14590
2017-02-07 21:57:38 -05:00
Juergen Hoeller 0da964f0a7 MockHttpServletRequest returns empty BufferedReader in case of no content
Issue: SPR-15215
2017-02-02 19:55:42 +01:00
Rossen Stoyanchev 1fb0b0b786 Expose remoteAddress from ServerHttpRequest
Issue: SPR-15200
2017-01-31 15:04:24 -05:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Sam Brannen 871f5efeaa Clean up warnings in spring-test 2017-01-26 01:27:15 +01:00
Rossen Stoyanchev eabd8a2964 Support Servlet Part in Spring MVC Test
Issue: SPR-14253
2017-01-25 17:05:30 -05:00
Rossen Stoyanchev c8f98ecd8d Add MockPart to spring-test
Issue: SPR-14252
2017-01-25 17:05:25 -05:00
Sam Brannen 3bc819799b Polishing 2017-01-25 19:40:08 +01:00
Rossen Stoyanchev f5d2b88e3f "sharedHttpSession" shortcut for MockMvc builders
Issue: SPR-13820
2017-01-25 12:33:11 -05:00
Rossen Stoyanchev 1d35c7c55a Polish MockMvc setup classes 2017-01-25 12:33:11 -05:00
Sam Brannen 4e65c10272 Fix broken test in SpringJUnit4ConcurrencyTests
Prior to this commit, SpringJUnit4ConcurrencyTests was broken due to
recent additions of test methods in SampleTests.

This commit fixes the broken test by removing hard coded constants and
replacing them with dynamic lookups for JUnit 4 @Test methods.
2017-01-25 05:56:02 +01:00
Rossen Stoyanchev bc884023e4 Add ExpectedCount#never()
Issue: SPR-15168
2017-01-20 17:12:13 -05:00
Sam Brannen bc87c27b18 Use MockitoJUnitRunner from Mockito 2's preferred location
Issue: SPR-14880
2017-01-18 06:37:44 +01:00
Rossen Stoyanchev 6e508f70d3 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:49:25 -05:00
Juergen Hoeller e88e8f1d09 MockHttpServletRequestBuilder reliably detects form body content type again
Issue: SPR-15116
2017-01-16 11:49:07 +01:00
Sam Brannen c9835f0f6c Clean up warnings spring-test 2017-01-16 03:21:43 +01:00
Vedran Pavić 83beb9d57d Set MockSessionCookieConfig#maxAge default to -1
Issue: SPR-15142
2017-01-16 03:17:54 +01:00
Rossen Stoyanchev ba3cc535f1 Refactor reactive mock request and response support
MockServerHttpRequest and MockServerHttpResponse now extend the same
abstract base classes that server-specific implementations do and
therefore approximate their behavior more closely.

As an immediate consequence MockServerHttpRequest is read-only after
it is created. Instead it now exposes static builder methods similar
to those found in RequestEntity. This enforces more strictness as well
as recycling of requests in tests and provides nicer builder methods.

To simplify tests DefaultServerWebExchange now offers a constructor
with just a request and response, and automatically creating a
DefaultWebSessionManager.

The spring-test module now also contains client-side reactive mock
request and response implementations. The mock client request extends
the same AbstractClientHttpRequest as client-specific implementations
do. There is no abstract base class for client responses.

Issue: SPR-14590
2017-01-13 15:23:06 -05:00
Juergen Hoeller 743ce2cda6 Polishing 2017-01-12 23:30:38 +01:00
Juergen Hoeller e19dff179e Polishing 2017-01-12 21:18:01 +01:00
Juergen Hoeller 02d727fd7c MockHttpServletRequestBuilder supports multiple locales
Includes revised content type handling.

Issue: SPR-15116
2017-01-12 21:17:54 +01:00
Sam Brannen e4a599f961 Ensure that JUnit Jupiter tests are executed during build
After the upgrade to JUnit Jupiter 5.0 M3, JUnit Jupiter tests in the
Spring build were no longer executed due to the introduction of a
default test class name pattern.

This commit addresses this issue by making use of the
@IncludeClassNamePatterns to specify that *TestCase test classes should
be executed within the org.springframework.test.context.junit.jupiter
package.
2017-01-07 02:24:46 +01:00
Sam Brannen 055da43e30 Clean up warnings in spring-test 2017-01-07 00:57:17 +01:00
Rossen Stoyanchev c66dd01724 Equal MockServerHttpResponse in spring-test and -web 2016-12-14 05:54:53 -05:00
Sebastien Deleuze b9892cc5d4 Add missing overrides to MockServerHttpResponse 2016-12-14 03:13:44 +01:00
Rossen Stoyanchev 128a1f8eed Polish MockRestRequestMatchers query param support
Issue: SPR-14995
2016-12-13 16:00:46 -05:00
schjan79 ba826f1026 MockRestRequestMatchers can match query params
Issue: SPR-14995
2016-12-13 16:00:46 -05:00
Drummond Dawson c9abd99f44 Add twice() to ExpectedCount as convenience method 2016-12-02 16:27:57 -05:00
Juergen Hoeller f6fc0a86b3 Polishing
(cherry picked from commit 0028b29)
2016-12-01 20:11:47 +01:00
Juergen Hoeller 7a8ec4f6eb Consistent use of "URI variables" terminology
Issue: SPR-14969
2016-12-01 12:30:10 +01:00
Rossen Stoyanchev 38b6746d3d HtmlUnitRequestBuilder detects form encoding type
Issue: SPR-14916
2016-11-28 18:07:40 -05:00
Sebastien Deleuze 0fcae5d2c5 Polishing
Issue: SPR-14952
2016-11-25 12:54:48 +01:00
Sebastien Deleuze 8d26c738a0 Polishing
This commit polishes previous one by also accepting
generic types explicitly declared with a class that
extends DataBuffer allowing to write Flux<DefaultDataBuffer>
for example.

Issue: SPR-14952
2016-11-25 10:33:13 +01:00
Daniel Fernández a98be035a3 Make the signature of RHOM#writeAndFlush() more flexible
This modifies the signature of
ReactiveHttpOutputMessage#writeAndFlush(...) in order to
be able to use Flux<Flux<DataBuffer>> objects as arguments of
this method.

Issue: SPR-14952
2016-11-25 09:59:33 +01:00
Juergen Hoeller 84d3808b3b Upgrade to Mockito 2.2
Issue: SPR-14880
2016-11-03 22:53:35 +01:00
Stephane Nicoll e3f6b61743 Polish 2016-10-29 11:15:26 +02:00
Stephane Nicoll 30291a8cd7 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 10:58:29 +02:00
Sam Brannen d59caaa2a7 Polishing 2016-10-28 16:37:33 +02:00
Sam Brannen 5c9350b8cb Support @EnabledIf & @DisabledIf w/o loading ApplicationContext
Prior to this commit, when using @EnabledIf or @DisabledIf in Spring's
JUnit Jupiter support, the test's ApplicationContext was always eagerly
loaded, even if the ApplicationContext would never be used (i.e., the
test was disabled). This behavior can lead to undesirable side effects
-- for example, attempting to load an application context that requires
services only available on the CI server when the test is not actually
running on the CI server.

This commit addresses this issue by introducing new boolean
`loadContext` flags in @EnabledIf and @DisabledIf. By default these
flags are set to false which means that the user's test application
context will not be loaded to evaluate the expression. On the contrary,
a dummy application context will be loaded instead, and expressions
will be evaluated against that dummy context. Consequently, if the user
wishes to interact with properties from the Spring Environment or with
beans from the test application context, the `loadContext` must be
explicitly set to true.

In addition, expressions which evaluate to a String must now evaluate
to exactly "true" or "false" (ignoring case and surrounding whitespace).

Issue: SPR-14649
2016-10-27 16:52:32 +02:00
Rossen Stoyanchev 0e886abf3d Sync MockServerHttpRequest in spring-test/spring-web 2016-10-21 15:17:28 -04:00
Juergen Hoeller 3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
Stephane Nicoll fc8bad36c9 Fix formatting
Closes gh-1206
2016-10-15 11:55:07 +03:00
Philippe Marschall ae5b0c6fb5 Replace J2EE with Java EE
String with version 5 the name of Java Platform, Enterprise Edition
changed from J2EE to Java EE. However a lot of the documentation still
uses the term J2EE.

This commit includes the following changes:

 * replace J2EE with Java EE where appropriate

This is not a blind search and replace. The following occurrences
remain unchanged:

 * references to old J2EE releases, most notably 1.3 and 1.4.
 * references to "Expert One-On-One J2EE Design and Development"
 * references to "Core J2EE patterns"
 * XML namespaces
 * package names

Issue: SPR-14811
See gh-1206
2016-10-15 11:49:00 +03:00
Rossen Stoyanchev 6cb7d51ee5 Polish 2016-10-14 17:16:23 -04:00
Sam Brannen a795fd4714 Add support for URI templates in redirectedUrl() & forwardedUrl()
Prior to this commit, the redirectedUrl() and forwardedUrl() methods in
MockMvcResultMatchers supported fully constructed URLs and URLs
containing Ant-style path patterns. However, URI templates were not
supported for these result matchers even though the request path can be
built using URL templates -- for example, via the get() and post()
methods in MockMvcRequestBuilders.

This commit addresses this shortcoming by allowing users to supply a
URL template instead of a fully constructed URL to redirectedUrl() and
forwardedUrl(). To populate the URL template, template variables may be
supplied to redirectedUrl() and forwardedUrl() as var-args.

Issue: SPR-14790
2016-10-13 17:02:00 +02:00
Sam Brannen 509796a4b5 Polish MockMvcResultMatchers[Tests] 2016-10-13 17:01:47 +02:00
Sam Brannen 8cf1933148 Only print request/response body if char enc is present in MVC Test
Commit e65a1a4372 introduced support in PrintingResultHandler for only
printing the request or response body in the Spring MVC Test framework
if the content type is known to be text-based (e.g., plain text, HTML,
XHTML, XML, JSON, etc.). For unknown content types the body is assumed
to be text-based and is therefore always printed. The latter behavior,
however, is undesirable since the content may in fact not be text-based.

This commit addresses this issue by making the printing of the request
or response body an opt-in feature. Specifically, if a character
encoding has been set, the request or response body will be printed by
the PrintingResultHandler. Note, however, that the character encoding
is set to ISO-8859-1 in MockHttpServletResponse by default.

In addition, MockHttpServletRequest's getContentAsString() method now
throws an IllegalStateException if the character encoding has not been
set.

Issue: SPR-14776
2016-10-13 16:55:14 +02:00
Sam Brannen e65a1a4372 Print only printable request/response body in MVC Test
Prior to this commit, PrintingResultHandler always printed the request
or response body regardless of its content type. For binary content,
however, the output was unreadable and therefore useless.

This commit addresses this issue by only printing the request or
response body if it is "printable" (i.e., if its content type is known
to be text-based such as plain text, HTML, XHTML, XML, JSON, etc.). If
the content type is unknown (e.g., unspecified for the HTTP request in
the test), it is assumed that the body is printable.

Issue: SPR-14776
2016-10-11 20:19:26 +02:00
Sam Brannen 487bc7505b Print request body in PrintingResultHandler in Spring MVC Test
Prior to this commit, the PrintingResultHandler used by the various
print() and log() methods in Spring MVC Test printed the response body
but not the request body.

Since request bodies are sometimes generated programmatically, however,
it can be beneficial to have the dynamically generated request body
logged as well.

This commit therefore prints the request body in PrintingResultHandler
by delegating to the recently introduced getContentAsString() method in
MockHttpServletRequest.

Issue: SPR-14717
2016-10-03 18:05:58 +02:00
Sam Brannen 04b8ae921e Introduce getContentAsByteArray()/getContentAsString() in MockHtttpSvltReq
In order to improve debugging and logging within test suites, this
commit introduces getContentAsByteArray() and getContentAsString()
methods in MockHttpServletRequest, analogous to the existing methods in
MockHttpServletResponse.

Issue: SPR-14717
2016-10-03 18:05:58 +02:00
Juergen Hoeller fb7ae010c8 Avoid unnecessary generics on emptyMap/Set/List 2016-09-26 18:04:49 +02:00
Sam Brannen 2f2e6dffb4 Upgrade to TestNG 6.9.12 2016-09-09 18:02:47 +02:00
Sam Brannen 2699504cb8 Introduce concurrency tests for Spring's JUnit 4 support
Whereas the existing TestContextConcurrencyTests verify support for
concurrency in the TestContextManager and TestContext, this commit
introduces SpringJUnit4ConcurrencyTests that verify support for
concurrent test execution in Spring's JUnit 4 support, namely in the
SpringRunner, SpringClassRule, and SpringMethodRule.

The tests executed by this new test class come from a hand-picked
collection of test classes within the test suite that is intended to
cover most categories of tests that are currently supported by the
TestContext Framework on JUnit 4.

Note, however, that the chosen test classes intentionally do not
include any classes that fall under the following categories.

 - tests that make use of Spring's @DirtiesContext support

 - tests that make use of JUnit 4's @FixMethodOrder support

 - tests that commit changes to the state of a shared in-memory database

Issue: SPR-5863
2016-09-05 17:26:25 +02:00
Sam Brannen e822e4cbe8 Improve exception msg for inactive test ApplicationContext
This commit improves the exception message thrown when a test's
ApplicationContext is no longer active by explaining that the cause
may be due to parallel test execution.

Issue: SPR-5863
2016-09-05 13:39:21 +02:00
Sam Brannen fbfad8695e Further improve thread safety for attributes in DefaultTestContext
Issue: SPR-5863
2016-09-05 13:34:25 +02:00
Sam Brannen a10a8e56df Support concurrent execution in TestContextManager & DefaultTestContext
Prior to this commit, executing tests concurrently in the TestContext
Framework (TCF) was unsupported and typically lead to unpredictable
results.

This commit addresses this core issue by supporting concurrent
execution in the TestContextManager and the DefaultTestContext.

Specifically, the TestContextManager now uses ThreadLocal storage for
the current TestContext, thereby ensuring that any registered
TestExecutionListeners and the TestContextManager itself operate on a
TestContext specific to the current thread.

In order to avoid repeatedly incurring the costs of the overhead of the
TCF bootstrapping process, the original TestContext built by the
TestContextBootstrapper is used as a template which is then passed to
the copy constructor of the concrete implementation of the TestContext
to create the context for the current thread. DefaultTestContext now
implements such a copy constructor, and all concrete implementations of
TestContext are encouraged to do the same.

If the TestContext built by the TestContextBootstrapper does not
provide a copy constructor, thread-safety and support for concurrency
are left completely to the implementation of the concrete TestContext.

Note, however, that this commit does not address any thread-safety or
concurrency issues in the ContextLoader SPI or its implementations.

Issue: SPR-5863
2016-09-02 20:28:02 +02:00
Sam Brannen ec7aefa858 Improve concurrency in DefaultTestContext regarding attributes
This commit inlines the basic implementation of AttributeAccessorSupport
and converts the LinkedHashMap to a ConcurrentHashMap.

In addition, attributes are now included in toString().

Issue: SPR-5863
2016-09-02 19:14:31 +02:00
Sam Brannen 5fe3bcf8f9 Polishing 2016-09-02 18:39:31 +02:00
Rossen Stoyanchev c813405ca3 Add @since tags 2016-09-02 12:19:50 -04:00
Rossen Stoyanchev a1ac51256a Add MockServerHttpRequest/Response to spring-test
Issue: SPR-14421
2016-09-02 12:15:00 -04:00
Sam Brannen 5202250179 Polish SpringClassRule and SpringMethodRule 2016-09-01 16:34:03 +02:00
Sam Brannen d9eaa5f3ac Use Map.computeIfAbsent() in SpringClassRule
Replace manual synchronization block in SpringClassRule with Java 8's
Map.computeIfAbsent().

Issue: SPR-12421
2016-09-01 13:38:42 +02:00
Sam Brannen feb02f813e Polishing 2016-08-31 20:52:39 +02:00
Sam Brannen e574820dc9 Introduce tests for @Nested tests in JUnit Jupiter
This commit introduces integration tests that verify the expected
behavior for @Nested tests in conjunction with the SpringExtension for
JUnit Jupiter, including automatic application of
TestExecutionListeners to the enclosing test instance of a @Nested
test instance.

Issue: SPR-14150
2016-08-31 20:29:08 +02:00
Sam Brannen ab7b5e5c77 Demo how to use SpringClassRule in nested test classes
Due to restrictions imposed by JUnit 4, the SpringClassRule must be
declared as a public static field, which makes it impossible to be
declared directly within a nested (i.e., inner) test class.

This commit demonstrates a work-around that makes it possible to use
the SpringClassRule and SpringMethodRule in a nested (i.e., inner) test
class when using a custom JUnit 4 runner such as the
HierarchicalContextRunner from Stefan Bechtold.

The trick is to have inner test classes extend a class that properly
declares the SpringClassRule and SpringMethodRule. The
SpringRuleConfigurer in this commit serves as an example.

Note, however, that each such nested test class must declare its own
@ContextConfiguration. Furthermore, TestExecutionListeners in the
Spring TestContext Framework are not applied to the enclosing instance
of such an inner test class, meaning that @Autowired fields in the
enclosing instance will not be injected, etc.

Issue: SPR-14150
2016-08-31 19:35:00 +02:00
Sam Brannen 634d1c03a3 Introduce @EnabledIf support for JUnit Jupiter
This commit picks up where SPR-14614 left off by introducing a new
@EnabledIf annotation to serve as a logical companion to @DisabledIf.

In addition, this commit extracts common logic from DisabledIfCondition
into a new AbstractExpressionEvaluatingCondition base class which the
new EnabledIfCondition also extends.

An @EnabledOnMac annotation is also included in the Javadoc as well as
in the test suite to demonstrate support for custom composed annotations.

Issue: SPR-14644
2016-08-31 16:11:58 +02:00
Juergen Hoeller ab9fea6b8d Polishing
(cherry picked from commit 3767092)
2016-08-31 02:08:31 +02:00
Juergen Hoeller 03609c1518 Consistent comma splitting without regex overhead
Issue: SPR-14635
2016-08-30 23:56:58 +02:00
Sam Brannen b6220cc19d Trim expressions supplied to @DisabledIf
Prior to this commit, the DisabledIfCondition did not trim whitespace
from expressions configured via @DisabledIf. Consequently, results such
as "  true  " would evaluate to "false".

This commit fixes this problem by trimming all expressions configured
via @DisabledIf.

Issue: SPR-14614
2016-08-29 15:47:38 +02:00
Sam Brannen d6d05e8ca0 Remove trailing whitespace in Java source code 2016-08-29 15:25:10 +02:00
Sam Brannen 9d21abcd37 Introduce dedicated tests for DisabledIfCondition
This commit introduces tests for DisabledIfCondition that verify actual
condition evaluation results and exception handling; whereas, the
existing tests in DisabledIfTestCase only test the "happy paths" and
standard cases.

Issue: SPR-14614
2016-08-29 15:17:59 +02:00
Sam Brannen 54d6f250e2 Disallow empty expression in @DisabledIf
This commit ensures that a user provides a non-empty expression in
declarations of @DisabledIf.

Issue: SPR-14614
2016-08-29 13:43:38 +02:00
Juergen Hoeller 728a548199 Consistent use of JDK 7 AssertionError with root cause
Issue: SPR-13188
2016-08-29 11:53:00 +02:00
Sam Brannen 19369094ac Revise @DisabledIf support for JUnit Jupiter
- Extracted stand-alone DisabledIfCondition from the SpringExtension
  so that the condition is only evaluated when necessary.

- Simplified implementation of DisabledIfCondition.

- Overhauled and extended logging in DisabledIfCondition.

- DisabledIfCondition now throws an IllegalStateException if @DisabledIf
  is not present on the test element or if the expression does not
  evaluate to a String or Boolean.

- Each generated ConditionEvaluationResult now includes the actual
  expression in the default reason.

- @DisabledIf is now auto-configured to be evaluated by the
  DisabledIfCondition since it is now meta-annotated with
  @ExtendWith(DisabledIfCondition.class)

- Overhauled documentation for @DisabledIf and provided standard
  examples as well as an @DisabledOnMac annotation to demonstrate
  support for custom composed annotations.

Issue: SPR-14614
2016-08-28 21:12:38 +02:00
Tadaya Tsuyukubo c03f6c6d85 Introduce @DisabledIf annotation for JUnit 5
This commit introduces @DisabledIf annotation that takes SpEL as a
condition.  The condition is evaluated at run time whether to disable
JUnit 5 (Jupiter) test method/class.

Issue: SPR-14614
2016-08-28 21:12:38 +02:00
Juergen Hoeller dfdfd72a3e Polishing
(cherry picked from commit 430180a)
2016-08-26 18:59:40 +02:00
Rossen Stoyanchev 7fdb892042 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
2016-08-26 10:38:03 -04:00
Sam Brannen 5998a297ce Simplify exception handling in JsonPathExpectationsHelper 2016-08-26 14:43:40 +02:00
Juergen Hoeller 14046575b0 Polishing 2016-08-26 13:27:33 +02:00
Rob Winch 966baea910 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:43:01 -05:00
Juergen Hoeller 6157fad91f PersistenceAnnotationBeanPostProcessor obtains default EntityManagerFactory via getBean(Class) algorithm
Issue: SPR-7549
2016-08-11 22:42:06 +02:00
Juergen Hoeller eeeab27f1f Polishing
(cherry picked from commit 35e247a)
2016-08-10 16:42:21 +02:00
Juergen Hoeller 59a24b406a Polishing 2016-08-10 14:20:42 +02:00
Juergen Hoeller a4b6682c3e Consistent spelling for StandaloneMockMvcBuilder's addPlaceholderValue 2016-08-10 14:18:41 +02:00
Juergen Hoeller 8acceba641 Polishing
(cherry picked from commit aade2d1)
2016-08-09 12:42:57 +02:00
Juergen Hoeller eae079ac2b Polishing 2016-08-09 10:44:10 +02:00
Juergen Hoeller 47e9360d62 MockClientHttpResponse closes body stream on close()
Issue: SPR-14563
2016-08-09 10:43:50 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Sam Brannen 2a3e62ddfc Delete unused imports in spring-test 2016-07-23 17:23:32 +02:00
Marius Grama 3635c9dbfe Update xmlunit library to version 2.1.0
xmlunit 2.1.0 is the latest release for xmlunit.
Most of the xmlunit functionality used within spring-framework
was done through the xmlunit 1.x helper class
`org.custommonkey.xmlunit.XMLAssert`.

As of xmlunit 2.0.0 most of the XML comparison methods are done
through hamcrest matchers exposed by the xmlunit-matchers
library. In some cases during the migration, the matchers
had to be customized with custom `NodeMatcher` or
`DifferenceEvaluator` instances in order to keep the assertions
correct (they were performed with xmlunit 1.x previously).

Issue: SPR-14043
2016-07-21 15:04:21 +02:00
Juergen Hoeller 99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Juergen Hoeller f0c397e4e2 Comprehensive Servlet 3.1 support in spring-web and spring-test
Issue: SPR-14467
2016-07-15 22:11:14 +02:00
Sam Brannen fd008405a1 Note in TEL: before/after test exec. callbacks don't work w/ JUnit 4 rules
Issue: SPR-4365
2016-07-14 15:46:54 +02:00
Sam Brannen 3fa88c2b56 Document suppressed exception support in TestContextManager
Issue: SPR-14459
2016-07-14 15:43:18 +02:00
Sam Brannen adfea826cc Configure JUL/log4j for JUnit 5 in spring-test
Issue: SPR-14431
2016-07-13 22:06:46 +02:00
Sam Brannen 833deadddc Ensure test fails for the correct reason
Prior to this commit, a dynamic test in
FailingBeforeAndAfterMethodsSpringExtensionTestCase was failing but for
the wrong reason. Namely, the @Configuration class was private which
resulted in an IllegalStateException being thrown, when in fact
an AssertionFailedError was expected.

This commit addresses this by introducing an explicit check for an
AssertionFailedError.

Issue: SPR-4365
2016-07-13 21:10:47 +02:00
Sam Brannen 7ec85a3c3b Support suppressed exceptions in the TestContext framework
Prior to this commit, if multiple TestExecutionListener 'after' methods
threw an exception, only the first such exception was rethrown.
Subsequent exceptions were logged, but there was no way to access or
process them other than via the log file.

This commit addresses this shortcoming by making use of the support for
suppressed exceptions introduced in Java 7. Specifically, if multiple
TestExecutionListener 'after' methods throw an exception, the first
exception will be rethrown with subsequent exceptions suppressed in the
first one.

Issue: SPR-14459
2016-07-13 20:29:01 +02:00
Sam Brannen 5f176f50d3 Polishing 2016-07-13 18:18:40 +02:00
Sam Brannen 6162e30f3c Clean up warnings in AsyncTests 2016-07-13 16:39:49 +02:00
Rossen Stoyanchev 01a63dd84d Polish AsyncTests 2016-07-12 17:49:55 -04:00
Vladimir L 7da63c57b3 tests for asynchronous processing if controller returns StreamingResponseBody 2016-07-12 17:44:10 -04:00
Sam Brannen 68b3bc0394 Use Supplier<String> support in Assert in spring-test
This commit makes use of the new Supplier<String> variants of utility
methods in org.springframework.util.Assert within the spring-test
module.

Issue: SPR-14450
2016-07-12 16:41:03 +02:00
Sam Brannen 80018c67e7 Introduce before/after test execution support in the SpringExtension
Issue: SPR-4365
2016-07-11 15:44:51 +02:00
Sam Brannen da89332840 Introduce before/after test execution support in SpringJUnit4ClassRunner
Issue: SPR-4365
2016-07-11 15:13:40 +02:00
Sam Brannen 3da5fbe995 Introduce before/after test execution support in AbstractTestNGSpringContextTests
Issue: SPR-4365
2016-07-11 15:13:40 +02:00
Sam Brannen 087efa668c Introduce before/after test execution callbacks in TestContextManager
Issue: SPR-4365
2016-07-11 15:13:40 +02:00
Sam Brannen 5302566cbb Introduce before/after test execution callbacks in TestExecutionListener
Issue: SPR-4365
2016-07-11 15:13:40 +02:00
Sam Brannen 629b95bd5c Ensure TestContextManager always tracks after-class exception
This commit fixes a minor bug introduced in 0adc4921ed.

Issue: SPR-14447
2016-07-10 16:04:00 +02:00
Sam Brannen 966d951329 Remove deprecated @TransactionConfiguration & TxCfgAttributes
Issue: SPR-14430
2016-07-08 18:16:44 +02:00
Sam Brannen 57c43f4273 Delete unused import 2016-07-08 17:40:42 +02:00
Sam Brannen d6d4251550 Utilize default methods in TestExecutionListener
Issue: SPR-14432
2016-07-08 17:38:41 +02:00
Sam Brannen a0cad5c48f Use streams and lambdas in spring-test where feasible
Issue: SPR-13188
2016-07-08 17:38:40 +02:00
Sam Brannen 8fff1c2ac0 Polishing 2016-07-08 17:18:14 +02:00
Sam Brannen 80216c243d Annotate ContextCustomizer[Factory] with @FunctionalInterface
Issue: SPR-14432
2016-07-08 17:17:25 +02:00
Sam Brannen 7e783dd91f Delete temporary MethodParameterFactory solution
SPR-14055 introduced first-class support for the Java 8 Parameter API.

This commit therefore replaces the MethodParameterFactory with use of
the new SynthesizingMethodParameter.forParameter(Parameter) factory
method.

Issue: SPR-13575
2016-07-07 13:02:49 +02:00
Sam Brannen 862fb2af5f Upgrade to JUnit 5.0.0-M1
Issue: SPR-13575
2016-07-07 12:49:46 +02:00
Juergen Hoeller da9c24c41e Polishing 2016-07-06 18:11:33 +02:00
Stephane Nicoll e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Sam Brannen 9a9551bf18 Make JUnit Jupiter support classes package private
Issue: SPR-13575
2016-07-05 17:09:18 +02:00
Sam Brannen 045c678622 Clean up warnings in spring-test 2016-07-05 17:09:18 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller b5db5d3aac Broadly remove deprecated core classes and methods
Issue: SPR-14430
2016-07-05 15:52:49 +02:00
Sam Brannen 5f53a60120 Restrict visibility of internal MethodParameterFactory
Issue: SPR-14055
2016-07-05 15:20:01 +02:00
Sam Brannen 016fa0eb39 Upgrade test to Hibernate 5.2 2016-07-05 11:05:23 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller 54004e0d78 Upgrade to JPA 2.1+ and Bean Validation 1.1+; remove native support for Hibernate 3.6 and 4.x
Issue: SPR-13481
Issue: SPR-13827
2016-07-04 23:37:23 +02:00
Juergen Hoeller 2b3445df81 Drop Portlet MVC support
This commit also removes the corresponding deprecated Servlet MVC variant and updates DispatcherServlet.properties to point to RequestMappingHandlerMapping/Adapter by default.

Issue: SPR-14129
2016-07-04 23:33:47 +02:00
Sam Brannen 873fc53a2f Introduce support for JUnit 5 in the TestContext framework
This commit introduces initial support for JUnit Jupiter (i.e., the new
programming and extension models in JUnit 5) in the Spring TestContext
Framework.

Specifically, this commit introduces the following.

- SpringExtension: an implementation of multiple extension APIs from
  JUnit Jupiter that provides full support for the existing feature set
  of the Spring TestContext Framework. This support is enabled via
  @ExtendWith(SpringExtension.class).

- @SpringJUnitConfig: a composed annotation that combines
  @ExtendWith(SpringExtension.class) from JUnit Jupiter with
  @ContextConfiguration from the Spring TestContext Framework.

- @SpringJUnitWebConfig: a composed annotation that combines
  @ExtendWith(SpringExtension.class) from JUnit Jupiter with
  @ContextConfiguration and @WebAppConfiguration from the Spring
  TestContext Framework.

Issue: SPR-13575
2016-07-04 22:40:58 +02:00
Sam Brannen 3be0ea9128 Suppress deprecation warning in spring-test 2016-07-04 15:20:52 +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
Juergen Hoeller 822e40e24f AssertionErrors.assertEquals exposes readable array representation
Issue: SPR-14281
2016-05-30 17:16:03 +02:00
Juergen Hoeller a1e9459a43 @SafeVarargs for header(String, Matcher...) method
Issue: SPR-14278
2016-05-30 15:06:55 +02:00
Sam Brannen 31a93792b2 Delete unused imports 2016-05-27 16:33:43 +02:00
Rossen Stoyanchev 4e8754ea87 Add reset() to MockRestServiceServer
Issue: SPR-14306
2016-05-26 11:44:40 -04:00
Rossen Stoyanchev f4ab6d8d52 MockRestServiceServerBuilder can be re-used
Issue: SPR-14306
2016-05-26 09:48:16 -04:00
Sam Brannen a1a87679da Support test annotations on interfaces
Prior to Java 8 it never really made much sense to author integration
tests using interfaces. Consequently, the Spring TestContext Framework
has never supported finding test-related annotations on interfaces in
its search algorithms.

However, Java 8's support for interface default methods introduces new
testing use cases for which it makes sense to declare test
configuration (e.g., @ContextConfiguration, etc.) on an interface
containing default methods instead of on an abstract base class.

This commit ensures that all non-repeatable, class-level test
annotations in the Spring TestContext Framework can now be declared on
test interfaces. The only test annotations that cannot be declared on
interfaces are therefore @Sql and @SqlGroup.

Issue: SPR-14184
2016-05-05 19:54:44 +02:00
Sam Brannen f09c7868d8 Polishing 2016-05-04 16:04:37 +02:00
Sam Brannen e26478e3de Polish Javadoc regarding @Commit support 2016-05-03 20:26:11 +02:00
Sam Brannen 0f6711fe3b Support @[Before|After]Transaction on default methods
Prior to this commit, @BeforeTransaction and @AfterTransaction could
only be declared on methods within test classes. However, JUnit 5 as
well as some existing third-party Runner implementations for JUnit 4
already support Java 8 based interface default methods in various
scenarios -- for example, @Test, @BeforeEach, etc.

This commit brings the Spring TestContext Framework up to date by
supporting the declaration of @BeforeTransaction and @AfterTransaction
on interface default methods.

Issue: SPR-14183
2016-05-03 18:57:31 +02:00
Sam Brannen 3433fe35df Fix assertion failure messages in TransactionalTestExecutionListenerTests 2016-05-03 18:57:31 +02:00
Juergen Hoeller 8ddb432694 Polishing 2016-04-27 21:35:26 +02:00
Rob Winch 9ec0873604 MockWebResponseBuilder defaults cookie domain
Previously MockWebResponseBuilder would use the cookie domain of the cookie
received from MockMvc response. This caused problems because the cookie
domain can be null, but HtmlUnit forbids a null domain.

This commit defaults the domain of the cookie to the domain of the
WebRequest.

Issues SPR-14169
2016-04-25 16:35:56 -05:00
Sam Brannen c84c1cfd1b Update Javadoc for TestContextBootstrapper
@WebAppConfiguration is no longer meta-annotated with @BootstrapWith.
2016-04-25 15:44:15 +02:00
Sam Brannen 67a9f40c95 Polish Javadoc for TestContextManager 2016-04-23 18:23:25 +02:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Sam Brannen ff38224da6 Introduce tests for @[Before|After]Transaction on default methods
This commit introduces @Ignore'd tests for future support for declaring
@BeforeTransaction and @AfterTransaction on interface default methods.

Issue: SPR-14183
2016-04-17 16:01:07 +02:00
Johnny Lim c402932ba1 Use the defined constant in MergedContextConfiguration
Closes gh-1037
2016-04-16 10:32:41 +02:00
Rob Winch 87ed8e939c HtmlUnitRequestBuilder decodes parameter names
Previously HtmlUnitRequestBuilder did not decode parameter names. This
means if a parameter like row[0] was submittted it would be encoded as
row%5B0%5D When the HttpServletRequest was created the parameter name would
not be decoded so the parameter name row[0] would not be found.

This commit ensures that HTTP parameter names are decoded.

Issue SPR-14177
2016-04-15 10:23:00 -05:00
Juergen Hoeller f1cb793ccb Rename MimeType's getCharSet() to getCharset()
Issue: SPR-14172
2016-04-14 16:38:59 +02:00
Juergen Hoeller b6f1afd471 Polishing 2016-04-11 21:20:31 +02:00
Juergen Hoeller 537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Sam Brannen 463c8f149d Add properties files directly to environment in TestPropertySourceUtils
This commit introduces a new method in TestPropertySourceUtils that
allows properties files to be added directly to the environment without
the need for a ConfigurableApplicationContext upfront; however, a
ResourceLoader is still necessary.

Issue: SPR-14131
2016-04-07 17:02:37 +02:00
Juergen Hoeller 6573e9142c Polishing 2016-04-05 12:17:21 +02:00
Juergen Hoeller d2d528dc05 Polishing 2016-04-05 09:42:41 +02:00
Sam Brannen 6c0cae87b4 Clean up warnings in spring-test 2016-04-04 21:30:01 +02:00
Sam Brannen e18d5b591a Limit size of context cache in the TestContext framework
Prior to this commit, the size of the ApplicationContext cache in the
Spring TestContext Framework could grow without bound, leading to
issues with memory and performance in large test suites.

This commit addresses this issue by introducing support for setting the
maximum cache size via a JVM system property or Spring property called
"spring.test.context.cache.maxSize". If no such property is set, a
default value of 32 will be used.

Furthermore, the DefaultContextCache has been refactored to use a
synchronized LRU cache internally instead of a ConcurrentHashMap. The
LRU cache is a simple bounded cache with a "least recently used" (LRU)
eviction policy.

Issue: SPR-8055
2016-04-04 20:56:04 +02:00
Sam Brannen 2ed3382a60 Document composed support for @Scheduled, @JmsListener, & @Sql
Issue: SPR-13973
2016-03-29 19:53:58 +02:00
Sam Brannen 26bbb6e767 Polishing 2016-03-28 16:17:47 +02:00
Juergen Hoeller 94cb7786c8 Polishing 2016-03-25 23:28:45 +01:00
Sam Brannen b0c6357540 Test @Sql as a merged composed annotation
Issue: SPR-13973
2016-03-25 20:47:16 +01:00
Phillip Webb fc839331a7 Refine TestPropertySourceUtils for direct use
Update methods in TestPropertySourceUtils to accept var-args and allow
addInlinedProperties to be called more than once.

Issue: SPR-14088
2016-03-25 11:12:27 -07:00
Sam Brannen c6f6e192c0 Support @Sql as a merged composed annotation
Issue: SPR-13973
2016-03-25 00:51:42 +01:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 9af12d290e Polishing 2016-03-23 18:39:29 +01:00
Juergen Hoeller 5025c615b1 Consistent use of AnnotatedElementUtils.findMergedAnnotation/hasAnnotation
Issue: SPR-13440
2016-03-23 18:39:20 +01:00
Sam Brannen 532ed0a4cf Clean up warnings in the spring-test module 2016-03-20 19:37:54 +01:00
Sam Brannen c5200978b0 Polishing 2016-03-18 19:44:20 +01:00
Rob Winch 411ff8450f Refine tests for SPR-14066
Explicitly define the response type as text/plain to avoid content type
confusion.

Issue SPR-14066
2016-03-18 13:24:10 -05:00
Sam Brannen 455bf45fa4 Fix test that failed due to upgrade to HtmlUnit 2.20 2016-03-18 18:43:46 +01:00
Brian Clozel 7ae44c2565 Allow skipping JSON prefix in MockMvc result matchers
JSON payloads are sometimes prepended with a static string prefix
to prevent Cross Site Scripting Inclusion attacks (XSSI).
Prior to this commit, doing so would fail the MockMvc
`JsonPathResultMatchers` since they're considering the whole response as
the JSON payload.

This commit adds a new `JsonPathResultMatchers.prefix` method that
configures the matchers to check for the presence of that string (i.e.
fail if it's not there) and only consider the rest of the response body
as the JSON payload for other assertions.

Issue: SPR-13577
2016-03-18 18:13:42 +01:00
Rossen Stoyanchev d3822c8d19 Polish 2016-03-18 12:01:09 -04:00
Rob Winch 7d96ad1f6e MockMvc HtmlUnit support shares CookieManager
Previously MockMvc builders failed to share the WebConnection used for
managing cookies in the MockMvcWebConnection. This meant that the various
CookieManagers would have different states.

This commit ensures that the WebConnection is set on the
MockMvcWebConnection.

Fixes SPR-14066
2016-03-18 12:01:09 -04:00
Sam Brannen 43661ededb Verify inlined props override files in @TestPropertySource
This commit introduces a test to demonstrate that inlined properties
override properties loaded from Properties files in
@TestPropertySource.

Issue: SPR-14068
2016-03-18 15:04:14 +01:00
Sam Brannen 7a3bc2e473 Polishing 2016-03-17 14:08:13 +01:00
Rossen Stoyanchev f5a5a81e95 Support response cookies in HtmlUnit integration
Issue: SPR-14051
2016-03-16 15:26:06 -04:00
Sam Brannen d9025ddaa7 Fully test proxy support in ReflectionTestUtils
This commit adds a test for JDK dynamic proxies and fleshes out the
test for CGLIB proxies.

Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 7beff7b40a Polishing 2016-03-16 18:34:07 +01:00
Sam Brannen b1ca18e0dc Document proxy support in ReflectionTestUtils
Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 2d565c7944 Fix bugs in ReflectionTestUtils related to proxies
Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen 7c7e7865bf Polishing 2016-03-16 18:34:07 +01:00
Marten Deinum 8d3ec50e87 Support proxied objects in ReflectionTestUtils
This commit adds support for unwrapping proxies in the setField() and
getField() methods in ReflectionTestUtils.

Instead of always accessing fields directly on the supplied
targetObject (which may be a proxy), AopTestUtils is now used to obtain
the potential ultimateTargetObject which is then used for accessing
fields.

Issue: SPR-14050
2016-03-16 18:34:07 +01:00
Sam Brannen c41c5dd5c9 Polishing 2016-03-12 14:58:06 +01:00
Sam Brannen cbd1342fbb Polish ContextCustomizer support in the TCF
Issue: SPR-13998
2016-03-11 21:22:08 +01:00
Phillip Webb 87a3a5cb3b Introduce ContextCustomizer API in the TestContext Framework
Allow third-parties to contribute ContextCustomizers that can customize
ApplicationContexts created by the Spring TestContext Framework (TCF)
before they are refreshed.

A customizer may be provided via a ContextCustomizerFactory which is
registered with `spring.factories`. Each factory is consulted whenever
a new ApplicationContext needs to be created by the TCF. Factories may
inspect various details about the test and either return a new
ContextCustomizer or null.

ContextCustomizers are similar to ApplicationContextInitializers and
may perform any number of tasks, including bean registration, setting
of active profiles, etc.

Issue: SPR-13998
2016-03-11 20:53:06 +01:00
Juergen Hoeller d124a13eb4 Consistent use of empty enumerations 2016-03-11 15:07:59 +01:00
Sam Brannen 51eccf552f Polish ServletTestExecutionListener[Tests] 2016-03-10 17:20:02 +01:00
Phillip Webb bb590db396 Support servlet listener activate attribute
Add a ServletTestExecutionListener.ACTIVATE_LISTENER attribute which
can be set on the TestContext to trigger activation of the listener
even if a `@WebAppConfiguration` is not present.

Issue: SPR-14035
2016-03-10 16:54:14 +01:00
Phillip Webb 2244461778 Allow @ContextConfiguration to be omitted
Prior to this commit, the @ContextConfiguration annotation was required
to be present even if default XML files, Groovy scripts, or
@Configuration classes were detected; however, in such cases the
@ContextConfiguration was typically declared empty and therefore
seemingly unnecessary boilerplate.

This commit permits @ContextConfiguration to be omitted whenever it can
be reasonably deduced. Consequently, integration tests such as the
following are now supported.

    @RunWith(SpringRunner.class)
    public class MyTest {

        @Autowired String myBean;

        @Test public void example() { /* ... */ }

        @Configuration
        static class Config {

            @Bean String myBean() {
                return "Hello";
            }
        }
    }

Issue: SPR-13955
2016-03-08 19:36:49 +01:00
Sam Brannen 89cf4772d5 Fix malformed HTML in Javadoc 2016-03-08 15:27:35 +01:00
Sam Brannen 93fb7be783 Polishing 2016-03-08 15:18:21 +01:00
Phillip Webb 504779e210 Remove @BootstrapWith from @WebAppConfiguration
Update @WebAppConfiguration so that it no longer directly specifies
a TestContextBootstrapper. This allows third parties to use the
annotation in combination with their own bootstrapper.

BootstrapUtils now provides the detection logic for when
WebTestContextBootstrapper should be used.

Issue: SPR-13991
2016-03-08 14:31:06 +01:00
Sam Brannen 067994712d Make TestContextManager.getTestContext() public
This commit changes the visibility of the getTestContext() method in
TestContextManager from 'protected' to 'public' in order to support
test method injection in JUnit 5 and similar use cases.

Issue: SPR-14011
2016-03-02 20:19:25 +01:00
Sam Brannen 18e9699a2b Demo @ContextConfiguration as composed annotation with ACI
This commit demonstrates how to register one or more @Configuration
classes via an ApplicationContextInitializer in a composed annotation so
that certain @Configuration classes are always registered whenever the
composed annotation is used, even if the composed annotation is used to
declare additional @Configuration classes.
2016-03-02 14:07:15 +01:00
Sebastien Deleuze b3abd3b809 Fix HeaderResultMatchers#string(String, String) assert order
Issue: SPR-14004
2016-03-01 14:18:29 +01:00
Sebastien Deleuze c385427397 Allow to specify AbstractHttpMessageConverter default charset
Before this commit, specifying the charset to use with produces or
consumes @RequestMapping attributes resulted in default charset
loss. That was really annoying for JSON for example, where using
UTF-8 charset is mandatory in a lot of use cases.

This commit adds a defaultCharset property to
AbstractHttpMessageConverter in order to avoid losing the
default charset when specifying the charset with these
@RequestMapping attributes.

It changes slightly the default behavior (that's why we have waited
4.3), but it is much more error prone, and will match with most
user's expectations since the charset loss was accidental in most
use cases (users usually just want to limit the media type supported
by a specific handler method).

Issue: SPR-13631
2016-02-29 23:34:32 +01:00
Sam Brannen 467b5f3f28 Introduce composed annotations for @RequestMapping
This commit introduces the following common composed annotations for
@RequestMapping in Spring MVC and Spring MVC REST.

- @GetMapping
- @PostMapping
- @PutMapping
- @DeleteMapping
- @PatchMapping

Issue: SPR-13992
2016-02-29 18:22:30 +01:00
Sam Brannen df7b24b8e7 Allow non-public @Transactional test methods
Prior to this commit, the TransactionalTestExecutionListener required
@Transactional test methods to be public; however, neither TestNG nor
JUnit 5 require that @Test methods are public. Consequently, non-public
transactional test methods silently run *without* a transaction.

This commit removes the 'public' restriction on transactional test
methods by setting the 'publicMethodsOnly' flag in
AnnotationTransactionAttributeSource to false.

Issue: SPR-14000
2016-02-29 15:30:22 +01:00
Sam Brannen 197434b3ec Polish TestNG integration tests 2016-02-29 15:30:22 +01:00
Sam Brannen 816185233d Polish TransactionalTestExecutionListener 2016-02-29 15:30:22 +01:00
Juergen Hoeller 9c0f99c0b5 Polishing 2016-02-29 12:57:09 +01:00
Sam Brannen a2bfe86630 Support @[Before|After]Transaction on non-public methods
In order to align with the relaxed programming models of TestNG and the
upcoming JUnit 5 (with regard to method visibility), this commit
removes the requirement that @BeforeTransaction and @AfterTransaction
methods must be 'public'.

Issue: SPR-13997
2016-02-29 00:42:47 +01:00
Sam Brannen 31e0386bcb Stop referencing deprecated @TransactionConfiguration in Javadoc 2016-02-27 23:50:00 +01:00
Sam Brannen 9d3dd1bc13 Introduce SpringRunner 'alias' for SpringJUnit4ClassRunner
This commit introduces a SpringRunner extension of
SpringJUnit4ClassRunner that is intended to be used as an 'alias' for
SpringJUnit4ClassRunner, primarily in order to simplify configuration
of JUnit 4 based integration tests.

Developers can use this alias as follows:

    @RunWith(SpringRunner.class)
    public class MySpringIntegrationTests { ... }

Issue: SPR-13954
2016-02-27 23:02:55 +01:00
Sam Brannen 6fcb6630d7 Clean up warnings in SampleAsyncTests 2016-02-26 22:35:51 +01:00
Rossen Stoyanchev 1bc1df2d0f Polish client-side REST updates
Issue: SPR-11365
2016-02-24 15:24:13 -05:00
Juergen Hoeller ca19920d74 Refined ApplicationContextInitializer assignability exception 2016-02-24 17:50:14 +01:00
Rossen Stoyanchev 91872b0d74 Add ExpectedCount
MockRestServicesServer now supports an expect variant that accepts
a range of expected count of executions.

Issue: SPR-11365
2016-02-23 23:31:34 -05:00
Rossen Stoyanchev 08a08725be Allow plugging in custom RequestExpectationManager
The MockRestServiceServer builder now has an option to plug in a
custom RequestExpectationManager.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Rossen Stoyanchev a56c69c9ca Introduce MockRestServiceServer builder
MockRestServiceServer now provides static methods for builder-style
creation of MockRestServiceServer. This includes an option ignore
the order of declaration expected requests.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Rossen Stoyanchev f58ef24efd Introduce RequestExpectationManager
This commit factors out the logic to declare and manage expectations
including matching them to requests and verifying at the end behind
a commong abstraction.

MockRestServiceServer delegates to the new abstraction and is no longer
aware of how that's done. There are two implementations, one for
ordered and another for unordered expectation.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Rossen Stoyanchev 37a3fa96d1 Separate ResponseActions from ClientHttpRequest
Before this commit RequestMatcherClientHttpRequest served both as
API to define request expectations, i.e. ResponseActions, as well as
the implementation of ClientHttpRequest representing actual requests.

DefaultResponseActions replaces this class as a simple holder of
expected requests and mock responses. MockRestServiceServer is then
responsible to match request expectations and create a mock response.

Issue: SPR-11365
2016-02-23 23:31:33 -05:00
Juergen Hoeller 028a690100 Polishing 2016-02-23 14:31:09 +01:00
Juergen Hoeller 1899fb37c1 Polishing 2016-02-22 23:26:41 +01:00
Juergen Hoeller 0adc4921ed TestContextManager consistently handles Errors from listener invocations
Issue: SPR-13961
2016-02-18 21:07:32 +01:00
Juergen Hoeller ac44f9edd9 Consistent equals implementations across class hierarchies
Issue: SPR-13951
2016-02-17 16:57:29 +01:00
Sam Brannen 677a321571 Support primary TxMgrs and DataSources in the TCF
Prior to this commit, the transaction manager and data source look-up
algorithms in the Spring TestContext Framework were not capable of
retrieving 'primary' beans of those types, even though 'primary' beans
are supported in production as well as for injecting dependencies into
test instances. Specifically, if there was more than one transaction
manager or data source bean and one of them was flagged as 'primary',
the retrieveTransactionManager() and retrieveDataSource() methods in
TestContextTransactionUtils would simply return null for such beans.

This commit updates TestContextTransactionUtils by adding support for
looking up primary transaction managers and data sources.

Issue: SPR-13891
2016-02-03 17:58:33 +01:00
Sam Brannen 6d2b9a0136 Throw exception if TxMgr cannot be retrieved for @Transactional test
Prior to this commit, a @Transactional integration test would silently
be executed without a transaction if the transaction manager could not
be retrieved from the application context -- for example, it no such
bean was defined or if multiple beans were present but none satisfied
the qualifier.

This commit addresses this issue by throwing an IllegalStateException
if the PlatformTransactionManager cannot be retrieved for a
@Transactional test.

Issue: SPR-13895
2016-02-03 14:56:27 +01:00
Sam Brannen ea46ad8022 Clean up warnings in spring-test 2016-01-28 19:27:53 +01:00
Rossen Stoyanchev 135738f9bf AbstractController supports HTTP OPTIONS
Issue: SPR-13130
2016-01-25 08:49:04 -05:00
Rossen Stoyanchev 415b2763ce MockHttpServletRequestBuilder parses form data
Spring MVC Test now parses application/x-www-form-urlencoded request
content and populates request parameters from it.

This can be useful when running client-side tests against a MockMvc
via MockMvcClientHttpRequestFactory.

Issue: SPR-13733
2016-01-21 17:26:23 -05:00
Rossen Stoyanchev 6a9455b7d0 Fix failing test 2016-01-21 17:05:05 -05:00
Rossen Stoyanchev 1416c2a00e ContentRequestMatchers asserts request with form data
Issue: SPR-13044
2016-01-21 12:42:33 -05:00
Rossen Stoyanchev 952a3170e6 HeaderResultMatchers supports multi-value headers
Issue: SPR-10087
2016-01-21 11:19:43 -05:00
Rossen Stoyanchev ae224bed3e Polish HeaderResultMatchers 2016-01-21 10:20:04 -05:00
Rossen Stoyanchev df223eb118 Polish custom HTTP verb in Spring MVC Test
Issue: SPR-13719
2016-01-21 09:13:33 -05:00
Kamill Sokol 3554348919 Support custom HTTP verbs in Spring MVC Test
Prior to this commit, Spring MVC Test only supported HTTP methods GET,
POST, HEAD, OPTIONS, PUT, PATCH, DELETE, TRACE and multipart file
upload. This change adds generic methods to MockMvcRequestBuilders in
order to allow testing of arbitrary HTTP methods in a Spring MVC
application.

Issue: SPR-13719
2016-01-21 09:12:43 -05:00
Rossen Stoyanchev 4b1183582a Add methodCall option to HandlerResultMatchers
Issue: SPR-13736
2016-01-15 12:44:00 -05:00
Rossen Stoyanchev 1320da906b Polish HandlerResultMatchers 2016-01-15 12:44:00 -05:00
Stephane Nicoll 2fc2c29e9a Update copyright header 2016-01-15 10:51:11 +01:00
Rossen Stoyanchev 4818378c25 Better document client-side tests against MockMvc
Issue: SPR-13815
2016-01-14 15:15:07 -05:00
Brian Clozel 74d3bceb19 Add missing StatusResultMatcher for HTTP Status 451
Issue: SPR-13632
2015-12-29 21:23:09 +01:00
Juergen Hoeller 41ee25b1e7 Convenience constructors for common view prefix/suffix scenarios
Issue: SPR-13813
2015-12-22 12:00:49 +01:00
Sam Brannen 66562f2589 Require JUnit 4.12 or higher in the TestContext framework
Issue: SPR-13275
2015-12-19 18:43:59 +01:00
Sam Brannen 9eb713ae2c Mention DCBeforeModesTEL in TestExecutionListener Javadoc 2015-12-17 17:45:08 +01:00
Juergen Hoeller db05f43a75 Require JsonPath 1.1+
Issue: SPR-13729
2015-12-17 17:13:27 +01:00
Juergen Hoeller 935c0a463e Revised MockMvcResultHandlers logger initialization
Issue: SPR-13802
2015-12-16 21:49:48 +01:00
Juergen Hoeller 997278e3ed Polishing 2015-12-16 20:19:41 +01:00
Rossen Stoyanchev c8aa48faa9 Add params(MultiValueMap) to MockMvc
Issue: SPR-13801
2015-12-16 11:51:59 -05:00
Juergen Hoeller 11806b9215 Class identity comparisons wherever possible (and further polishing)
Issue: SPR-12926
2015-12-09 12:28:09 +01:00
Juergen Hoeller 4261f34b63 Consistent and lenient HttpMethod resolution across all web modules
Issue: SPR-13776
2015-12-09 12:26:44 +01:00