Polish "Add Jsonb support"

Closes gh-9648
This commit is contained in:
Stephane Nicoll
2017-09-21 14:58:56 +02:00
parent 97aeaa4a32
commit 8d63b7458c
8 changed files with 205 additions and 249 deletions

View File

@@ -297,7 +297,7 @@ content into your application; rather pick only the properties that you need.
spring.hateoas.use-hal-as-default-json-media-type=true # Specify if application/hal+json responses should be sent to requests that accept application/json.
# HTTP message conversion
spring.http.converters.preferred-json-mapper=jackson # Preferred JSON mapper to use for HTTP message conversion. Set to "gson" to force the use of Gson when both it and Jackson are on the classpath.
spring.http.converters.preferred-json-mapper= # Preferred JSON mapper to use for HTTP message conversion, auto-detected according to the environment by default.
# HTTP encoding ({sc-spring-boot-autoconfigure}/http/HttpEncodingProperties.{sc-ext}[HttpEncodingProperties])
spring.http.encoding.charset=UTF-8 # Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly.

View File

@@ -5675,16 +5675,21 @@ TIP: It's also possible to use the `@AutoConfigure...` annotations with the stan
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-json-tests]]
==== Auto-configured JSON tests
To test that Object JSON serialization and deserialization is working as expected you can
use the `@JsonTest` annotation. `@JsonTest` will auto-configure Jackson `ObjectMapper`,
any `@JsonComponent` beans and any Jackson `Modules`. It also configures `Gson`
if you happen to be using that instead of, or as well as, Jackson. If you need to
configure elements of the auto-configuration you can use the `@AutoConfigureJsonTesters`
annotation.
use the `@JsonTest` annotation. `@JsonTest` will auto-configure the available supported
json mapper:
* Jackson `ObjectMapper`, any `@JsonComponent` beans and any Jackson `Modules`
* `Gson`
* `Jsonb`
If you need to configure elements of the auto-configuration you can use the
`@AutoConfigureJsonTesters` annotation.
Spring Boot includes AssertJ based helpers that work with the JSONassert and JsonPath
libraries to check that JSON is as expected. The `JacksonTester`, `GsonTester` and
`BasicJsonTester` classes can be used for Jackson, Gson and Strings respectively. Any
helper fields on the test class can be `@Autowired` when using `@JsonTest`.
libraries to check that JSON is as expected. The `JacksonTester`, `GsonTester`,
`JsonbTester` and `BasicJsonTester` classes can be used for Jackson, Gson, Jsonb and
Strings respectively. Any helper fields on the test class can be `@Autowired` when using
`@JsonTest`.
[source,java,indent=0]
----
@@ -6237,9 +6242,9 @@ A list of the auto-configuration that is enabled by `@DataLdapTest` can be
[[boot-features-testing-spring-boot-applications-testing-autoconfigured-rest-client]]
==== Auto-configured REST clients
The `@RestClientTest` annotation can be used if you want to test REST clients. By default
it will auto-configure Jackson and GSON support, configure a `RestTemplateBuilder` and
add support for `MockRestServiceServer`. The specific beans that you want to test should
be specified using `value` or `components` attribute of `@RestClientTest`:
it will auto-configure Jackson, GSON and Jsonb support, configure a `RestTemplateBuilder`
and add support for `MockRestServiceServer`. The specific beans that you want to test
should be specified using `value` or `components` attribute of `@RestClientTest`:
[source,java,indent=0]