1
- package com .fasterxml .jackson .dataformat .xml .failing ;
1
+ package com .fasterxml .jackson .dataformat .xml .deser ;
2
2
3
3
import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
4
4
import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
5
5
6
- public class XsiNil366Test extends XmlTestBase
6
+ public class XsiNilNestingTest extends XmlTestBase
7
7
{
8
8
// for [dataformat-xml#366]
9
9
protected static class Parent366 {
@@ -12,7 +12,6 @@ protected static class Parent366 {
12
12
13
13
protected static class Level1 {
14
14
public Level2 level2 ;
15
- public String field ; // this should not be needed, but an unknown element is thrown without it
16
15
}
17
16
18
17
protected static class Level2 {
@@ -26,21 +25,25 @@ protected static class Level2 {
26
25
public void testDoesNotAffectHierarchy () throws Exception
27
26
{
28
27
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>"
28
+ + " <level1>"
29
+ + " <level2>"
30
+ + " <ignored xsi:nil=\" true\" />"
31
+ + " <field>test-value</field>"
32
+ + " </level2>"
33
+ + " </level1>"
35
34
+ "</Parent>" ;
36
35
Parent366 bean = MAPPER .readValue (xml , Parent366 .class );
37
36
38
37
assertNotNull (bean );
38
+ assertNotNull (bean .level1 );
39
+ Level2 l2 = bean .level1 .level2 ;
40
+ assertNotNull (l2 );
39
41
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
+ // should be null
43
+ assertNull (l2 .ignored );
44
+ // and should not be null
45
+ assertNotNull (l2 .field );
42
46
43
- // fails because field is set on level1 instead of on level2
44
- assertEquals ("test-value" , bean .level1 .level2 .field );
47
+ assertEquals ("test-value" , l2 .field );
45
48
}
46
49
}
0 commit comments