Add shortcuts for Jackson mix-in annotations registration
This commit adds support for direct Jackson mix-in annotations registration in Jackson2ObjectMapperFactoryBean and Jackson2ObjectMapperBuilder. Issue: SPR-12144
This commit is contained in:
committed by
Sebastien Deleuze
parent
5a631177ff
commit
25bb58a1e8
@@ -190,6 +190,19 @@ public class Jackson2ObjectMapperBuilderTests {
|
||||
assertSame(strategy, objectMapper.getDeserializationConfig().getPropertyNamingStrategy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mixIns() {
|
||||
Class<?> target = String.class;
|
||||
Class<?> mixinSource = Object.class;
|
||||
Map<Class<?>, Class<?>> mixIns = new HashMap<Class<?>, Class<?>>();
|
||||
mixIns.put(target, mixinSource);
|
||||
|
||||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().mixIns(mixIns).build();
|
||||
|
||||
assertEquals(1, objectMapper.mixInCount());
|
||||
assertSame(mixinSource, objectMapper.findMixInClassFor(target));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completeSetup() {
|
||||
NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance;
|
||||
|
||||
@@ -207,6 +207,21 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
assertSame(strategy, this.factory.getObject().getDeserializationConfig().getPropertyNamingStrategy());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMixIns() {
|
||||
Class<?> target = String.class;
|
||||
Class<?> mixinSource = Object.class;
|
||||
Map<Class<?>, Class<?>> mixIns = new HashMap<Class<?>, Class<?>>();
|
||||
mixIns.put(target, mixinSource);
|
||||
|
||||
this.factory.setMixIns(mixIns);
|
||||
this.factory.afterPropertiesSet();
|
||||
ObjectMapper objectMapper = this.factory.getObject();
|
||||
|
||||
assertEquals(1, objectMapper.mixInCount());
|
||||
assertSame(mixinSource, objectMapper.findMixInClassFor(target));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void completeSetup() {
|
||||
NopAnnotationIntrospector annotationIntrospector = NopAnnotationIntrospector.instance;
|
||||
|
||||
Reference in New Issue
Block a user