Skip to content

Commit 234d067

Browse files
committed
#1330 Test Jackson defaultTyping configuration
Verify that configuration option for Jackson's defaultTyping is correctly converted and set on ObjectMapper.
1 parent 670d17d commit 234d067

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

runtime/src/test/groovy/io/micronaut/jackson/JacksonSetupSpec.groovy

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ class JacksonSetupSpec extends Specification {
6969
applicationContext?.close()
7070
}
7171

72+
void "verify that the defaultTyping configuration option is correctly converted and set on the object mapper"() {
73+
given:
74+
ApplicationContext applicationContext = new DefaultApplicationContext("test")
75+
applicationContext.environment.addPropertySource(MapPropertySource.of(
76+
'jackson.dateFormat': 'yyMMdd',
77+
'jackson.defaultTyping': 'NON_FINAL'
78+
))
79+
applicationContext.start()
80+
81+
expect:
82+
applicationContext.containsBean(ObjectMapper.class)
83+
((ObjectMapper.DefaultTypeResolverBuilder) applicationContext.getBean(ObjectMapper.class).deserializationConfig.getDefaultTyper(null))._appliesFor == ObjectMapper.DefaultTyping.NON_FINAL
84+
85+
applicationContext.containsBean(JacksonConfiguration)
86+
applicationContext.getBean(JacksonConfiguration).defaultTyping == ObjectMapper.DefaultTyping.NON_FINAL
87+
88+
cleanup:
89+
applicationContext?.close()
90+
}
91+
7292
@Unroll
7393
void 'Configuring #configuredJackonPropertyNamingStrategy sets PropertyNamingStrategy on the Context ObjectMapper.'() {
7494
when:

0 commit comments

Comments
 (0)