Skip to content

Commit e00f6d1

Browse files
committed
...
1 parent 563646b commit e00f6d1

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EmptyListDeser124Test.java

-26
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,4 @@
1010
// for [dataformat-xml#124]
1111
public class EmptyListDeser124Test extends XmlTestBase
1212
{
13-
public static class TestList {
14-
@JsonProperty("list")
15-
public List<Object> list;
16-
}
17-
18-
// [dataformat-xml#124]
19-
public void test124() throws Exception {
20-
final XmlMapper xmlMapper = XmlMapper.builder()
21-
.build();
22-
23-
// 14-Jan-2020, tatu: This is actual working override to resolve the issue...
24-
// Not sure if this can be otherwise resolved.
25-
26-
// xmlMapper.configOverride(List.class)
27-
// .setSetterInfo(JsonSetter.Value.forValueNulls(Nulls.AS_EMPTY));
28-
29-
TestList originalObject = new TestList();
30-
originalObject.list = new ArrayList<Object>();
31-
String xml = xmlMapper.writeValueAsString(originalObject);
32-
//System.err.println(xml); // prints <TestList><list/>></TestList>
33-
34-
TestList result = xmlMapper.readValue(xml, TestList.class);
35-
36-
assertNotNull(result.list);
37-
assertEquals(0, result.list.size());
38-
}
3913
}

src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
package com.fasterxml.jackson.dataformat.xml.lists;
22

3+
import java.util.ArrayList;
34
import java.util.List;
45

6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
58
import com.fasterxml.jackson.core.type.TypeReference;
9+
610
import com.fasterxml.jackson.dataformat.xml.*;
711
import com.fasterxml.jackson.dataformat.xml.annotation.*;
812

913
public class EmptyListDeserTest extends XmlTestBase
1014
{
15+
// for [dataformat-xml#124]
16+
public static class TestList124 {
17+
@JsonProperty("list")
18+
public List<Object> list;
19+
}
20+
1121
// [dataformat-xml#177]
1222
static class Config
1323
{
@@ -37,6 +47,18 @@ static class Value319 {
3747

3848
private final XmlMapper MAPPER = new XmlMapper();
3949

50+
// [dataformat-xml#124]
51+
public void test124() throws Exception {
52+
TestList124 originalObject = new TestList124();
53+
originalObject.list = new ArrayList<Object>();
54+
String xml = MAPPER.writeValueAsString(originalObject);
55+
56+
TestList124 result = MAPPER.readValue(xml, TestList124.class);
57+
58+
assertNotNull(result.list);
59+
assertEquals(0, result.list.size());
60+
}
61+
4062
// [dataformat-xml#177]
4163
public void testEmptyList() throws Exception
4264
{

0 commit comments

Comments
 (0)