|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
* Copyright 2012-2018 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -82,7 +82,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void registersJodaModuleAutomatically() {
|
|
|
|
public void registersJodaModuleAutomatically() {
|
|
|
|
this.contextRunner.run(context -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(objectMapper.canSerialize(LocalDateTime.class)).isTrue();
|
|
|
|
assertThat(objectMapper.canSerialize(LocalDateTime.class)).isTrue();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -93,7 +93,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner.withUserConfiguration(DoubleModulesConfig.class)
|
|
|
|
this.contextRunner.withUserConfiguration(DoubleModulesConfig.class)
|
|
|
|
.withConfiguration(AutoConfigurations
|
|
|
|
.withConfiguration(AutoConfigurations
|
|
|
|
.of(HttpMessageConvertersAutoConfiguration.class))
|
|
|
|
.of(HttpMessageConvertersAutoConfiguration.class))
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.writeValueAsString(new Foo()))
|
|
|
|
assertThat(mapper.writeValueAsString(new Foo()))
|
|
|
|
.isEqualTo("{\"foo\":\"bar\"}");
|
|
|
|
.isEqualTo("{\"foo\":\"bar\"}");
|
|
|
@ -108,7 +108,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void noCustomDateFormat() {
|
|
|
|
public void noCustomDateFormat() {
|
|
|
|
this.contextRunner.run(context -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.getDateFormat()).isInstanceOf(StdDateFormat.class);
|
|
|
|
assertThat(mapper.getDateFormat()).isInstanceOf(StdDateFormat.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -117,7 +117,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void customDateFormat() {
|
|
|
|
public void customDateFormat() {
|
|
|
|
this.contextRunner.withPropertyValues("spring.jackson.date-format:yyyyMMddHHmmss")
|
|
|
|
this.contextRunner.withPropertyValues("spring.jackson.date-format:yyyyMMddHHmmss")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
DateFormat dateFormat = mapper.getDateFormat();
|
|
|
|
DateFormat dateFormat = mapper.getDateFormat();
|
|
|
|
assertThat(dateFormat).isInstanceOf(SimpleDateFormat.class);
|
|
|
|
assertThat(dateFormat).isInstanceOf(SimpleDateFormat.class);
|
|
|
@ -131,7 +131,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.date-format:yyyyMMddHHmmss",
|
|
|
|
.withPropertyValues("spring.jackson.date-format:yyyyMMddHHmmss",
|
|
|
|
"spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss")
|
|
|
|
"spring.jackson.joda-date-time-format:yyyy-MM-dd HH:mm:ss")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30,
|
|
|
|
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30,
|
|
|
|
DateTimeZone.UTC);
|
|
|
|
DateTimeZone.UTC);
|
|
|
@ -148,7 +148,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat")
|
|
|
|
"spring.jackson.date-format:org.springframework.boot.autoconfigure.jackson.JacksonAutoConfigurationTests.MyDateFormat")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
|
|
|
|
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -156,7 +156,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void noCustomPropertyNamingStrategy() {
|
|
|
|
public void noCustomPropertyNamingStrategy() {
|
|
|
|
this.contextRunner.run(context -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.getPropertyNamingStrategy()).isNull();
|
|
|
|
assertThat(mapper.getPropertyNamingStrategy()).isNull();
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -166,7 +166,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void customPropertyNamingStrategyField() {
|
|
|
|
public void customPropertyNamingStrategyField() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.property-naming-strategy:SNAKE_CASE")
|
|
|
|
.withPropertyValues("spring.jackson.property-naming-strategy:SNAKE_CASE")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.getPropertyNamingStrategy())
|
|
|
|
assertThat(mapper.getPropertyNamingStrategy())
|
|
|
|
.isInstanceOf(SnakeCaseStrategy.class);
|
|
|
|
.isInstanceOf(SnakeCaseStrategy.class);
|
|
|
@ -178,7 +178,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy")
|
|
|
|
"spring.jackson.property-naming-strategy:com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.getPropertyNamingStrategy())
|
|
|
|
assertThat(mapper.getPropertyNamingStrategy())
|
|
|
|
.isInstanceOf(SnakeCaseStrategy.class);
|
|
|
|
.isInstanceOf(SnakeCaseStrategy.class);
|
|
|
@ -189,7 +189,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void enableSerializationFeature() {
|
|
|
|
public void enableSerializationFeature() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.serialization.indent_output:true")
|
|
|
|
.withPropertyValues("spring.jackson.serialization.indent_output:true")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(SerializationFeature.INDENT_OUTPUT.enabledByDefault())
|
|
|
|
assertThat(SerializationFeature.INDENT_OUTPUT.enabledByDefault())
|
|
|
|
.isFalse();
|
|
|
|
.isFalse();
|
|
|
@ -203,7 +203,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.serialization.write_dates_as_timestamps:false")
|
|
|
|
"spring.jackson.serialization.write_dates_as_timestamps:false")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
|
|
|
|
assertThat(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
|
|
|
|
.enabledByDefault()).isTrue();
|
|
|
|
.enabledByDefault()).isTrue();
|
|
|
@ -218,7 +218,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.deserialization.use_big_decimal_for_floats:true")
|
|
|
|
"spring.jackson.deserialization.use_big_decimal_for_floats:true")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS
|
|
|
|
assertThat(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS
|
|
|
|
.enabledByDefault()).isFalse();
|
|
|
|
.enabledByDefault()).isFalse();
|
|
|
@ -234,7 +234,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.deserialization.fail-on-unknown-properties:false")
|
|
|
|
"spring.jackson.deserialization.fail-on-unknown-properties:false")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
|
|
|
|
assertThat(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
|
|
|
|
.enabledByDefault()).isTrue();
|
|
|
|
.enabledByDefault()).isTrue();
|
|
|
@ -250,7 +250,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.mapper.require_setters_for_getters:true")
|
|
|
|
"spring.jackson.mapper.require_setters_for_getters:true")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(
|
|
|
|
assertThat(
|
|
|
|
MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault())
|
|
|
|
MapperFeature.REQUIRE_SETTERS_FOR_GETTERS.enabledByDefault())
|
|
|
@ -268,7 +268,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void disableMapperFeature() {
|
|
|
|
public void disableMapperFeature() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.mapper.use_annotations:false")
|
|
|
|
.withPropertyValues("spring.jackson.mapper.use_annotations:false")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(MapperFeature.USE_ANNOTATIONS.enabledByDefault()).isTrue();
|
|
|
|
assertThat(MapperFeature.USE_ANNOTATIONS.enabledByDefault()).isTrue();
|
|
|
|
assertThat(mapper.getDeserializationConfig()
|
|
|
|
assertThat(mapper.getDeserializationConfig()
|
|
|
@ -284,7 +284,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void enableParserFeature() {
|
|
|
|
public void enableParserFeature() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.parser.allow_single_quotes:true")
|
|
|
|
.withPropertyValues("spring.jackson.parser.allow_single_quotes:true")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(JsonParser.Feature.ALLOW_SINGLE_QUOTES.enabledByDefault())
|
|
|
|
assertThat(JsonParser.Feature.ALLOW_SINGLE_QUOTES.enabledByDefault())
|
|
|
|
.isFalse();
|
|
|
|
.isFalse();
|
|
|
@ -297,7 +297,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void disableParserFeature() {
|
|
|
|
public void disableParserFeature() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.parser.auto_close_source:false")
|
|
|
|
.withPropertyValues("spring.jackson.parser.auto_close_source:false")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledByDefault())
|
|
|
|
assertThat(JsonParser.Feature.AUTO_CLOSE_SOURCE.enabledByDefault())
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
@ -311,7 +311,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues(
|
|
|
|
.withPropertyValues(
|
|
|
|
"spring.jackson.generator.write_numbers_as_strings:true")
|
|
|
|
"spring.jackson.generator.write_numbers_as_strings:true")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS
|
|
|
|
assertThat(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS
|
|
|
|
.enabledByDefault()).isFalse();
|
|
|
|
.enabledByDefault()).isFalse();
|
|
|
@ -325,7 +325,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void disableGeneratorFeature() {
|
|
|
|
public void disableGeneratorFeature() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.generator.auto_close_target:false")
|
|
|
|
.withPropertyValues("spring.jackson.generator.auto_close_target:false")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault())
|
|
|
|
assertThat(JsonGenerator.Feature.AUTO_CLOSE_TARGET.enabledByDefault())
|
|
|
|
.isTrue();
|
|
|
|
.isTrue();
|
|
|
@ -337,7 +337,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void defaultObjectMapperBuilder() {
|
|
|
|
public void defaultObjectMapperBuilder() {
|
|
|
|
this.contextRunner.run(context -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
Jackson2ObjectMapperBuilder builder = context
|
|
|
|
Jackson2ObjectMapperBuilder builder = context
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class);
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class);
|
|
|
|
ObjectMapper mapper = builder.build();
|
|
|
|
ObjectMapper mapper = builder.build();
|
|
|
@ -360,7 +360,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void moduleBeansAndWellKnownModulesAreRegisteredWithTheObjectMapperBuilder() {
|
|
|
|
public void moduleBeansAndWellKnownModulesAreRegisteredWithTheObjectMapperBuilder() {
|
|
|
|
this.contextRunner.withUserConfiguration(ModuleConfig.class).run(context -> {
|
|
|
|
this.contextRunner.withUserConfiguration(ModuleConfig.class).run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context.getBean(Jackson2ObjectMapperBuilder.class)
|
|
|
|
ObjectMapper objectMapper = context.getBean(Jackson2ObjectMapperBuilder.class)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
assertThat(context.getBean(CustomModule.class).getOwners())
|
|
|
|
assertThat(context.getBean(CustomModule.class).getOwners())
|
|
|
@ -372,7 +372,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void defaultSerializationInclusion() {
|
|
|
|
public void defaultSerializationInclusion() {
|
|
|
|
this.contextRunner.run(context -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context.getBean(Jackson2ObjectMapperBuilder.class)
|
|
|
|
ObjectMapper objectMapper = context.getBean(Jackson2ObjectMapperBuilder.class)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
assertThat(objectMapper.getSerializationConfig().getDefaultPropertyInclusion()
|
|
|
|
assertThat(objectMapper.getSerializationConfig().getDefaultPropertyInclusion()
|
|
|
@ -384,7 +384,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
public void customSerializationInclusion() {
|
|
|
|
public void customSerializationInclusion() {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.default-property-inclusion:non_null")
|
|
|
|
.withPropertyValues("spring.jackson.default-property-inclusion:non_null")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context
|
|
|
|
ObjectMapper objectMapper = context
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
|
|
|
assertThat(objectMapper.getSerializationConfig()
|
|
|
|
assertThat(objectMapper.getSerializationConfig()
|
|
|
@ -398,7 +398,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
this.contextRunner
|
|
|
|
this.contextRunner
|
|
|
|
.withPropertyValues("spring.jackson.time-zone:America/Los_Angeles",
|
|
|
|
.withPropertyValues("spring.jackson.time-zone:America/Los_Angeles",
|
|
|
|
"spring.jackson.date-format:zzzz", "spring.jackson.locale:en")
|
|
|
|
"spring.jackson.date-format:zzzz", "spring.jackson.locale:en")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context
|
|
|
|
ObjectMapper objectMapper = context
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
|
|
|
DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC);
|
|
|
|
DateTime dateTime = new DateTime(1436966242231L, DateTimeZone.UTC);
|
|
|
@ -410,7 +410,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void customTimeZoneFormattingADate() throws JsonProcessingException {
|
|
|
|
public void customTimeZoneFormattingADate() throws JsonProcessingException {
|
|
|
|
this.contextRunner.withPropertyValues("spring.jackson.time-zone:GMT+10",
|
|
|
|
this.contextRunner.withPropertyValues("spring.jackson.time-zone:GMT+10",
|
|
|
|
"spring.jackson.date-format:z").run(context -> {
|
|
|
|
"spring.jackson.date-format:z").run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context
|
|
|
|
ObjectMapper objectMapper = context
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
|
|
|
.getBean(Jackson2ObjectMapperBuilder.class).build();
|
|
|
|
Date date = new Date(1436966242231L);
|
|
|
|
Date date = new Date(1436966242231L);
|
|
|
@ -425,7 +425,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
.withPropertyValues("spring.jackson.locale:de_DE",
|
|
|
|
.withPropertyValues("spring.jackson.locale:de_DE",
|
|
|
|
"spring.jackson.date-format:zzzz",
|
|
|
|
"spring.jackson.date-format:zzzz",
|
|
|
|
"spring.jackson.serialization.write-dates-with-zone-id:true")
|
|
|
|
"spring.jackson.serialization.write-dates-with-zone-id:true")
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper objectMapper = context.getBean(ObjectMapper.class);
|
|
|
|
DateTime jodaTime = new DateTime(1478424650000L,
|
|
|
|
DateTime jodaTime = new DateTime(1478424650000L,
|
|
|
|
DateTimeZone.forID("Europe/Rome"));
|
|
|
|
DateTimeZone.forID("Europe/Rome"));
|
|
|
@ -437,7 +437,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void additionalJacksonBuilderCustomization() {
|
|
|
|
public void additionalJacksonBuilderCustomization() {
|
|
|
|
this.contextRunner.withUserConfiguration(ObjectMapperBuilderCustomConfig.class)
|
|
|
|
this.contextRunner.withUserConfiguration(ObjectMapperBuilderCustomConfig.class)
|
|
|
|
.run(context -> {
|
|
|
|
.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
|
|
|
|
assertThat(mapper.getDateFormat()).isInstanceOf(MyDateFormat.class);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -457,7 +457,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void writeDatesAsTimestampsDefault() {
|
|
|
|
public void writeDatesAsTimestampsDefault() {
|
|
|
|
this.contextRunner.run(context -> {
|
|
|
|
this.contextRunner.run((context) -> {
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
ObjectMapper mapper = context.getBean(ObjectMapper.class);
|
|
|
|
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC);
|
|
|
|
DateTime dateTime = new DateTime(1988, 6, 25, 20, 30, DateTimeZone.UTC);
|
|
|
|
String expected = FormatConfig.DEFAULT_DATETIME_PRINTER.rawFormatter()
|
|
|
|
String expected = FormatConfig.DEFAULT_DATETIME_PRINTER.rawFormatter()
|
|
|
@ -469,7 +469,7 @@ public class JacksonAutoConfigurationTests {
|
|
|
|
|
|
|
|
|
|
|
|
private void assertParameterNamesModuleCreatorBinding(Mode expectedMode,
|
|
|
|
private void assertParameterNamesModuleCreatorBinding(Mode expectedMode,
|
|
|
|
Class<?>... configClasses) {
|
|
|
|
Class<?>... configClasses) {
|
|
|
|
this.contextRunner.withUserConfiguration(configClasses).run(context -> {
|
|
|
|
this.contextRunner.withUserConfiguration(configClasses).run((context) -> {
|
|
|
|
DeserializationConfig deserializationConfig = context
|
|
|
|
DeserializationConfig deserializationConfig = context
|
|
|
|
.getBean(ObjectMapper.class).getDeserializationConfig();
|
|
|
|
.getBean(ObjectMapper.class).getDeserializationConfig();
|
|
|
|
AnnotationIntrospector annotationIntrospector = deserializationConfig
|
|
|
|
AnnotationIntrospector annotationIntrospector = deserializationConfig
|
|
|
|