Commit Graph

1607 Commits

Author SHA1 Message Date
wonwoo f8d6896e40 Replace context object with "it" argument
Closes gh-23482
2019-12-13 16:19:06 +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
Johnny Lim 1e83e889aa Use hasSize() where possible
See gh-24172
2019-12-10 07:58:53 +01:00
Sam Brannen 2108bdf876 Introduce regression test for prototype @ControllerAdvice beans
See gh-24157
2019-12-07 18:30:56 +01: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
Sébastien Deleuze 6c7250b0ae Make Kotlin DSL class constructors internal
Closes gh-24059
2019-11-22 16:10:42 +01:00
Sébastien Deleuze dc0ebefc56 Add support for asyncDispatch to MockMvc Kotlin DSL
Closes gh-23758
2019-11-22 15:03:17 +01: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
Sam Brannen 2728f10a07 Test instance behavior for request-scoped @ControllerAdvice beans
The test introduced in this commit is intended to serve as a regression
test for the status quo.

See gh-23985
2019-11-19 17:10:18 +01:00
Sam Brannen b4e1d48322 Ignore scoped proxy targets for @ControllerAdvice beans
Prior to this commit, methods in a @ControllerAdvice bean were
registered and invoked twice if the advice was a scoped bean (e.g.,
request or session scoped). In other words, both the proxy bean and the
target bean were wrapped in ControllerAdviceBean instances.

This commit fixes this bug by modifying the findAnnotatedBeans() method
in ControllerAdviceBean so that it filters out targets of scoped
proxies.

Closes gh-24017
2019-11-19 14:20:25 +01:00
Rossen Stoyanchev f4c847b723 MockHttpServletRequestBuilder sets content-length
Closes gh-23978
2019-11-12 17:33:14 +00:00
Rossen Stoyanchev 16c7a40c53 Minor refactoring
See gh-23296
2019-11-12 16:14:02 +00:00
Johannes Teklote 879b2df052 queryParam options for MockMVC requeusts
See gh-23296
2019-11-12 16:13:51 +00:00
Sam Brannen a26d37b407 Polishing 2019-11-12 14:01:13 +01:00
Rossen Stoyanchev 347f16c8ac Polishing
See gh-2023
2019-11-11 15:04:36 +00:00
Pat Turner 6db8306e46 XpathResultMatcher supports Hamcrest Matcher NodeList
Use when xpath result is XPathConstants.NODESET
2019-11-11 15:04:36 +00:00
Sam Brannen cb9d27b9b8 Polish contribution and fix build
See gh-1954
2019-11-09 12:45:02 +01:00
Rob Tompkins cfb7777a07 Exception response for MockRestServiceServer
Closes gh-1954
2019-11-08 18:09:49 +00:00
Rossen Stoyanchev 5d2fc2fc32 HttpHandlerConnector uses non-blocking thread
Closes gh-23936
2019-11-06 21:58:02 +00:00
Sam Brannen 29599a93a4 Re-enable support for invalid Expires attributes in MockCookie
Changes introduced in commit 9b2087618b
caused a regression for Cookie support in MockHttpServletResponse.
Specifically, an Expires attribute that cannot be parsed using
`ZonedDateTime.parse()` now results in an exception; whereas,
previously an entry such as `Expires=0` was allowed.

This commit fixes this issue in MockCookie by catching and ignoring any
DateTimeException thrown while attempting to parse an Expires attribute.

Closes gh-23911
2019-11-06 18:28:28 +01:00
Sam Brannen cef4478b7b Treat InvalidPathException like an IOException in MockServletContext
Prior to this commit, if MockServletContext was configured with a
FileSystemResourceLoader, invocations of the following methods on a
Microsoft Windows operating system resulted in an InvalidPathException
if the supplied path contained a colon (such as "C:\\temp"). This is
inconsistent with the behavior on non-Windows operating systems. In
addition, for comparable errors resulting in an IOException, those
methods (except getRealPath()) return null instead of throwing the
exception.

- getResourcePaths()
- getResource()
- getResourceAsStream()
- getRealPath()

This commit makes handling of InvalidPathException and IOException
consistent for these methods: both exceptions now result in null be
returned by these methods.

Closes gh-23717
2019-10-30 15:59:44 +01:00
Juergen Hoeller 046380988b Nullability refinements 2019-10-30 00:26:11 +01:00
Sam Brannen ce0b012f43 Polish contribution
See gh-23769
2019-10-29 13:27:39 +01:00
Vedran Pavic 9b2087618b Preserve expires attribute in MockCookie
At present, MockCookie doesn't preserve expires attribute. This has a
consequence that a cookie value set using
MockHttpServletResponse#addHeader containing an expires attribute will
not match the cookie value obtained from
MockHttpServletResponse#getHeader, since the expires attribute will get
calculated based on current time.

This commit enhances MockCookie to preserve the expires attribute.

Closes gh-23769
2019-10-29 12:56:24 +01:00
Sam Brannen 46329d0b97 Polish Javadoc for HeaderAssertions and StatusAssertions
See gh-23878
2019-10-28 13:33:30 +01:00
Sam Brannen 5bd1af2a7f Away with the "manger"; time to fix that typo 2019-10-25 17:04:21 +02:00
Sam Brannen 5b6337b6a9 Clean up warning in spring-test 2019-10-24 13:55:26 +02:00
Sam Brannen 13cdb70f64 Reinstate protected XpathRequestMatchers constructor
This commit makes the XpathRequestMatchers constructor protected again
in case users have extended this class.
2019-10-24 13:49:35 +02:00
Sam Brannen f3cad9f685 Polish XpathRequestMatchers Javadoc and implementation 2019-10-24 13:37:56 +02:00
Sam Brannen db4d51ba32 Remove unused type parameter declarations in XpathRequestMatchers
Prior to this commit, several of the methods in XpathRequestMatchers
declared unused type parameters (e.g., <T>). This was obviously the
result of copying an existing method that actually needs the type
parameter for proper casting.

For example, the following ...

public <T> RequestMatcher exists() {
    // ...
}

... should actually be declared without <T>, since T is not used in the
implementation or in the return type:

public RequestMatcher exists() {
    // ...
}

This commit removes all unused type parameter declarations in
XpathRequestMatchers.

Side Effects:

Now that we have removed the unused type parameter declarations, users
will see the following side effects if they had previously declared a
type argument when invoking such methods.

- Java: an "Unused type arguments for the non generic method ..."
  warning will be generated by the compiler, but the code will continue
  to work unmodified.

- Kotlin: a "Type inference failed: Not enough information to infer
  parameter T in fun ..." compiler error will be raised, causing the
  code to no longer compile (see
  https://youtrack.jetbrains.com/issue/KT-5464). Removal of the type
  argument declaration will allow the code to work correctly again.

Closes gh-23860
2019-10-24 13:12:02 +02:00
Sam Brannen 693101ded8 Remove unused type parameter declarations in MockMvc result matchers
Prior to this commit, several of the ResultMatcher methods used in
MockMvc declared unused type parameters (e.g., <T>). This was obviously
the result of copying an existing method that actually needs the type
parameter for proper casting.

For example, the following in RequestResultMatchers ...

public <T> ResultMatcher attribute(String name, Object expectedValue) {
    // ...
}

... should actually be declared without <T>, since T is not used in the
implementation or in the return type:

public ResultMatcher attribute(String name, Object expectedValue) {
    // ...
}

This commit removes all unused type parameter declarations in MockMvc
result matchers.

Side Effects:

Now that we have removed the unused type parameter declarations, users
will see the following side effects if they had previously declared a
type argument when invoking such methods.

- Java: an "Unused type arguments for the non generic method ..."
  warning will be generated by the compiler, but the code will continue
  to work unmodified.

- Kotlin: a "Type inference failed: Not enough information to infer
  parameter T in fun ..." compiler error will be raised, causing the
  code to no longer compile (see
  https://youtrack.jetbrains.com/issue/KT-5464). Removal of the type
  argument declaration will allow the code to work correctly again.

Closes gh-23858
2019-10-24 10:41:37 +02:00
Sam Brannen 6c4ac8f9c9 Remove unused type parameter declaration in RequestResultMatchers
The new sessionAttributeDoesNotExist() method introduced in commit
e73344fc71 declares an unused type
parameter <T>.

This commit removes that unused type parameter from the method
signature.

See gh-23756
2019-10-23 14:27:00 +02:00
Sam Brannen eabf357640 Polish MockMvc result matchers and tests 2019-10-23 14:03:50 +02:00
Sam Brannen 82f64f6a8d Polish contribution
See gh-23756
2019-10-23 12:34:51 +02:00
Drummond Dawson e73344fc71 Introduce sessionAttributeDoesNotExist in RequestResultMatchers
Analogous to the attributeDoesNotExist() method in ModelResultMatchers,
this commit introduces a new sessionAttributeDoesNotExist() method in
RequestResultMatchers which asserts that the given attributes are null
in the HttpSession.

Closes gh-23756
2019-10-23 12:28:08 +02:00
Sam Brannen 6fd50d7d17 Register EventPublishingTEL in JUnit 4 & TestNG base classes
Spring Framework 5.2 introduced an EventPublishingTestExecutionListener
in the Spring TestContext Framework. This listener is automatically
registered via the spring.factories mechanism; however, this listener is
not registered in the abstract JUnit 4 and TestNG base classes.

This commit addresses this oversight by explicitly registering the
EventPublishingTestExecutionListener in the following classes.

- AbstractJUnit4SpringContextTests
- AbstractTransactionalJUnit4SpringContextTests
- AbstractTestNGSpringContextTests
- AbstractTransactionalTestNGSpringContextTests

Closes gh-23748
2019-10-02 15:04:03 +02:00
Sam Brannen fc74c43718 Polishing 2019-10-02 14:49:23 +02:00
Sam Brannen 3a59b01be8 Polish Javadoc for abstract JUnit 4 and TestNG base classes 2019-10-02 14:26:50 +02:00
Sebastien Deleuze b24ac74106 Restore TransactionOperations Kotlin API compatibilty
This commit renames the Runnable variant to executeWithoutResult
and uses a Consumer<TransactionStatus> parameter for better
consistency with TransactionCallbackWithoutResult.

Closes gh-23724
2019-09-29 19:31:12 +02:00
Sam Brannen 06563d8b4b Add headerDoesNotExist() to MockRestRequestMatchers
Prior to this commit, one could not test for the absence of a specific
HTTP header in a request.

This commit adds a headerDoesNotExist() method in MockRestRequestMatchers.

Closes gh-23721
2019-09-27 17:38:11 +02:00
Sam Brannen 6186239287 Remove obsolete references to specific release versions in testing docs 2019-09-26 15:02:30 +02:00