-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
DefaultTyping325Test.java
36 lines (29 loc) · 1.12 KB
/
DefaultTyping325Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.fasterxml.jackson.dataformat.xml.failing;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
public class DefaultTyping325Test extends XmlTestBase
{
static class Simple {
protected List<String> list;
public List<String> getList( ) { return list; }
public void setList(List<String> l) { list = l; }
}
public void testCanSerialize() throws IOException
{
ObjectMapper mapper = objectMapperBuilder()
.build();
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
// construct test object
Simple s = new Simple();
s.setList(Arrays.asList("foo", "bar"));
String doc = mapper.writeValueAsString(s);
System.err.println("DOC: "+doc);
Simple result = mapper.readValue(doc, Simple.class);
assertNotNull(result.list);
assertEquals(2, result.list.size());
}
}