1- package com .fasterxml .jackson .dataformat .xml .failing ;
1+ package com .fasterxml .jackson .dataformat .xml .deser ;
22
33import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
44import com .fasterxml .jackson .dataformat .xml .XmlTestBase ;
55
6- public class XsiNil366Test extends XmlTestBase
6+ public class XsiNilNestingTest extends XmlTestBase
77{
88 // for [dataformat-xml#366]
99 protected static class Parent366 {
@@ -12,7 +12,6 @@ protected static class Parent366 {
1212
1313 protected static class Level1 {
1414 public Level2 level2 ;
15- public String field ; // this should not be needed, but an unknown element is thrown without it
1615 }
1716
1817 protected static class Level2 {
@@ -26,21 +25,25 @@ protected static class Level2 {
2625 public void testDoesNotAffectHierarchy () throws Exception
2726 {
2827 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>"
3534 + "</Parent>" ;
3635 Parent366 bean = MAPPER .readValue (xml , Parent366 .class );
3736
3837 assertNotNull (bean );
38+ assertNotNull (bean .level1 );
39+ Level2 l2 = bean .level1 .level2 ;
40+ assertNotNull (l2 );
3941
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 );
4246
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 );
4548 }
4649}
0 commit comments