File tree 2 files changed +22
-26
lines changed
src/test/java/com/fasterxml/jackson/dataformat/xml
2 files changed +22
-26
lines changed Original file line number Diff line number Diff line change 10
10
// for [dataformat-xml#124]
11
11
public class EmptyListDeser124Test extends XmlTestBase
12
12
{
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
- }
39
13
}
Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .dataformat .xml .lists ;
2
2
3
+ import java .util .ArrayList ;
3
4
import java .util .List ;
4
5
6
+ import com .fasterxml .jackson .annotation .JsonProperty ;
7
+
5
8
import com .fasterxml .jackson .core .type .TypeReference ;
9
+
6
10
import com .fasterxml .jackson .dataformat .xml .*;
7
11
import com .fasterxml .jackson .dataformat .xml .annotation .*;
8
12
9
13
public class EmptyListDeserTest extends XmlTestBase
10
14
{
15
+ // for [dataformat-xml#124]
16
+ public static class TestList124 {
17
+ @ JsonProperty ("list" )
18
+ public List <Object > list ;
19
+ }
20
+
11
21
// [dataformat-xml#177]
12
22
static class Config
13
23
{
@@ -37,6 +47,18 @@ static class Value319 {
37
47
38
48
private final XmlMapper MAPPER = new XmlMapper ();
39
49
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
+
40
62
// [dataformat-xml#177]
41
63
public void testEmptyList () throws Exception
42
64
{
You can’t perform that action at this time.
0 commit comments