Commit Graph

1301 Commits

Author SHA1 Message Date
Sam Brannen
7d6be2e26e Polishing 2019-06-26 15:12:32 +03:00
Sam Brannen
0f1d16bb05 Fix Checkstyle violation 2019-06-24 17:54:04 +03:00
Sam Brannen
d0231cb29a Presort beans in ControllerAdviceBean.findAnnotatedBeans()
Prior to this commit, all clients of
ControllerAdviceBean.findAnnotatedBeans() sorted the returned list
manually. In addition, clients within the core Spring Framework
unnecessarily used AnnotationAwareOrderComparator instead of
OrderComparator to sort the list.

This commit presorts the ControllerAdviceBean list using OrderComparator
directly within ControllerAdviceBean.findAnnotatedBeans().

Closes gh-23188
2019-06-24 16:26:11 +03:00
Sam Brannen
9239ab1891 Support Ordered interface for @ControllerAdvice beans
Closes gh-23163
2019-06-23 19:31:35 +03:00
Sam Brannen
4568edf6c4 Simplify ControllerAdviceBean constructors
See gh-23163
2019-06-22 19:02:49 +03:00
Sam Brannen
8f30639a0a Test status quo for Ordered support for @ControllerAdvice beans
See gh-23163
2019-06-22 18:18:57 +03:00
Sam Brannen
59901592d2 Introduce regression tests for ControllerAdviceBean
This commit introduces unit tests for the status quo in
ControllerAdviceBeanTests to serve as regression tests for future
changes to ControllerAdviceBean.
2019-06-21 17:21:50 +03:00
Rossen Stoyanchev
030caea9cf Merge branch '5.1.x' 2019-06-21 14:15:26 +01:00
Rossen Stoyanchev
594c5806a6 Handle error in apply of writeFunction
Closes gh-23175
2019-06-21 14:15:14 +01:00
Brian Clozel
cc05608ae9 PathPattern does not use custom separator
Prior to this commit, `PathPattern::extractPathWithinMapping`
would always use the default path pattern separator `/` when extracting
the path within the pattern of a matched route.

This commit ensures that `PathPattern` uses the configured separator
when extracting the path within the matched mapping.

Fixes gh-23168
2019-06-20 20:27:22 +02:00
Brian Clozel
5787fc16fb PathPatternRouteMatcher should use custom separator
Prior to this commit, the `PathPatternRouteMatcher` would always use the
default path pattern separator when parsing incoming route strings to
`RouteMatcher.Route` instances.
When the `PathPatternRouteMatcher` is configured with a
`PathPatternParser` that has a custom separator (e.g., `.`), then the
matching algorithm can't match routes against parsed patterns.

This commit ensures that the route matcher uses the configured separator
at all times.

Fixes gh-23167
2019-06-20 20:23:04 +02:00
Sam Brannen
d2e6d0269b Preliminary tests for multipart/related & multipart/mixed in RestTemplate
See gh-23159
2019-06-20 11:35:18 +03:00
Sam Brannen
4000b244ff Forbid null converters in RestTemplate & HttpMessageConverterExtractor
Prior to this commit, RestTemplate and HttpMessageConverterExtractor did
not validate that the supplied HttpMessageConverter list contained no
null elements, which can lead to a NullPointerException when the
converters are accessed.

This commit improves the user experience by failing immediately if the
supplied HttpMessageConverter list contains a null element. This applies
to constructors for RestTemplate and HttpMessageConverterExtractor as
well as to RestTemplate#setMessageConverters().

Note, however, that RestTemplate#getMessageConverters() returns a mutable
list. Thus, if a user modifies that list so that it contains null values,
that will still lead to a NullPointerException when the converters are
accessed.

This commit also introduces noNullElements() variants for collections in
org.springframework.util.Assert.

Closes gh-23151
2019-06-18 16:13:20 +03:00
Sam Brannen
aa0a8d66a8 Polishing 2019-06-18 10:19:03 +03:00
Rossen Stoyanchev
14e2c6803e Support for RSocket composite metadata
Closes gh-22798
2019-06-12 17:11:30 -04:00
Sam Brannen
61bf45c86f Merge branch '5.1.x' 2019-06-06 17:40:51 +03:00
Ilya Lukyanovich
2ed81be831 Fix MockHttpServletRequest.setCookies to produce single cookie header
Prior to this commit, MockHttpServletRequest.setCookies() produced one
Cookie header per supplied cookie, resulting in multiple Cookie headers
which violates the specification.

This commit fixes this by ensuring that all cookie name-value pairs are
stored under a single Cookie header, separated by a semicolon.

Closes gh-23074
2019-06-06 17:13:21 +03:00
Brian Clozel
33becd8258 Allow separator configuration in PathPatternParser
This commit allows to configure a custom path separator when parsing and
matching path patterns with `PathPatternParser`, but also when parsing
incoming paths as `PathContainer` instances.

Closes gh-23092
2019-06-06 11:39:53 +02:00
Rossen Stoyanchev
69eba32284 Improved Part support in MultipartBodyBuilder
1. Add contentType and filename options to PartBuilder.

2. Revert recently committed #44659f since asyncPart can't properly
support Publisher of Part (only Mono, can't support filename), and
replace that with support for Part in the regular part method.

Closes gh-23083
2019-06-04 17:21:39 -04:00
Rossen Stoyanchev
e89fd5c3be Merge branch '5.1.x' 2019-06-03 16:34:58 -04:00
Rossen Stoyanchev
4f05da7fed Support escape character in ContentDisposition
Closes gh-23077
2019-06-03 16:03:35 -04:00
Sam Brannen
141ef9082f Clean up Mockito usage
This commit migrates to the MockitoJUnitRunner where sensible, which
will later allow for an easier migration to Mockito's extension for
JUnit Jupiter.

In addition, this commit deletes unnecessary stubbing for various mocks
and polishes test fixture setup in various test classes.
2019-05-28 13:59:43 +02:00
Phillip Webb
9d74da006c Migrate JUnit 4 assertions to AssertJ
Migrate all existing JUnit 4 `assert...` based assertions to AssertJ
and add a checkstyle rule to ensure they don't return.

See gh-23022
2019-05-23 15:52:49 -07:00
Phillip Webb
95a9d46a87 Migrate Hamcrest assertions to AssertJ
Migrate all existing `assertThat(..., Matcher)` assertions to AssertJ
and add checkstyle rules to ensure they don't return.

See gh-23022
2019-05-23 15:49:59 -07:00
Sam Brannen
f806594e60 Introduce getOrEmpty(String) convenience method in HttpHeaders
This commit introduces a getOrEmpty(String) method in HttpHeaders that
returns an immutable, empty list if no values are present for the
specified header name. This is provided as a convenience over the
existing get(String) method which returns null in such cases.

Closes gh-22949
2019-05-22 15:26:45 +02:00
Sam Brannen
9ca7354146 Polishing 2019-05-22 15:22:29 +02:00
Sam Brannen
819097a07a Clean up warning in Gradle build 2019-05-22 14:48:40 +02:00
Juergen Hoeller
3645281c35 Polishing 2019-05-21 19:26:39 +02:00
Phillip Webb
02850f357f Migrate exception checking tests to use AssertJ
Migrate tests that use `@Test(expectedException=...)` or
`try...fail...catch` to use AssertJ's `assertThatException`
instead.
2019-05-20 10:47:53 -07:00
Rossen Stoyanchev
ed2a3bd451 Take advantage of Encoder#encodeValue
EncoderHttpMessageWriter takes advantage of the Encoder#encodeValue
that's new in 5.2 in order to produce a Mono<DataBuffer> instead of
producing a Flux<DataBuffer> and then using flux.singleOrEmpty().

Closes gh-22952
2019-05-15 17:31:59 -04:00
Rossen Stoyanchev
013249757a Merge branch '5.1.x' 2019-05-15 16:44:05 -04:00
Rossen Stoyanchev
0274752fe9 Use singleOrEmpty to avoid upstream cancel
Closes gh-22952
2019-05-15 16:02:28 -04:00
Rossen Stoyanchev
afc0ae3752 Add hasPatternSyntax method to PathPattern 2019-05-14 15:36:47 -04:00
Sam Brannen
73dbd06361 Enforces static imports for JUnit 4 assertions and assumptions
This commit configures Checkstyle to enforces static imports for JUnit 4
assertions and assumptions.

See gh-22932
2019-05-12 15:13:07 +02:00
Sam Brannen
deecab6311 Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen
724c805211 Discontinue use of JUnit 3 APIs
This commit also ensures that the JSR-330 TCK is executed with the
normal build by adhering to naming conventions for test classes.

See gh-22894
2019-05-12 14:46:55 +02:00
Sam Brannen
9b61316c2e Clean up warnings in spring-web 2019-05-10 17:31:23 +02:00
Sam Brannen
d8f1d56100 Fix broken test 2019-05-09 16:21:54 +02:00
Sebastien Deleuze
c601ecf169 Merge branch '5.1.x' 2019-05-09 15:00:53 +02:00
Sebastien Deleuze
c8d49ed284 Fix EncoderHttpMessageWriter.isStreamingMediaType()
Closes gh-22936
2019-05-09 14:57:15 +02:00
Sam Brannen
e465f51d56 Suppress deprecation warnings 2019-05-09 13:21:42 +02:00
Phillip Webb
798b51f4a3 Migrate to BDD Mockito
Migrate all tests to consistently use BDD Mockito. Also add
checksyle rule to enforce going forwards.
2019-05-08 13:46:13 -07:00
Phillip Webb
816bbee8de Remove '.*' imports from tests
Organize test imports to expand all '.*' static imports into
fully qualified imports.

This update will allow us to use additional checkstyle rules in
the future, and will also help if we migrate fully to AssertJ.
2019-05-08 09:55:09 -07:00
Juergen Hoeller
82d32f0875 Remove unused import 2019-05-08 17:51:54 +02:00
Rossen Stoyanchev
44659f4945 Unwrap Part content in asyncPart builder method
Closes gh-22876
2019-05-08 10:59:58 -04:00
Phil Webb
d7320de871 Migrate away from ExpectedException (#22922)
* Add limited checkstyles to test code

Add a limited set of checkstyle rules to the test codebase to improve
code consistency.

* Fix checksyle violations in test code

* Organize imports to fix checkstyle for test code

* Migrate to assertThatExceptionOfType

Migrate aware from ExpectedException rules to AssertJ exception
assertions. Also include a checkstyle rules to ensure that the
the ExpectedException is not accidentally used in the future.

See gh-22894
2019-05-08 16:25:52 +02:00
Rossen Stoyanchev
7e6e3d7027 Switch writeAcceptCharset to false by default
Closes gh-22506
2019-05-08 09:56:52 -04:00
Arjen Poutsma
e7cca7792d Add way to override default multipartReader
This commit introduces a way to override the default multipart reader,
for instance to the SynchronossPartHttpMessageReader.
2019-05-08 12:10:20 +02:00
Arjen Poutsma
fb642ce723 Introduce DefaultMultipartMessageReader
This commit introduces the DefaultMultipartMessageReader, a fully
reactive multipart parser that does have any third party dependencies.

Closes gh-21659
2019-05-07 12:14:45 +02:00
Sam Brannen
d616e10dca Use assertThat from Hamcrest instead of JUnit 4
org.junit.Assert.assertThat() is deprecated as of JUnit 4.13.

See gh-22894
2019-05-05 19:26:04 +02:00