Commit Graph

1184 Commits

Author SHA1 Message Date
Juergen Hoeller
71e70aed14 Polishing 2020-08-27 17:13:33 +02:00
Juergen Hoeller
6f0461c569 Polishing 2020-08-25 16:17:22 +02:00
Juergen Hoeller
04df9b8f49 Efficient checks for empty strings and single character matches
Closes gh-25552
Closes gh-25553
2020-08-25 16:17:12 +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
969aa8ad47 Update copyright date 2020-08-03 12:19:21 +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
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
XenoAmess
ab859fcc96 Refine use of substring operations
Closes gh-25445
2020-07-22 17:26:42 +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
d71957ce7c Polishing 2020-06-06 17:45:12 +02:00
Juergen Hoeller
f3d4df2fd4 Consistently check available local/remote addresses for non-null 2020-06-06 15:15:16 +02:00
Rossen Stoyanchev
955f77bf5d Add error message to MockServerHttpRequest
Closes gh-25109
2020-05-27 18:57:02 +01:00
Rossen Stoyanchev
8204055924 MockServerHttpRequest accepts custom HTTP method
Closes gh-25109
2020-05-23 10:40:25 +01:00
Sam Brannen
b8835c9f32 Copy MockHttpServletRequest changes to spring-web
See gh-24916
2020-04-17 16:20:42 +02:00
Sam Brannen
6b410df45b Retain brackets for IPV6 address in MockHttpServletRequest
According to the Javadoc for ServletRequest's getServerName() method,
when the `Host` header is set, the server name is "the value of the
part before ':' in the Host header value ...". For a value representing
an IPV6 address such as `[::ffff:abcd:abcd]`, the enclosing square
brackets should therefore not be stripped from the enclosed IPV6
address.

However, the changes made in conjunction with gh-16704 introduced a
regression in Spring Framework 4.1 for the getServerName() method in
MockHttpServletRequest by stripping the enclosing brackets from the
IPV6 address in the `Host` header. Similarly, the changes made in
conjunction with gh-20686 introduced a regression in Spring Framework
4.3.13 and 5.0.2 in the getRequestURL() method in
MockHttpServletRequest by delegating to the getServerName() method
which strips the enclosing brackets.

This commit fixes the implementation of getServerName() so that the
enclosing brackets are no longer stripped from an IPV6 address in the
`Host` header. The implementation of getRequestURL() is therefore also
fixed.

In addition, in order to avoid a NullPointerException, the
implementations of getServerName() and getServerPort() now assert that
an IPV6 address present in the `Host` header correctly contains an
opening and closing bracket and throw an IllegalStateException if that
is not the case.

Closes gh-24916
2020-04-17 15:01:35 +02:00
Sam Brannen
dc5ddffd03 Polishing 2020-04-06 14:42:23 +02:00
Sam Brannen
a842434bff Document precedence for @DynamicPropertySource
Closes gh-24837
2020-04-01 18:09:31 +02:00
Sam Brannen
e26764d249 Remove duplicate words in documentation and polish Javadoc 2020-03-31 12:17:58 +02:00
Sam Brannen
9e30620ac2 Polish contribution
See gh-24805
2020-03-30 13:47:00 +02:00
Сергей Цыпанов
e63d1cf12d Improve usage of ByteArrayOutputStream/ByteArrayInputStream
Closes gh-24805
2020-03-30 13:22:21 +02:00
Qimiao Chen
7db00c9e22 Remove incorrect @Nullable in DynamicPropertiesContextCustomizer
Closes gh-24796
2020-03-28 15:29:01 +01:00
Rossen Stoyanchev
7aa06b8610 Polishing contribution
See gh-24786
2020-03-26 21:42:12 +00:00
Сергей Цыпанов
f17b0125ff Simplify conversion of DataBuffer to String
See gh-24786
2020-03-26 21:42:12 +00:00
Qimiao Chen
9f2fd4f0d5 Fix broken link in Javadoc for DynamicPropertySource
Closes gh-24792

Co-authored-by: Sam Brannen <sbrannen@pivotal.io>
2020-03-26 16:20:55 +01:00
Sam Brannen
cf7daa36c8 Add @DynamicPropertySource support in TestContext framework
This commit introduces a @DynamicPropertySource annotation that can be
used on methods in test classes that want to add properties to the
Environment with a dynamically supplied value.

This new feature can be used in conjunction with Testcontainers and
other frameworks that manage resources outside the lifecycle of a
test's ApplicationContext.

Closes gh-24540

Co-authored-by: Phillip Webb <pwebb@pivotal.io>
2020-03-23 17:10:18 +01:00
Sam Brannen
a8feb792da Fix broken Javadoc links 2020-03-16 16:30:27 +01:00
Arjen Poutsma
3cbea86335 Deprecate MockServerRequest
Deprecate MockServerRequest in favor of ServerRequest::create
combined with a MockServerWebExchange.
2020-03-10 15:45:11 +01:00
Rossen Stoyanchev
a134e92e7f Improve checks on URI string in MockMvc request builder
Closes gh-24556
2020-02-20 15:07:40 +00:00
Hyunjin Choi
7528b9487d Simplify code in spring-test by using Collections.addAll
Closes gh-24555
2020-02-19 17:28:22 +01:00
Rossen Stoyanchev
009dfbfafc MockRestServiceServer clears failed requests map
Closes gh-24486
2020-02-10 15:01:47 +00:00
Hyunjin Choi
273812f9c5 Remove unnecessary escapes in regular expressions
See gh-24470
2020-02-03 20:22:40 +00:00
Rossen Stoyanchev
547342b27d Status code as Integer methods in ServerHttpResponse
Closes gh-24400
2020-01-30 10:06:58 +00:00
Rossen Stoyanchev
c69703ffdb Deprecate path extension strategies
This commit deprecates PathExtensionContentNegotiationStrategy and
ServletPathExtensionContentNegotiationStrategy and also updates code
that depends on them internally to remove that dependence.

See gh-24179
2020-01-22 13:35:09 +00:00
Rossen Stoyanchev
542297b30d Polishing of contribution
See gh-2079
2019-12-13 16:54:53 +00:00
Dzmitry Kabysh
f4509d6e3a Allow any Accept and Content-Type raw values
See gh-2079
2019-12-13 16:20:55 +00:00
Rossen Stoyanchev
dd9b6287b4 Expose ClientCodecConfigurer in WebClient.Builder
Using Consumer<ClientCodecConfigurer> instead of
Consumer<ExchangeStrategies> eliminates one level of nesting that is
also unnecessary since codecs are the only strategy at present.

Closes gh-24124
2019-12-12 21:58:14 +00:00
Rossen Stoyanchev
1b172c1d20 Expose localAddress in WebFlux server
Closes gh-24174
2019-12-10 15:10:13 +00:00
Rossen Stoyanchev
fcbc437825 Polishing (follow-up on acfeb7) 2019-12-02 17:14:13 +00:00
Rossen Stoyanchev
acfeb77d41 Polishing
See gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel
d4209392d2 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-12-02 14:12:59 +00:00
Brian Clozel
1560bbd81e Revert "Allow ExchangeStrategies customizations in WebClient"
This reverts commit b3020bc484.
2019-12-02 10:39:53 +01:00
Brian Clozel
b3020bc484 Allow ExchangeStrategies customizations in WebClient
Prior to this commit, developers could configure their WebClient to use
their custom `ExchangeStrategies`, by providing it in the
`WebClient.Builder` chain.
Once created, an `ExchangeStrategies` instance is not mutable, which
makes it hard for further customizations by other components. In the
case of the reported issue, other components would override the default
configuration for the codecs maxInMemorySize.

This commit makes the `ExchangeStrategies` mutable and uses that fact to
further customize them with a new `WebClient.Builder#exchangeStrategies`
`Consumer` variant. This commit is also deprecating those mutating
variants in favor of a new `WebClient.Builder#exchangeStrategies` that
takes a `ExchangeStrategies#Builder` directly and avoids mutation issues
altogether.

Closes gh-23961
2019-11-29 22:26:52 +01:00
Rossen Stoyanchev
395c1e415c Polishing contribution
See gh-24074
2019-11-29 15:54:58 +00:00
Frederik Boster
a15a726fef Improve getMultipartContentType in mock request.
See gh-24074
2019-11-29 15:54:58 +00:00
Rossen Stoyanchev
21b2fc1f01 Improve HttpHandlerConnection completion
Before this commit the connector waited for a completed response (via
ServerHttpResponse#setComplete or ServerHttpResponse#writeWith) or an
error signal in handling, but it didn't deal explicitly with the case
where both can occur.

This commit explicitly waits for the completion of handling (success
or error) before passing the response downstream. If an error occurs
after response completion, it is wrapped in a dedicated exception that
also provides access to the completed response.

Close gh-24051
2019-11-22 10:28:05 +00:00
stsypanov
1f3b595a03 Use String.isEmpty() instead of String.equals("") 2019-11-21 16:42:01 +01:00
Rossen Stoyanchev
f4e0288357 Remove mentions of Tomcat async request timeout value
Close gh-24030
2019-11-19 17:08:43 +00:00