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:
Tadaya Tsuyukubo
2014-09-02 23:17:32 -07:00
committed by Sebastien Deleuze
parent 5a631177ff
commit 25bb58a1e8
4 changed files with 62 additions and 0 deletions

View File

@@ -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;

View File

@@ -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;