Commit Graph

1601 Commits

Author SHA1 Message Date
Rossen Stoyanchev
443e9ee618 MockMvc applies StandardMultipartHttpServletRequest wrapper
This is necessary to correctly process multipart requests and resolve
@RequestPart arguments and MultipartFile arguments.

Closes gh-25602
2020-08-19 09:06:20 +01:00
Sam Brannen
50b20c2bb7 Merge branch '5.2.x' 2020-08-17 16:01:32 +02:00
Sam Brannen
d939016a09 Polish contribution
See gh-25600
2020-08-17 15:53:45 +02:00
Maciej Miklas
a83529c844 Introduce createContext() factory method in AbstractGenericContextLoader
Prior to this commit it was possible to configure the
DefaultListableBeanFactory used by the GenericApplicationContext
created by AbstractGenericContextLoader, but it was not possible to
completely replace the bean factory.

This commit introduces a new createContext() factory method in
AbstractGenericContextLoader which indirectly allows subclasses to
supply a custom DefaultListableBeanFactory implementation to the
GenericApplicationContext.

Closes gh-25600
2020-08-17 15:38:24 +02:00
Sam Brannen
32e851617e Fix Javadoc formatting in GenericGroovyXmlContextLoader 2020-08-17 15:37:51 +02:00
Sam Brannen
13183c89ce Update tests due to deprecations in Reactor 2020-08-12 13:46:32 +02:00
Sam Brannen
c558391e2c Declare interfaces as @FunctionalInterface where feasible
This commit declares each of the following public interfaces as a
@FunctionalInterface.

- org.springframework.context.ApplicationContextInitializer
- org.springframework.test.web.servlet.DispatcherServletCustomizer
- org.springframework.validation.MessageCodeFormatter
- org.springframework.util.IdGenerator
- org.springframework.beans.factory.config.YamlProcessor.MatchCallback
- org.springframework.beans.factory.config.YamlProcessor.DocumentMatcher

Closes gh-25580
2020-08-11 17:01:03 +02:00
Sam Brannen
5de549d7d4 Update contentType property via MockHttpServletResponse::setCharacterEncoding()
Prior to this commit, MockHttpServletResponse's setCharacterEncoding()
method did not update the contentType property, which violates the
Servlet 2.4 Javadoc for getContentType() and setCharacterEncoding().

This commit addresses this issue; however, some existing tests may have
to be updated as a result of this change.

For example, note how some of the tests in this commit have been
refactored to use MediaType##isCompatibleWith() instead of asserting
exact matches for the value returned by MockHttpServletResponse's
getContentType() method.

Closes gh-25536
2020-08-10 16:05:18 +02:00
Sam Brannen
c5bb5d6c03 Polish ViewResolutionTests 2020-08-10 15:31:51 +02:00
Brian Clozel
617ec359bd Update after MonoProcessor deprecation in Reactor
This commit adapts the usage of `MonoProcessor` after deprecations
introduced in reactor/reactor-core#1053
2020-08-07 18:59:21 +02:00
Juergen Hoeller
b345019415 Introduce getBeanProvider variants with allowEagerInit flag
Closes gh-25559
2020-08-07 12:07:13 +02:00
Sam Brannen
dded51fa80 Merge branch '5.2.x' 2020-08-05 17:47:44 +02:00
Sam Brannen
96da1ff9ea Support @RestControllerAdvice in Standalone MockMvc again
Since Spring Framework 5.2, @RestControllerAdvice registered with
MockMvc when using MockMvcBuilders.standaloneSetup() has no longer been
properly supported if annotation attributes were declared in the
@RestControllerAdvice annotation. Prior to 5.2, this was not an issue.

The cause for this regression is two-fold.

1. Commit 50c257794f refactored
   DefaultListableBeanFactory so that findAnnotationOnBean() supports
   merged annotations; however, that commit did not refactor
   StaticListableBeanFactory#findAnnotationOnBean() to support merged
   annotations.

2. Commit 978adbdae7 refactored
   ControllerAdviceBean so that a merged @ControllerAdvice annotation
   is only looked up via ApplicationContext#findAnnotationOnBean().

The latter relies on the fact that findAnnotationOnBean() supports
merged annotations (e.g., @RestControllerAdvice as a merged instance of
@ControllerAdvice). Behind the scenes, MockMvcBuilders.standaloneSetup()
creates a StubWebApplicationContext which internally uses a
StubBeanFactory which extends StaticListableBeanFactory. Consequently,
since the implementation of findAnnotationOnBean() in
StaticListableBeanFactory was not updated to support merged annotations
like it was in DefaultListableBeanFactory, we only see this regression
with the standalone MockMvc support and not with MockMvc support for an
existing WebApplicationContext or with standard Spring applications
using an ApplicationContext that uses DefaultListableBeanFactory.

This commit fixes this regression by supporting merged annotations in
StaticListableBeanFactory#findAnnotationOnBean() as well.

Closes gh-25520
2020-08-05 17:40:16 +02:00
Sam Brannen
40fc472c70 Polish ExceptionHandlerTests 2020-08-05 17:24:45 +02:00
Sam Brannen
d646e602d9 Merge branch '5.2.x' 2020-08-03 12:19:49 +02:00
Sam Brannen
969aa8ad47 Update copyright date 2020-08-03 12:19:21 +02:00
Sam Brannen
d8554c498c Merge branch '5.2.x' 2020-08-01 16:42:31 +02:00
Sam Brannen
482adb9478 Fix error message for type mismatch in jsonPath().value()
Prior to this commit, if a value existed at the specified JSON path but
had an incompatible type, the AssertionError thrown contained a message
stating that the value did not exist (i.e., "No Value at JSON Path"),
which was not only misleading but also technically incorrect.

This commit fixes the error message for such use cases. For example, the
AssertionError thrown in such use cases now resembles the following.

  At JSON path "$.name", value <Lisa> of type <java.lang.String> cannot
  be converted to type <byte[]>

Closes gh-25480
2020-08-01 16:35:54 +02:00
Sam Brannen
5a12e7b2c5 Fix typo in test method names 2020-08-01 16:30:12 +02:00
Sam Brannen
58412affaa Merge branch '5.2.x' 2020-08-01 14:02:22 +02:00
Sam Brannen
5576321b04 Reset charset field in MockHttpServletResponse
Prior to this commit, calling reset() on MockHttpServletResponse did not
reset the `charset` field to `false` which could result in the
"Content-Type" header containing `;charset=null` which in turn would
result in errors when parsing the "Content-Type" header.

This commit resets the charset field to `false` in
MockHttpServletResponse's reset() method to avoid such errors.

Closes gh-25501
2020-08-01 14:01:39 +02:00
Sam Brannen
89bb9cb749 Polish Javadoc 2020-08-01 12:26:56 +02:00
Sam Brannen
9b0729007f Polish MockHttpServletResponseTests 2020-08-01 12:26:38 +02:00
Sam Brannen
86c52a842f Support multiple Content-Language values in MockHttpServletResponse
Prior to this commit, if the user supplied a comma-separated list such
as "en, it" as the Content-Language header value to
MockHttpServletResponse's setHeader() method, only the first language
was actually set in the response's Content-Language header (e.g., "en").

This commit ensures that all supplied content languages are set in the
response's Content-Language header.

Closes gh-25281
2020-07-27 17:47:46 +02:00
Sam Brannen
d2db43a900 Polish Javadoc 2020-07-27 14:38:24 +02:00
Sam Brannen
27e0febacf Polish MockHttpServletResponseTests 2020-07-26 09:57:25 +02:00
XenoAmess
ab859fcc96 Refine use of substring operations
Closes gh-25445
2020-07-22 17:26:42 +02:00
XenoAmess
edfc6c0293 Refine use of substring operations
Closes gh-25445
2020-07-22 16:28:58 +02:00
Sam Brannen
cdc234d7db Polish contribution
See gh-25446
2020-07-22 14:06:29 +02:00
XenoAmess
c547809e89 Use instanceof instead of Class#isInstance where feasible
Closes gh-25446
2020-07-22 14:06:29 +02:00
XenoAmess
3b12beb1b8 Simplify if-statements with instanceof checks
Closes gh-25449
2020-07-22 10:34:27 +02:00
Rossen Stoyanchev
b16f6fa456 Shared static instance of DefaultDataBufferFactory 2020-06-24 16:12:56 +01:00
Sam Brannen
9d5881e0ad Suppress warnings, remove unused code, etc. 2020-06-20 17:15:35 +02:00
Rossen Stoyanchev
de0a043739 Add contains form data RequestMatcher
See gh-23671
2020-06-18 07:49:27 +01:00
Rossen Stoyanchev
bc33ae3f8b Update multipart RequestMatcher
See gh-23772
2020-06-18 07:49:27 +01:00
vspac
e01160db31 Multipart RequestMatcher's
See gh-23772
2020-06-18 07:49:27 +01:00
Juergen Hoeller
d36407d585 Deprecate rarely used bean definition variants
Closes gh-24875
2020-06-17 10:59:55 +02:00
Rossen Stoyanchev
5225a57411 Support for parsed PathPatterns in Spring MVC
See gh-24945
2020-06-15 11:25:35 +01:00
Sam Brannen
adc76a1d8f Suppress warnings in ResponseCreatorsTests 2020-06-14 19:45:51 +02:00
Sam Brannen
b9e52a8089 Delete dead code in MockServerHttpRequest 2020-06-09 17:38:34 +02:00
Arjen Poutsma
8b59b6a7f4 Merge branch '5.2.x' 2020-06-08 15:43:49 +02:00
Arjen Poutsma
0ccf5e19aa Undo MockServerRequest deprecation
Setting path variables (and making sure they are available in a
HandlerFunction) is more convenient with MockServerRequest than
having to set attributes in MockServerWebExchange.

This commit removes MockServerRequest's deprecation.

Closes gh-25087
2020-06-08 15:40:09 +02:00
Juergen Hoeller
a34f1e3759 Merge branch '5.2.x'
# Conflicts:
#	build.gradle
#	spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java
#	spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java
#	spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java
2020-06-06 18:52:51 +02:00
Juergen Hoeller
d71957ce7c Polishing 2020-06-06 17:45:12 +02:00
Juergen Hoeller
5051d7302d Merge branch '5.2.x'
# Conflicts:
#	build.gradle
#	spring-test/src/main/java/org/springframework/mock/http/server/reactive/MockServerHttpRequest.java
#	spring-web/src/main/java/org/springframework/http/HttpHeaders.java
#	spring-web/src/testFixtures/java/org/springframework/web/testfixture/http/server/reactive/MockServerHttpRequest.java
2020-06-06 15:27:15 +02:00
Juergen Hoeller
f3d4df2fd4 Consistently check available local/remote addresses for non-null 2020-06-06 15:15:16 +02:00
Rossen Stoyanchev
8d449471c7 Polishing contribution
See gh-25148
2020-05-29 17:37:43 +01:00
Mihai Dumitrescu
b31b8ce6c1 Polishing in MockServerHttpRequest
Closes gh-25109
2020-05-29 16:31:19 +01:00
Rossen Stoyanchev
90ccabd60b Merge branch '5.2.x' 2020-05-27 19:12:57 +01:00
Rossen Stoyanchev
955f77bf5d Add error message to MockServerHttpRequest
Closes gh-25109
2020-05-27 18:57:02 +01:00