File tree 2 files changed +46
-35
lines changed
src/test/java/com/fasterxml/jackson/dataformat/xml
2 files changed +46
-35
lines changed Original file line number Diff line number Diff line change @@ -14,20 +14,6 @@ public DoubleWrapper(Double value) {
14
14
}
15
15
}
16
16
17
- protected static class Parent {
18
- public Level1 level1 ;
19
- }
20
-
21
- protected static class Level1 {
22
- public Level2 level2 ;
23
- public String field ; // this should not be needed, but an unknown element is thrown without it
24
- }
25
-
26
- protected static class Level2 {
27
- public String ignored ;
28
- public String field ;
29
- }
30
-
31
17
private final XmlMapper MAPPER = newMapper ();
32
18
33
19
public void testWithDoubleAsNull () throws Exception
@@ -71,25 +57,4 @@ public void testRootPojoAsNonNull() throws Exception
71
57
Point .class );
72
58
assertNotNull (bean );
73
59
}
74
-
75
- public void testDoesNotAffectHierarchy () throws Exception
76
- {
77
- String xml = "<Parent xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" >"
78
- + "<level1>"
79
- + "<level2>"
80
- + "<ignored xsi:nil=\" true\" />"
81
- + "<field>test-value</field>"
82
- + "</level2>"
83
- + "</level1>"
84
- + "</Parent>" ;
85
- Parent bean = MAPPER .readValue (xml , Parent .class );
86
-
87
- assertNotNull (bean );
88
-
89
- // this should not be set, but having an xsi:nil field before it causes it to set the next field on the wrong class
90
- assertEquals ("test-value" , bean .level1 .field );
91
-
92
- // fails because field is set on level1 instead of on level2
93
- assertEquals ("test-value" , bean .level1 .level2 .field );
94
- }
95
60
}
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .dataformat .xml .failing ;
2
+
3
+ import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
4
+ import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
5
+
6
+ public class XsiNil366Test extends XmlTestBase
7
+ {
8
+ // for [dataformat-xml#366]
9
+ protected static class Parent366 {
10
+ public Level1 level1 ;
11
+ }
12
+
13
+ protected static class Level1 {
14
+ public Level2 level2 ;
15
+ public String field ; // this should not be needed, but an unknown element is thrown without it
16
+ }
17
+
18
+ protected static class Level2 {
19
+ public String ignored ;
20
+ public String field ;
21
+ }
22
+
23
+ private final XmlMapper MAPPER = newMapper ();
24
+
25
+ // for [dataformat-xml#366]
26
+ public void testDoesNotAffectHierarchy () throws Exception
27
+ {
28
+ String xml = "<Parent xmlns:xsi=\" http://www.w3.org/2001/XMLSchema-instance\" >"
29
+ + "<level1>"
30
+ + "<level2>"
31
+ + "<ignored xsi:nil=\" true\" />"
32
+ + "<field>test-value</field>"
33
+ + "</level2>"
34
+ + "</level1>"
35
+ + "</Parent>" ;
36
+ Parent366 bean = MAPPER .readValue (xml , Parent366 .class );
37
+
38
+ assertNotNull (bean );
39
+
40
+ // this should not be set, but having an xsi:nil field before it causes it to set the next field on the wrong class
41
+ assertEquals ("test-value" , bean .level1 .field );
42
+
43
+ // fails because field is set on level1 instead of on level2
44
+ assertEquals ("test-value" , bean .level1 .level2 .field );
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments