-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
EmptyListDeserTest.java
68 lines (56 loc) · 1.82 KB
/
EmptyListDeserTest.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.fasterxml.jackson.dataformat.xml.lists;
import java.util.List;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.*;
public class EmptyListDeserTest extends XmlTestBase
{
// [dataformat-xml#177]
static class Config
{
@JacksonXmlProperty(isAttribute=true)
public String id;
@JacksonXmlElementWrapper(useWrapping=false)
public List<Entry> entry;
}
static class Entry
{
@JacksonXmlProperty(isAttribute=true)
public String id;
}
// [dataformat-xml#319]
static class Value319 {
public Long orderId, orderTypeId;
}
/*
/**********************************************************
/* Test methods
/**********************************************************
*/
private final XmlMapper MAPPER = new XmlMapper();
// [dataformat-xml#177]
public void testEmptyList() throws Exception
{
Config r = MAPPER.readValue(
"<Config id='123'>\n"+
" <entry id='foo'> </entry>\n"+
"</Config>\n",
Config.class);
assertNotNull(r);
assertEquals("123", r.id);
assertNotNull(r.entry);
assertEquals(1, r.entry.size());
assertEquals("foo", r.entry.get(0).id);
}
// [dataformat-xml#319]
public void testEmptyList319() throws Exception
{
final String DOC = "<orders></orders>";
List<Value319> list = MAPPER.readValue(DOC, new TypeReference<List<Value319>>() { });
assertNotNull(list);
assertEquals(0, list.size());
Value319[] array = MAPPER.readValue(DOC, Value319[].class);
assertNotNull(array);
assertEquals(0, array.length);
}
}