-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor backported failing test for #366
- Loading branch information
1 parent
521b8df
commit ad85f0b
Showing
2 changed files
with
46 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XsiNil366Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.fasterxml.jackson.dataformat.xml.failing; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.fasterxml.jackson.dataformat.xml.XmlTestBase; | ||
|
||
public class XsiNil366Test extends XmlTestBase | ||
{ | ||
// for [dataformat-xml#366] | ||
protected static class Parent366 { | ||
public Level1 level1; | ||
} | ||
|
||
protected static class Level1 { | ||
public Level2 level2; | ||
public String field; // this should not be needed, but an unknown element is thrown without it | ||
} | ||
|
||
protected static class Level2 { | ||
public String ignored; | ||
public String field; | ||
} | ||
|
||
private final XmlMapper MAPPER = newMapper(); | ||
|
||
// for [dataformat-xml#366] | ||
public void testDoesNotAffectHierarchy() throws Exception | ||
{ | ||
String xml = "<Parent xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" | ||
+ "<level1>" | ||
+ "<level2>" | ||
+ "<ignored xsi:nil=\"true\"/>" | ||
+ "<field>test-value</field>" | ||
+ "</level2>" | ||
+ "</level1>" | ||
+ "</Parent>"; | ||
Parent366 bean = MAPPER.readValue(xml, Parent366.class); | ||
|
||
assertNotNull(bean); | ||
|
||
// this should not be set, but having an xsi:nil field before it causes it to set the next field on the wrong class | ||
assertEquals("test-value", bean.level1.field); | ||
|
||
// fails because field is set on level1 instead of on level2 | ||
assertEquals("test-value", bean.level1.level2.field); | ||
} | ||
} |