-
-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b72e31c
commit 9f2c351
Showing
2 changed files
with
74 additions
and
0 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
72 changes: 72 additions & 0 deletions
72
.../java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappedJsonIdentityConflict286Test.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,72 @@ | ||
package com.fasterxml.jackson.dataformat.xml.misc; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIdentityInfo; | ||
import com.fasterxml.jackson.annotation.ObjectIdGenerators; | ||
|
||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.fasterxml.jackson.dataformat.xml.XmlTestBase; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
|
||
// for [dataformat-xml#286]: parser getting confused with unwrapped lists, | ||
// object id | ||
public class UnwrappedJsonIdentityConflict286Test extends XmlTestBase | ||
{ | ||
static class Town | ||
{ | ||
public School[] schools; | ||
public Student[] students; | ||
} | ||
|
||
static class Student | ||
{ | ||
public School school; | ||
@JacksonXmlElementWrapper(useWrapping = false) | ||
@JacksonXmlProperty(localName = "year") | ||
public Year[] years; | ||
} | ||
|
||
static class Year | ||
{ | ||
public String grade; | ||
} | ||
|
||
@JsonIdentityInfo(scope = School.class, generator = ObjectIdGenerators.PropertyGenerator.class, | ||
property = "name") | ||
static class School | ||
{ | ||
@JacksonXmlElementWrapper(useWrapping = false) | ||
@JacksonXmlProperty(localName = "staffMember") | ||
public String[] staffMembers; | ||
public String name; | ||
} | ||
|
||
public void testCaseInsensitiveComplex() throws Exception | ||
{ | ||
|
||
XmlMapper mapper = XmlMapper.builder().build(); | ||
|
||
final String input = | ||
"<town>\n"+ | ||
" <schools>\n"+ | ||
" <school name=\"Springfield Elementary\">\n"+ | ||
" <staffMember>Principal Skinner</staffMember>\n"+ | ||
" <staffMember>Groundskeeper Willie</staffMember>\n"+ | ||
" </school>\n"+ | ||
" </schools>\n"+ | ||
" <students>\n"+ | ||
" <student>\n"+ | ||
" <school>Springfield Elementary</school>\n"+ | ||
" <year>\n"+ | ||
" <grade>3</grade>\n"+ | ||
" </year>\n"+ | ||
" </student>\n"+ | ||
" </students>\n"+ | ||
"</town>"; | ||
Town result = mapper.readValue(input, Town.class); | ||
assertNotNull(result); | ||
assertEquals("Principal Skinner", result.schools[0].staffMembers[0]); | ||
assertEquals("Principal Skinner", result.students[0].school.staffMembers[0]); | ||
assertEquals("3", result.students[0].years[0].grade); | ||
} | ||
} |