Commit Graph

1077 Commits

Author SHA1 Message Date
Rossen Stoyanchev
274eab7c5d Merge branch '5.1.x' 2019-08-21 13:36:11 +03:00
Rossen Stoyanchev
a7bb5ca473 Remove unnecessary iteration over headers
The use of LinkedCaseInsensitiveMap, going back to 3.0, makes it
unnecessary to iterate over keys which can cause
ConcurrentModificationException.

Closes gh-23460
2019-08-21 13:34:17 +03:00
Rossen Stoyanchev
26dc93d0f6 Polish body methods
WebClient, WebTestClient, and ServerResponse
2019-08-20 10:27:06 +03:00
Rossen Stoyanchev
b75674f5e9 Polish method order 2019-08-20 10:27:05 +03:00
Rossen Stoyanchev
008687d5ae Rename body(Object) to bodyValue
The recently added body(Object) variant can be confused easily with
body(Publisher, Class) forgetting to provide the element type and
only running into the IllegalArgumentException at runtime.

See gh-23212
2019-08-20 10:27:05 +03:00
Sam Brannen
fabdb07e53 Redeclare default methods in AbstractTestExecutionListener
This commit redeclares default methods in AbstractTestExecutionListener
in order to make them inlinable.
2019-08-09 16:39:35 +02:00
Sam Brannen
50e5334378 Simplify assertions within MockMvc internals 2019-08-07 17:32:19 +02:00
Phillip Webb
a6021cc968 Rename SearchStrategy.EXHAUSTIVE to TYPE_HIERARCHY
Rename `SearchStrategy.EXHAUSTIVE` from `MergedAnnotations` to
`SearchStrategy.TYPE_HIERARCHY`

See gh-23378
2019-07-31 13:52:53 +01:00
Juergen Hoeller
e6f86c5c75 Nullability refinements and related polishing 2019-07-31 13:45:48 +02:00
Phillip Webb
2ee1ce61c0 Add missing variants of getBeanNamesForType
Update `ListableBeanFactory` and `BeanFactoryUtils` to add the missing
`getBeanNamesForType` methods that accept a `ResolvableType` rather
than a `Class`.

This completes the work started in 778a01943b.

Closes gh-23335
2019-07-31 12:22:03 +02:00
Juergen Hoeller
3b235a098f Merge branch '5.1.x' 2019-07-30 22:52:20 +02:00
Juergen Hoeller
960079e5f5 Retain non-null HttpStatus return value in Client(Http)Response
See gh-23366
2019-07-30 22:26:46 +02:00
Arjen Poutsma
ac9a11a581 Merge branch '5.1.x' 2019-07-30 18:03:01 +02:00
Arjen Poutsma
29ef985411 Add support for non-standard status codes
Added support for status codes that do not occur in HttpStatus in
DefaultClientResponseBuilder and made ClientResponse::statusCode
ClientHttpResponse::getStatusCode @Nullable.

Closed gh-23366
2019-07-30 17:44:47 +02:00
Juergen Hoeller
27aaad5a89 Add isTooEarly() method to StatusResultMatchers
See gh-23384
2019-07-30 17:37:26 +02:00
Juergen Hoeller
8ef557df2f Merge branch '5.1.x' 2019-07-30 17:34:29 +02:00
Juergen Hoeller
c4622dbebc Polishing 2019-07-30 16:59:01 +02:00
Sam Brannen
027fd78306 Further refine @TestPropertySource merged annotation calls
See gh-23320
2019-07-29 22:53:15 +02:00
Phillip Webb
c9479ff20f Refine @TestPropertySource merged annotation calls
See gh-23320
2019-07-29 22:53:00 +02:00
Sam Brannen
c72bf10eb9 Polish MergedSqlConfig 2019-07-28 18:41:26 +02:00
Sam Brannen
bfbe8f8780 Polish MergedTestPropertySources 2019-07-28 15:40:39 +02:00
Sam Brannen
1954861844 Update @TestPropertySource Javadoc regarding "local" semantics
See gh-23320
2019-07-28 12:12:28 +02:00
Sam Brannen
136af0b164 Overhaul repeatable @TestPropertySource support
Prior to this commit, if multiple, directly present
`@TestPropertySource` annotations declared the same property, the
precedence ordering was top-down instead of bottom-up, in contrast to
the semantics for class hierarchies. In other words, a subsequent
`@TestPropertySource` annotation could not override a property in a
previous `@TestPropertySource` annotation.

This commit overhauls the internals of `TestPropertySourceUtils` in
order to provide proper support for property overrides within local,
directly present `@TestPropertySource` declarations.

Specifically, the `locations` and `properties` attributes from all
`@TestPropertySource` declarations that are directly present or
meta-present on a given class are now merged into a single instance of
`TestPropertySourceAttributes` internally, with assertions in place to
ensure that such "same level" `@TestPropertySource` declarations do not
configure different values for the `inheritLocations` and
`inheritProperties` flags. Effectively, all "same level"
`@TestPropertySource` declarations are treated internally as if there
were only one such annotation declared by the user.

See gh-23320
2019-07-27 22:30:34 +02:00
Anatoliy Korovin
2e476ca14f Support @TestPropertySource as a repeatable annotation
Prior to this commit, @TestPropertySource could not be declared as a
repeatable annotation. In addition, a local declaration of
@TestPropertySource would silently override a meta-present
@TestPropertySource.

This commit addresses this issue by introducing @TestPropertySources as
a container for @TestPropertySource. This commit also updates the
search and algorithms within TestPropertySourceUtils.

Closes gh-23320
2019-07-27 22:27:30 +02:00
Sam Brannen
c3c152f806 Add multi-prefix comment support for @SqlConfig
gh-23289 introduced support for multiple single-line comment prefixes
for ScriptUtils, ResourceDatabasePopulator, and EmbeddedDatabaseBuilder.

This commit adds the same support for @SqlConfig in the TestContext
Framework. Specifically, @SqlConfig has a new `commentPrefixes`
attribute for setting multiple single-line comment prefixes.

Closes gh-23331
2019-07-24 12:01:14 +02:00
Sam Brannen
d1570fd05b Fix copy-n-paste error in WebTestClient Javadoc 2019-07-22 18:16:46 +02:00
Sam Brannen
89571ea236 Introduce @SqlMergeMode for configuring @Sql annotation merging
Closes gh-1835
2019-07-21 14:34:35 +02:00
Sam Brannen
ab8876219f Polish contribution
See gh-1835
2019-07-21 13:26:55 +02:00
asympro
d77b715d38 Merge class-level and method-level @Sql declarations
See gh-1835
2019-07-21 13:26:48 +02:00
Sam Brannen
8db73c80e2 Polish MockRestServiceServer internals regarding "effectively final" 2019-07-18 15:45:44 +02:00
Sam Brannen
42f033e439 Polish MockMvc internals regarding "effectively final" 2019-07-18 15:45:44 +02:00
Juergen Hoeller
94e3210ae7 Fix nullability warnings and javadoc-triggered package cycles 2019-07-17 22:34:07 +02:00
Sam Brannen
e92cbe1938 Improve failure messages for redirect/forward in MockMvc 2019-07-17 16:53:47 +02:00
Sebastien Deleuze
b4a0e71ccc Polishing
See gh-23219
2019-07-16 18:46:36 +02:00
Sam Brannen
b2b79ae1e6 Polish contribution
See gh-23219
2019-07-16 14:57:32 +02:00
Sebastien Deleuze
adadffe0e1 Improve charset handling in MockHttpServletResponse
This commit adds a getContentAsString(Charset fallbackCharset) method
to MockHttpServletResponse in order to make it easier to get the content
in a specific charset like UTF-8 when the response charset has not been
explicitly set (by default ISO-8859-1 is used).

JsonPathResultMatchers leverages this new feature to support UTF-8
content out of the box.

Closes gh-23219
2019-07-16 11:44:16 +02:00
Sam Brannen
09c10232a4 Polishing
See gh-23224
2019-07-12 13:08:33 +02:00
Rob Winch
fde92793b5 Fix http URLs
See gh-22839
2019-07-11 18:14:20 +02:00
Sam Brannen
fc38bb4fc6 Change @TestConstructor.autowire attribute into an enum
Prior to this commit, @TestConstructor supported a boolean `autowire`
attribute which naturally limited the configuration to two states: on
or off. Since we may need to support additional autowiring modes in the
future, the use of a boolean is limiting.

This commit address this issue by introducing a new AutowireMode enum
in @TestConstructor with ALL and ANNOTATED constants. In addition, the
attribute has been renamed to `autowireMode`, and the system property
has been renamed to `spring.test.constructor.autowire.mode` for greater
clarity of purpose.

Closes gh-23224
2019-07-11 18:00:52 +02:00
Arjen Poutsma
2909de8829 Remove ServerWebExchange::getParts and ServerRequest::parts
Revert to state before DefaultMultipartMessageReader
2019-07-10 16:20:20 +02:00
Sebastien Deleuze
08a5196c3a Use elementClass and elementTypeRef consistently 2019-07-08 12:08:40 +02:00
Sebastien Deleuze
2b4d6ce354 Add body methods with Object parameter to WebFlux
The commit deprecates syncBody(Object) in favor of body(Object)
which has the same behavior in ServerResponse, WebClient and
WebTestClient. It also adds body(Object, Class) and
body(Object, ParameterizedTypeReference) methods in order to support
any reactive type that can be adapted to a Publisher via
ReactiveAdapterRegistry. Related BodyInserters#fromProducer
methods are provided as well.

Shadowed Kotlin body<T>() extensions are deprecated in favor of
bodyWithType<T>() ones, including dedicated Publisher<T> and
Flow<T> variants. Coroutines extensions are adapted as well, and
body(Object) can now be used with suspending functions.

Closes gh-23212
2019-07-07 22:27:57 +02:00
Arjen Poutsma
92981ac9de Add Flux<Part> ServerRequest.parts()
This commit introduces Flux<Part> ServerRequest.parts() that delegates
to ServerWebExchange.getParts() and offers an alternative,
streaming way of accessing multipart data.

Closes gh-23131
2019-06-21 10:59:13 +02:00
Sam Brannen
ef6471fcbf Polish contribution
See gh-23141
2019-06-18 18:59:18 +03:00
RustyTheClone
72adc3d37e Support target type in MockMvcResultMatchers.jsonPath()
This commit introduces an overloaded jsonPath() method to specify a
target type to coerce into for MockMvcResultMatchers.

 - jsonPath(String, Matcher<T>, Class<T>)

Closes gh-23141
2019-06-18 18:57:27 +03:00
Sam Brannen
89ebdc766c Polishing 2019-06-18 18:53:47 +03:00
Sam Brannen
8ceac9c015 Document supported @Transactional attributes in the TCF
This commit documents which attributes in @Transactional are supported
for test-managed transactions in the Spring TestContext Framework (TCF).

Closes gh-23149
2019-06-18 14:34:28 +03:00
Juergen Hoeller
0a77477d32 Merge branch '5.1.x' 2019-06-12 18:16:30 +02:00
Juergen Hoeller
fc46abf0b7 Polishing 2019-06-12 18:04:06 +02:00
Juergen Hoeller
a89bfffd8c Merge branch '5.1.x' 2019-06-11 23:16:03 +02:00